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

List:       kde-commits
Subject:    KDE/kdelibs/kdeui/dialogs
From:       Christoph Feck <christoph () maxiom ! de>
Date:       2010-09-22 21:45:00
Message-ID: 20100922214500.7078DAC888 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1178388 by cfeck:

Allow application language to be reset to default language

Okey'd by tsdgeos on IRC.

REVIEW: 5324
FEATURE: 230108
FIXED-IN: 4.6.0


 M  +30 -1     kswitchlanguagedialog_p.cpp  
 M  +1 -0      kswitchlanguagedialog_p.h  


--- trunk/KDE/kdelibs/kdeui/dialogs/kswitchlanguagedialog_p.cpp #1178387:1178388
@@ -96,9 +96,10 @@
     d(new KSwitchLanguageDialogPrivate(this))
 {
     setCaption(i18n("Switch Application Language"));
-    setButtons(Ok | Cancel);
+    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);
@@ -236,6 +237,34 @@
     accept();
 }
 
+void KSwitchLanguageDialog::slotDefault()
+{
+    const QStringList defaultLanguages = d->applicationLanguageList();
+
+    KConfigGroup group(KGlobal::config(), "Locale");
+
+    group.revertToDefault("Language");
+    group.sync();
+    // read back the new default
+    QString language = group.readEntry("Language", "en_US");
+
+    if (defaultLanguages != (QStringList() << language)) {
+
+        KMessageBox::information(
+            this,
+            i18n("The language for this application has been changed. The change \
will take effect the next time the application is started."), //text +            \
i18n("Application Language Changed"), //caption +            \
"ApplicationLanguageChangedWarning" //dontShowAgainName +            );
+
+        KGlobal::locale()->setLanguage(QStringList() << language);
+        QEvent ev(QEvent::LanguageChange);
+        QApplication::sendEvent(qApp, &ev);
+    }
+
+    accept();
+}
+
 /************************ KSwitchLanguageDialogPrivate ***********************/
 
 KSwitchLanguageDialogPrivate::KSwitchLanguageDialogPrivate(
--- trunk/KDE/kdelibs/kdeui/dialogs/kswitchlanguagedialog_p.h #1178387:1178388
@@ -65,6 +65,7 @@
         * Activated when the Ok button has been clicked.
         */
         virtual void slotOk();
+        void slotDefault();
         
         /**
             Called when one of language buttons changes state.


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

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