Add missing xdxf caching dialog source files
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 16 Aug 2010 08:01:59 +0000 (10:01 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 16 Aug 2010 08:01:59 +0000 (10:01 +0200)
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/MainWindow.h
trunk/src/base/gui/SearchBarWidget.cpp
trunk/src/plugins/xdxf/src/XdxfCachingDialog.cpp [new file with mode: 0644]
trunk/src/plugins/xdxf/src/XdxfCachingDialog.h [new file with mode: 0644]

index 252d816..c4e3958 100644 (file)
@@ -34,6 +34,26 @@ MainWindow::MainWindow(Backbone *backbone, QWidget *parent):
 
     this->backbone = backbone;
 
+    initializeUI();
+
+    connectBackbone();
+    connectSearchBar();
+    connectWordList();
+    connectTranslationWidget();
+    connectDictManager();
+    connectMenu();
+
+    setExactSearch(false);
+
+    setWindowTitle("mDictionary");
+}
+
+MainWindow::~MainWindow() {
+    delete ui;
+}
+
+
+void MainWindow::initializeUI() {
     ui->setupUi(this);
 
     //sets attribute to maemo's stacked window
@@ -62,24 +82,8 @@ MainWindow::MainWindow(Backbone *backbone, QWidget *parent):
     menuWidget->addSubMenu(tr("About"), new QPushButton("About"));
 
     ui->menuBar->addAction(menuWidget);
-
-    connectBackbone();
-    connectSearchBar();
-    connectWordList();
-    connectTranslationWidget();
-    connectDictManager();
-    connectMenu();
-
-    setExactSearch(false);
-
-    setWindowTitle("mDictionary");
-}
-
-MainWindow::~MainWindow() {
-    delete ui;
 }
 
-
 void MainWindow::closeEvent(QCloseEvent *event) {
     //reqest to stop all searches and close app
         emit quit();
index 644cc04..9a47cad 100644 (file)
@@ -176,6 +176,8 @@ private:
     Backbone* backbone;
     Ui::MainWindow *ui;
 
+    void initializeUI();
+
 
     SearchBarWidget* searchBarWidget;
     TranslationWidget* translationWidget;
index 80541e9..40c83a4 100644 (file)
@@ -82,13 +82,16 @@ QIcon SearchBarWidget::generateIcon(QIcon oryginal, qreal rotation) {
         p = p.transformed(m);
     }
 
+
     QIcon newIcon;
     newIcon.addPixmap(p);
 
-    QPainter painter(&p);
-    painter.fillRect(p.rect(), QColor(0,0,0,192));
+    #ifdef Q_WS_MAEMO_5
+        QPainter painter(&p);
+        painter.fillRect(p.rect(), QColor(0,0,0,192));
 
-    newIcon.addPixmap(p, QIcon::Disabled, QIcon::Off);
+        newIcon.addPixmap(p, QIcon::Disabled, QIcon::Off);
+    #endif
 
     return newIcon;
 }
@@ -101,11 +104,19 @@ void SearchBarWidget::initializeUI() {
 
     searchPushButton = new QPushButton(tr("Search"));
     searchPushButton->setMinimumWidth(150);
-
+    #ifndef Q_WS_MAEMO_5
+        searchPushButton->setMinimumHeight(
+                searchPushButton->sizeHint().height()*2);
+    #endif
 
     searchWordLineEdit = new QLineEdit();
     searchWordLineEdit->setMinimumWidth(300);
 
+    #ifndef Q_WS_MAEMO_5
+        searchWordLineEdit->setMinimumHeight(
+                searchWordLineEdit->sizeHint().height()*2);
+    #endif
+
 
 
     //create layout for lineEdit to have clear button on it
@@ -114,25 +125,56 @@ void SearchBarWidget::initializeUI() {
 
 
     clearSearchWordToolButton = new QToolButton();
-    clearSearchWordToolButton->setIcon(QIcon::fromTheme("general_stop"));
-    //tool buttons will have size 2 times smaller
-    clearSearchWordToolButton->setMaximumSize(
-            clearSearchWordToolButton->sizeHint().width()/2,
-            clearSearchWordToolButton->sizeHint().height()/2);
+
+    #ifdef Q_WS_MAEMO_5
+        clearSearchWordToolButton->setIcon(QIcon::fromTheme("general_stop"));
+        //tool buttons will have size 2 times smaller
+        clearSearchWordToolButton->setMaximumSize(
+                clearSearchWordToolButton->sizeHint().height()/2,
+                clearSearchWordToolButton->sizeHint().height()/2);
+    #else
+        clearSearchWordToolButton->setIcon(QIcon::fromTheme("edit-clear"));
+        clearSearchWordToolButton->setMinimumSize(
+                clearSearchWordToolButton->sizeHint().height(),
+                clearSearchWordToolButton->sizeHint().height());
+    #endif
 
 
     historyNextToolButton = new QToolButton();
-    historyNextToolButton->setIcon(
-            generateIcon(QIcon::fromTheme("general_forward")));
+    #ifdef Q_WS_MAEMO_5
+        historyNextToolButton->setIcon(
+                generateIcon(QIcon::fromTheme("general_forward")));
+    #else
+        historyNextToolButton->setIcon(
+                generateIcon(QIcon::fromTheme("go-next")));
+        historyNextToolButton->setMinimumSize(
+                clearSearchWordToolButton->sizeHint().height()*2,
+                clearSearchWordToolButton->sizeHint().height()*2);
+    #endif
 
     historyPrevToolButton = new QToolButton();
-    historyPrevToolButton->setIcon(
-            generateIcon(QIcon::fromTheme("general_back")));
+    #ifdef Q_WS_MAEMO_5
+        historyPrevToolButton->setIcon(
+                generateIcon(QIcon::fromTheme("general_back")));
+    #else
+        historyPrevToolButton->setIcon(
+                generateIcon(QIcon::fromTheme("go-previous")));
+        historyPrevToolButton->setMinimumSize(
+                clearSearchWordToolButton->sizeHint().height()*2,
+                clearSearchWordToolButton->sizeHint().height()*2);
+    #endif
 
     historyShowToolButton = new QToolButton();
-    historyShowToolButton->setIcon(
-            generateIcon(QIcon::fromTheme("general_back"), 90));
-
+    #ifdef Q_WS_MAEMO_5
+        historyShowToolButton->setIcon(
+                generateIcon(QIcon::fromTheme("general_back"), 90));
+    #else
+        historyShowToolButton->setIcon(
+                generateIcon(QIcon::fromTheme("go-up")));
+        historyShowToolButton->setMinimumSize(
+                clearSearchWordToolButton->sizeHint().height()*2,
+                clearSearchWordToolButton->sizeHint().height()*2);
+    #endif
 
 
     searchingProgressBar = new QProgressBar();
diff --git a/trunk/src/plugins/xdxf/src/XdxfCachingDialog.cpp b/trunk/src/plugins/xdxf/src/XdxfCachingDialog.cpp
new file mode 100644 (file)
index 0000000..2a3b935
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#include "XdxfCachingDialog.h"
+#include "xdxfplugin.h"
+#include <QDebug>
+
+
+XdxfCachingDialog::XdxfCachingDialog(XdxfPlugin *parent) :
+    QDialog(0)
+{
+    verticalLayout = new QVBoxLayout;
+    setLayout(verticalLayout);
+
+    setWindowTitle(tr("Caching dictionary, please wait"));
+    cachingProgressBar = new QProgressBar;
+    cachingProgressBar->setMinimum(0);
+    cachingProgressBar->setMaximum(100);
+    cachingProgressBar->setTextVisible(true);
+
+    cancelButton = new QPushButton(tr("Cancel"));
+
+
+    verticalLayout->addWidget(cachingProgressBar);
+    verticalLayout->addWidget(cancelButton);
+
+    connect(cancelButton, SIGNAL(clicked()),
+            this, SIGNAL(cancelCaching()));
+
+    connect(parent, SIGNAL(updateCachingProgress(int, int)),
+            this, SLOT(updateCachingProgress(int, int)));
+
+    time.start();
+}
+
+void XdxfCachingDialog::updateCachingProgress(int progress, int time) {
+    cachingProgressBar->setValue(progress);
+
+
+    int seconds = float((100 - progress)*time) / (5*1000);
+
+    setWindowTitle(tr("Caching dictionary, please wait ") + "( " +
+                      QString::number(seconds) + tr(" seconds left") + " )");
+
+}
+
+void XdxfCachingDialog::reject() {
+    return;
+}
diff --git a/trunk/src/plugins/xdxf/src/XdxfCachingDialog.h b/trunk/src/plugins/xdxf/src/XdxfCachingDialog.h
new file mode 100644 (file)
index 0000000..7ab79c5
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#ifndef XDXFCACHINGDIALOG_H
+#define XDXFCACHINGDIALOG_H
+
+#include <QDialog>
+#include <QtGui>
+
+
+class XdxfPlugin;
+
+
+class XdxfCachingDialog : public QDialog
+{
+    Q_OBJECT
+public:
+    explicit XdxfCachingDialog(XdxfPlugin *parent = 0);
+
+Q_SIGNALS:
+    void cancelCaching();
+
+public Q_SLOTS:
+    void reject();
+
+private Q_SLOTS:
+    void cancelButtonClicked();
+    void updateCachingProgress(int, int);
+
+private:
+    QLabel* cachingLabel;
+    QProgressBar* cachingProgressBar;
+    QPushButton* cancelButton;
+    QVBoxLayout* verticalLayout;
+    QTime time;
+};
+
+#endif // XDXFCACHINGDIALOG_H