Rest of refactorization
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Thu, 2 Sep 2010 07:30:12 +0000 (09:30 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Thu, 2 Sep 2010 07:30:12 +0000 (09:30 +0200)
trunk/src/base/gui/AboutWidget.cpp
trunk/src/base/gui/BookmarksWidget.h
trunk/src/base/gui/DBusAdapter.h
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/DictManagerWidget.h
trunk/src/base/gui/DictTypeSelectDialog.h
trunk/src/base/gui/MainWindow.cpp
trunk/src/base/gui/TranslationWidget.cpp
trunk/src/base/gui/TranslationWidget.h
trunk/src/base/gui/main.cpp

index 03bbf6c..edc52e0 100644 (file)
@@ -30,20 +30,28 @@ AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent)
     infoNote = "<center><h2><u>mDictionary</u></h2></center>";
     comarchNote = "<center>Meamo/Meego Multilingual Dictionary</center>";
     comarchNote += "<center>Copyright 2006-2010, Comarch S.A. <br>";
-    comarchNote += "<a href=\"http://mdictionary.garage.maemo.org\">http://mdictionary.garage.maemo.org</a></center>";
-    licenseNote = QString("<br><p><font size=\"small\">This program is free software: you can redistribute it and/or modify\n")+
-                  QString("it under the terms of the GNU General Public License as published by\n")+
-                  QString("the Free Software Foundation, either version 3 of the License, or\n")+
-                  QString("(at your option) any later version.<br>")+
-                  QString("This program is distributed in the hope that it will be useful,\n")+
-                  QString("but WITHOUT ANY WARRANTY; without even the implied warranty of\n")+
-                  QString("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n")+
-                  QString("GNU General Public License for more details.<br>") +
-                  QString("You should have received a copy of the GNU General Public License<br>") +
-                  QString("along with this program.  If not, see") +
-                  QString("&lt;<a href=\"http://www.gnu.org/licenses/\">") +
-                  QString("http://www.gnu.org/licenses/</a>&gt;.") +
-                  QString("</p></font>");
+    comarchNote += "<a href=\"http://mdictionary.garage.maemo.org\">"
+                   "http://mdictionary.garage.maemo.org</a></center>";
+    licenseNote = QString("<br><p><font size=\"small\">This program is free"
+                  "software: you can redistribute it and/or modify\n"
+                  "it under the terms of the GNU General Public License as"
+                  "published by\n"
+                  "the Free Software Foundation, either version 3 of the License,"
+                  "or\n"
+                  "(at your option) any later version.<br>"
+                  "This program is distributed in the hope that it will be"
+                  "useful,\n"
+                  "but WITHOUT ANY WARRANTY; without even the implied warranty"
+                  "of\n"
+                  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
+                  "See the\n"
+                  "GNU General Public License for more details.<br>"
+                  "You should have received a copy of the GNU General Public "
+                  "License<br>"
+                  "along with this program.  If not, see"
+                  "&lt;<a href=\"http://www.gnu.org/licenses/\">"
+                  "http://www.gnu.org/licenses/</a>&gt;."
+                  "</p></font>");
 
     setWindowTitle(tr("About"));
     mainLayout = new QVBoxLayout;
index 623e89f..65ffb7c 100644 (file)
@@ -32,7 +32,7 @@
 //! Implements bookmarks management widget
 /*!
   Allows user to show all or remove all bookmarks
-  */
+*/
 class BookmarksWidget : public QDialog
 {
     Q_OBJECT
index 0680c8c..e9ed118 100644 (file)
 #include <QDBusAbstractAdaptor>
 #include "MainWindow.h"
 
+/*!
+    Implements dbus adapter which defines dbus interface for application.
+    Other application can use this interface to call mdictionary methods.
+*/
 class DBusAdapter : public QDBusAbstractAdaptor
 {
     Q_OBJECT
@@ -36,7 +40,11 @@ public:
     explicit DBusAdapter(MainWindow* w);
 
 public slots:
-    void search(QString);
+    //! Search for given word
+    void search(QString word);
+
+    //! Shows application in foreground, can be used to trun on mdictionary
+    //! by another application
     void showApplication();
 
 private:
index 4157889..a070d9c 100644 (file)
 
 DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
     QDialog(parent) {
-
-
-
     setWindowTitle(tr("Dictionaries"));
     this->guiInterface = parent;
 
+    initalizeUI();
+}
+
+void DictManagerWidget::initalizeUI() {
     verticalLayout = new QVBoxLayout;
     setLayout(verticalLayout);
 
@@ -135,11 +136,12 @@ void DictManagerWidget::showEvent(QShowEvent *e) {
 void DictManagerWidget::saveChanges() {
 
     #ifndef Q_WS_MAEMO_5
-    if(_save) {
+        if(_save) {
     #else
-    if(_changed &&
-            QMessageBox::question(this, tr("Save"), tr("Do you want to save changes?"),
-            QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
+        if(_changed &&
+                QMessageBox::question(this, tr("Save"),
+                                      tr("Do you want to save changes?"),
+                QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
     #endif
         QList<CommonDictInterface*> checkedDicts;
 
@@ -154,8 +156,7 @@ void DictManagerWidget::saveChanges() {
     }
 }
 
-void DictManagerWidget::hideEvent(QHideEvent *e)
-{
+void DictManagerWidget::hideEvent(QHideEvent *e) {
     saveChanges();
     QWidget::hideEvent(e);
 }
@@ -192,10 +193,10 @@ void DictManagerWidget::itemSelected(QListWidgetItem *) {
 }
 
 void DictManagerWidget::removeButtonClicked() {
-    qDebug()<<dictsHash.count();
     if(QMessageBox::question(this, tr("Remove dictionary"),
             tr("Do you want to remove selected dictionary?"),
-            QMessageBox::Yes, QMessageBox::Cancel) == QMessageBox::Yes) {
+            QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
+
         QList<QListWidgetItem*> selected = dictListWidget->selectedItems();
         if(selected.count() > 0) {
             emit removeDictionary(dictsHash[selected[0]]);
index fc7daf4..07cb16a 100644 (file)
@@ -36,7 +36,7 @@
   It allows to change dicts states, add new dict, remove selected one or
   change settings of selected dict. All changes are saved automatically after
   hiding of this widget.
-  */
+*/
 class DictManagerWidget : public QDialog {
     Q_OBJECT
 public:
@@ -45,7 +45,7 @@ public:
       \param parent parent of this widget, which must be subclass of
       GUIInterface, because it will use it to get info about loaded plugins
       and dicts.
-      */
+    */
     explicit DictManagerWidget(GUIInterface *parent = 0);
 
 protected:
@@ -54,43 +54,58 @@ protected:
 
 Q_SIGNALS:
     //! Emitted when hiding widget, it will save states of dictionaries
-    /*! \param list of only active dictionaries
-      */
+    /*!
+        \param list of only active dictionaries
+    */
     void selectedDictionaries(QList<CommonDictInterface*>);
 
     //! Emitted when user wants to add new dictionary
-    /*! \param new dictionary returned by specific plugin dialog
-      */
+    /*!
+        \param new dictionary returned by specific plugin dialog
+    */
     void addDictionary(CommonDictInterface*);
 
     //! Emitted when user wants to remove dictionary
-    /*! \param dictionary which will be removed
-      */
+    /*!
+        \param dictionary which will be removed
+    */
     void removeDictionary(CommonDictInterface*);
 
 
+public Q_SLOTS:
+    #ifndef Q_WS_MAEMO_5
+        void save();
+    #endif
 
 private Q_SLOTS:
-    /*! Shows plugin select dialog and then specific plugin add new dictionary
+    /*!
+        Shows plugin select dialog and then specific plugin add new dictionary
         dialog, which will return new CommonDictInterface* object, which is
-        later passed as parameter of addDictionary signal*/
+        later passed as parameter of addDictionary signal
+    */
     void addNewDictButtonClicked();
 
-    /*! Passes selected dictionary from list as parameter of removeDictionary
-        signal */
+    /*!
+        Passes selected dictionary from list as parameter of removeDictionary
+        signal
+    */
     void removeButtonClicked();
+
+    //! user select one of items
     void itemSelected(QListWidgetItem*);
 
-    /*! Shows plugin's settings dialog*/
+    //! Shows plugin's settings dialog
     void settingsButtonClicked();
 
-    //! Each change of state (that needs to be saved) should call this to indicate state change
+    //! Each change of state (that needs to be saved) should call this to
+    //! indicate state change
     void changed();
 
     //! saves changes
     void saveChanges();
 
 private:
+    void initalizeUI();
     QPushButton* addNewDictButton;
     QPushButton* removeDictButton;
     QPushButton* settingsButton;
@@ -102,15 +117,14 @@ private:
     //holds association between items on list and CommonDictInterface objects
     QHash<QListWidgetItem*, CommonDictInterface*> dictsHash;
     GUIInterface* guiInterface;
+
     bool _changed;
 
     void refreshDictsList();
+
     #ifndef Q_WS_MAEMO_5
         QPushButton* closeButton;
         bool _save;
-
-        public Q_SLOTS:
-            void save();
     #endif
 };
 
index d953aff..5fb53fd 100644 (file)
@@ -36,7 +36,7 @@
 /*!
   Shows list of loaded dictionaries plugins.
   Static function addNewdict will return selected plugin.
-  */
+*/
 class DictTypeSelectDialog : public QDialog {
     Q_OBJECT
 public:    
index 6a592f5..d07553a 100644 (file)
@@ -208,7 +208,6 @@ void MainWindow::wordListReady() {
         if(isInExactSearch()) {
             QList<Translation*> exactTranslation;
             if(checkExactSearch(searchResult, exactTranslation)) {
-                qDebug()<<exactTranslation.count();
                 Q_EMIT searchTranslations(exactTranslation);
             }
             else {
index 064789d..5cea174 100644 (file)
@@ -68,8 +68,9 @@ void TranslationWidget::show(QStringList translations) {
         if(!buttonsInitialized)
             initButtons();
     #endif
-    webkit->repaint(this->rect());
-    update(this->rect());
+
+   // webkit->repaint(this->rect());
+   // update(this->rect());
 
     QString trans;
     QString t;
@@ -95,10 +96,10 @@ void TranslationWidget::show(QStringList translations) {
     webkit->setHtml(trans, QUrl().fromLocalFile("/"));
 
 
-    webkit->repaint(this->rect());
-    update(this->rect());
+    //webkit->repaint(this->rect());
+    //update(this->rect());
 
-    Q_EMIT updateSize();
+  //  Q_EMIT updateSize();
 }
 
 QString TranslationWidget::XslConversion(QString translation)
@@ -120,7 +121,8 @@ void TranslationWidget::initButtons() {
 
         showButtonsButton->move(QPoint(x,y));
         showButtonsButton->show();
-//==================================================================
+
+
 
         x = width() - zoomOutButton->sizeHint().width();
         y = height() - 2*zoomOutButton->sizeHint().height();
@@ -133,7 +135,9 @@ void TranslationWidget::initButtons() {
         zoomOutButtonAnimation->setEndValue(QPoint(x,y));
         zoomOutButtonAnimation->setDuration(200);
         zoomOutButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
-//==================================================================
+
+
+
         x = width() - zoomInButton->sizeHint().width();
         y = height() - 3*zoomInButton->sizeHint().height();
         zoomInButton->move(QPoint(x, height()));
@@ -145,7 +149,9 @@ void TranslationWidget::initButtons() {
         zoomInButtonAnimation->setEndValue(QPoint(x,y));
         zoomInButtonAnimation->setDuration(400);
         zoomInButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
-//==================================================================
+
+
+
         x = 0;
         y = height() - copyButton->sizeHint().height();
 
@@ -158,7 +164,9 @@ void TranslationWidget::initButtons() {
         copyButtonAnimation->setEndValue(QPoint(x,y));
         copyButtonAnimation->setDuration(200);
         copyButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
-//==================================================================
+
+
+
         x = 0;
         y = height() - 2*copyButton->sizeHint().height();
 
@@ -171,7 +179,9 @@ void TranslationWidget::initButtons() {
         selectAllButtonAnimation->setEndValue(QPoint(x,y));
         selectAllButtonAnimation->setDuration(400);
         selectAllButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
-//==================================================================
+
+
+
         x = 0;
         y = height() - 3*copyButton->sizeHint().height();
 
@@ -184,7 +194,9 @@ void TranslationWidget::initButtons() {
         searchButtonAnimation->setEndValue(QPoint(x,y));
         searchButtonAnimation->setDuration(600);
         searchButtonAnimation->setEasingCurve(QEasingCurve::InOutBack);
-//==================================================================
+
+
+
 
         buttonsAnimation = new QParallelAnimationGroup(this);
         buttonsAnimation->addAnimation(zoomInButtonAnimation);
index 12d4089..4a9ed65 100644 (file)
@@ -44,8 +44,6 @@ public:
     explicit TranslationWidget(QWidget *parent = 0);
 
 Q_SIGNALS:
-    void updateSize();
-
     void search(QString);
 
 public Q_SLOTS:
@@ -76,6 +74,7 @@ private:
     QToolButton* zoomOutToolButton;
     TranslationTextEdit *webkit;
     QString xslt;
+
     #ifdef Q_WS_MAEMO_5
         QToolButton* zoomInButton;
         QToolButton* zoomOutButton;
@@ -97,6 +96,7 @@ private:
 
         void grabZoomKeys(bool);
     #endif
+
     QVBoxLayout *verticalLayout;
     QHBoxLayout* horizontalLayout;
     GUIInterface* guiinterface;
index 531258c..b51e326 100644 (file)
@@ -73,7 +73,6 @@ int main(int argc, char *argv[]) {
     qtTranslator.load("qt_" + QLocale::system().name(),
     QLibraryInfo::location(QLibraryInfo::TranslationsPath));
 
-    qDebug()<<QLibraryInfo::location(QLibraryInfo::TranslationsPath);
     a.installTranslator(&qtTranslator);
 
     QTranslator myTranslator;