Use KDialog instead of QMessageBox for confirmation dialog (can't use KMessageBox)

svn path=/trunk/KDE/kdebase/workspace/; revision=714120
This commit is contained in:
Rivo Laks 2007-09-18 19:38:57 +00:00
parent d965cdee99
commit d32b4a3130
2 changed files with 17 additions and 7 deletions

View file

@ -24,6 +24,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <QtDBus/QtDBus> #include <QtDBus/QtDBus>
#include <QTimer> #include <QTimer>
#include <QLabel>
#include <KPluginFactory> #include <KPluginFactory>
#include <KPluginLoader> #include <KPluginLoader>
@ -37,9 +38,16 @@ namespace KWin
ConfirmDialog::ConfirmDialog() : ConfirmDialog::ConfirmDialog() :
QMessageBox(QMessageBox::Question, i18n("Compositing settings changed"), "", KDialog()
QMessageBox::Yes | QMessageBox::No)
{ {
setCaption( i18n( "Compositing settings changed" ));
setButtons( KDialog::Yes | KDialog::No );
setDefaultButton(KDialog::No);
setEscapeButton(KDialog::No);
mTextLabel = new QLabel(this);
setMainWidget(mTextLabel);
mSecondsToLive = 10+1; mSecondsToLive = 10+1;
advanceTimer(); advanceTimer();
} }
@ -52,12 +60,12 @@ void ConfirmDialog::advanceTimer()
QString text = i18n("Compositing settings have changed.\n" QString text = i18n("Compositing settings have changed.\n"
"Do you want to keep the new settings?\n" "Do you want to keep the new settings?\n"
"They will be automatically reverted in %1 seconds", mSecondsToLive); "They will be automatically reverted in %1 seconds", mSecondsToLive);
setText(text); mTextLabel->setText(text);
QTimer::singleShot(1000, this, SLOT(advanceTimer())); QTimer::singleShot(1000, this, SLOT(advanceTimer()));
} }
else else
{ {
reject(); slotButtonClicked(KDialog::No);
} }
} }
@ -125,7 +133,7 @@ void KWinCompositingConfig::showConfirmDialog()
ConfirmDialog confirm; ConfirmDialog confirm;
int result = confirm.exec(); int result = confirm.exec();
kDebug() << "result:" << result; kDebug() << "result:" << result;
if(result != QMessageBox::Yes) if(result != KDialog::Yes)
{ {
// Revert settings // Revert settings
KConfigGroup config(mKWinConfig, "Compositing"); KConfigGroup config(mKWinConfig, "Compositing");

View file

@ -16,17 +16,18 @@ License. See the file "COPYING" for the exact licensing terms.
#include <ksharedconfig.h> #include <ksharedconfig.h>
#include <QMessageBox> #include <kdialog.h>
#include "ui_main.h" #include "ui_main.h"
#include "compositingprefs.h" #include "compositingprefs.h"
class KPluginSelector; class KPluginSelector;
class QLabel;
namespace KWin namespace KWin
{ {
class ConfirmDialog : public QMessageBox class ConfirmDialog : public KDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -37,6 +38,7 @@ protected slots:
private: private:
int mSecondsToLive; int mSecondsToLive;
QLabel* mTextLabel;
}; };
class KWinCompositingConfig : public KCModule class KWinCompositingConfig : public KCModule