How to open last opned folder in QFileDialog using PyQt - pyqt4

I want to know is it possible to open last browsed folder using QFileDialog
I used QFileDialog to browse and select a file.
Step 1
I browsed c:\test\files and selected xyz filde from that folder
Step2
Again when i need to browse for files. This time i want QFileDialog to point to my last visited folder (i.e., c:\test\files)
I know its is possible to do by saving the current visited directory and use QFileDialog.setDirectory to set the previous directory.
Is there any other option like savelast path browse, something like that....?
Is it possible...?
If YES how can i do it.

You can try using the saveState() and restoreState() methods in conjunction with QSettings, but this is just a variant of saving the last path even if probably it is a better method

Related

Sublime Text 3: import projects list from folder/files to OpenRecent list

I save several projects in a same folder by manual click Project -> Save Project As...
and I used to use cmd + ctrl + p to open Switch Projectlist to switch between projects
and everything's works fine.
but today, I accidentally remove my Switch Project list in by click Project -> Open Recent -> Clear Items, so my Switch Project list is empty now...
I know I could add them back through reopen ALL my projects. due to the number of projects is pretty a lot, that will be kind of annoying to add them back one by one.
I wanna know if there's a smarter way to do that for me.
maybe import all my *.sublime-project files from folder or something.
thanks
Short of manually opening every project, I don't think there is any way to do something like this directly. There isn't a command or plugin endpoint that I'm aware of that lets you open a project by name or filename, so it's not possible to create a plugin to do the work, and Sublime doesn't have the ability to pre-load the list of packages directly either.
That said, it is possible to manually update the list of recent projects, but whether or not that is more or less work than opening all of the projects is something to consider.
If you use Preferences > Browse Packages from the menu or the command palette, a file browser will open on your Packages folder. From there go up one directory level and go inside of the Local folder, where you will find a Session.sublime_session file.
Sublime saves it's state into this file when you quit it, and uses it to restore state when you start it again. Here you will find all of the saved information, such as the windows and files that were open and so on.
Changing this file will change the data that Sublime loads, so you can modify the session file to set up the data that you want. You need to make sure that you modify the file while Sublime is not running or your changes will be ignored and clobbered away. Also it's a good idea to make a backup of the file before you start in case things go pear shaped.
Down near the bottom of the file you will find a top level key named workspaces, and inside of it a recent_workspaces key:
"workspaces":
{
"recent_workspaces":
[
"/home/tmartin/local/src/OverrideAudit/OverrideAudit.sublime-workspace",
]
}
This is where the list of recent projects is stored for use in the menu and the quick switch project command. Particular things to notice are that the entries are naming sublime-workspace files, and that the paths are absolute.
NOTE: On windows, the filenames stored in the session file are in a format like /C/Users/tmartin and not c:\users\tmartin; on that platform you need to make sure that you adjust the paths accordingly. As long as there is already at least one entry in the list when you look at the session file, you can easily see how to construct the paths that you need.
Despite the name of the commands and menu items, what you're actually switching between is different workspaces. Every sublime-project is associated with a sublime-workspace file, which acts as a dedicated sublime_session file for that particular project. This mapping is one-to-many in that you can have multiple workspaces for the same project file, allowing you to reference the same paths in multiple windows but have different window layouts.
While Sublime is not running you can edit this file to add in the full paths to all of your workspace files; when you start Sublime up the list will be populated (every sublime-workspace file knows what sublime-project it is associated with).
What remains is whether or not it's quick to come up with the list of files in a way that you can easily paste them into the session file.

GTK file/folder tree view: enable only highlighting/selecting file name

since this is my first question here, I hope I do not distract you ;-)
I have wondered for a long time now wether there was an option in any
GTK setting that allows me (p.ex. in Nautilus) to select only the file's
or folder's name in an expanded tree view, NOT like this:
https://www.dropbox.com/s/fkeit8nk6ezhjnv/BadNautilus.png?dl=0
But more like this:
https://www.dropbox.com/s/52b9iv2lz0zvahl/GoodSystem7.png?dl=0
In the top picture you see that I wanted to get the context menu of
my home folder while I had the "Downloads" folder expanded, p.ex.
for opening a terminal.
If a (right-)click in the middle of nowhere would be taken as being directed at the current view's top level folder (in this example, my home folder), opening a terminal wouldn't be that of a problem.
Another example: Suppose I wanted to add a new file by selecting right click->New document->... (any template here). This is not possible in a folder
where I have to scroll down because it has so much content in it.
So summing it up:
There are context menu actions that "belong" to the empty screen space in a folder view below the listed files (at least in Nautilus) that I also want to be able to use in a folder which is so crowded that there is no more empty screen space. I know some, at least System 7 finder and Win (up to XP), file managers which are capable of this. Is it possible to system-wide set
the screen space next to the file name string to be equivalent to the empty screen space below a file listing?
Any ideas?
Best regards,
JohnS

Matlab: open files 'outside Matlab' by default

I'm looking for a way to have Excel files in my Matlab folder open 'outside Matlab' (i.e., by MS Excel in most cases) directly by double-clicking the file, rather than right-clicking and selecting 'Open Outside Matlab'.
The .xls files reader built in Matlab can be terribly slow for large files, and an unwanted double-click on a file can cost quite some time in which Matlab is unresponsive.
Thanks.
When you click something in the Current Folder tab, it's actually running the open command, which itself calls finfo to determine what it means by "open" for a given extension. You can see this by creating a breakpoint in open.m directly after the line [~, openAction] = finfo(fullpath); and double clicking - when it hits the breakpoint you'll see it returns openAction as uiimport.
In theory, you can create custom methods for extensions by creating on the path a function openabc where abc is the extension, which should be returned as the openAction.
However, if I look at my finfo.m it first searches for said functions and then regardless of whether or not it finds them if there is an inbuilt method it overwrites them with the standard behaviour. There's even a comment:
% this setup will not allow users to override the default EXTread behavior
If you are willing to muck about in the inbuilts, you may be able to do it like this (backup first! - this could affect other things). I did it temporarily by shadowing the existing finfo like this:
edit finfo.m (Now save a copy to the current folder)
Add these lines after the loop that defines the openAction (in my version, around line 85):
if any(strcmp(['.' ext], matlab.io.internal.xlsreadSupportedExtensions))
openAction = 'winopen';
end
From the folder containing your edited finfo.m, type which finfo -all. You should see two copies, the MATLAB one labelled as shadowed. Opening something from the current folder window should now open Excel externally.
I don't believe there's any straightforward way to do that. It's built in to MATLAB that Excel files will open in the import tool when you double click on them, and there's no way to change that.
You might be able to get around it by changing the file extension on your Excel files to something other than .xls or .xlsx. That would stop MATLAB from opening it in the import tool. Then in Windows, you could associate the new file extension with Excel.

How to Get specific version of solution when there are multiple solution?

I have multiple solutions in a folder. For example
C:\Code
-Solution1.sln
-Solution2.sln
-Solution3.sln
-[All other project files/folders belongs to above solution, etc]
Note that having these solutions in separate folders is not an option for me.
Assume if I open a one solution in VS2012 (i.e Solution1.sln). I right click on the solution
and select Source Control -> Get Specific Version...
Select Type "Latest Version", and tick two check boxes
a. Overwrite writable files that are not checked out
b. Overwrite all files even if the local version matches
And then press the "Get" button.
The problem is that this operation gets the all the latest files for the c:\Code folder - even the ones that are not belongs to my current opened solution (Solution1.sln). It replaces the files for Solution2 and Solution3.
Is there a way I can configure TFS only to get Solution1 file?
I'm using TFS2012
Update: Please see the sample structure below.
Okay. You have to move all your solution files to a solution folder will solve your problem. TFS is trying to get all the files from the solution folder and its sub folder. That's why you having this issue. Create a folder called Solution, you can create it inside the code folder or outside. Open your solution1 file in vs2012 and select the solution file and choose File -> Save Solution1.sln as and save it in the solutions directory. Repeat the same for all the solution files.
Once you are happy with the new solution files from the solutions directory, delete the old solutions files form the code directory.
Browse to your solution in Source Control Explorer, select "Get Specific Version" from the Advanced menu: it should work fine.

Total Commander How to feed list listbox with selected files

Just like Search result can feed the listbox (which opens new temporary tab),
is there a way to:
simply select files from one directory and feed the listbox?
select files from multiple directories and feed the same listbox?
Just to rename listbox's temporary tab and you could have favorite list of items over which you could perform more actions. This would increase productivity tremendously!
Regarding #1:
After you select the files activate:
Menu > Show > Only Selected Files
Regarding #2:
It's probably not what you were after, but you can use DiskDir / DiskDir Extended to add files (using a packer functionality, so you create an 'archive' file with extension .lst which contains a hierarchical list of the added files. You can then change source folder and then add more files. Later you just click on the .lst file and it looks no different then your normal file / folder list. Unfortunatelly you cannot rename the files, but you can launch them, with an extra confirmation.
UPDATE
Similar functionalitybut with 'source' renaming functionality limited to one file only (?): Virtual Panel, (File System Plugin, accessible through the Network Neighborhood 'drive'). It can launch files without a confirmation window. Rename 'source/target' file when you use it's own subbar (located here: %%COMMANDER_PATH%%\Plugins\WFX\VirtualPanel\EN\VirtualPanel.bar, make sure that you also have installed the AskParam addon and have paths in the VirtualPanel.bar right (both to AskParam.exe and VPBatch.exe). 'Regular' rename will change the file name only in the virtual panel.
URL: Virtual Panel Plugin

Resources