QFileDialog prompt to overwrite if selection changed - qt

I would like a QFileDialog to prompt for overwrite confirmation only if the selection changed. Is there any way to achieve this?
Currently, I'm getting a save file name as follows:
data_file_name = QtGui.QFileDialog.getSaveFileName(self, "Data File", selected, self.FILTER_DATA_FILE)
If I'm re-saving an open project, selected is the name of the project file. If I'm creating a new project, selected is the name of the directory where the user most recently saved a project. If I enter a file name that doesn't exist (regardless of the value of selected), I don't get prompted for confirmation, as desired. However, if the selected name is a file that exists, also regardless of the value of selected, I always get promoted for confirmation. I would like the following behaviour:
If the dialog has a default selection and the user does not change this selection, do not prompt for confirmation.
Else if the user enters a file name that does not currently exist, do not prompt for confirmation.
Else prompt for confirmation. (I don't particularly care what happens if the user enters the empty string as a file name.)
I'm currently using Qt 4, though I'm not against upgrading to Qt 5 if that would make my life easier.

It looks like what I want isn't possible: QFileDialog::accept() doesn't provide any mechanism for that sort of customization. I'll have to disable overwrite confirmation in my dialog and implement that logic myself.

Related

Applescript dictionary missing fields how to iterate over settings set

In my previous question I asked how to change an AppleScript current settings to have the ShowActiveProcessArgumentsInTitle for the terminal profile. Because you can apply that plist field from another settings set yet the keywords in AppleScript are missing. This is proved by setting the terminal to a different profile red sands with that option toggled off using the current setting of that tab.
tell application "Terminal"
set newTab to do script "bash /Users/jredfox/Desktop/hello.sh"
set current settings of newTab to settings set "Red Sands"
end tell
#!/bin/bash
echo hello
read -p "Press ENTER to continue..."
exit
I have current settings of xtab and from there I want to iterate over every field in there. How can I do this? The AppleScript dictionary I just proved is missing a field that can be applied from AppleScript but isn't in the dictionary from the script editor app. So how do I iterate every field from current settings which is a settings set object. There appears to be new fields which are not in the dictionary. It's not iterable so using a repeat list isn't an option.

how to handle file upload by a button in robot framework

when testing the webUI, when uploading a file through button,but when use input element, but it is ugly, If you have some ideas not replace button to handle uploading file.
Selenium 2 library provides "Choose File" keyword to upload the file. It takes two arguments, first is locator for the button and second is path to the file which needs to be uploaded.
Example: choose file xpath=.//div/input ${TEMPDIR}${/}file_pa.csv
Reference: http://robotframework.org/Selenium2Library/Selenium2Library.html#Choose%20File
I had the same issue and I was able to solve it using other libraries. Selenium2Library support "Input" field, so it only works when you have an input field to select the field then click other button to make the upload. Which is an old fashioned scenario. In order to achieve this you need other libraries that control the windows control like AutoItLibrary or SikuliLibrary Below is a quick example using either ways
AutoItLibrary:
sleep 2s
Send ${ImagePath} # This sends the file path to the entery field where the cursor is focused
sleep 3s
Control Click strTitle=Open, strText=Open, strControl=1, strButton=Button1, nNumClicks=1, nX=1228, nY=291
# In some cases some parameters cannot be identified easily so yo might just use only the buttong name as the following
# Control Click ${EMPTY} ${EMPTY} Button1 ${EMPTY} 1
For SikuliLibrary you can use the Press key to click the controllers and you can find many ways to emulate the copy paste either using javascripts or other key words. For the enter emulation on SikuliLibrary use the following:
Press Special Key ENTER #Case senstive (to press enter with Sikuli)

Install4j console handler for directory selection

My app has an installation directory chooser form. It validates whether dir has required available space. Screen looks like:
some text
Dir chooser component
A label which prints the available disk space. This is bound to a context variable availableSpace.
Disk space is calculated in "validation expression".
This works correctly in UI mode. In console mode - the behaviour is:
A. #1 is shown.
B. #2 asks user to select dir
(user selects a dir)
C. #3 shows the label text. Since there is no calculation done yet, availableSpace is not updated yet. User sees an old value.
D. Validation logic triggers and the UI is rerendered.
E. #1 is shown. #2 is shown and user enters the dir again. #3 shows the value which was set in #C.
From UI's perspective the form has already calculated data so #C is correct.
But from console user's perspective, user entered a dir and so #C is confusing to user. Because he just entered a dir and space value is old. He thinks that the dir has space, why is application shows old value ?
How to fix this behaviour ?
One solutionis to not show #C on console mode and instead use a Util.showMessage().
Can ConsoleHandlerFormComponent solve this ?
Is there a handler for DirectoryChooserComponent selection ? That can check for space in real time.
Thanks for your help.
In console mode, the "Validation script" property of the "Installation directory chooser" form component is executed as soon as you confirm the selection.
The problem in your case is that the label is not updated. This is because form components are initialized only once at the time that the screen is created. You can call
formEnvironment.reinitializeFormComponents();
in the "Validation script", then the contents of the label will be evaluated again.

How to set user command in Qt Fakevim?

(1) For example, I want to set map gd g* in Qt's Fakevim like below but failed.
(2) And also I'd like to set F3 as the save command, how to do it?
(3) In Fakevim, it provides an option "Read .vimrc", but where to find the file .vimrc?
Thank you!
It doesn't look like there is a lot of documentation for FakeVim, so official sources might not exist. Most of this was obtained by experimentation.
If you want to dig deeper, I guess there's no source as official as the actual source: http://qt.gitorious.org/qt-creator/qt-creator/blobs/0809986e501415fe2c8508800b94b5b3169dc048/src/plugins/fakevim/fakevimplugin.cpp
User commands
First off, realize that in Tools>Options>FakeVim>User Command Mapping, you're only setting what your user actions will perform, not how you perform them.
By default, user command #1 is triggered by pressing Alt-V, then 1.
Alt-V, then 2, triggers user action #2, and so on.
You can change the keyboard shortcuts through the general QtCreator configuration interface, under Tools>Options>Environment>Keyboard. There is a "FakeVim" section with all the user actions listed. Select your user action of choice, press the little "erase" icon in the input field under "Shortcut", then press your desired shortcut key, which should appear in the input field.
Second, to finish a command where you would normally press enter, you should literally type in <CR> after the commands. You also need to enter in ':' to enter command mode.
So if you wanted to map the vim save command, ":w", to F3 via FakeVim, you would:
Go to Tools>Options>FakeVim>User Command Mapping.
Enter ":w<CR>" as one of the user commands (say #7).
Go to Tools>Options>Environment>Keyboard.
Find the FakeVim action "UserAction7".
Set F3 as a shortcut for it.
Now, every time you're in the editor, you should be able to click F3 and have the FakeVim :w command execute, which will save your file.
Note that there is also an option to set a shortcut for "Save" directly in the QtCreator keyboard settings, so for this particular shortcut you don't actually need to go through FakeVim.
Setting shortcuts for other vim commands should be similar. Note that you're restricted to the subset of vim commands that FakeVim implements. Refer to the source, linked above, for checking any particular command you're wondering about.
Vimrc file
On Linux this would be ~/.vimrc, a file in the user's home directory. I presume you're asking about Windows.
The best source I can find is this bug report about it being hard to use Fakevim's vimrc on Windows: https://bugreports.qt.io/browse/QTCREATORBUG-8748
Following that, the file Fakevim looks for is ".vimrc" in %USERPROFILE% (you can enter a name like that in Explorer to go to the folder). However, it's tricky to access a file with a name like that on Windows. (Thus why the real vim uses '_vimrc' on Windows -- but FakeVim apparently doesn't, at least at the moment.)
Here is a superuser page with workarounds for how to create such files on Windows: https://superuser.com/questions/64471/create-rename-a-file-folder-that-begins-with-a-dot-in-windows

Run solution exe after installtion using installshield

I want to run my exe after installation using InstallShield.
InstallShield completes the setup correctly but do not run the exe.
I found another way to add an exe in startup but it runs after restart.
I would like it to run without restart.
Is it possible ?
What version and edition of InstallShield are you using? Also what project type are you using? (InstallScript, InstallScript MSI, Basic MSI? )
Assuming Basic MSI, InstallShield has a built-in pattern to support this story:
1) Click on the Project Assistant Tab
2) Click on the Installation Interview Icon (Page)
3) Click Yes for "Do you want to give the users the option to launch your application when the installation completes?
4) Click the browse button to select the EXE that should be the target of the operation.
By default the checkbox (launch program) on the setup complete dialog will not be selected. To select it automatically add the property LAUNCHPROGRAM to the property table and set it to a value of '1'.
Christopher Painter's answer will work for you most of the time. Those are the initial steps to take, but there are some additional details if you find that isn't enough. For instance, skb reported that this didn't work for him. I found that I was in the same boat (even though I've built a dozen other installers which had this work!).
Follow Christopher Painter's instructions.
Click on the "Installation Designer" tab. Within "User Interface" select "Dialogs".
Within "All Dialogs", expand "SetupCompleteSuccess", and select "Behavior".
Select the "Ok" push button control. Then, select "Events". (look to the bottom of the screen where it says Events/Subscriptions/Conditions)
You should have a "DoAction" event, with an "argument" equal to "IS_LAUNCH_MY_PROGRAM_PLEASE" and a "condition" of "LAUNCHPROGRAM". If not - add that. "LAUNCHPROGRAM" refers to the property of that name. It will have a value of 1 if the launch checkbox is selected, and thus meet this condition. IS_LAUNCH_MY_PROGRAM_PLEASE refers to the Custom Action which is launched. If you want, you can change that CA here to make any custom action fire instead. I opted to leave this alone, but replace the CA with one of my own.
Open your list of Custom Actions (Behavior and logic... Custom actions and sequences). You should find a CA there named IS_LAUNCH_MY_PROGRAM_PLEASE. Delete it!
Add your own IS_LAUNCH_MY_PROGRAM_PLEASE CA. Right-click "Custom Action" (the list header) and select the type of CA you want - or launch the wizard. Just be sure to name it "IS_LAUNCH_MY_PROGRAM_PLEASE" if you left the dialog behavior as it defaults.
To launch an exe - with the WORKING DIRECTORY changed (which was the reason my app wouldn't appear, and apparently skb's as well based on the comments) Select "New EXE"..."Path referencing a directory". Change "Return processing" to "Asynchronous (no wait for completion)". Note the "MSI type number" becomes 226. Set the "Working directory" to INSTALLDIR(assuming the program you want to launch should be found in your new program's directory). Set "Filename & command line" to [INSTALLDIR]YourApp.exe.

Resources