[PC-BSD Commits] r18429 - pcbsd-projects/PCDM

svn at pcbsd.org svn at pcbsd.org
Mon Aug 13 11:37:12 PDT 2012


Author: kenmoore
Date: 2012-08-13 18:37:11 +0000 (Mon, 13 Aug 2012)
New Revision: 18429

Modified:
   pcbsd-projects/PCDM/PCDM.pro
   pcbsd-projects/PCDM/main.cpp
   pcbsd-projects/PCDM/pcdm-backend.cpp
   pcbsd-projects/PCDM/pcdm-backend.h
   pcbsd-projects/PCDM/pcdm-gui.cpp
   pcbsd-projects/PCDM/pcdm-gui.h
Log:
Get the localization ability working for PCDM. It works as well as the pc-sysintaller at the moment, but since I already have it sub-classed, I want to put some more work into detection of languages and showing each language option in that respective language.



Modified: pcbsd-projects/PCDM/PCDM.pro
===================================================================
--- pcbsd-projects/PCDM/PCDM.pro	2012-08-13 16:43:20 UTC (rev 18428)
+++ pcbsd-projects/PCDM/PCDM.pro	2012-08-13 18:37:11 UTC (rev 18429)
@@ -9,16 +9,18 @@
     	   pcdm-themes.cpp \
            pcdm-config.cpp \
            fancySwitcher.cpp \
-           dialogKeyboard.cpp
+           dialogKeyboard.cpp \
+           dialogLocale.cpp
 
 HEADERS += pcdm-gui.h \
     	   pcdm-backend.h \
 	   pcdm-themes.h \
            pcdm-config.h \
            fancySwitcher.h \
-           dialogKeyboard.h
+           dialogKeyboard.h \
+           dialogLocale.h \
            
-FORMS += dialogKeyboard.ui
+FORMS += dialogKeyboard.ui dialogLocale.ui
 
 TRANSLATIONS =  i18n/PCDM_af.ts \
 		i18n/PCDM_ar.ts \

Modified: pcbsd-projects/PCDM/main.cpp
===================================================================
--- pcbsd-projects/PCDM/main.cpp	2012-08-13 16:43:20 UTC (rev 18428)
+++ pcbsd-projects/PCDM/main.cpp	2012-08-13 18:37:11 UTC (rev 18429)
@@ -10,6 +10,8 @@
 #include "pcdm-backend.h"
 #include "pcdm-config.h"
 
+#define TMPLANGFILE QString("/tmp/.PCDMLang")
+
 int main(int argc, char *argv[])
 {
     int returnCode;
@@ -79,27 +81,19 @@
         w.setGeometry((wid/2) - (thWid/2), (hig/2) - (thHig/2), thWid, thHig);
       }
 
-      // Start the init
-      //w.progInit();
-
-      // Check if we are using diff language
-      //if ( ! langCode.isEmpty() )
-        //w.changeLang(langCode);
-
       w.show();
       splash.finish(&w);
       
       returnCode = a.exec();
-      bool changeLang = FALSE; //QFile::exists(TMPLANGFILE)
-      if ( changeLang ) {
-/*         QFile lfile(TMPLANGFILE);
+      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;
       }

Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp	2012-08-13 16:43:20 UTC (rev 18428)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp	2012-08-13 18:37:11 UTC (rev 18429)
@@ -164,6 +164,30 @@
    kbp.waitForFinished();
 }
 
+QStringList Backend::languages()
+{
+    QStringList _languages;
+    QString code, desc, line;
+
+    QFile mFile;
+    mFile.setFileName("/usr/share/pc-sysinstall/conf/avail-langs");
+    if ( ! mFile.open(QIODevice::ReadOnly | QIODevice::Text))
+       return QStringList();
+
+    // Read in the meta-file for categories
+    QTextStream in(&mFile);
+    in.setCodec("UTF-8");
+    while ( !in.atEnd() ) {
+       line = in.readLine();
+       code = line;
+       code.truncate(line.indexOf(" "));
+       desc = line.remove(0, line.indexOf(" "));
+        _languages.append(desc.simplified() + " - (" + code.simplified() + ")");
+    }
+    mFile.close();
+    return _languages;
+}
+
 //****** PRIVATE FUNCTIONS ******
 
 void Backend::loadXSessionsData(){

Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h	2012-08-13 16:43:20 UTC (rev 18428)
+++ pcbsd-projects/PCDM/pcdm-backend.h	2012-08-13 18:37:11 UTC (rev 18429)
@@ -38,6 +38,7 @@
     static QStringList keyLayouts();
     static QStringList keyVariants(const QString &layout, QStringList &savedKeyVariants);
     static void changeKbMap(QString model, QString layout, QString variant);
+    static QStringList languages();
     
 private:	
     static void loadXSessionsData();

Modified: pcbsd-projects/PCDM/pcdm-gui.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.cpp	2012-08-13 16:43:20 UTC (rev 18428)
+++ pcbsd-projects/PCDM/pcdm-gui.cpp	2012-08-13 18:37:11 UTC (rev 18429)
@@ -287,27 +287,23 @@
 }
 
 void PCDMgui::slotChangeLocale(){
-  qDebug() << "PCDM: Changing of Locale is not implemented yet";
-  /*
-  if ( comboLanguage->currentIndex() == -1 )
-    return;
+  //Get the available languages and codes
+  QStringList lang,lcode,ltot;
+  ltot = Backend::languages();
+  //qDebug() << ltot;
+  for(int i=0; i<ltot.length(); i++){
+      lang << ltot[i].section("-",0,0).simplified();
+      lcode << ltot[i].section("-",1,1).section("(",1,1).section(")",0,0).simplified();
+  }
+  //Open the selector
+  wLoc = new widgetLocale();
+  wLoc->programInit(lang,lcode);
+  wLoc->setWindowModality(Qt::ApplicationModal);
+  wLoc->show();
+  wLoc->raise();
 
-  // Figure out the language code
-  QString langCode = languages.at(comboLanguage->currentIndex());
-    
-  // Grab the language code
-  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();
-  }
-  close();
-  */
+  //Connect the language changed signal
+  connect(wLoc,SIGNAL(languageChanged()),this,SLOT(slotClosePCDM()) );
 }
 
 void PCDMgui::slotChangeKeyboardLayout(){

Modified: pcbsd-projects/PCDM/pcdm-gui.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.h	2012-08-13 16:43:20 UTC (rev 18428)
+++ pcbsd-projects/PCDM/pcdm-gui.h	2012-08-13 18:37:11 UTC (rev 18429)
@@ -21,6 +21,7 @@
 #include "pcdm-themes.h"
 #include "fancySwitcher.h"
 #include "dialogKeyboard.h"
+#include "dialogLocale.h"
 
 #define TMPLANGFILE QString("/tmp/.PCDMLang")
 
@@ -46,6 +47,7 @@
 private:
     //Objects
     widgetKeyboard* wKey;
+    widgetLocale* wLoc;
     QToolBar* toolbar;
     QMenu* systemMenu;
     QComboBox* unameline;
@@ -58,8 +60,6 @@
     //Functions
     void createGUIfromTheme();
 
-
-
 };
 
 #endif // PCDMGUI_H



More information about the Commits mailing list