Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary
authorPiotrek <ppilar11@gmail.com>
Wed, 1 Sep 2010 13:04:28 +0000 (15:04 +0200)
committerPiotrek <ppilar11@gmail.com>
Wed, 1 Sep 2010 13:04:28 +0000 (15:04 +0200)
Conflicts:
data/icons/gui.qrc
trunk/src/base/base.pro
trunk/src/base/gui/MainWindow.cpp

31 files changed:
data/other/com.comarch.mdictionary.service [new file with mode: 0644]
data/other/mdictionary.desktop
data/other/mdictionarywidget.desktop [new file with mode: 0644]
trunk/src/base/backbone/Bookmarks.cpp
trunk/src/base/backbone/backbone.cpp
trunk/src/base/backbone/backbone.h
trunk/src/base/base.pro
trunk/src/base/gui/DBusAdapter.cpp [new file with mode: 0644]
trunk/src/base/gui/DBusAdapter.h [new file with mode: 0644]
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/MainWindow.h
trunk/src/base/gui/NotifyManager.cpp [new file with mode: 0644]
trunk/src/base/gui/NotifyManager.h [new file with mode: 0644]
trunk/src/base/gui/TranslationTextEdit.cpp
trunk/src/base/gui/TranslationTextEdit.h
trunk/src/base/gui/TranslationWidget.cpp
trunk/src/base/gui/TranslationWidget.h
trunk/src/base/gui/TranslationWidgetAutoResizer.h [deleted file]
trunk/src/base/gui/main.cpp
trunk/src/base/xsl.xsl
trunk/src/base/xslt2.qrc
trunk/src/desktopWidget/MainWidget.cpp [new file with mode: 0644]
trunk/src/desktopWidget/MainWidget.h [new file with mode: 0644]
trunk/src/desktopWidget/desktopWidget.pro [new file with mode: 0644]
trunk/src/desktopWidget/main.cpp [new file with mode: 0644]
trunk/src/plugins/google/src/GoogleSettingsDialog.cpp
trunk/src/plugins/google/src/GoogleSettingsDialog.h
trunk/src/plugins/google/src/src.pro
trunk/src/plugins/xdxf/src/XdxfLoadDialog.cpp
trunk/src/plugins/xdxf/src/XdxfLoadDialog.h
trunk/src/src.pro

diff --git a/data/other/com.comarch.mdictionary.service b/data/other/com.comarch.mdictionary.service
new file mode 100644 (file)
index 0000000..718ea09
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.comarch.mdictionary
+Exec=/usr/bin/mdictionary
index b1e23ed..f3819c7 100644 (file)
@@ -7,3 +7,4 @@ Name=mDictionary
 Icon=mdictionary
 Exec=/usr/bin/mdictionary
 X-Maemo-Category=Main
+X-Osso-Service=com.comarch.mdictionary
diff --git a/data/other/mdictionarywidget.desktop b/data/other/mdictionarywidget.desktop
new file mode 100644 (file)
index 0000000..826b54f
--- /dev/null
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Name=mDictionary
+Type=qt
+X-Path=/usr/lib/hildon-desktop/mdictionarywidget
+X-Multiple-Instances=false
index 6468dd0..527a8a5 100644 (file)
@@ -21,20 +21,17 @@ QSqlDatabase Bookmarks::getDbCnx(QString dbName) {
 
 bool Bookmarks::checkAndCreateDb() {
     QSqlDatabase db = getDbCnx(dbName);
-    if(!db.isOpen() && !db.open()) {
-        qDebug() << "Database error: " << db.lastError().text() << endl;
-        return false;
-    }
+    db.open();
     QSqlQuery cur(db);
     cur.exec("create table bookmarks(key text, normalized text, translation text)");
     db.close();
-
     return true;
 }
 
 
 
 void Bookmarks::clear() {
+    checkAndCreateDb();
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
         qDebug() << "Database error: " << db.lastError().text() << endl;
@@ -49,6 +46,7 @@ void Bookmarks::clear() {
 
 
 void Bookmarks::add(Translation* translation) {
+    checkAndCreateDb();
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
         qDebug() << "Database error: " << db.lastError().text() << endl;
@@ -66,6 +64,7 @@ void Bookmarks::add(Translation* translation) {
 
 
 void Bookmarks::remove(Translation* translation) {
+    checkAndCreateDb();
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
         qDebug() << "Database error: " << db.lastError().text() << endl;
@@ -81,6 +80,7 @@ void Bookmarks::remove(Translation* translation) {
 
 
 QList<Translation*> Bookmarks::list() {
+    checkAndCreateDb();
     QList<Translation*> res;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
@@ -98,7 +98,7 @@ QList<Translation*> Bookmarks::list() {
 
 
 QList<Translation*> Bookmarks::searchWordList(QString word) {
-
+    checkAndCreateDb();
     if(word.indexOf("*")==-1 && word.indexOf("?")== -1)
         word+="%";
     word = word.replace("*", "%");
@@ -128,6 +128,7 @@ QList<Translation*> Bookmarks::searchWordList(QString word) {
 
 
 QStringList Bookmarks::search(QString word, QString dbName) {
+    checkAndCreateDb();
     QStringList result;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
@@ -149,6 +150,7 @@ QStringList Bookmarks::search(QString word, QString dbName) {
 
 
 bool Bookmarks::inBookmarks(QString word) {
+    checkAndCreateDb();
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
         qDebug() << "Database error: " << db.lastError().text() << endl;
index d9eae98..9662984 100644 (file)
@@ -73,6 +73,9 @@ void Backbone::init() {
 
    _dictNum = 0;
    _dir = QDir::homePath() + "/.mdictionary/";
+   if(!QDir(_dir).exists())
+       QDir().mkdir(_dir);
+
    if(!_configPath.size())
        _configPath = _dir + "mdictionary.config";
    if(!_pluginPath.size())
@@ -210,6 +213,12 @@ void Backbone::search(QString word){
     dictFin = !_searchDicts;
     bookmarkFin = !_searchBookmarks;
 
+    if(!_searchDicts && !_searchBookmarks) {
+        Q_EMIT notify(Notify::Warning, tr("You have to specify where You want "
+                "to look for translations"));
+        Q_EMIT ready();
+    }
+
     if (_searchDicts) {
         _innerResult = QtConcurrent::mapped(activeDicts(), mapSearch);
         _resultWatcher.setFuture(_innerResult);
@@ -281,8 +290,14 @@ void Backbone::translationReady() {
 
         while(it.hasNext()) {
             QList<Translation* > list = it.next();
-            foreach(Translation* trans, list)
+            foreach(Translation* trans, list) {
+                if(!trans)
+                    continue;
+                if(!_searchBookmarks)
+                    trans->setBookmark(_bookmarks.
+                            inBookmarks(trans->key()));
                 _result.insert(trans->key().toLower(), trans);
+           }
         }
     }
 
@@ -379,6 +394,7 @@ void Backbone::loadPrefs(QString fileName) {
     _searchLimit = set.value("general/search_limit", 15).toInt();
     _searchBookmarks = set.value("general/search_bookmarks",1).toBool();
     _searchDicts = set.value("general/search_dictionaries",1).toBool();
+    _zoom = set.value("general/zoom", 1.0).toReal();
 }
 
 
@@ -391,6 +407,7 @@ void Backbone::savePrefs(QSettings *set) {
     set->setValue("general/search_limit", _searchLimit);
     set->setValue("general/search_bookmarks", _searchBookmarks);
     set->setValue("general/search_dictionaries", _searchDicts);
+    set->setValue("general/zoom", _zoom);
 }
 
 
@@ -567,6 +584,10 @@ void Backbone::setSettings(Settings *settings) {
         _searchBookmarks = 1;
     else
         _searchBookmarks = 0;
+    _zoom = settings->value("zoom").toFloat();
+    if(!_zoom)
+        _zoom ++;
+
     dictUpdated();
     if(settings)
         delete settings;
@@ -579,6 +600,7 @@ Settings* Backbone::settings() {
     Settings * settings = new Settings();
     settings->setValue("history_size", QString("%1").arg(_historyLen));
     settings->setValue("search_limit", QString("%1").arg(_searchLimit));
+    settings->setValue("zoom", QString("%1").arg(_zoom));
     if(_searchBookmarks)
         settings->setValue("search_bookmarks", "true");
     else
index 55b3ebb..623dd98 100644 (file)
@@ -307,6 +307,7 @@ private:
     QString _configPath;
     QString _dir;
     int _historyLen;
+    qreal _zoom;
 
     bool dryRun; // mainly for testing - when true then doesn't bother configs etc
     bool stopped; // true when user stops searching/fetching
index b929c80..79f0288 100644 (file)
@@ -5,8 +5,9 @@ QT += core \
     gui \
     sql \
     xml \
-    xmlpatterns
-
+    xmlpatterns \
+    webkit \
+    dbus
 maemo5:QT += maemo5
 TARGET = mdictionary
 TEMPLATE = app
@@ -32,7 +33,9 @@ SOURCES += gui/main.cpp \
     gui/BookmarksWidget.cpp \
     gui/WelcomeScreenWidget.cpp \
     gui/AboutWidget.cpp \
-    gui/TranslationTextEdit.cpp
+    gui/TranslationTextEdit.cpp \
+    gui/DBusAdapter.cpp \
+    gui/NotifyManager.cpp
 HEADERS += gui/MainWindow.h \
     backbone/ConfigGenerator.h \
     gui/AboutWidget.h \
@@ -47,7 +50,6 @@ HEADERS += gui/MainWindow.h \
     gui/MenuTabWidget.h \
     gui/DictManagerWidget.h \
     gui/DictTypeSelectDialog.h \
-    gui/TranslationWidgetAutoResizer.h \
     ../includes/History.h \
     gui/HistoryListDialog.h \
     ../includes/GUIInterface.h \
@@ -61,21 +63,27 @@ HEADERS += gui/MainWindow.h \
     gui/TranslationTextEdit.h \
     ../includes/AccentsNormalizer.h \
     ../includes/DictDialog.h
-RESOURCES += \
-    translations.qrc \
-    ../../../data/gui.qrc
+    ../includes/DictDialog.h \
+    gui/DBusAdapter.h \
+    gui/NotifyManager.h
+
+RESOURCES += ../../../data/gui.qrc
 unix { 
     # VARIABLES
     isEmpty(PREFIX):PREFIX = /usr
     BINDIR = $$PREFIX/bin
     DATADIR = $$PREFIX/share
+    LIBDIR = $$PREFIX/lib/mdictionary
     DEFINES += DATADIR=\\\"$$DATADIR\\\" \
-        PKGDATADIR=\\\"$$PKGDATADIR\\\"
+        PKGDATADIR=\\\"$$PKGDATADIR\\\" \
+        LIBDIR=\\\"$$LIBDIR\\\"
     
     # MAKE INSTALL
     INSTALLS += target \
         desktop \
-        icon64
+        icon64 \
+        bookmarks \
+        service
     target.path = $$BINDIR
     maemo5 { 
         desktop.path = $$DATADIR/applications/hildon
@@ -87,5 +95,9 @@ unix {
     }
     desktop.files += ../../../data/other/$${TARGET}.desktop
     icon64.files += ../../../data/icons/64x64/$${TARGET}.png
+    bookmarks.path = $$LIBDIR
+    bookmarks.files += ../../../data/icons/16x16/staron.png
+    service.path = $$DATADIR/dbus-1/services
+    service.files += ../../../data/other/com.comarch.mdictionary.service
 }
 RESOURCES += xslt2.qrc
diff --git a/trunk/src/base/gui/DBusAdapter.cpp b/trunk/src/base/gui/DBusAdapter.cpp
new file mode 100644 (file)
index 0000000..a86624d
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+
+    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 "DBusAdapter.h"
+#include <QDebug>
+
+DBusAdapter::DBusAdapter(MainWindow *w):
+    QDBusAbstractAdaptor(w)
+{
+    mainWindow = w;
+}
+
+void DBusAdapter::search(QString word) {
+    showApplication();
+    mainWindow->search(word);
+}
+
+void DBusAdapter::showApplication() {
+    if(!mainWindow->isActiveWindow())
+        mainWindow->activateWindow();
+}
diff --git a/trunk/src/base/gui/DBusAdapter.h b/trunk/src/base/gui/DBusAdapter.h
new file mode 100644 (file)
index 0000000..1c3f8c8
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+
+    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 DBUSADAPTER_H
+#define DBUSADAPTER_H
+
+#include <QDBusAbstractAdaptor>
+#include "MainWindow.h"
+
+class DBusAdapter : public QDBusAbstractAdaptor
+{
+    Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "com.comarch.mdictionary")
+public:
+    explicit DBusAdapter(MainWindow* w);
+
+public slots:
+    void search(QString);
+    void showApplication();
+
+private:
+    MainWindow* mainWindow;
+
+};
+
+#endif // DBUSADAPTER_H
index 29b16e5..b706572 100644 (file)
@@ -19,7 +19,8 @@
 
 *******************************************************************************/
 
-//Created by Mateusz Półrola
+//! \file MainWindow.cpp
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #include "MainWindow.h"
 #include <QtGui>
@@ -46,8 +47,6 @@ MainWindow::MainWindow(Backbone *backbone, QWidget *parent):
 
     setExactSearch(false);
 
-    setWindowTitle("mDictionary");
-
     showMaximized();
 }
 
@@ -62,27 +61,41 @@ void MainWindow::initializeUI() {
         setAttribute(Qt::WA_Maemo5StackedWindow);
     #endif
 
-    //translationWidget is another stacked window, so we don't add it to layout
-    //only create it with this widget as parent
-    translationWidget = new TranslationWidget(this);
 
+    setWindowIcon(QIcon(":/icons/64x64/mdictionary.png"));
+    setWindowTitle("mDictionary");
+
+    /*translationWidget is another stacked window, so we don't add it to
+      layout only create it with this widget as parent
+      it must be created as first object in main window, otherwise sometimes
+      when app starts in maemo, when trying to set stacked window attribure
+      it segfaults*/
+    translationWidget = new TranslationWidget(this);
 
     mainLayout = new QVBoxLayout();
     QWidget* w = new QWidget();
     w->setLayout(mainLayout);
     setCentralWidget(w);
+
     menuBar = new QMenuBar();
     setMenuBar(menuBar);
 
+    initializeSearchWidgets();
+
+    initializeMenu();
+
+    notifyManager = new NotifyManager(this);
+}
+
+void MainWindow::initializeSearchWidgets() {
     searchBarWidget = new SearchBarWidget();
 
     wordListWidget = new WordListWidget();
 
     welcomeScreenWidget = new WelcomeScreenWidget();
 
-
     #ifdef Q_WS_MAEMO_5
-    //At start we set widget as welcome screen widget
+        //At start we set widget as welcome screen widget
         mainLayout->addWidget(welcomeScreenWidget);
         mainLayout->addWidget(searchBarWidget, 0, Qt::AlignBottom);
     #else
@@ -92,11 +105,48 @@ void MainWindow::initializeUI() {
         splitter->addWidget(wordListWidget);
         splitter->addWidget(welcomeScreenWidget);
         splitter->setStretchFactor(1, 150);
+
         mainLayout->addWidget(splitter);
         mainLayout->addWidget(searchBarWidget);
     #endif
+}
 
+void MainWindow::initializeMenu() {
+    initializeMenuWidgets();
 
+#ifdef Q_WS_MAEMO_5
+    menuWidget = new MenuWidget(this);
+
+    menuWidget->addSubMenu(tr("Settings"), settingsWidget);
+    menuWidget->addSubMenu(tr("Dictionaries"), dictManagerWidget);
+    menuWidget->addSubMenu(tr("Bookmarks"), bookmarksWidget);
+    menuWidget->addSubMenu(tr("About"), aboutWidget);
+
+    menuBar->addAction(menuWidget);
+#else
+    dictionariesAction = menuBar->addAction(tr("Dictionaries"));
+    connect(dictionariesAction, SIGNAL(triggered()),
+            dictManagerWidget, SLOT(show()));
+
+    settingsAction = menuBar->addAction(tr("Settings"));
+    connect(settingsAction, SIGNAL(triggered()),
+            settingsWidget, SLOT(show()));
+
+    QMenu* m = menuBar->addMenu(tr("Bookmarks"));
+    bookmarksShowAllAction = new QAction(tr("Show all"), m);
+
+    bookmarksRemoveAllAction = new QAction(tr("Remove all"), m);
+
+    m->addAction(bookmarksShowAllAction);
+    m->addAction(bookmarksRemoveAllAction);
+
+    aboutAction = menuBar->addAction(tr("About"));
+    connect(aboutAction, SIGNAL(triggered()),
+            aboutWidget, SLOT(show()));
+#endif
+}
+
+void MainWindow::initializeMenuWidgets() {
     dictManagerWidget = new DictManagerWidget(this);
     dictManagerWidget->hide();
 
@@ -108,46 +158,15 @@ void MainWindow::initializeUI() {
 
     aboutWidget = new AboutWidget(this);
     aboutWidget->hide();
-
-    //creating menus
-
-    #ifdef Q_WS_MAEMO_5
-        menuWidget = new MenuWidget(this);
-        menuWidget->addSubMenu(tr("Settings"), settingsWidget);
-        menuWidget->addSubMenu(tr("Dictionaries"), dictManagerWidget);
-        menuWidget->addSubMenu(tr("Bookmarks"), bookmarksWidget);
-        menuWidget->addSubMenu(tr("About"), aboutWidget);
-        menuBar->addAction(menuWidget);
-    #else
-        dictionariesAction = menuBar->addAction(tr("Dictionaries"));
-        connect(dictionariesAction, SIGNAL(triggered()),
-                dictManagerWidget, SLOT(show()));
-
-        settingsAction = menuBar->addAction(tr("Settings"));
-        connect(settingsAction, SIGNAL(triggered()),
-                settingsWidget, SLOT(show()));
-
-        QMenu* m = menuBar->addMenu(tr("Bookmarks"));
-        bookmarksShowAllAction = new QAction(tr("Show all"), m);
-
-        bookmarksRemoveAllAction = new QAction(tr("Remove all"), m);
-
-        m->addAction(bookmarksShowAllAction);
-        m->addAction(bookmarksRemoveAllAction);
-
-        aboutAction = menuBar->addAction(tr("About"));
-        connect(aboutAction, SIGNAL(triggered()),
-                aboutWidget, SLOT(show()));
-    #endif
 }
 
 void MainWindow::closeEvent(QCloseEvent *event) {
     //request to stop all searches and close app
-        Q_EMIT quit();
-        event->accept();
+    Q_EMIT quit();
+    event->accept();
 }
 
-bool MainWindow::exactSearch() {
+bool MainWindow::isInExactSearch() {
     return _exactSearch;
 }
 
@@ -155,28 +174,21 @@ void MainWindow::setExactSearch(bool exact) {
     _exactSearch = exact;
 }
 
-void MainWindow::setSearchString(QString word) {
+void MainWindow::setExactSearchString(QString word) {
     searchString = word;
 }
 
 void MainWindow::wordListReady() {
     //gets results from backbone
-    QMultiHash<QString, Translation*> res = backbone->result();
+    QMultiHash<QString, Translation*> backboneResult = backbone->result();
     QHash<QString, QList<Translation*> > searchResult;
 
     #ifdef Q_WS_MAEMO_5
-    //switch welcome screen with word list
-    if(!wordListWidget->isVisible()) {
-        int i = mainLayout->indexOf(welcomeScreenWidget);
-        QBoxLayout* l = (QBoxLayout*)(mainLayout);
-        l->removeWidget(welcomeScreenWidget);
-        welcomeScreenWidget->deleteLater();
-        l->insertWidget(0, wordListWidget);
-    }
+        hideWelcomeScreen();
     #endif
 
     //if nothing was found
-    if(res.count() == 0) {
+    if(backboneResult.count() == 0) {
         showNotify(Notify::Info, tr("Can't find any matching words"));
 
         //show empty list to remove results of old search
@@ -185,54 +197,73 @@ void MainWindow::wordListReady() {
     else {
         //find translations of the same key word
         QMultiHash<QString, Translation*>::iterator i;
-        for(i = res.begin(); i != res.end(); i++) {
+        for(i = backboneResult.begin(); i != backboneResult.end(); i++) {
             searchResult[i.key()].push_back(i.value());
         }
 
+        //show search results
+        Q_EMIT showWordList(searchResult);
 
-        if(!exactSearch()) {
-            Q_EMIT showWordList(searchResult);
-        }
-        else {
-            #ifndef Q_WS_MAEMO_5
-            //on desktop we show word list in exact search
-                Q_EMIT showWordList(searchResult);
-            #endif
-            bool foundExactMatch = false;
-            QHash<QString, QList<Translation*> >::iterator j;
-            for(j = searchResult.begin(); j != searchResult.end(); j++) {
-                if(j.key() == searchString && !foundExactMatch) {
-                    foundExactMatch = true;
-                    Q_EMIT searchTranslations(j.value());
-                    break;
-                }
-            }
 
-            if(!foundExactMatch) {
+        if(isInExactSearch()) {
+            QList<Translation*> exactTranslation;
+            if(checkExactSearch(searchResult, exactTranslation)) {
+                qDebug()<<exactTranslation.count();
+                Q_EMIT searchTranslations(exactTranslation);
+            }
+            else {
                 showNotify(Notify::Info,
                            tr("Can't find exactly matching word"));
-
-                Q_EMIT showWordList(searchResult);
             }
 
+            setExactSearch(false);
         }
     }
-    setExactSearch(false);
+}
+
+bool MainWindow::checkExactSearch(
+        QHash<QString, QList<Translation *> > searchResult,
+        QList<Translation *> &found) {
+
+    bool foundExactMatch = false;
+    QHash<QString, QList<Translation*> >::iterator j;
+    for(j = searchResult.begin(); j != searchResult.end(); j++) {
+        if(j.key().toLower() == searchString.toLower()
+            && !foundExactMatch) {
+            found = j.value();
+            return true;
+        }
+    }
+    return false;
 }
 
 void MainWindow::translationsReady() {
     #ifndef Q_WS_MAEMO_5
+        hideWelcomeScreen();
+    #endif
+
+    Q_EMIT showTranslation(backbone->htmls());
+    notifyManager->screenChanged();
+}
+
+
+void MainWindow::hideWelcomeScreen() {
+#ifdef Q_WS_MAEMO_5
+    //switch welcome screen with word list
+    if(!wordListWidget->isVisible()) {
+        mainLayout->removeWidget(welcomeScreenWidget);
+        welcomeScreenWidget->deleteLater();
+
+        mainLayout->insertWidget(0, wordListWidget);
+    }
+#else
     //switch welcome screen with translation widget
     if(!translationWidget->isVisible()) {
-        QBoxLayout* l = (QBoxLayout*)(mainLayout);
-        QSplitter* s = (QSplitter*)((QWidgetItem*)(l->itemAt(0))->widget());
-        s->insertWidget(1,translationWidget);
-        s->setStretchFactor(1, 150);
+        splitter->insertWidget(1,translationWidget);
+        splitter->setStretchFactor(1, 150);
         welcomeScreenWidget->deleteLater();
     }
-    #endif
-
-    Q_EMIT showTranslation(backbone->htmls());
+#endif
 }
 
 QList<CommonDictInterface*> MainWindow::getPlugins() {
@@ -251,15 +282,18 @@ void MainWindow::search(QString word) {
 
 void MainWindow::searchExact(QString word) {
     setExactSearch(true);
-    //searching with searchBar, not directly by emitting searchWordList(),
-    //because it will set search word in searchBar's edit line
-    //this function is only used by history and when searching from attributes
     searchBarWidget->search(word);
 }
 
+void MainWindow::searchDelay(QString word) {
+    searchBarWidget->searchDelay(word);
+}
+
 
 
-void MainWindow::breakSearching() {
+
+
+void MainWindow::searchingInterrupted() {
     //make sure to unset exact search mode
     setExactSearch(false);
 }
@@ -276,7 +310,7 @@ void MainWindow::historyNext() {
         #ifndef Q_WS_MAEMO_5
             setExactSearch(true);
         #endif
-        searchBarWidget->searchDelay(next);
+        searchDelay(next);
     }
 }
 
@@ -286,7 +320,7 @@ void MainWindow::historyPrev() {
             setExactSearch(true);
         #endif
         QString prev = backbone->history()->previous();
-        searchBarWidget->searchDelay(prev);
+        searchDelay(prev);
     }
 }
 
@@ -311,6 +345,7 @@ void MainWindow::enableMenu() {
 }
 
 void MainWindow::showHistory(QPoint p) {
+
     HistoryListDialog historyDialog(backbone->history()->list(), searchBarWidget);
 
     #ifndef Q_WS_MAEMO_5
@@ -338,37 +373,28 @@ Settings* MainWindow::settings() {
 
 
 void MainWindow::showNotify(Notify::NotifyType type, QString text) {
+    notifyManager->showNotify(type, text);
+}
 
-    switch(type) {
-    case Notify::Info:
-        #ifdef Q_WS_MAEMO_5
-            QMaemo5InformationBox::information(0,
-                                text,
-                                QMaemo5InformationBox::DefaultTimeout);
-        #else
-            QMessageBox::information(this, tr("Information"), text);
-        #endif
-        break;
+void MainWindow::connectBackbone() {
+
+    connect(this, SIGNAL(searchWordList(QString)),
+            this, SIGNAL(setBusy()));
+
+    connect(this, SIGNAL(searchTranslations(QList<Translation*>)),
+            this, SIGNAL(setBusy()));
+
+    connect(this, SIGNAL(stopSearching()),
+            this, SIGNAL(setIdle()));
+
+    connect(this, SIGNAL(searchWordList(QString)),
+            this, SLOT(setExactSearchString(QString)));
+
+    connect(this, SIGNAL(searchTranslations(QList<Translation*>)),
+            this, SLOT(addToHistory(QList<Translation*>)));
 
-    case Notify::Warning:
-        #ifndef Q_WS_MAEMO_5
-                QMessageBox::warning(this, tr("Warning"), text);
-                break;
-        #endif
 
-    case Notify::Error:
-        #ifdef Q_WS_MAEMO_5
-            QMaemo5InformationBox::information(0,
-                                text,
-                                QMaemo5InformationBox::NoTimeout);
-        #else
-            QMessageBox::critical(this, tr("Error"), text);
-        #endif
-        break;
-    }
-}
 
-void MainWindow::connectBackbone() {
     connect(this, SIGNAL(quit()),
             backbone, SLOT(quit()));
 
@@ -382,7 +408,7 @@ void MainWindow::connectBackbone() {
             backbone, SLOT(stopSearching()));
 
     connect(this, SIGNAL(stopSearching()),
-            this, SLOT(breakSearching()));
+            this, SLOT(searchingInterrupted()));
 
     connect(this, SIGNAL(addNewDictionary(CommonDictInterface*)),
             backbone, SLOT(addDictionary(CommonDictInterface*)));
@@ -412,26 +438,6 @@ void MainWindow::connectBackbone() {
 
     connect(backbone, SIGNAL(notify(Notify::NotifyType,QString)),
             this, SLOT(showNotify(Notify::NotifyType,QString)));
-
-
-
-
-    connect(this, SIGNAL(searchWordList(QString)),
-            this, SIGNAL(setBusy()));
-
-    connect(this, SIGNAL(searchTranslations(QList<Translation*>)),
-            this, SIGNAL(setBusy()));
-
-    connect(this, SIGNAL(stopSearching()),
-            this, SIGNAL(setIdle()));
-
-    connect(this, SIGNAL(searchWordList(QString)),
-            this, SLOT(setSearchString(QString)));
-
-    connect(this, SIGNAL(searchTranslations(QList<Translation*>)),
-            this, SLOT(addToHistory(QList<Translation*>)));
-
-
 }
 
 void MainWindow::connectSearchBar() {
index 1046fde..4ed7c8d 100644 (file)
@@ -19,7 +19,6 @@
 
 *******************************************************************************/
 //! \file MainWindow.h
-//! \brief Implements interface for GUI
 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #ifndef MAINWINDOW_H
 #include "BookmarksWidget.h"
 #include "WelcomeScreenWidget.h"
 #include "AboutWidget.h"
+#include "NotifyManager.h"
 
 
 //! Implements interface for GUI
 /*!
-  Creates all of GUI subcomponents, and connects all GUI interface signals with
-  suitable backbone signals and slots. Only this class has direct access to
-  backbone object. It manages all requests of subcomponents e. g. searching of
-  given word, displaying history, removing dictionary.
+  Creates all of GUI subcomponents, and connects all GUI interface signals
+  with suitable backbone signals and slots.
+  Only this class has direct access to backbone object.
+  It manages all requests of subcomponents e. g. searching of given word,
+  displaying history, removing dictionary.
   It also provide data from backbone to subcomponents e. g. result of search.
 */
 class MainWindow : public GUIInterface
@@ -58,9 +59,8 @@ public:
     /*!
       \param backbone object which will be doing all searches and returning data
       \param parent parent widget of this window
-      */
-
-    explicit MainWindow(Backbone* backbone, QWidget *parent = 0);
+    */
+    MainWindow(Backbone* backbone, QWidget *parent = 0);
     ~MainWindow();
 
     //! Returns all loaded dictionaries with infromation about that they are
@@ -68,46 +68,39 @@ public:
     /*!
         \return Hash of pointers to dictionary and boolean flag indicating if
         dictionary is active
-     */
+    */
     QHash<CommonDictInterface*, bool> getDictionaries();
 
     //! Returns all loaded plugins
     /*!
         \return List of pointers to plugins
-     */
+    */
     QList<CommonDictInterface*> getPlugins();
 
     //! Indicates if GUI is in exact search mode.
-    /*! When GUI is in exact search mode it searches for word, and
-        if it finds exactly matching translation it directly displays it, without
-        displaying matching word list. This mode is used for browsing search
-        history and searching words from application arguments.
+    /*! When GUI is in exact search mode it searches for word, and if it
+        finds exactly matching translation it displaying matching words list
+        and then directly displays translation of first exactly matched word.
+        This mode is used for browsing search history and searching words
+        from application arguments.
         \returns flag indicating if GUI is in exact search mode
+        \sa setExactSearch()
+        \sa setExactSearchString()
     */
-    bool exactSearch();
-
-    //! Sets GUI exact search mode.
-    /*! When GUI is in exact search mode it searches for word, and
-        if it finds exactly matching translation it directly displays it, without
-        displaying matching word list. This mode is used for browsing search
-        history and searching words from application arguments.
-        \param exactSearch flag indicating if GUI will be in exact search mode
-        \sa exactSearch()
-    */
-    void setExactSearch(bool);
+    bool isInExactSearch();
 
 
-    //! Returns current settings.
+    //! Returns current application settings.
     /*!
        \returns Settings object containing current application settings
-      */
+    */
     Settings* settings();
 
 
     //! Sets new settings.
     /*!
        \param Settings object containing new application settings
-      */
+    */
     void setSettings(Settings*);
 
 
@@ -115,29 +108,65 @@ public:
     //! Searches in exact mode for given word
     /*!
       GUI will be automatically set into exact search mode, and after search or
-      break will be unset from exact search mode.
+      when user break the search it will be unset from exact search mode.
       \param word which will be searched in dictionaries
-      */
+      \sa search()
+    */
     void searchExact(QString);
 
 
     //! Search for given word
     /*!
+      It sets passed word in line edit of search bar and search for given word.
       \param word which will be searched in dictionaries
-      */
+      \sa SearchBarWidget
+      \sa searchExact()
+    */
     void search(QString);
 
+    //! Start searching for given word after 500 ms delay
+    /*!
+      After times up it sets passed word in line edit of search bar and search
+      for given word.
+      \param word which will be searched in dictionaries
+      \sa SearchBarWidget
+      \sa searchExact()
+      \sa search()
+    */
+    void searchDelay(QString);
+
+    //! Sets string for exact search
+    /*!
+        Sets string for which current search is ongoing, is used to find exact
+        word when GUI is in search exact mode.
+    */
+    void setExactSearchString(QString);
+
+    //! Sets GUI exact search mode.
+    /*! When GUI is in exact search mode it searches for word, and if it
+        finds exactly matching translation it displaying matching words list
+        and then directly displays translation of first exactly matched word.
+        This mode is used for browsing search history and searching words
+        from application arguments.
+        \param exactSearch flag indicating if GUI will be in exact search mode
+        \sa isInExactSearch()
+        \sa setExactSearchString()
+    */
+    void setExactSearch(bool);
 
 
     //! Gets word list from backbone and prepares received list to display
     /*!
       Checks if received list is empty, in that case displays suitable
-      information. If GUI is in exact search mode it will search for exact
-      word in received list, and if word is found it will emit signal to
-      display its translation. Otherwise it will display list of matching
-      words and show suitable information.
-      \sa exactSearch()
+      information. Otherwise it merge results of the same key word and emit
+      signal to display word list.
+      If GUI is in exact search mode it will search for exact word in received
+      list and if any of found words match exacly the word passed to
+      searchExact() method.
+      \sa isInExactSearch()
+      \sa searchExact()
       \sa showTranslation()
+      \sa setExactSearchString()
      */
     void wordListReady();
 
@@ -155,12 +184,20 @@ public:
     void addToHistory(QList<Translation*>);
 
     //! Shows history dialog
+    /*!
+       In meamo shows dialog with history.
+       In desktop shows popup containing history, which bottom edge is on the
+       same height as passed point.
+       \param point on screen when popup has to show
+    */
     void showHistory(QPoint);
 
     //! Shows translation of next word in history
     /*!
       It will work only if there is available next word in history.
-      Translation of word is searched with searchExact() function
+      Translation of word is searched with searchDelay() function.
+      On maemo search is in normal mode, on desktop in exact search mode.
+      \sa searchDelay()
       \sa searchExact()
       */
     void historyNext();
@@ -168,20 +205,25 @@ public:
     //! Shows translation of previous word in history
     /*!
       It will work only if there is available previous word in history.
-      Translation of word is searched with searchExact() function
+      Translation of word is searched with searchDelay() function.
+      On maemo search is in normal mode, on desktop in exact search mode.
+      \sa searchDelay()
       \sa searchExact()
       */
     void historyPrev();
 
 
-    void showNotify(Notify::NotifyType, QString);
+    //! Shows notify to user
+    /*!
+      It shows different type of notyfies as informations, warnings and errors.
+      In maemo they are represented as notes, on desktop as message boxes.
+      \param type type of notify
+      \param message notify message
+    */
+    void showNotify(Notify::NotifyType type, QString message);
 
 private Q_SLOTS:
-    //! Sets string for which current search is ongoing, is used to find exact
-    //! word when GUI is in search exact mode.
-    void setSearchString(QString);
-
-    //! Disables menu when search is ongoing
+    //! Disables menu
     void disableMenu();
 
     //! Enables menu
@@ -189,14 +231,14 @@ private Q_SLOTS:
 
     //! When user breaks searching it makes sure that exact search mode will be
     //! disabled
-    void breakSearching();
+    void searchingInterrupted();
 
     //! Asks for confirmation when user click on "delete all bookmarks"
     void removeBookmarks();
 
-
 protected:
-    /*! When user wants to close application, we first send signal to stop all
+    /*!
+        When user wants to close application, we first send signal to stop all
         ongoing searches.
     */
     void closeEvent(QCloseEvent *);
@@ -206,6 +248,14 @@ private:
     Backbone* backbone;
 
     void initializeUI();
+    void initializeSearchWidgets();
+    void initializeMenu();
+    void initializeMenuWidgets();
+
+    void hideWelcomeScreen();
+
+    bool checkExactSearch(QHash<QString, QList<Translation*> > searchResult,
+                          QList<Translation*> &found);
 
     SearchBarWidget* searchBarWidget;
     QWidget* translationWidget;
@@ -216,8 +266,9 @@ private:
     BookmarksWidget* bookmarksWidget;
     QWidget* welcomeScreenWidget;
     AboutWidget* aboutWidget;
-    QVBoxLayout* mainLayout;
     QMenuBar* menuBar;
+    QVBoxLayout* mainLayout;
+    NotifyManager* notifyManager;
 
     #ifndef Q_WS_MAEMO_5
         QSplitter* splitter;
diff --git a/trunk/src/base/gui/NotifyManager.cpp b/trunk/src/base/gui/NotifyManager.cpp
new file mode 100644 (file)
index 0000000..257f611
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+
+    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 "NotifyManager.h"
+#include <QMessageBox>
+#ifdef Q_WS_MAEMO_5
+    #include <QMaemo5InformationBox>
+#endif
+#include <QDebug>
+#include <QLabel>
+
+NotifyManager::NotifyManager(QObject *parent) :
+    QObject(parent)
+{
+}
+
+void NotifyManager::notifyClosed() {
+    QObject* dialog = QObject::sender();
+
+    QHash<QString, QDialog*>::Iterator it;
+
+    for(it = activeNotifies.begin(); it != activeNotifies.end(); it++) {
+        if(it.value() == dialog) {
+            activeNotifies.remove(it.key());
+            return;
+        }
+    }
+}
+
+void NotifyManager::screenChanged() {
+    QHash<QString, QDialog*>::Iterator it;
+
+    for(it = activeNotifies.begin(); it != activeNotifies.end(); it++) {
+        it.value()->hide();
+        it.value()->show();
+    }
+}
+
+void NotifyManager::showNotify(Notify::NotifyType type, QString text) {
+
+    if(activeNotifies.contains(text)) {
+        return;
+    }
+
+    #ifdef Q_WS_MAEMO_5
+        QMaemo5InformationBox* mbox =
+                new QMaemo5InformationBox(0);
+
+        QLabel* infoLabel = new QLabel(text);
+        infoLabel->setAlignment(Qt::AlignCenter);
+        infoLabel->setWordWrap(true);
+
+        mbox->setWidget(infoLabel);
+    #else
+        QMessageBox* mbox =
+                new QMessageBox(qobject_cast<QWidget*>(this->parent()));
+
+    #endif
+
+
+    switch(type) {
+
+    case Notify::Info:
+        #ifdef Q_WS_MAEMO_5
+            mbox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
+        #else
+            mbox->setText(text);
+            mbox->setWindowTitle(tr("Information"));
+            mbox->setIcon(QMessageBox::Information);
+
+        #endif
+        break;
+
+    case Notify::Warning:
+        #ifndef Q_WS_MAEMO_5
+                mbox->setText(text);
+                mbox->setWindowTitle(tr("Warning"));
+                mbox->setIcon(QMessageBox::Warning);
+                break;
+        #endif
+
+    case Notify::Error:
+        #ifdef Q_WS_MAEMO_5
+            mbox->setTimeout(QMaemo5InformationBox::NoTimeout);
+        #else
+            mbox->setText(text);
+            mbox->setWindowTitle(tr("Error"));
+            mbox->setIcon(QMessageBox::Critical);
+        #endif
+        break;
+    }
+
+    activeNotifies.insert(text, mbox);
+    connect(mbox, SIGNAL(finished(int)), this, SLOT(notifyClosed()));
+    mbox->exec();
+}
diff --git a/trunk/src/base/gui/NotifyManager.h b/trunk/src/base/gui/NotifyManager.h
new file mode 100644 (file)
index 0000000..be5507f
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+
+    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 NOTIFYMANAGER_H
+#define NOTIFYMANAGER_H
+
+#include <QObject>
+#include <QHash>
+#include <QString>
+#include <QDialog>
+#include "../../includes/Notify.h"
+
+class NotifyManager : public QObject
+{
+    Q_OBJECT
+public:
+    NotifyManager(QObject *parent = 0);
+
+public slots:
+    void showNotify(Notify::NotifyType type, QString text);
+    void screenChanged();
+
+private slots:
+    void notifyClosed();
+
+private:
+    QHash<QString, QDialog*> activeNotifies;
+};
+
+#endif // NOTIFYMANAGER_H
index 69d24d7..4bf961c 100644 (file)
 
 #include <QtGui>
 #include "TranslationTextEdit.h"
+#include "TranslationWidget.h"
 
 TranslationTextEdit::TranslationTextEdit(QWidget *parent) :
-    QTextEdit(parent)
+    QWebView(parent)
 {
+    realParent = qobject_cast<TranslationWidget*>(parent);
     searchSelectedAction = new QAction(tr("Search"), this);
+    copySelectedAction = new QAction(tr("Copy"), this);
+    selectAllAction = new QAction(tr("Select All"), this);
+    setAcceptDrops(false);
+
+    #ifdef Q_WS_MAEMO_5
+        installEventFilter(this);
+        property("kineticScroller").value<QAbstractKineticScroller*>()->
+                setEnabled(true);
+    #endif
+
 
     connect(searchSelectedAction, SIGNAL(triggered()),
             this, SIGNAL(search()));
+    connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
 }
 
+
+bool TranslationTextEdit::eventFilter(QObject *, QEvent *e)
+{
+    switch (e->type()) {
+    case QEvent::MouseButtonPress:
+        if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
+            mousePressed = true;
+        break;
+    case QEvent::MouseButtonRelease:
+        if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
+            mousePressed = false;
+        break;
+    case QEvent::MouseMove:
+        if (mousePressed)
+            return true;
+        break;
+    default:
+        break;
+    }
+    return false;
+}
+
+
 void TranslationTextEdit::contextMenuEvent(QContextMenuEvent *e) {
-    QMenu *menu = createStandardContextMenu(e->pos());
-    if(textCursor().selectedText().isEmpty())
+    QMenu *menu = new QMenu;
+    if(selectedText().isEmpty())
         searchSelectedAction->setEnabled(false);
     else
         searchSelectedAction->setEnabled(true);
 
-    menu->addSeparator();
     menu->addAction(searchSelectedAction);
+    menu->addSeparator();
+    menu->addAction(pageAction(QWebPage::Copy));
+    menu->addAction(pageAction(QWebPage::SelectAll));
 
     menu->exec(e->globalPos());
     delete menu;
 
     e->ignore();
 }
+
+
+void TranslationTextEdit::zoomIn() {
+    setZoomFactor(zoomFactor()*1.05);
+    realParent->updateZoom(zoomFactor());
+
+}
+
+void TranslationTextEdit::zoomOut() {
+    setZoomFactor(zoomFactor()*0.95);
+    realParent->updateZoom(zoomFactor());
+}
+
+void TranslationTextEdit::copy() {
+      pageAction(QWebPage::Copy)->trigger();
+}
+
+void TranslationTextEdit::selection() {
+    if(selectedText().size())
+        Q_EMIT copyAvailable(true);
+    else
+        Q_EMIT copyAvailable(false);
+}
+
+
+void TranslationTextEdit::selectAll() {
+    pageAction(QWebPage::SelectAll)->trigger();
+}
+
+
+
index 0747317..7fdd2dc 100644 (file)
 
 #include <QTextEdit>
 #include <QAction>
+#include <QWebView>
+#include <QEvent>
 
-class TranslationTextEdit : public QTextEdit
+class TranslationWidget;
+
+class TranslationTextEdit : public QWebView
 {
     Q_OBJECT
 public:
     explicit TranslationTextEdit(QWidget *parent = 0);
 
+public Q_SLOTS:
+    void zoomIn();
+    void zoomOut();
+    void copy();
+    void selection();
+    void selectAll();
+
 Q_SIGNALS:
     void search();
+    void copyAvailable(bool);
 
 protected:
     void contextMenuEvent(QContextMenuEvent *);
 
 private:
     QAction* searchSelectedAction;
+    QAction* copySelectedAction;
+    QAction* selectAllAction;
+    TranslationWidget* realParent;
+    bool mousePressed;
+    bool eventFilter(QObject *, QEvent *);
+
 };
 
 #endif // TRANSLATIONTEXTEDIT_H
index 79f0402..689bef0 100644 (file)
@@ -22,7 +22,6 @@
 //Created by Mateusz Półrola
 
 #include "TranslationWidget.h"
-#include "TranslationWidgetAutoResizer.h"
 #include <QDebug>
 #ifdef Q_WS_MAEMO_5
     #include <QtGui/QX11Info>
@@ -31,7 +30,9 @@
 #endif
 
 TranslationWidget::TranslationWidget(QWidget *parent):
-    QScrollArea(parent) {
+        QScrollArea(parent){
+
+    guiinterface = qobject_cast<GUIInterface*>(parent);
 
     #ifdef Q_WS_MAEMO_5
         setAttribute(Qt::WA_Maemo5StackedWindow);
@@ -43,7 +44,7 @@ TranslationWidget::TranslationWidget(QWidget *parent):
 
     setWindowTitle("mDictionary");
 
-    connect(textEdit, SIGNAL(search()),
+    connect(webkit, SIGNAL(search()),
            this, SLOT(searchSelected()));
 
     QFile file(":/xsl/xsl.xsl");
@@ -60,41 +61,40 @@ void TranslationWidget::show() {
 
 
 void TranslationWidget::show(QStringList translations) {
-    textEdit->clear();
-
     showMaximized();
 
     #ifdef Q_WS_MAEMO_5
         if(!buttonsInitialized)
             initButtons();
     #endif
-    textEdit->repaint(this->rect());
+    webkit->repaint(this->rect());
     update(this->rect());
 
     QString trans;
     QString t;
+
     foreach(t, translations) {
         trans += t + "\n";
     }
 
-    QImage image(":icons/16x16/staron.png");
-    QTextDocument *document = textEdit->document();
-    document->addResource(QTextDocument::ImageResource,
-            QUrl("mydata://image.png"), QVariant(image));
+    trans=tr("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") + tr("\n <ar>")
+            + trans + tr("\n </ar>");
+    trans=XslConversion(trans);
 
-    QFile cssFile(QDir::homePath() + "/.mdictionary/style.css");
-    cssFile.open(QFile::ReadOnly);
-    document->addResource(QTextDocument::StyleSheetResource,
-            QUrl("mydata://style.css"),
-            QVariant(cssFile.readAll()));
+    QString head = "<html><head>";
+    head += "<link rel=\"stylesheet\" type=\"text/css\" " ;
+    head += "href=\"" + QDir::homePath() + "/.mdictionary/style.css";
+    head += "\" /></head><body ondragstart=\"return false\">";
+    trans = head + trans;
 
+    trans+= "</body></html>";
+    trans.replace("$STAR$", "/usr/lib/mdictionary/staron.png");
 
-    trans=tr("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") + tr("\n <ar>") + trans + tr("\n </ar>");
-    trans=XslConversion(trans);
 
-    textEdit->insertHtml(trans);
+    webkit->setHtml(trans, QUrl().fromLocalFile("/"));
+
 
-    textEdit->repaint(this->rect());
+    webkit->repaint(this->rect());
     update(this->rect());
 
     Q_EMIT updateSize();
@@ -201,19 +201,16 @@ void TranslationWidget::initButtons() {
 
 void TranslationWidget::initializeUI() {
 
-    textEdit = new TranslationTextEdit(this);
-    textEdit->setReadOnly(true);
-
-    resizer = new TranslationWidgetAutoResizer(textEdit);
-    connect(this, SIGNAL(updateSize()),
-            resizer, SLOT(textEditChanged()));
+    webkit = new TranslationTextEdit(this);
+    Settings* set = guiinterface->settings();
+    qreal fac = set->value("zoom").toFloat();
+    if(!fac)
+        fac++;
+    webkit->setZoomFactor(fac);
 
     QWidget*w = new QWidget(this);
     verticalLayout = new QVBoxLayout(w);
-    verticalLayout->addWidget(textEdit);
-
-    textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    verticalLayout->addWidget(webkit);
 
     this->setWidget(w);
     this->setWidgetResizable(true);
@@ -246,26 +243,26 @@ void TranslationWidget::initializeUI() {
         showButtonsButton->setMinimumSize(searchButton->sizeHint());
 
         connect(zoomInButton, SIGNAL(clicked()),
-                textEdit, SLOT(zoomIn()));
+                webkit, SLOT(zoomIn()));
 
         connect(zoomOutButton, SIGNAL(clicked()),
-                textEdit, SLOT(zoomOut()));
+                webkit, SLOT(zoomOut()));
 
 
         connect(searchButton, SIGNAL(clicked()),
                 this, SLOT(searchSelected()));
 
         connect(copyButton, SIGNAL(clicked()),
-                textEdit, SLOT(copy()));
+                webkit, SLOT(copy()));
 
-        connect(textEdit, SIGNAL(copyAvailable(bool)),
+        connect(webkit, SIGNAL(copyAvailable(bool)),
                 searchButton, SLOT(setEnabled(bool)));
 
-        connect(textEdit, SIGNAL(copyAvailable(bool)),
+        connect(webkit, SIGNAL(copyAvailable(bool)),
                 copyButton, SLOT(setEnabled(bool)));
 
         connect(selectAllButton, SIGNAL(clicked()),
-                textEdit, SLOT(selectAll()));
+                webkit, SLOT(selectAll()));
 
         buttonsInitialized = false;
 
@@ -279,7 +276,7 @@ void TranslationWidget::searchSelected() {
     #ifdef Q_WS_MAEMO_5
         hide();
     #endif
-    Q_EMIT search(textEdit->textCursor().selectedText());
+    Q_EMIT search(webkit->selectedText().toLower());
 }
 
 #ifdef Q_WS_MAEMO_5
@@ -331,12 +328,12 @@ void TranslationWidget::hideEvent(QHideEvent* e) {
 void TranslationWidget::keyPressEvent(QKeyEvent* event) {
     switch (event->key()) {
         case Qt::Key_F7:
-        textEdit->zoomIn();
+        webkit->zoomIn();
         event->accept();
         break;
 
         case Qt::Key_F8:
-        textEdit->zoomOut();
+        webkit->zoomOut();
         event->accept();
         break;
     }
@@ -345,4 +342,11 @@ void TranslationWidget::keyPressEvent(QKeyEvent* event) {
 #endif
 
 
+void TranslationWidget::updateZoom(qreal factor) {
+    Settings* set = guiinterface->settings();
+    set->setValue("zoom", QString("%1").arg(factor));
+    guiinterface->setSettings(set);
+}
+
+
 
index c172d04..055aaad 100644 (file)
 #include <QModelIndex>
 #include <QtGui>
 #include "../backbone/backbone.h"
-#include "TranslationWidgetAutoResizer.h"
 #include <QtXml>
 #include <QXmlQuery>
 #include "TranslationTextEdit.h"
 #include <QPropertyAnimation>
+#include "../../includes/GUIInterface.h"
 
 //! Displays translation of word found in dictionaries
 /*!
@@ -56,6 +56,9 @@ public Q_SLOTS:
     //! Requests to show translation of word list passed as parameter.
     void show(QStringList);
 
+    //! Updates users zoom preferences and sends its to backbone to be saved
+    void updateZoom(qreal);
+
 protected:
     #ifdef Q_WS_MAEMO_5
         void keyPressEvent(QKeyEvent *);
@@ -72,7 +75,7 @@ private:
     QString XslConversion(QString translation);
     QToolButton* zoomInToolButton;
     QToolButton* zoomOutToolButton;
-    TranslationTextEdit *textEdit;
+    TranslationTextEdit *webkit;
     QString xslt;
     #ifdef Q_WS_MAEMO_5
         QToolButton* zoomInButton;
@@ -97,7 +100,7 @@ private:
     #endif
     QVBoxLayout *verticalLayout;
     QHBoxLayout* horizontalLayout;
-    TranslationWidgetAutoResizer* resizer;
+    GUIInterface* guiinterface;
 
     void initializeUI();
 };
diff --git a/trunk/src/base/gui/TranslationWidgetAutoResizer.h b/trunk/src/base/gui/TranslationWidgetAutoResizer.h
deleted file mode 100644 (file)
index cc68304..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
-
-    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.
-
-*******************************************************************************/
-//! \file TranslationWidgetAutoResizer.h
-//! \brief Implements translation widget auto resizer
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>a
-
-#ifndef TRANSLATIONWIDGETAUTORESIZER_H
-#define TRANSLATIONWIDGETAUTORESIZER_H
-
-#include <QtGui/qtextedit.h>
-class TranslationWidgetAutoResizer : public QObject
-{
-    Q_OBJECT
-
-public:
-    TranslationWidgetAutoResizer(QWidget *parent) :QObject(parent),
-    textEdit(qobject_cast<QTextEdit* >((parent))),
-    edit(qobject_cast<QFrame* >((parent))) {
-
-     connect(parent, SIGNAL(textChanged()), this,
-             SLOT(textEditChanged()));
-     connect(parent, SIGNAL(cursorPositionChanged()),
-             this, SLOT(textEditChanged()));
-     }
-
-public Q_SLOTS:
-    inline void textEditChanged();
-
-private:
-    QTextEdit *textEdit;
-    QFrame *edit;
-};
-
-void TranslationWidgetAutoResizer::textEditChanged() {
-    QTextDocument *doc = textEdit->document();
-
-    QSize s = doc->size().toSize();
-
-    const QRect fr = edit->frameRect();
-    const QRect cr = edit->contentsRect();
-
-    edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height()) -
-                                1));
-
-    edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height()) -
-                                1));
-}
-
-#endif // TRANSLATIONWIDGETAUTORESIZER_H
index 12a4625..71cd63a 100644 (file)
 #include "../backbone/backbone.h"
 #include "../../includes/translation.h"
 #include "../../includes/Notify.h"
+#include "DBusAdapter.h"
 #include <QDebug>
+#include <QDBusConnection>
+
 
 
 QStringList parseParameters(int argc, char *argv[]) {
@@ -79,8 +82,17 @@ int main(int argc, char *argv[]) {
 
     Backbone backbone;
     MainWindow w(&backbone);
+
+    DBusAdapter* adapter = new DBusAdapter(&w);
+
+    QDBusConnection::sessionBus().registerObject("/mainWindow",
+                                                 &w);
+    QDBusConnection::sessionBus().registerService("com.comarch.mdictionary");
+
+
     w.show();
 
+
     if(search.count() > 0) {
         w.setExactSearch(true);
         w.searchExact(search[0]);
index 0a9f174..96770eb 100644 (file)
@@ -2,25 +2,18 @@
 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
 <xsl:template match="/">
-       <html>
-           <head>
-               <link rel="stylesheet" type="text/css" href="mydata://style.css" />  
-           </head>
-             <body>
                 <table border="1" width="100%">
                    <xsl:for-each select="ar/dict"> 
                        <xsl:apply-templates/>
                    </xsl:for-each>
                 </table>
-             </body>
-       </html>
 </xsl:template> 
 
 <xsl:template match="info">
        <tr>
                <th class="info">               
                <xsl:if test="@bookmark = 'true'">
-                       <img src="mydata://image.png"/>   
+                       <img src="$STAR$" width="16" height="16"/>   
                </xsl:if>
                <xsl:value-of select="."/> <!-- <img src="{$path}"/> -->
                </th>
index 243b9b6..4f1dbbb 100644 (file)
@@ -1,7 +1,7 @@
 <RCC>
     <qresource prefix="/xsl">
-        <file>xsl.xsl</file>
         <file>style.css</file>
+        <file>xsl.xsl</file>
     </qresource>
     <qresource prefix="/config">
         <file>mdictionary.config</file>
diff --git a/trunk/src/desktopWidget/MainWidget.cpp b/trunk/src/desktopWidget/MainWidget.cpp
new file mode 100644 (file)
index 0000000..a4977a6
--- /dev/null
@@ -0,0 +1,158 @@
+/*******************************************************************************
+
+    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 "MainWidget.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <QtGui/QX11Info>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusPendingCall>
+#include <QList>
+#include <QDebug>
+
+
+HomeWidget::HomeWidget(QWidget *parent):
+    QWidget(parent)
+{
+    //setting application name, it will use it later to set home applet id
+    QCoreApplication::instance()->setApplicationName(
+            "mDictionary desktop widget");
+
+    //setting this attribute to get transparent backgorund
+    setAttribute(Qt::WA_TranslucentBackground);
+
+    initializeX11();
+
+    initializeUI();
+}
+
+
+void HomeWidget::initializeUI() {
+
+
+    horizontalLayout = new QHBoxLayout;
+    setLayout(horizontalLayout);
+
+
+    searchStringLineEdit = new QLineEdit;
+
+    searchButton = new QPushButton(tr("Search"));
+    searchButton->setMaximumHeight(60);
+
+    logo = new QToolButton();
+    logo->setIcon(QIcon(":/icons/64x64/mdictionary.png"));
+
+    horizontalLayout->addWidget(logo);
+    horizontalLayout->addWidget(searchStringLineEdit);
+    horizontalLayout->addWidget(searchButton);
+    horizontalLayout->setContentsMargins(10,10,10,10);
+
+    connect(searchStringLineEdit, SIGNAL(returnPressed()),
+            this, SLOT(search()));
+
+    connect(searchButton, SIGNAL(clicked()),
+            this, SLOT(search()));
+
+    connect(logo, SIGNAL(clicked()),
+            this, SLOT(logoClicked()));
+
+
+    setMinimumHeight(100);
+    setMaximumHeight(100);
+}
+
+void HomeWidget::initializeX11() {
+
+    Atom winTypeAtom = XInternAtom(QX11Info::display(),
+                                   "_NET_WM_WINDOW_TYPE",
+                                   false);
+
+    Atom homeAppletAtom = XInternAtom(QX11Info::display(),
+                                     "_HILDON_WM_WINDOW_TYPE_HOME_APPLET",
+                                     false);
+
+    Atom appletIDAtom = XInternAtom(QX11Info::display(),
+                                    "_HILDON_APPLET_ID",
+                                    false);
+
+    Atom utf8Atom = XInternAtom(QX11Info::display(),
+                                "UTF8_STRING",
+                                false);
+
+
+    // Set window type to home applet
+    XChangeProperty(QX11Info::display(), winId(), winTypeAtom,
+                    XA_ATOM, 32, PropModeReplace,
+                    (unsigned char *) &homeAppletAtom, 1);
+
+    // Applet id will be the same as application name
+    QByteArray id (
+            QCoreApplication::instance()->applicationName().remove(' ').toUtf8());
+
+
+    XChangeProperty(QX11Info::display(), winId(), appletIDAtom, utf8Atom, 8,
+                    PropModeReplace, (unsigned char *)id.constData(),
+                    id.length());
+}
+
+void HomeWidget::search() {
+    if(searchStringLineEdit->text().isEmpty()) return;
+
+    QDBusMessage message =
+            QDBusMessage::createMethodCall("com.comarch.mdictionary",
+                                           "/mainWindow",
+                                           "com.comarch.mdictionary",
+                                           "search");
+
+    QList<QVariant> args;
+    args.append(searchStringLineEdit->text());
+    message.setArguments(args);
+
+    QDBusConnection::sessionBus().send(message);
+}
+
+void HomeWidget::logoClicked() {
+    QDBusMessage message =
+            QDBusMessage::createMethodCall("com.comarch.mdictionary",
+                                           "/mainWindow",
+                                           "com.comarch.mdictionary",
+                                           "showApplication");
+    QDBusConnection::sessionBus().send(message);
+}
+
+
+
+void HomeWidget::paintEvent(QPaintEvent *event) {
+    //custom painting of rounded corners
+    QPainter p(this);
+    p.setBrush(QColor(0, 0, 0, 255));
+
+    p.setPen(Qt::NoPen);
+
+    p.drawRoundedRect(rect(), 25, 25);
+
+    p.end();
+
+    QWidget::paintEvent(event);
+}
diff --git a/trunk/src/desktopWidget/MainWidget.h b/trunk/src/desktopWidget/MainWidget.h
new file mode 100644 (file)
index 0000000..375951d
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+
+    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.
+
+*******************************************************************************/
+
+//! \file MainWidget.cpp
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+
+#ifndef MAINWIDGET_H
+#define MAINWIDGET_H
+
+#include <QWidget>
+#include <QtGui>
+#include <QtDBus/QDBusConnection>
+#include <QPushButton>
+
+//! Implements widget for maemo that allows user to quick search using mdictionary right of home screen.
+/*!
+  Shows tool button with logo of mDictionary which can start application.
+  In line edit user inputs word, and using button next to it or by pressing enter, widget start mDictionary already witch started search for given word.
+  If mDictionary is already running in background it will show the program.
+  */
+class HomeWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    HomeWidget(QWidget *parent = 0);
+
+private slots:
+    void search();
+    void logoClicked();
+
+protected:
+    /*! Reimplemented paintEvent to display rounded corners with transparency */
+    void paintEvent(QPaintEvent *);
+
+private:
+    /*! Initializes ui of widget*/
+    void initializeUI();
+
+    /*! Initializes X11 to set application type as home widget*/
+    void initializeX11();
+
+
+    QLineEdit* searchStringLineEdit;
+    QPushButton* searchButton;
+    QToolButton* logo;
+    QHBoxLayout* horizontalLayout;
+};
+
+#endif // MAINWIDGET_H
diff --git a/trunk/src/desktopWidget/desktopWidget.pro b/trunk/src/desktopWidget/desktopWidget.pro
new file mode 100644 (file)
index 0000000..6aed979
--- /dev/null
@@ -0,0 +1,43 @@
+# -------------------------------------------------
+# Project created by QtCreator 2010-08-03T08:54:27
+# -------------------------------------------------
+QT += core gui dbus
+
+TARGET = mdictionarywidget
+
+TEMPLATE = app
+
+MDICT_BINDIR = $$[MDICT_BINDIR]
+
+isEmpty(MDICT_BINDIR):MDICT_BINDIR = .
+
+DESTDIR = $${MDICT_BINDIR}
+
+
+unix {
+    # VARIABLES
+    isEmpty(PREFIX):PREFIX = /usr
+    BINDIR = $$PREFIX/bin
+    DATADIR = $$PREFIX/share
+    DEFINES += DATADIR=\\\"$$DATADIR\\\" \
+        PKGDATADIR=\\\"$$PKGDATADIR\\\"
+    
+    # MAKE INSTALL
+    INSTALLS += target \
+        desktop
+
+    target.path = /usr/lib/hildon-desktop
+
+    desktop.path = $$DATADIR/applications/hildon-home
+    desktop.files += ../../../data/other/$${TARGET}.desktop
+}
+
+SOURCES += \
+    main.cpp \
+    MainWidget.cpp
+
+HEADERS += \
+    MainWidget.h
+
+RESOURCES += \
+    ../../../data/icons/gui.qrc
diff --git a/trunk/src/desktopWidget/main.cpp b/trunk/src/desktopWidget/main.cpp
new file mode 100644 (file)
index 0000000..2f9b15d
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+
+    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 "MainWidget.h"
+#include <QtGui/QApplication>
+#include <X11/extensions/Xrender.h>
+
+
+int main(int argc, char *argv[]) {
+
+    Display *dpy = XOpenDisplay(0); // open default display
+    if (!dpy) {
+        qWarning("Cannot connect to the X server");
+        exit(1);
+    }
+
+    QApplication a(dpy, argc, argv);
+    QApplication::setOrganizationName("Comarch S.A.");
+    QApplication::setOrganizationDomain("comarch.com");
+    QApplication::setApplicationName("mDictionaryWidget");
+
+    HomeWidget w;
+
+    w.show();
+
+    return a.exec();
+}
index 0887429..cdadfe2 100644 (file)
@@ -46,6 +46,7 @@ GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,
         _langFrom=languages.key(pluginSettings->value("lang_from"));
     }
 
+    setMinimumHeight(370);
     #ifdef Q_WS_MAEMO_5
 
         changeLangButton=new QPushButton(
@@ -77,6 +78,7 @@ GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,
                    tr("To: ") + _langTo);
     verticalLayout->addWidget(infoLabel);
 
+
     langFromComboBox = new QComboBox;
     langToComboBox = new QComboBox;
 
@@ -93,12 +95,17 @@ GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,
     langToComboBox->setCurrentIndex(actualLangTo);
     langFromComboBox->setCurrentIndex(actualLangFrom);
 
+
+
     setWindowTitle(tr("Google Settings"));
     verticalLayout->addWidget(connectInfoLabel);
+
     langFromLayout->addWidget(langFromLabel);
     langFromLayout->addWidget(langFromComboBox);
     langToLayout->addWidget(langToLabel);
     langToLayout->addWidget(langToComboBox);
+
+
     langLayout->addLayout(langFromLayout);
     langLayout->addLayout(langToLayout);
     changelangLayout->addLayout(langLayout);
@@ -112,29 +119,37 @@ GoogleSettingsDialog::GoogleSettingsDialog(QWidget *parent,
 
     connect(saveButton, SIGNAL(clicked()),
             this, SLOT(accept()));
+
+
     connect(langFromComboBox, SIGNAL(activated(int)),
             this, SLOT(activatedFrom(int)));
     connect(langToComboBox, SIGNAL(activated(int)),
             this, SLOT(activatedTo(int)));
+
+
     connect(changeLangButton, SIGNAL(clicked()),
             this, SLOT(changeLangButtonClicked()));
 }
 
+
 void GoogleSettingsDialog::activatedFrom(int index) {
-    _langFrom=langFromComboBox->itemText(index);
+        _langFrom=langFromComboBox->itemText(index);
 }
 
 void GoogleSettingsDialog::activatedTo(int index) {
      _langTo=langToComboBox->itemText(index);
 }
 
+
 void GoogleSettingsDialog::changeLangButtonClicked() {
+
     int tempIndexTo=langToComboBox->currentIndex();
     QString tempLangTo=_langTo;
     langToComboBox->setCurrentIndex(langFromComboBox->currentIndex());
     langFromComboBox->setCurrentIndex(tempIndexTo);
     _langTo=_langFrom;
     _langFrom=tempLangTo;
+
 }
 
 QString GoogleSettingsDialog::langFrom() {
index 5e3d7c3..aa2cea7 100644 (file)
@@ -64,11 +64,12 @@ public:
     //! \return destination language code iso 639-2
     QString langTo();
 
-public slots:
+private slots:
     void activatedFrom(int);
     void activatedTo(int);
     void changeLangButtonClicked();
 
+
 private:
     QLabel* infoLabel;
     QLabel* langFromLabel;
@@ -76,6 +77,8 @@ private:
     QLabel* connectInfoLabel;
     QPushButton* saveButton;
     QPushButton* changeLangButton;
+
+
     QComboBox *langFromComboBox;
     QComboBox *langToComboBox;
 
index 8d862e0..122e377 100644 (file)
@@ -5,7 +5,7 @@
 #-------------------------------------------------
 
 QT       += core xml gui network
-
+maemo5:QT += maemo5
 
 TARGET = GooglePlugin
 TEMPLATE = lib
index 99f6759..4bb5282 100644 (file)
 
 XdxfLoadDialog::XdxfLoadDialog(QWidget *parent) :
     QDialog(parent) {
-    verticalLayout = new QVBoxLayout(this);
+    verticalLayout = new QVBoxLayout;
     setLayout(verticalLayout);
 
     setWindowTitle(tr("Add new XDXF dictionary"));
 
-    browseLayout = new QHBoxLayout(this);
-    verticalLayout->addLayout(browseLayout);
+    browseLayout = new QVBoxLayout;
 
-    browseButton =  new QPushButton(tr("Browse"),this);
-    browseLabel = new QLabel(tr("Dictionary file: not selected"),this);
+    browseButton =  new QPushButton(tr("Browse"));
+    browseLabel = new QLabel(tr("Dictionary file: not selected"));
+    //browseLabel->setWordWrap(true);
+    browseLabel->setMargin(5);
 
-    browseLayout->addWidget(browseLabel);
-    browseLayout->addWidget(browseButton,0, Qt::AlignRight);
+    browseLayout->addWidget(browseLabel, 0, Qt::AlignLeft);
+    browseLayout->addWidget(browseButton);
 
+    verticalLayout->addLayout(browseLayout);
 
-    cacheLayout = new QHBoxLayout(this);
+    cacheLayout = new QHBoxLayout;
     verticalLayout->addLayout(cacheLayout);
     accentsCheckBox = new QCheckBox(tr("Strip accents \n(searching takes more time, "
                  "but spelling don't have to be exact)"));
@@ -52,7 +54,7 @@ XdxfLoadDialog::XdxfLoadDialog(QWidget *parent) :
     cacheCheckBox->setChecked(true);
     cacheLayout->addWidget(cacheCheckBox);
 
-    addButton = new QPushButton(tr("Add"),this);
+    addButton = new QPushButton(tr("Add"));
 
     verticalLayout->addWidget(addButton);
 
@@ -74,10 +76,13 @@ void XdxfLoadDialog::selectFile() {
                                      tr("XDXF Files (*.xdxf)"),
                                      NULL,
                                      NULL);
+
     if (!fileName.isEmpty()) {
-        browseLabel->setText(tr("Dictionary file: ") + fileName);
+        qDebug()<<fileName;
+        browseLabel->setText(tr("Dictionary file: %1").arg(fileName));
         _dicitonaryFilePath = fileName;
-    }
+    }repaint(rect());
+    resize(size());
 }
 
 void XdxfLoadDialog::addDictionary() {
index 58a3bd2..de2750f 100644 (file)
@@ -62,7 +62,7 @@ private:
     QCheckBox* cacheCheckBox;
     QCheckBox* accentsCheckBox;
     QVBoxLayout* verticalLayout;
-    QHBoxLayout* browseLayout;
+    QVBoxLayout* browseLayout;
     QHBoxLayout* cacheLayout;
     QString _dicitonaryFilePath;
     bool _generateCache;
index 25f3dfd..e2e1358 100644 (file)
@@ -1,5 +1,5 @@
 TEMPLATE=subdirs
-SUBDIRS = plugins base
+SUBDIRS = plugins base desktopWidget
 
 check.target = check
 check.CONFIG = recursive