Added translations for desktopWidget, fixed xdxf caching dialog to not close menu...
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Fri, 10 Sep 2010 06:58:11 +0000 (08:58 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Fri, 10 Sep 2010 07:27:30 +0000 (09:27 +0200)
src/desktopWidget/desktopWidget.pro
src/desktopWidget/desktopWidget.qrc [new file with mode: 0644]
src/desktopWidget/main.cpp
src/desktopWidget/translations/en_US.qm [new file with mode: 0644]
src/desktopWidget/translations/pl_PL.qm [new file with mode: 0644]
src/plugins/xdxf/XdxfCachingDialog.cpp
src/plugins/xdxf/XdxfCachingDialog.h
src/plugins/xdxf/XdxfDictDialog.cpp
src/plugins/xdxf/XdxfDictDialog.h
src/plugins/xdxf/xdxfplugin.cpp

index 1d792b1..794f143 100644 (file)
@@ -18,8 +18,11 @@ HEADERS += \
     MainWidget.h
 
 RESOURCES += \
-    ../../data/gui.qrc
+    ../../data/gui.qrc \
+    desktopWidget.qrc
 
+TRANSLATIONS += pl_PL.ts \
+                en_US.ts
 
 unix {
         target.path = $$INSTALL_PREFIX/lib/hildon-desktop
diff --git a/src/desktopWidget/desktopWidget.qrc b/src/desktopWidget/desktopWidget.qrc
new file mode 100644 (file)
index 0000000..8315db8
--- /dev/null
@@ -0,0 +1,6 @@
+<RCC>
+    <qresource prefix="/desktopWidget">
+        <file>translations/en_US.qm</file>
+        <file>translations/pl_PL.qm</file>
+    </qresource>
+</RCC>
index 2f9b15d..cfe07d6 100644 (file)
@@ -35,6 +35,17 @@ int main(int argc, char *argv[]) {
     }
 
     QApplication a(dpy, argc, argv);
+
+    QString locale = QLocale::system().name();
+
+    QTranslator translator;
+
+    if(!translator.load("://desktopWidget/translations/" + locale)) {
+        translator.load("://desktopWidget/translations/en_US");
+    }
+
+    QCoreApplication::installTranslator(&translator);
+
     QApplication::setOrganizationName("Comarch S.A.");
     QApplication::setOrganizationDomain("comarch.com");
     QApplication::setApplicationName("mDictionaryWidget");
diff --git a/src/desktopWidget/translations/en_US.qm b/src/desktopWidget/translations/en_US.qm
new file mode 100644 (file)
index 0000000..be651ee
--- /dev/null
@@ -0,0 +1 @@
+<¸d\18Êï\9c\95Í!\1c¿`¡½Ý
\ No newline at end of file
diff --git a/src/desktopWidget/translations/pl_PL.qm b/src/desktopWidget/translations/pl_PL.qm
new file mode 100644 (file)
index 0000000..07f6827
Binary files /dev/null and b/src/desktopWidget/translations/pl_PL.qm differ
index ac23b2d..9ddad98 100644 (file)
@@ -28,7 +28,7 @@
 #include <QDebug>
 
 
-XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) {
+XdxfCachingDialog::XdxfCachingDialog(QWidget *parent): QDialog(parent) {
     verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
@@ -52,13 +52,11 @@ XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) {
     connect(cancelButton, SIGNAL(clicked()),
             this, SIGNAL(cancelCaching()));
 
-    connect(parent, SIGNAL(updateCachingProgress(int, int)),
-       this, SLOT(updateCachingProgress(int, int)));
     time.start();
 
-    #ifndef Q_WS_MAEMO_5
-        setModal(true);
-    #endif
+    //#ifndef Q_WS_MAEMO_5
+    setModal(true);
+    //#endif
 }
 
 
index aacb56d..5632bd9 100644 (file)
@@ -41,7 +41,7 @@ class XdxfCachingDialog : public QDialog
 {
     Q_OBJECT
 public:
-    explicit XdxfCachingDialog(XdxfPlugin *parent = 0);
+    explicit XdxfCachingDialog(QWidget *parent = 0);
 
 public Q_SLOTS:
     void reject();
index 9baf951..07b7b31 100644 (file)
 XdxfDictDialog::XdxfDictDialog(XdxfPlugin *plugin, QObject *parent) :
     DictDialog(parent) {
     this->plugin = plugin;
+    _lastDialogParent=0;
+}
+
+QWidget* XdxfDictDialog::lastDialogParent() {
+    return _lastDialogParent;
 }
 
 Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
     XdxfDialog d(0, XdxfDialog::New, parent);
 
+    _lastDialogParent = parent;
+
     connect(&d, SIGNAL(notify(Notify::NotifyType,QString)),
             this, SIGNAL(notify(Notify::NotifyType,QString)));
 
@@ -48,6 +55,8 @@ Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
 void XdxfDictDialog::changeSettings(QWidget * parent) {
     XdxfDialog d(plugin, XdxfDialog::Change, parent);
 
+    _lastDialogParent = parent;
+
     connect(&d, SIGNAL(notify(Notify::NotifyType,QString)),
             this, SIGNAL(notify(Notify::NotifyType,QString)));
 
index 5edadbe..fe6e2f4 100644 (file)
@@ -47,8 +47,11 @@ public:
       */
     void changeSettings(QWidget *parent);
 
+    QWidget* lastDialogParent();
+
 private:
     XdxfPlugin* plugin;
+    QWidget* _lastDialogParent;
 };
 
 #endif // XDXFDICTDIALOG_H
index 6bd0215..e886f23 100644 (file)
@@ -35,18 +35,12 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
     connect(_dictDialog, SIGNAL(notify(Notify::NotifyType,QString)),
             this, SIGNAL(notify(Notify::NotifyType,QString)));
 
-    cachingDialog = new XdxfCachingDialog(this);
-
 
     _settings->setValue("type","xdxf");
     _icon = QIcon("/usr/share/mdictionary/xdxf.png");
     _wordsCount = -1;
     stopped = false;
 
-    connect(cachingDialog, SIGNAL(cancelCaching()),
-            this, SLOT(stop()));
-    connect(this, SIGNAL(updateCachingProgress(int,int)),
-            cachingDialog, SLOT(updateCachingProgress(int,int)));
     initAccents();
 }
 
@@ -64,7 +58,6 @@ void XdxfPlugin::retranslate() {
 
 XdxfPlugin::~XdxfPlugin() {
     delete _settings;
-    delete cachingDialog;
     delete _dictDialog;
 }
 
@@ -486,11 +479,24 @@ int XdxfPlugin::countWords() {
 
 
 bool XdxfPlugin::makeCache(QString) {
-    #ifdef Q_WS_MAEMO_5
-        cachingDialog->setVisible(true);
-    #else
-        cachingDialog->show();
-    #endif
+
+    XdxfCachingDialog d(_dictDialog->lastDialogParent());
+
+    connect(&d, SIGNAL(cancelCaching()),
+            this, SLOT(stop()));
+
+    connect(this, SIGNAL(updateCachingProgress(int,int)),
+            &d, SLOT(updateCachingProgress(int,int)));
+
+    d.show();
+
+
+  //  cachingDialog->setParent(_dictDialog->lastDialogParent());
+ //   #ifdef Q_WS_MAEMO_5
+ //       cachingDialog->setVisible(true);
+ //   #else
+  //      cachingDialog->exec();
+ //   #endif
     QCoreApplication::processEvents();
     QFileInfo dictFileN(_settings->value("path"));
     QString cachePathN;
@@ -550,6 +556,7 @@ bool XdxfPlugin::makeCache(QString) {
 
     /*add all words to db*/
     while (!reader.atEnd() && !stopped) {
+
         QCoreApplication::processEvents();
         reader.readNext();
         if(reader.tokenType() == QXmlStreamReader::StartElement) {
@@ -590,9 +597,10 @@ bool XdxfPlugin::makeCache(QString) {
             cur.exec();
             counter++;
             int prog = counter*100/_wordsCount;
-            if(prog % 5 == 0 && lastProg != prog) {
+            if(prog % 2 == 0 && lastProg != prog) {
                 Q_EMIT updateCachingProgress(prog,timer.restart());
                 lastProg = prog;
+                sleep(1);
             }
         }
     }
@@ -613,6 +621,13 @@ bool XdxfPlugin::makeCache(QString) {
     _settings->setValue("cache_path", cachePathN);
     _settings->setValue("cached", "true");
 
+
+    disconnect(&d, SIGNAL(cancelCaching()),
+            this, SLOT(stop()));
+
+    disconnect(this, SIGNAL(updateCachingProgress(int,int)),
+            &d, SLOT(updateCachingProgress(int,int)));
+
     db.close();
     return true;
 }