Added Desktop/MeeGo GUI
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 16 Aug 2010 11:48:05 +0000 (13:48 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 16 Aug 2010 11:48:05 +0000 (13:48 +0200)
trunk/src/base/base.pro
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/DictManagerWidget.h
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/MainWindow.h
trunk/src/base/gui/MainWindow.ui
trunk/src/base/gui/SearchBarWidget.cpp
trunk/src/base/gui/WordListWidget.cpp
trunk/src/plugins/xdxf/src/XdxfCachingDialog.cpp
trunk/src/plugins/xdxf/src/xdxfplugin.cpp

index 8e17537..03bfb66 100644 (file)
@@ -72,9 +72,15 @@ unix {
 
   target.path =$$BINDIR
 
+maemo5 {
   desktop.path = $$DATADIR/applications/hildon
-  desktop.files += ../../../data/other/$${TARGET}.desktop
-
   icon64.path = $$DATADIR/icons/hicolor/64x64/hildon
+}
+
+unix {
+  desktop.path = $$DATADIR/applications
+  icon64.path = $$DATADIR/icons
+}
+  desktop.files += ../../../data/other/$${TARGET}.desktop
   icon64.files += ../../../data/icons/64x64/$${TARGET}.png
 }
index 457529d..7e793ad 100644 (file)
 #include "../../includes/DictDialog.h"
 
 DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
-    QWidget(parent) {
+    QDialog(parent) {
+
 
-    this->guiInterface = parent;
 
+    setWindowTitle(tr("Dictionaries"));
+    this->guiInterface = parent;
 
     verticalLayout = new QVBoxLayout;
     setLayout(verticalLayout);
index 25e922d..324ae11 100644 (file)
@@ -38,7 +38,7 @@
   change settings of selected dict. All changes are saved automatically after
   hiding of this widget.
   */
-class DictManagerWidget : public QWidget {
+class DictManagerWidget : public QDialog {
     Q_OBJECT
 public:
     //! Constructor
index c4e3958..943cc78 100644 (file)
@@ -69,19 +69,33 @@ void MainWindow::initializeUI() {
     //only create it with this widget as parent
     translationWidget = new TranslationWidget(this);
 
-    ui->centralWidget->layout()->addWidget(wordListWidget);
+    #ifdef Q_WS_MAEMO_5
+        ui->centralWidget->layout()->addWidget(wordListWidget);
+    #else
+        splitter = new QSplitter(Qt::Horizontal);
+        splitter->addWidget(wordListWidget);
+        splitter->addWidget(translationWidget);
+        splitter->setStretchFactor(1, 150);
+        ui->centralWidget->layout()->addWidget(splitter);
+    #endif
     ui->centralWidget->layout()->addWidget(searchBarWidget);
 
 
 
     dictManagerWidget = new DictManagerWidget(this);
+    dictManagerWidget->hide();
+    #ifdef Q_WS_MAEMO_5
+        menuWidget = new MenuWidget(this);
+        menuWidget->addSubMenu(tr("Dictionaries"), dictManagerWidget);
+        menuWidget->addSubMenu(tr("Settings"), new QPushButton("Settings"));
+        menuWidget->addSubMenu(tr("About"), new QPushButton("About"));
+        ui->menuBar->addAction(menuWidget);
+    #else
+        dictionariesAction = ui->menuBar->addAction(tr("Dictionaries"));
+        connect(dictionariesAction, SIGNAL(triggered()),
+                dictManagerWidget, SLOT(show()));
+    #endif
 
-    menuWidget = new MenuWidget(this);
-    menuWidget->addSubMenu(tr("Dictionaries"), dictManagerWidget);
-    menuWidget->addSubMenu(tr("Settings"), new QPushButton("Settings"));
-    menuWidget->addSubMenu(tr("About"), new QPushButton("About"));
-
-    ui->menuBar->addAction(menuWidget);
 }
 
 void MainWindow::closeEvent(QCloseEvent *event) {
@@ -204,15 +218,23 @@ void MainWindow::historyPrev() {
 }
 
 void MainWindow::disableMenu() {
-    if(ui->menuBar->actions().contains(menuWidget)) {
-        ui->menuBar->removeAction(menuWidget);
-    }
+    #ifdef Q_WS_MAEMO_5
+        if(ui->menuBar->actions().contains(menuWidget)) {
+              ui->menuBar->removeAction(menuWidget);
+        }
+    #else
+        ui->menuBar->setEnabled(false);
+    #endif
 }
 
 void MainWindow::enableMenu() {
-    if(!ui->menuBar->actions().contains(menuWidget)) {
-        ui->menuBar->addAction(menuWidget);
-    }
+    #ifdef Q_WS_MAEMO_5
+        if(!ui->menuBar->actions().contains(menuWidget)) {
+            ui->menuBar->addAction(menuWidget);
+        }
+    #else
+        ui->menuBar->setEnabled(true);
+    #endif
 }
 
 void MainWindow::showHistory() {
index 9a47cad..7ee6614 100644 (file)
@@ -185,6 +185,14 @@ private:
     MenuWidget* menuWidget;
     DictManagerWidget* dictManagerWidget;
 
+    #ifndef Q_WS_MAEMO_5
+        QSplitter* splitter;
+        QAction* dictionariesAction;
+        //QAction* edit;
+       // QAction* settingsAction;
+        //QAction* aboutAction;
+    #endif
+
     bool _exactSearch;
     QString searchString;
 
index a9ee0be..31e98e2 100644 (file)
    <string>MainWindow</string>
   </property>
   <widget class="QWidget" name="centralWidget">
-   <property name="palette">
-    <palette>
-     <active>
-      <colorrole role="Base">
-       <brush brushstyle="SolidPattern">
-        <color alpha="255">
-         <red>255</red>
-         <green>255</green>
-         <blue>255</blue>
-        </color>
-       </brush>
-      </colorrole>
-      <colorrole role="Window">
-       <brush brushstyle="SolidPattern">
-        <color alpha="255">
-         <red>0</red>
-         <green>0</green>
-         <blue>0</blue>
-        </color>
-       </brush>
-      </colorrole>
-     </active>
-     <inactive>
-      <colorrole role="Base">
-       <brush brushstyle="SolidPattern">
-        <color alpha="255">
-         <red>255</red>
-         <green>255</green>
-         <blue>255</blue>
-        </color>
-       </brush>
-      </colorrole>
-      <colorrole role="Window">
-       <brush brushstyle="SolidPattern">
-        <color alpha="255">
-         <red>0</red>
-         <green>0</green>
-         <blue>0</blue>
-        </color>
-       </brush>
-      </colorrole>
-     </inactive>
-     <disabled>
-      <colorrole role="Base">
-       <brush brushstyle="SolidPattern">
-        <color alpha="255">
-         <red>0</red>
-         <green>0</green>
-         <blue>0</blue>
-        </color>
-       </brush>
-      </colorrole>
-      <colorrole role="Window">
-       <brush brushstyle="SolidPattern">
-        <color alpha="255">
-         <red>0</red>
-         <green>0</green>
-         <blue>0</blue>
-        </color>
-       </brush>
-      </colorrole>
-     </disabled>
-    </palette>
-   </property>
    <property name="autoFillBackground">
-    <bool>true</bool>
+    <bool>false</bool>
    </property>
    <layout class="QVBoxLayout" name="verticalLayout"/>
   </widget>
     </rect>
    </property>
   </widget>
-  <widget class="QToolBar" name="mainToolBar">
-   <attribute name="toolBarArea">
-    <enum>TopToolBarArea</enum>
-   </attribute>
-   <attribute name="toolBarBreak">
-    <bool>false</bool>
-   </attribute>
-  </widget>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources/>
index 40c83a4..ee9fca7 100644 (file)
@@ -33,7 +33,6 @@ SearchBarWidget::SearchBarWidget(QWidget *parent) :
 
     initializeUI();
 
-    setMaximumHeight(150);
 
     _isSearching = false;
 
@@ -98,6 +97,14 @@ QIcon SearchBarWidget::generateIcon(QIcon oryginal, qreal rotation) {
 
 
 void SearchBarWidget::initializeUI() {
+
+    #ifdef Q_WS_MAEMO_5
+        setMaximumHeight(150);
+    #else
+        setMaximumHeight(100);
+    #endif
+
+
     horizontalLayout = new QHBoxLayout();
     verticalLayout = new QVBoxLayout();
 
@@ -118,14 +125,12 @@ void SearchBarWidget::initializeUI() {
     #endif
 
 
-
     //create layout for lineEdit to have clear button on it
     QHBoxLayout* lineEditLayout = new QHBoxLayout;
     searchWordLineEdit->setLayout(lineEditLayout);
 
 
     clearSearchWordToolButton = new QToolButton();
-
     #ifdef Q_WS_MAEMO_5
         clearSearchWordToolButton->setIcon(QIcon::fromTheme("general_stop"));
         //tool buttons will have size 2 times smaller
@@ -152,6 +157,8 @@ void SearchBarWidget::initializeUI() {
                 clearSearchWordToolButton->sizeHint().height()*2);
     #endif
 
+
+
     historyPrevToolButton = new QToolButton();
     #ifdef Q_WS_MAEMO_5
         historyPrevToolButton->setIcon(
@@ -164,6 +171,8 @@ void SearchBarWidget::initializeUI() {
                 clearSearchWordToolButton->sizeHint().height()*2);
     #endif
 
+
+
     historyShowToolButton = new QToolButton();
     #ifdef Q_WS_MAEMO_5
         historyShowToolButton->setIcon(
@@ -183,7 +192,9 @@ void SearchBarWidget::initializeUI() {
     searchingProgressBar->setMinimum(0);
     searchingProgressBar->setMaximum(0);
     searchingProgressBar->hide();
-    searchingProgressBar->setMaximumHeight(50);
+    #ifdef Q_WS_MAEMO_5
+        searchingProgressBar->setMaximumHeight(50);
+    #endif
 
 
     setLayout(verticalLayout);
index 5c066a7..bd3cf02 100644 (file)
@@ -35,10 +35,10 @@ WordListWidget::WordListWidget(QWidget *parent):
 
     wordListModel = new QStringListModel();
 
-
     connect(this, SIGNAL(clicked(QModelIndex)),
             this, SLOT(itemClicked(QModelIndex)));
 
+
     setModel(wordListModel);
 }
 
@@ -50,6 +50,7 @@ void WordListWidget::addWord(QString word) {
     QModelIndex newWordIndex = wordListModel->index(wordsCount);
 
     wordListModel->setData(newWordIndex, word);
+
 }
 
 void WordListWidget::clear() {
index 2a3b935..e57585f 100644 (file)
@@ -41,6 +41,11 @@ XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) :
     cancelButton = new QPushButton(tr("Cancel"));
 
 
+    cachingLabel = new QLabel();
+    cachingLabel->hide();
+
+
+    verticalLayout->addWidget(cachingLabel);
     verticalLayout->addWidget(cachingProgressBar);
     verticalLayout->addWidget(cancelButton);
 
@@ -56,11 +61,13 @@ XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) :
 void XdxfCachingDialog::updateCachingProgress(int progress, int time) {
     cachingProgressBar->setValue(progress);
 
+    if(!cachingLabel->isVisible())
+        cachingLabel->show();
 
     int seconds = float((100 - progress)*time) / (5*1000);
 
-    setWindowTitle(tr("Caching dictionary, please wait ") + "( " +
-                      QString::number(seconds) + tr(" seconds left") + " )");
+    cachingLabel->setText(tr("Estimated time left: ") +
+                      QString::number(seconds) + tr(" seconds"));
 
 }
 
index 7f26868..4d7828d 100644 (file)
@@ -409,10 +409,9 @@ bool XdxfPlugin::makeCache(QString dir) {
 
     QXmlStreamReader reader(&dictionaryFile);
 
-
     db.setDatabaseName(cachePathN);
     if(!db.open()) {
-        qDebug() << "Database error" << endl;
+        qDebug() << "Database error" << db.lastError().text() << endl;
         return false;
     }
     QCoreApplication::processEvents();
@@ -437,7 +436,7 @@ bool XdxfPlugin::makeCache(QString dir) {
     while (!reader.atEnd() && !stopped) {
 
         QCoreApplication::processEvents();
-        usleep(50);
+        //usleep(50);
         reader.readNext();
 
         if(reader.tokenType() == QXmlStreamReader::StartElement) {