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

List:       kde-commits
Subject:    [kdelibs/frameworks] kdeui/dialogs: Port away from KDialog
From:       Kevin Ottens <ervin+bluesystems () kde ! org>
Date:       2012-12-13 17:14:01
Message-ID: 20121213171401.06ECBA60E8 () git ! kde ! org
[Download RAW message or body]

Git commit 85be4d18486f8d9e6e6c9e2d4cf8d199f38fba81 by Kevin Ottens.
Committed on 13/12/2012 at 13:34.
Pushed by ervin into branch 'frameworks'.

Port away from KDialog

M  +25   -17   kdeui/dialogs/kswitchlanguagedialog_p.cpp
M  +2    -2    kdeui/dialogs/kswitchlanguagedialog_p.h

http://commits.kde.org/kdelibs/85be4d18486f8d9e6e6c9e2d4cf8d199f38fba81

diff --git a/kdeui/dialogs/kswitchlanguagedialog_p.cpp \
b/kdeui/dialogs/kswitchlanguagedialog_p.cpp index 57a7059..7c2c443 100644
--- a/kdeui/dialogs/kswitchlanguagedialog_p.cpp
+++ b/kdeui/dialogs/kswitchlanguagedialog_p.cpp
@@ -22,6 +22,7 @@
 #include "moc_kswitchlanguagedialog_p.cpp"
 
 #include <QApplication>
+#include <QDialogButtonBox>
 #include <QLayout>
 #include <QLabel>
 #include <QPushButton>
@@ -30,6 +31,7 @@
 
 #include <klanguagebutton.h>
 #include <kconfig.h>
+#include <kconfiggroup.h>
 #include <klocale.h>
 #include <klocalizedstring.h>
 #include <kmessagebox.h>
@@ -88,26 +90,20 @@ public:
     QMap<QPushButton*, LanguageRowData> languageRows;
     QList<KLanguageButton*> languageButtons;
     QGridLayout *languagesLayout;
-    QWidget *page;
 };
 
 /*************************** KSwitchLanguageDialog **************************/
 
 KSwitchLanguageDialog::KSwitchLanguageDialog( QWidget *parent )
-  : KDialog(parent),
+  : QDialog(parent),
     d(new KSwitchLanguageDialogPrivate(this))
 {
-    setCaption(i18n("Switch Application Language"));
-    setButtons(Ok | Cancel | Default);
-    setDefaultButton(Ok);
-    connect(this, SIGNAL(okClicked()), SLOT(slotOk()));
-    connect(this, SIGNAL(defaultClicked()), SLOT(slotDefault()));
-
-    d->page = new QWidget( this );
-    setMainWidget(d->page);
-    QVBoxLayout *topLayout = new QVBoxLayout( d->page );
-    topLayout->setMargin( 0 );
-    QLabel *label = new QLabel( i18n("Please choose the language which should be \
used for this application:"), d->page ); +    setWindowTitle(i18n("Switch Application \
Language")); +
+    QVBoxLayout *topLayout = new QVBoxLayout;
+    setLayout(topLayout);
+
+    QLabel *label = new QLabel(i18n("Please choose the language which should be used \
for this application:"), this);  topLayout->addWidget( label );
 
     QHBoxLayout *languageHorizontalLayout = new QHBoxLayout();
@@ -135,13 +131,25 @@ KSwitchLanguageDialog::KSwitchLanguageDialog( QWidget *parent )
     QHBoxLayout *addButtonHorizontalLayout = new QHBoxLayout();
     topLayout->addLayout(addButtonHorizontalLayout);
 
-    QPushButton *addLangButton = new QPushButton(i18n("Add Fallback Language"), \
d->page); +    QPushButton *addLangButton = new QPushButton(i18n("Add Fallback \
                Language"), this);
     addLangButton->setToolTip(i18n("Adds one more language which will be used if \
                other translations do not contain a proper translation."));
     connect(addLangButton, SIGNAL(clicked()), this, SLOT(slotAddLanguageButton()));
     addButtonHorizontalLayout->addWidget(addLangButton);
     addButtonHorizontalLayout->addStretch();
 
     topLayout->addStretch(10);
+
+    QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
+    buttonBox->setStandardButtons(QDialogButtonBox::Ok
+                                | QDialogButtonBox::Cancel
+                                | QDialogButtonBox::RestoreDefaults);
+    topLayout->addWidget(buttonBox);
+
+    connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotOk()));
+    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+    connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()),
+            this, SLOT(slotDefault()));
 }
 
 KSwitchLanguageDialog::~KSwitchLanguageDialog()
@@ -322,7 +330,7 @@ void KSwitchLanguageDialogPrivate::addLanguageButton(const \
QString & languageCod  {
     QString labelText = primaryLanguage ? i18n("Primary language:") : i18n("Fallback \
language:");  
-    KLanguageButton *languageButton = new KLanguageButton(page);
+    KLanguageButton *languageButton = new KLanguageButton(p);
 
     fillApplicationLanguages(languageButton);
 
@@ -340,7 +348,7 @@ void KSwitchLanguageDialogPrivate::addLanguageButton(const \
QString & languageCod  
     if (!primaryLanguage)
     {
-        removeButton = new QPushButton(i18n("Remove"), page);
+        removeButton = new QPushButton(i18n("Remove"), p);
 
         QObject::connect(
             removeButton,
@@ -356,7 +364,7 @@ void KSwitchLanguageDialogPrivate::addLanguageButton(const \
QString & languageCod  
     int numRows = languagesLayout->rowCount();
 
-    QLabel *languageLabel = new QLabel(labelText, page);
+    QLabel *languageLabel = new QLabel(labelText, p);
     languagesLayout->addWidget( languageLabel, numRows + 1, 1, Qt::AlignLeft );
     languagesLayout->addWidget( languageButton, numRows + 1, 2, Qt::AlignLeft );
 
diff --git a/kdeui/dialogs/kswitchlanguagedialog_p.h \
b/kdeui/dialogs/kswitchlanguagedialog_p.h index f0a54c0..64151b5 100644
--- a/kdeui/dialogs/kswitchlanguagedialog_p.h
+++ b/kdeui/dialogs/kswitchlanguagedialog_p.h
@@ -22,7 +22,7 @@
 #ifndef _KSWITCHLANGUAGEDIALOG_H_
 #define _KSWITCHLANGUAGEDIALOG_H_
 
-#include <kdialog.h>
+#include <QDialog>
 
 namespace KDEPrivate {
 
@@ -38,7 +38,7 @@ class KSwitchLanguageDialogPrivate;
  * @internal
  */
 
-class KSwitchLanguageDialog : public KDialog
+class KSwitchLanguageDialog : public QDialog
 {
   Q_OBJECT
 


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

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