aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Fabio Bas2010-09-01 07:34:57 +0000
committerGravatar Fabio Bas2010-09-01 07:34:57 +0000
commit13f9211bd8d2406c3a06ab32fc2db41419ebf465 (patch)
treedef4239f01f4f9fd9c631087b54a9f893b48ac6d
parentimplemented #928 (diff)
downloadKVIrc-13f9211bd8d2406c3a06ab32fc2db41419ebf465.tar.gz
KVIrc-13f9211bd8d2406c3a06ab32fc2db41419ebf465.tar.bz2
KVIrc-13f9211bd8d2406c3a06ab32fc2db41419ebf465.zip
fixed dialog.message return value when closed with the window manager close button
fixes to switch, dialog module and toolbar module by OmegaPhil git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4961 17fca916-40b9-46aa-a4ea-0a15b648b75c
-rw-r--r--src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp31
-rw-r--r--src/modules/dialog/libkvidialog.cpp39
-rw-r--r--src/modules/toolbar/libkvitoolbar.cpp8
3 files changed, 43 insertions, 35 deletions
diff --git a/src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp b/src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp
index 31465c6c9..cfe7ccf68 100644
--- a/src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp
+++ b/src/kvirc/kvs/kvi_kvs_parser_specialcommands.cpp
@@ -1312,34 +1312,31 @@ KviKvsTreeNodeCommand * KviKvsParser::parseSpecialCommandSwitch()
Another flow control command
@description:
The switch command is based on the standard C 'switch' keyword.
- It executes conditionally groups of commands chosen from
- a larger set of command groups.[br]
+ It conditionally executes groups of commands chosen from a larger set of command groups.[br]
First <expression> is evaluated (<expression> is any arithmetic or string expression).[br]
- Then the 'match','regexp','case' and 'default' labels are evaluated sequentially
+ Then the 'match', 'regexp', 'case' and 'default' labels are evaluated sequentially
in the order of appearance.[br]
[b]case(<value>)[:]<command>[/b][br]
The <value> is evaluated and is compared against the result of <expression>.
- The comparison is case insensitive (if the values are strings).[br]
+ String comparison is case insensitive.[br]
If <value> is equal to <expression> then <command> is executed.
Please note that <command> must be either a single instruction or an instruction block [b]enclosed in braces[/b].
- If <command> contains a [cmd]break[/cmd] statement inside or if [cmd]break[/cmd]
- is specified just after the <command> then the execution of the switch is terminated
- otherwise the nex label is evaluated.[br]
+ During or after <command> execution, if a [cmd]break[/cmd] statement is encountered the execution of the switch
+ is terminated, otherwise the next label is evaluated.[br]
If the -p (--passthrough) option is enabled, than the switch command will execute all the istructions blocks
- until a [cmd]break[/cmd] statement is found.
+ until a [cmd]break[/cmd] statement is found.[br]
[b]match(<value>)[:]<command>[/b][br]
- The <value> is expected to be a wildcard expression (containing '*' and '?' wildcards)
- that is matched against <expression>.[br]
- If there is a match (a complete case insensitive match!) then the related <command>
- is executed. [cmd]brea[/cmd] is treated just like in the case label.[br]
+ The <value> is expected to be a wildcard expression (wildcard characters being '*' and '?')
+ that is matched in a case insensitive fashion against <expression>.[br]
+ If a match occurs, the related <command> is executed.
+ The [cmd]break[/cmd] statement is treated as in the case label.[br]
[b]regexp(<value>)[:]<command>[/b][br]
The <value> is expected to be a complete standard regular expression
- that is matched agains <expression>.[br]
- If there is a match (a complete case insensitive match!) then the related <command>
- is executed. [cmd]brea[/cmd] is treated just like in the case label.[br]
+ that is matched in a case insensitive fashion against <expression>.[br]
+ If a match occurs, the related <command> is executed.
+ The [cmd]break[/cmd] statement is treated as in the case label.[br]
[b]default[:]<command>[/b][br]
- The default label is executed unconditionally (unless there was a previous label
- that terminated the execution with break).[br]
+ The default label is executed unconditionally if no previous label terminated execution with the [cmd]break[/cmd] statement.[br]
@examples:
[comment]# Try to change the 1 below to 2 or 3 to see the results[/comment]
[example]
diff --git a/src/modules/dialog/libkvidialog.cpp b/src/modules/dialog/libkvidialog.cpp
index 8c4f91a70..ffb1cc629 100644
--- a/src/modules/dialog/libkvidialog.cpp
+++ b/src/modules/dialog/libkvidialog.cpp
@@ -69,12 +69,18 @@ KviKvsCallbackMessageBox::KviKvsCallbackMessageBox(
setIcon(QMessageBox::NoIcon);
QMessageBox::StandardButtons buttons;
bool btn=false;
- if (!szButton0.isEmpty()) {btn=true;buttons=QMessageBox::Yes | QMessageBox::Default;}
+ if (!szButton0.isEmpty()) {btn=true;buttons=QMessageBox::Yes;}
if (!szButton1.isEmpty()) {btn=true;buttons|=QMessageBox::No;}
- if (!szButton2.isEmpty()) {btn=true;buttons|=QMessageBox::Cancel | QMessageBox::Escape;}
+ if (!szButton2.isEmpty()) {btn=true;buttons|=QMessageBox::Cancel; }
if (!btn) buttons=QMessageBox::Ok;
setStandardButtons(buttons);
+ setDefaultButton(QMessageBox::Yes);
+ if(szButton2.isEmpty())
+ setEscapeButton(QMessageBox::No);
+ else
+ setEscapeButton(QMessageBox::Cancel);
+
g_pDialogModuleDialogList->append(this);
QPixmap * pix = g_pIconManager->getImage(szIcon);
@@ -105,6 +111,13 @@ void KviKvsCallbackMessageBox::done(int code)
{
case QMessageBox::No: iVal = 1; break;
case QMessageBox::Cancel: iVal = 2; break;
+ case 0:
+ // user closed the dialog, fake an "escape button" press
+ if(standardButtons() & QMessageBox::Cancel)
+ iVal = 2;
+ else
+ iVal = 1;
+ break;
}
KviKvsVariantList params;
@@ -137,20 +150,18 @@ void KviKvsCallbackMessageBox::done(int code)
<icon> can be a relative or absolute path to an image file, a signed number (in that case it defines
an internal KVIrc image) or one of the special strings "critical", "information" and "warning".[br]
<button0> is the text of the first button (on the left).[br]
- <button1> is the text of the second button (if empty or not given at all, only one button will appear in the dialog).[br]
- <button2> is the text of the third button (if empty or not given, only two buttons will appear in the dialog).[br]
- The first button is always the default button: it is activated when the user presses the
- enter key. The thirs, or the second if the third is not present, is the escape button
- and is activated when the user presses the Esc key.[br]
- <magic1>,<magic2>... are the magic parameters: evaluated at dialog.message call time and passed
+ <button1> is the text of the second button (if empty or specified, only one button will appear in the dialog).[br]
+ <button2> is the text of the third button (if empty or specified, only two buttons will appear in the dialog).[br]
+ The first button is always the default button - it is activated when the user presses the
+ enter key. The third (or the second if only two buttons are present) is treated as the escape button
+ and is activated when the user presses the Esc key or closes the dialog with the window manager close button.[br]
+ <magic1>,<magic2>... are the magic parameters - evaluated at dialog.message call time and passed
to the <callback_command> as positional parameters.[br]
- If the -b or -modal switch is specified the dialog will have non-blocking modal behaviour:
- it will appear above its parent widget and block its input until it's closed.[br]
- Once the dialog has been shown, the user will click one of the buttons. At this point the dialog
- is hidden and the <callback_command> is executed passing the number of the button clicked
+ If the -b or -modal switch is specified the dialog will have non-blocking modal behaviour -
+ it will appear above its parent widget and block its input until the dialog is closed.[br]
+ Once the dialog is displayed, the user will click one of the buttons. At this point the dialog
+ is hidden and the <callback_command> is executed, passing the number of the button clicked
as $0 and the magic parameters as positional parameters $1, $2, $3....[br]
- Please note that if the user closes the window with the window manager close button,
- the action is interpreted as a button2 click (that is usually sth as "Cancel").[br]
@examples:
[example]
[comment]# Just a warning dialog[/comment]
diff --git a/src/modules/toolbar/libkvitoolbar.cpp b/src/modules/toolbar/libkvitoolbar.cpp
index 703ec2557..ba68e31fe 100644
--- a/src/modules/toolbar/libkvitoolbar.cpp
+++ b/src/modules/toolbar/libkvitoolbar.cpp
@@ -320,8 +320,8 @@ static bool toolbar_kvs_fnc_exists(KviKvsModuleFunctionCall * c)
@syntax:
<boolean> $toolbar.isVisible(<id:string>)
@description:
- Returns 1 if the toolbar with the specified <id> is actually visible and 0 otherwise.[br]
- If the toolbar is not defined at all this function still returns 0.[br]
+ Returns 1 if the toolbar with the specified <id> is visible,
+ or 0 when invisible or the given toolbar does not exist.
@seealso:
[cmd]toolbar.show[/cmd]
*/
@@ -348,8 +348,8 @@ static bool toolbar_kvs_fnc_isVisible(KviKvsModuleFunctionCall * c)
@syntax:
<array> $toolbar.list()
@description:
- Returns a list of defined toolbar identifiers.[br]
- You can use this function to loop thru all the toolbar definitions.[br]
+ Returns a list of defined toolbar identifiers -
+ this can be used to loop through all defined toolbars.
@seealso:
*/