[PC-BSD Commits] r19684 - in pcbsd/branches/9.1/src-qt4/pc-firstbootgui: . i18n

svn at pcbsd.org svn at pcbsd.org
Mon Oct 15 14:32:51 PDT 2012


Author: kris
Date: 2012-10-15 21:32:51 +0000 (Mon, 15 Oct 2012)
New Revision: 19684

Added:
   pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en.ts
   pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en_US.ts
Modified:
   pcbsd/branches/9.1/src-qt4/pc-firstbootgui/firstboot.cpp
   pcbsd/branches/9.1/src-qt4/pc-firstbootgui/firstboot.h
   pcbsd/branches/9.1/src-qt4/pc-firstbootgui/main.cpp
   pcbsd/branches/9.1/src-qt4/pc-firstbootgui/pc-firstbootgui.pro
Log:

MFC fix to first-boot GUI as well



Modified: pcbsd/branches/9.1/src-qt4/pc-firstbootgui/firstboot.cpp
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-firstbootgui/firstboot.cpp	2012-10-15 21:30:44 UTC (rev 19683)
+++ pcbsd/branches/9.1/src-qt4/pc-firstbootgui/firstboot.cpp	2012-10-15 21:32:51 UTC (rev 19684)
@@ -14,6 +14,7 @@
 Installer::Installer(QWidget *parent) : QMainWindow(parent)
 {
     setupUi(this);
+    translator = new QTranslator();
 
     connect(backButton, SIGNAL(clicked()), this, SLOT(slotBack()));
     connect(nextButton, SIGNAL(clicked()), this, SLOT(slotNext()));
@@ -217,14 +218,24 @@
     langCode.truncate(langCode.lastIndexOf(")"));
     langCode.remove(0, langCode.lastIndexOf("(") + 1); 
 
-    // Now write out the lang code and close
-    QFile lfile( TMPLANGFILE );
-    if ( lfile.open( QIODevice::WriteOnly ) ) {
-      QTextStream stream( &lfile );
-        stream <<  langCode;
-      lfile.close();
+    // Check what directory our app is in
+    QString appDir;
+    if ( QFile::exists("/usr/local/bin/pc-sysinstaller") )
+      appDir = "/usr/local/share/pcbsd";
+    else
+      appDir = QCoreApplication::applicationDirPath();
+    
+    //QTranslator *translator = new QTranslator();
+    qDebug() << "Remove the translator";
+    if ( ! translator->isEmpty() )
+      QCoreApplication::removeTranslator(translator);
+    
+    if (translator->load( QString("FirstBoot_") + langCode, appDir + "/i18n/" )) {
+      qDebug() << "Load new Translator" << langCode;
+      QCoreApplication::installTranslator(translator);
+      this->retranslateUi(this);
     }
-    exit(0);
+
 }
 
 void Installer::changeLang(QString code)

Modified: pcbsd/branches/9.1/src-qt4/pc-firstbootgui/firstboot.h
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-firstbootgui/firstboot.h	2012-10-15 21:30:44 UTC (rev 19683)
+++ pcbsd/branches/9.1/src-qt4/pc-firstbootgui/firstboot.h	2012-10-15 21:32:51 UTC (rev 19684)
@@ -5,6 +5,7 @@
 #include <QMessageBox>
 #include <QFile>
 #include <QProcess>
+#include <QTranslator>
 
 #include "ui_firstboot.h"
 #include "dialogHelp.h"
@@ -82,6 +83,8 @@
     QString kbLay;
     QString kbVar;
 
+    QTranslator *translator;
+
 protected:
     void closeEvent(QCloseEvent *event);
 

Index: pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en.ts
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en.ts	2012-10-15 21:30:44 UTC (rev 19683)
+++ pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en.ts	2012-10-15 21:32:51 UTC (rev 19684)

Property changes on: pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en.ts
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
Index: pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en_US.ts
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en_US.ts	2012-10-15 21:30:44 UTC (rev 19683)
+++ pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en_US.ts	2012-10-15 21:32:51 UTC (rev 19684)

Property changes on: pcbsd/branches/9.1/src-qt4/pc-firstbootgui/i18n/FirstBoot_en_US.ts
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
Modified: pcbsd/branches/9.1/src-qt4/pc-firstbootgui/main.cpp
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-firstbootgui/main.cpp	2012-10-15 21:30:44 UTC (rev 19683)
+++ pcbsd/branches/9.1/src-qt4/pc-firstbootgui/main.cpp	2012-10-15 21:32:51 UTC (rev 19684)
@@ -10,77 +10,52 @@
 
 int main(int argc, char *argv[])
 {
-    int returnCode;
     QString changeLang;
 
-    // Start a loop to watch for language changes
-    for ( ;; )
-    {
-      QApplication a(argc, argv);
+    QApplication a(argc, argv);
 
-      // Check what directory our app is in
-      QString appDir;
-      if ( QFile::exists("/usr/local/bin/pc-firstboot") )
-      {
-        appDir = "/usr/local/share/pcbsd";
-      } else {
-        appDir = QCoreApplication::applicationDirPath();
-      }
+    // Check what directory our app is in
+    QString appDir;
+    if ( QFile::exists("/usr/local/bin/pc-firstboot") )
+      appDir = "/usr/local/share/pcbsd";
+    else
+      appDir = QCoreApplication::applicationDirPath();
 
-      QTranslator translator;
-      QLocale mylocale;
-      QString langCode = mylocale.name();
+    QTranslator translator;
+    QLocale mylocale;
+    QString langCode = mylocale.name();
 
-      if ( ! changeLang.isEmpty() )       
-         langCode = changeLang;
+    if ( ! changeLang.isEmpty() )       
+       langCode = changeLang;
 
-      if ( QFile::exists(appDir + "/i18n/FirstBoot_" + langCode + ".qm" ) ) {
-        translator.load( QString("FirstBoot_") + langCode, appDir + "/i18n/" );
-        a.installTranslator(&translator);
-        qDebug() << "Loaded Translation:" << appDir + "/i18n/FirstBoot_" + langCode + ".qm";
-      } else {
-        qDebug() << "Could not find: " << appDir + "/i18n/FirstBoot_" + langCode + ".qm";
-        langCode = "";
-      }
+    if ( QFile::exists(appDir + "/i18n/FirstBoot_" + langCode + ".qm" ) ) {
+      translator.load( QString("FirstBoot_") + langCode, appDir + "/i18n/" );
+      a.installTranslator(&translator);
+      qDebug() << "Loaded Translation:" << appDir + "/i18n/FirstBoot_" + langCode + ".qm";
+    } else {
+      qDebug() << "Could not find: " << appDir + "/i18n/FirstBoot_" + langCode + ".qm";
+      langCode = "";
+    }
 
-      // Show our splash screen, so the user doesn't freak that that it takes a few seconds to show up
-      QPixmap pixmap(":/PCBSD/images/pcbsdheader.png");
-      QSplashScreen splash(pixmap);
-      splash.show();
+    // Show our splash screen, so the user doesn't freak that that it takes a few seconds to show up
+    QPixmap pixmap(":/PCBSD/images/pcbsdheader.png");
+    QSplashScreen splash(pixmap);
+    splash.show();
 
 
-      Installer w;
+    Installer w;
 
-      // Center the installer
-      QRect dimensions = QApplication::desktop()->screenGeometry();
-      int wid = dimensions.width();     // returns desktop width
-      int hig = dimensions.height();    // returns desktop height
-      w.setGeometry((wid/2) - (650/2), (hig/2) - (435/2), 650, 435);
+    // Center the installer
+    QRect dimensions = QApplication::desktop()->screenGeometry();
+    int wid = dimensions.width();     // returns desktop width
+    int hig = dimensions.height();    // returns desktop height
+    w.setGeometry((wid/2) - (650/2), (hig/2) - (435/2), 650, 435);
 
-      // Start the init
-      w.initInstall();
+    // Start the init
+    w.initInstall();
 
-      // Check if we are using diff language
-      if ( ! langCode.isEmpty() )
-        w.changeLang(langCode);
-
-      w.show();
-      splash.finish(&w);
-      
-      returnCode = a.exec();
-
-      if ( QFile::exists(TMPLANGFILE) ) {
-         QFile lfile(TMPLANGFILE);
-         if (!lfile.open(QIODevice::ReadOnly | QIODevice::Text))
-           return 150;
-         changeLang = lfile.readLine();
-         lfile.close();
-         qDebug() << "Language switch requested for:" << changeLang;
-         QFile::remove(TMPLANGFILE);
-      } else {
-        break;
-      }
-    }
-
-    return returnCode;
+    w.show();
+    splash.finish(&w);
+    
+    return a.exec();
 }

Modified: pcbsd/branches/9.1/src-qt4/pc-firstbootgui/pc-firstbootgui.pro
===================================================================
--- pcbsd/branches/9.1/src-qt4/pc-firstbootgui/pc-firstbootgui.pro	2012-10-15 21:30:44 UTC (rev 19683)
+++ pcbsd/branches/9.1/src-qt4/pc-firstbootgui/pc-firstbootgui.pro	2012-10-15 21:32:51 UTC (rev 19684)
@@ -33,6 +33,8 @@
 		i18n/FirstBoot_de.ts \
 		i18n/FirstBoot_el.ts \
 		i18n/FirstBoot_es.ts \
+		i18n/FirstBoot_en.ts \
+		i18n/FirstBoot_en_US.ts \
 		i18n/FirstBoot_en_GB.ts \
 		i18n/FirstBoot_en_ZA.ts \
 		i18n/FirstBoot_et.ts \



More information about the Commits mailing list