[PC-BSD Commits] r19681 - in pcbsd/current/src-qt4/pc-installgui: . i18n

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


Author: kris
Date: 2012-10-15 21:21:31 +0000 (Mon, 15 Oct 2012)
New Revision: 19681

Added:
   pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en.ts
   pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en_US.ts
Modified:
   pcbsd/current/src-qt4/pc-installgui/installer.cpp
   pcbsd/current/src-qt4/pc-installgui/installer.h
   pcbsd/current/src-qt4/pc-installgui/main.cpp
   pcbsd/current/src-qt4/pc-installgui/pc-installgui.pro
Log:

Fix issues loading translations on system installer, do it on the fly now
and don't restart the app



Index: pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en.ts
===================================================================
--- pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en.ts	2012-10-15 20:04:47 UTC (rev 19680)
+++ pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en.ts	2012-10-15 21:21:31 UTC (rev 19681)

Property changes on: pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en.ts
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
Index: pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en_US.ts
===================================================================
--- pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en_US.ts	2012-10-15 20:04:47 UTC (rev 19680)
+++ pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en_US.ts	2012-10-15 21:21:31 UTC (rev 19681)

Property changes on: pcbsd/current/src-qt4/pc-installgui/i18n/SysInstaller_en_US.ts
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
Modified: pcbsd/current/src-qt4/pc-installgui/installer.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-installgui/installer.cpp	2012-10-15 20:04:47 UTC (rev 19680)
+++ pcbsd/current/src-qt4/pc-installgui/installer.cpp	2012-10-15 21:21:31 UTC (rev 19681)
@@ -1,6 +1,7 @@
 #include <QCloseEvent>
 #include <QProcess>
 #include <QTimer>
+#include <QTranslator>
 #include <QGraphicsPixmapItem>
 
 #include "backend.h"
@@ -10,6 +11,7 @@
 Installer::Installer(QWidget *parent) : QMainWindow(parent)
 {
     setupUi(this);
+    translator = new QTranslator();
 
     connect(abortButton, SIGNAL(clicked()), this, SLOT(slotAbort()));
     connect(backButton, SIGNAL(clicked()), this, SLOT(slotBack()));
@@ -812,14 +814,23 @@
     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("SysInstaller_") + langCode, appDir + "/i18n/" )) {
+      qDebug() << "Load new Translator" << langCode;
+      QCoreApplication::installTranslator(translator);
+      this->retranslateUi(this);
     }
-    exit(0);
 }
 
 void Installer::changeLang(QString code)

Modified: pcbsd/current/src-qt4/pc-installgui/installer.h
===================================================================
--- pcbsd/current/src-qt4/pc-installgui/installer.h	2012-10-15 20:04:47 UTC (rev 19680)
+++ pcbsd/current/src-qt4/pc-installgui/installer.h	2012-10-15 21:21:31 UTC (rev 19681)
@@ -7,6 +7,7 @@
 #include <QMenu>
 #include <QProcess>
 #include <QGraphicsScene>
+#include <QTranslator>
 
 #include "ui_installer.h"
 #include "dialogHelp.h"
@@ -163,6 +164,7 @@
 
     // Disk setup wizard
     wizardDisk *wDisk;
+    QTranslator *translator;
 
 protected:
     void closeEvent(QCloseEvent *event);

Modified: pcbsd/current/src-qt4/pc-installgui/main.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-installgui/main.cpp	2012-10-15 20:04:47 UTC (rev 19680)
+++ pcbsd/current/src-qt4/pc-installgui/main.cpp	2012-10-15 21:21:31 UTC (rev 19681)
@@ -11,96 +11,71 @@
 
 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-sysinstaller") )
-      {
-        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-sysinstaller") )
+      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/SysInstaller_" + langCode + ".qm" ) ) {
-        translator.load( QString("SysInstaller_") + langCode, appDir + "/i18n/" );
-        a.installTranslator(&translator);
-        qDebug() << "Loaded Translation:" << appDir + "/i18n/SysInstaller_" + langCode + ".qm";
-      } else {
-        qDebug() << "Could not find: " << appDir + "/i18n/SysInstaller_" + langCode + ".qm";
-        langCode = "";
-      }
+    if ( QFile::exists(appDir + "/i18n/SysInstaller_" + langCode + ".qm" ) ) {
+      translator.load( QString("SysInstaller_") + langCode, appDir + "/i18n/" );
+      a.installTranslator(&translator);
+      qDebug() << "Loaded Translation:" << appDir + "/i18n/SysInstaller_" + langCode + ".qm";
+    } else {
+      qDebug() << "Could not find: " << appDir + "/i18n/SysInstaller_" + langCode + ".qm";
+      langCode = "";
+    }
 
-      if ( argc == 2)
+    if ( argc == 2)
+    {
+      QString flag = argv[1];
+      if ( flag == "-checkhardware" )
       {
-        QString flag = argv[1];
-        if ( flag == "-checkhardware" )
-        {
-          dialogCheckHardware d;
-          QDesktopWidget *desk = a.desktop();
-          QRect dimensions = desk->screenGeometry();
-          int wid = dimensions.width();     // returns desktop width
-          int hig = dimensions.height();    // returns desktop height
-          d.setGeometry((wid/2) - (355/2), (hig/2) - (151/2), 355, 151);
-          d.programInit();
-          d.show();
-          a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
-          return a.exec();
-        }
+        dialogCheckHardware d;
+        QDesktopWidget *desk = a.desktop();
+        QRect dimensions = desk->screenGeometry();
+        int wid = dimensions.width();     // returns desktop width
+        int hig = dimensions.height();    // returns desktop height
+        d.setGeometry((wid/2) - (355/2), (hig/2) - (151/2), 355, 151);
+        d.programInit();
+        d.show();
+        a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
+        return a.exec();
       }
+    }
 
 
-      // 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/current/src-qt4/pc-installgui/pc-installgui.pro
===================================================================
--- pcbsd/current/src-qt4/pc-installgui/pc-installgui.pro	2012-10-15 20:04:47 UTC (rev 19680)
+++ pcbsd/current/src-qt4/pc-installgui/pc-installgui.pro	2012-10-15 21:21:31 UTC (rev 19681)
@@ -39,6 +39,8 @@
 		i18n/SysInstaller_de.ts \
 		i18n/SysInstaller_el.ts \
 		i18n/SysInstaller_es.ts \
+		i18n/SysInstaller_en.ts \
+		i18n/SysInstaller_en_US.ts \
 		i18n/SysInstaller_en_GB.ts \
 		i18n/SysInstaller_en_ZA.ts \
 		i18n/SysInstaller_et.ts \



More information about the Commits mailing list