From kde-core-devel Wed Oct 06 22:45:49 2004 From: Adriaan de Groot Date: Wed, 06 Oct 2004 22:45:49 +0000 To: kde-core-devel Subject: Why do all KMessageBox methods call exec()? Message-Id: <200410070045.49982.groot () kde ! org> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=109710278307691 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_dWHZB6rfUVF4DN5" --Boundary-00=_dWHZB6rfUVF4DN5 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline I need a KMessageBox with a timeout -- that is, I want to be able to do something like this: QTimer *timeout = new QTimer(this); KMessageBox *box = KMessageBox::questionYesNoCancel(...); connect(timeout,SIGNAL(timeout()),box,SLOT(cancel())); timeout->start(20000,true); box->exec(); OK, I can understand that the question* and similar static methods call exec(), but what about createKMessageBox()? I would expect that it creates the message box -- no more than that The attached patch adds a NoExec option to the message box, so that you can get createKMessageBox() to behave like I would expect it to - creates a message box and does nothing else. Seem reasonable? -- Don't worry, 't ain't no shame to be stupid - ol' mouse. GPG: FEA2 A3FE Adriaan de Groot --Boundary-00=_dWHZB6rfUVF4DN5 Content-Type: text/x-diff; charset="us-ascii"; name="kmessagebox.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kmessagebox.diff" Index: kmessagebox.h =================================================================== RCS file: /home/kde/kdelibs/kdeui/kmessagebox.h,v retrieving revision 1.58 diff -u -3 -p -r1.58 kmessagebox.h --- kmessagebox.h 25 Jun 2004 09:34:40 -0000 1.58 +++ kmessagebox.h 2 Oct 2004 23:48:28 -0000 @@ -73,12 +73,16 @@ public: * @li Notify Emit a KNotifyClient event * @li AllowLink The message may contain links. * @li Dangerous The action to be confirmed by the dialog is a potentially destructive one + * @li NoExec Relevant for createKMessageBox() only, will _only_ add the layout + * to the KDialogBox and return a bogus value (Cancel); you will have to + * exec() the KMessageBox yourself. */ enum OptionsType { Notify = 1, AllowLink = 2, - Dangerous = 4 + Dangerous = 4, + NoExec = 8 }; /** Index: kmessagebox.cpp =================================================================== RCS file: /home/kde/kdelibs/kdeui/kmessagebox.cpp,v retrieving revision 1.94 diff -u -3 -p -r1.94 kmessagebox.cpp --- kmessagebox.cpp 25 Jun 2004 09:34:40 -0000 1.94 +++ kmessagebox.cpp 2 Oct 2004 23:48:28 -0000 @@ -282,6 +282,11 @@ int KMessageBox::createKMessageBox(KDial if ( (options & KMessageBox::Notify) != 0 ) sendNotification( text, strlist, notifyType, dialog->topLevelWidget()->winId()); + if ( (options & KMessageBox::NoExec) != 0 ) + { + return KMessageBox::Cancel; // We have to return something. + } + if (KMessageBox_queue) { KDialogQueue::queueDialog(dialog); --Boundary-00=_dWHZB6rfUVF4DN5--