[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Why do all KMessageBox methods call exec()?
From:       Adriaan de Groot <groot () kde ! org>
Date:       2004-10-06 22:45:49
Message-ID: 200410070045.49982.groot () kde ! org
[Download RAW message or body]

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

["kmessagebox.diff" (text/x-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);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic