mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdeui: raise and activate KMessageBox and queued KDialog windows
this is mostly for status notifier dialogs, if the dialogs are not raised and activated they will block (because QDialog::exec() is called) and manual activation has to be done (via alt+tab) Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
37f9ea4dba
commit
b3b190e6ae
4 changed files with 20 additions and 10 deletions
|
@ -44,6 +44,7 @@
|
||||||
#include <kstandardguiitem.h>
|
#include <kstandardguiitem.h>
|
||||||
#include <ktoolinvocation.h>
|
#include <ktoolinvocation.h>
|
||||||
#include <kurllabel.h>
|
#include <kurllabel.h>
|
||||||
|
#include <kwindowsystem.h>
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#include <qx11info_x11.h>
|
#include <qx11info_x11.h>
|
||||||
|
@ -1108,6 +1109,9 @@ void KDialogQueue::Private::slotShowQueuedDialog()
|
||||||
} while(!dialog);
|
} while(!dialog);
|
||||||
|
|
||||||
busy = true;
|
busy = true;
|
||||||
|
dialog->show();
|
||||||
|
KWindowSystem::raiseWindow(dialog->winId());
|
||||||
|
KWindowSystem::forceActiveWindow(dialog->winId());
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
busy = false;
|
busy = false;
|
||||||
delete dialog;
|
delete dialog;
|
||||||
|
|
|
@ -40,21 +40,20 @@
|
||||||
*/
|
*/
|
||||||
class KDialogQueue : public QObject
|
class KDialogQueue : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
public:
|
||||||
public:
|
|
||||||
static void queueDialog(QDialog *);
|
static void queueDialog(QDialog *);
|
||||||
|
|
||||||
~KDialogQueue();
|
~KDialogQueue();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
KDialogQueue();
|
KDialogQueue();
|
||||||
static KDialogQueue *self();
|
static KDialogQueue *self();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PRIVATE_SLOT(d, void slotShowQueuedDialog())
|
Q_PRIVATE_SLOT(d, void slotShowQueuedDialog())
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
friend class Private;
|
friend class Private;
|
||||||
Private* const d;
|
Private* const d;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "kwindowsystem.h"
|
#include "kwindowsystem.h"
|
||||||
|
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
#include <QtGui/QCheckBox>
|
#include <QtGui/QCheckBox>
|
||||||
#include <QtGui/QGroupBox>
|
#include <QtGui/QGroupBox>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
|
@ -333,11 +334,17 @@ int KMessageBox::createKMessageBox(KDialog *dialog, const QIcon &icon,
|
||||||
return KMessageBox::Cancel; // We have to return something.
|
return KMessageBox::Cancel; // We have to return something.
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use a QPointer because the dialog may get deleted
|
// use a QPointer because the dialog may get deleted
|
||||||
// during exec() if the parent of the dialog gets deleted.
|
// during exec() if the parent of the dialog gets deleted.
|
||||||
// In that case the QPointer will reset to 0.
|
// In that case the QPointer will reset to 0.
|
||||||
QPointer<KDialog> guardedDialog = dialog;
|
QPointer<KDialog> guardedDialog = dialog;
|
||||||
|
|
||||||
|
// raise the dialog in case the parent is minimized (hidden), e.g. status
|
||||||
|
// status notifier item (kget)
|
||||||
|
guardedDialog->show();
|
||||||
|
KWindowSystem::raiseWindow(guardedDialog->winId());
|
||||||
|
KWindowSystem::forceActiveWindow(guardedDialog->winId());
|
||||||
|
|
||||||
const int result = guardedDialog->exec();
|
const int result = guardedDialog->exec();
|
||||||
if (checkbox && checkboxReturn) {
|
if (checkbox && checkboxReturn) {
|
||||||
*checkboxReturn = checkbox->isChecked();
|
*checkboxReturn = checkbox->isChecked();
|
||||||
|
|
|
@ -22,13 +22,13 @@
|
||||||
#ifndef KMESSAGEBOX_H
|
#ifndef KMESSAGEBOX_H
|
||||||
#define KMESSAGEBOX_H
|
#define KMESSAGEBOX_H
|
||||||
|
|
||||||
#include <QtGui/QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include <kguiitem.h>
|
#include <kguiitem.h>
|
||||||
#include <kstandardguiitem.h>
|
#include <kstandardguiitem.h>
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QStringList>
|
|
||||||
class KConfig;
|
class KConfig;
|
||||||
class KDialog;
|
class KDialog;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue