From: mateusz Date: Wed, 4 Aug 2010 09:47:34 +0000 (+0200) Subject: Added custom menu widget X-Git-Tag: 0.4~114^2~3^2 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=e276cb11bf7211649666708859c3660ba3e174db;p=mdictionary Added custom menu widget --- diff --git a/debian/mDictionary/usr/bin/mDictionary b/debian/mDictionary/usr/bin/mDictionary deleted file mode 100755 index 400c3dc..0000000 Binary files a/debian/mDictionary/usr/bin/mDictionary and /dev/null differ diff --git a/debian/mDictionary/usr/bin/mdictionary b/debian/mDictionary/usr/bin/mdictionary deleted file mode 100755 index 400c3dc..0000000 Binary files a/debian/mDictionary/usr/bin/mdictionary and /dev/null differ diff --git a/debian/mDictionary/usr/share/applications/hildon/mDictionary.desktop b/debian/mDictionary/usr/share/applications/hildon/mDictionary.desktop deleted file mode 100644 index 4771e34..0000000 --- a/debian/mDictionary/usr/share/applications/hildon/mDictionary.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Categories=Office -Name=mDictionary -Icon = mdictonary -Exec=/usr/bin/mdictionary -X-Maemo-Category = Main - diff --git a/debian/mDictionary/usr/share/applications/hildon/mdictionary.desktop b/debian/mDictionary/usr/share/applications/hildon/mdictionary.desktop deleted file mode 100644 index 4771e34..0000000 --- a/debian/mDictionary/usr/share/applications/hildon/mdictionary.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Categories=Office -Name=mDictionary -Icon = mdictonary -Exec=/usr/bin/mdictionary -X-Maemo-Category = Main - diff --git a/debian/mDictionary/usr/share/icons/hicolor/64x64/apps/mDictionary.png b/debian/mDictionary/usr/share/icons/hicolor/64x64/apps/mDictionary.png deleted file mode 100644 index 241ca6d..0000000 Binary files a/debian/mDictionary/usr/share/icons/hicolor/64x64/apps/mDictionary.png and /dev/null differ diff --git a/debian/mDictionary/usr/share/icons/hicolor/64x64/apps/mdictionary.png b/debian/mDictionary/usr/share/icons/hicolor/64x64/apps/mdictionary.png deleted file mode 100644 index 241ca6d..0000000 Binary files a/debian/mDictionary/usr/share/icons/hicolor/64x64/apps/mdictionary.png and /dev/null differ diff --git a/debian/mdictionary/DEBIAN/control b/debian/mdictionary/DEBIAN/control deleted file mode 100644 index d7bda3d..0000000 --- a/debian/mdictionary/DEBIAN/control +++ /dev/null @@ -1,10 +0,0 @@ -Package: mdictionary -Version: 1.0.0-2 -Architecture: i386 -Maintainer: Mateusz Polrola -Installed-Size: 128 -Depends: libc6 (>= 2.5.0-1), libgcc1 (>= 1:4.2.1), libqt4-core (>= 4.6.2~git20100401), libqt4-gui (>= 4.6.2~git20100401), libstdc++6 (>= 4.2.1) -Section: user/multimedia -Priority: optional -Description: Multilanguage dictionary - Long desc diff --git a/debian/mdictionary/DEBIAN/md5sums b/debian/mdictionary/DEBIAN/md5sums deleted file mode 100644 index db9e51c..0000000 --- a/debian/mdictionary/DEBIAN/md5sums +++ /dev/null @@ -1,6 +0,0 @@ -d45ee4b6faabfa5b22950fc2ac5390a2 usr/share/doc/mdictionary/README.Debian -149c5fa98facd4cc7d708c96c11fe028 usr/share/doc/mdictionary/copyright -d985aecef87f4ab660ca2d5396aac6ff usr/share/doc/mdictionary/changelog.Debian.gz -35612a2bf496e172d7abcf76c0d8b47b usr/share/applications/hildon/mdictionary.desktop -30a33a60d95c3518fce3cf69a7bfc288 usr/share/icons/hicolor/64x64/apps/mdictionary.png -c125649ba95d59ea878802095c178213 usr/bin/mdictionary diff --git a/debian/mdictionary/usr/bin/mdictionary b/debian/mdictionary/usr/bin/mdictionary deleted file mode 100755 index 6445d73..0000000 Binary files a/debian/mdictionary/usr/bin/mdictionary and /dev/null differ diff --git a/debian/mdictionary/usr/share/applications/hildon/mdictionary.desktop b/debian/mdictionary/usr/share/applications/hildon/mdictionary.desktop deleted file mode 100644 index c6131cf..0000000 --- a/debian/mdictionary/usr/share/applications/hildon/mdictionary.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Categories=Office -Name=mDictionary -Icon=mdictonary -Exec=/usr/bin/mdictionary -X-Maemo-Category=Main - diff --git a/debian/mdictionary/usr/share/doc/mdictionary/README.Debian b/debian/mdictionary/usr/share/doc/mdictionary/README.Debian deleted file mode 100644 index cac9e94..0000000 --- a/debian/mdictionary/usr/share/doc/mdictionary/README.Debian +++ /dev/null @@ -1,6 +0,0 @@ -mdictionary for Debian ----------------------- - - - - -- Mateusz Polrola , Tue, 3 Aug 2010 13:44:27 +0200 diff --git a/debian/mdictionary/usr/share/doc/mdictionary/changelog.Debian.gz b/debian/mdictionary/usr/share/doc/mdictionary/changelog.Debian.gz deleted file mode 100644 index 60acc07..0000000 Binary files a/debian/mdictionary/usr/share/doc/mdictionary/changelog.Debian.gz and /dev/null differ diff --git a/debian/mdictionary/usr/share/doc/mdictionary/copyright b/debian/mdictionary/usr/share/doc/mdictionary/copyright deleted file mode 100644 index 0d60794..0000000 --- a/debian/mdictionary/usr/share/doc/mdictionary/copyright +++ /dev/null @@ -1,28 +0,0 @@ -This package was debianized by Mateusz Polrola on -Tue, 3 Aug 2010 13:44:27 +0200. - -It was downloaded from - -Copyright: - -Upstream Author(s): - -License: - - This package 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; version 2 dated June, 1991. - - This package 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 this package; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - -On Debian systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL'. - diff --git a/debian/mdictionary/usr/share/icons/hicolor/64x64/apps/mdictionary.png b/debian/mdictionary/usr/share/icons/hicolor/64x64/apps/mdictionary.png deleted file mode 100644 index 241ca6d..0000000 Binary files a/debian/mdictionary/usr/share/icons/hicolor/64x64/apps/mdictionary.png and /dev/null differ diff --git a/trunk/src/base/base.pro b/trunk/src/base/base.pro index 6a7de25..e5c069f 100644 --- a/trunk/src/base/base.pro +++ b/trunk/src/base/base.pro @@ -15,7 +15,9 @@ SOURCES += gui/main.cpp\ gui/SearchBarWidget.cpp \ gui/WordListWidget.cpp \ gui/TranslationWidget.cpp \ - backbone/backbone.cpp + backbone/backbone.cpp \ + gui/MenuWidget.cpp \ + gui/MenuTabWidget.cpp HEADERS += gui/MainWindow.h \ gui/SearchBarWidget.h \ @@ -24,7 +26,9 @@ HEADERS += gui/MainWindow.h \ backbone/backbone.h \ ../includes/translation.h \ ../includes/settings.h \ - ../includes/CommonDictInterface.h + ../includes/CommonDictInterface.h \ + gui/MenuWidget.h \ + gui/MenuTabWidget.h FORMS += gui/MainWindow.ui diff --git a/trunk/src/base/gui/MainWindow.cpp b/trunk/src/base/gui/MainWindow.cpp index 632c27b..6c2d121 100644 --- a/trunk/src/base/gui/MainWindow.cpp +++ b/trunk/src/base/gui/MainWindow.cpp @@ -1,3 +1,26 @@ +/******************************************************************************* + + 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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +//Created by Mateusz Półrola + #include "MainWindow.h" #include "ui_MainWindow.h" @@ -13,6 +36,15 @@ MainWindow::MainWindow(Backbone *backbone, QWidget *parent): searchBarWidget = new SearchBarWidget(backbone); wordListWidget = new WordListWidget(backbone); translationWidget = new TranslationWidget(backbone, this); + menuWidget = new MenuWidget(this); + + + menuWidget->addSubMenu(tr("Dictionaries"), new QPushButton("Dictionaries")); + menuWidget->addSubMenu(tr("Settings"), new QPushButton("Settings")); + menuWidget->addSubMenu(tr("About"), new QPushButton("About")); + + ui->menuBar->addAction(menuWidget); + connect(wordListWidget, SIGNAL(clicked(QModelIndex)), translationWidget, SLOT(show(QModelIndex))); diff --git a/trunk/src/base/gui/MainWindow.h b/trunk/src/base/gui/MainWindow.h index 7cf7522..f32effe 100644 --- a/trunk/src/base/gui/MainWindow.h +++ b/trunk/src/base/gui/MainWindow.h @@ -1,3 +1,26 @@ +/******************************************************************************* + + 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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +//Created by Mateusz Półrola + #ifndef MAINWINDOW_H #define MAINWINDOW_H @@ -6,6 +29,7 @@ #include "TranslationWidget.h" #include "WordListWidget.h" #include "SearchBarWidget.h" +#include "MenuWidget.h" namespace Ui { class MainWindow; @@ -20,22 +44,27 @@ public: ~MainWindow(); public Q_SLOTS: + //! Confirmation from backbone that we can close program void closeOk(); Q_SIGNALS: + //! Request to backbone to stop all it's activities void quit(); protected: + /*! When user wants to close application, we first sends signal to stop all + ongoing searches. + */ void closeEvent(QCloseEvent *); - private: Backbone* backbone; Ui::MainWindow *ui; SearchBarWidget* searchBarWidget; TranslationWidget* translationWidget; WordListWidget* wordListWidget; + MenuWidget* menuWidget; }; #endif // MAINWINDOW_H diff --git a/trunk/src/base/gui/MenuTabWidget.cpp b/trunk/src/base/gui/MenuTabWidget.cpp new file mode 100644 index 0000000..9432d38 --- /dev/null +++ b/trunk/src/base/gui/MenuTabWidget.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* + + 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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +//Created by Mateusz Półrola + +#include "MenuTabWidget.h" +#include + +MenuTabWidget::MenuTabWidget(QWidget *parent) : + QTabWidget(parent) { +} + +void MenuTabWidget::hideEvent(QHideEvent *) { + //just set parent to null, and allow event to by handled by default handler + setParent(NULL); + } diff --git a/trunk/src/base/gui/MenuTabWidget.h b/trunk/src/base/gui/MenuTabWidget.h new file mode 100644 index 0000000..7cfc203 --- /dev/null +++ b/trunk/src/base/gui/MenuTabWidget.h @@ -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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +//Created by Mateusz Półrola + +#ifndef MENUTABWIDGET_H +#define MENUTABWIDGET_H +#include + +/*! + Menu's main widget, which will hold all submenu's widgets. + It is simply QTabWidget, with changed hideEvent function. +*/ +class MenuTabWidget : public QTabWidget { + Q_OBJECT +public: + explicit MenuTabWidget(QWidget *parent = 0); + +protected: + /*! + Reimplemented default hideEvent function. + Right before hide widget it sets it's parent to NULL, which prevent + widget to be deleted by menu bar. + */ + void hideEvent(QHideEvent *); +}; + +#endif // MENUTABWIDGET_H diff --git a/trunk/src/base/gui/MenuWidget.cpp b/trunk/src/base/gui/MenuWidget.cpp new file mode 100644 index 0000000..f80e3fa --- /dev/null +++ b/trunk/src/base/gui/MenuWidget.cpp @@ -0,0 +1,60 @@ +/******************************************************************************* + + 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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +//Created by Mateusz Półrola + +#include "MenuWidget.h" +#include + +MenuWidget::MenuWidget(QWidget *parent) : + QWidgetAction(parent) { + + //creating custom tab widget, and sets style sheet to have centered tabs + tabWidget = new MenuTabWidget(); + tabWidget->setStyleSheet("QTabWidget::tab-bar {alignment: center;}"); +} + +MenuWidget::~MenuWidget() { + //because tabWidget have no parent we must destroy it + delete tabWidget; +} + +void MenuWidget::addSubMenu(QString title, QWidget *widget) { + tabWidget->addTab(widget, title); +} + + +void MenuWidget::removeSubMenu(QString title) { + for(int i = 0; i < tabWidget->count(); i++) { + if(tabWidget->tabText(i) == title) { + tabWidget->removeTab(i); + break; + } + } +} + +QWidget* MenuWidget::createWidget(QWidget *) { + /*When we have request to create new widget we returns tabWidget. + When the menu is closing, tabWidget will receive hideEvent which will set + it parent to NULL and prevent it from delete, so we can still use this + widget*/ + return tabWidget; +} diff --git a/trunk/src/base/gui/MenuWidget.h b/trunk/src/base/gui/MenuWidget.h new file mode 100644 index 0000000..ccab0aa --- /dev/null +++ b/trunk/src/base/gui/MenuWidget.h @@ -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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +//Created by Mateusz Półrola + +#ifndef MENUWIDGET_H +#define MENUWIDGET_H + +#include +#include "MenuTabWidget.h" + +/*! Displays custom menu with tab widget containing all submenus. + Each submenu is simply QWidget. +*/ +class MenuWidget : public QWidgetAction { + Q_OBJECT +public: + explicit MenuWidget(QWidget *parent = 0); + virtual ~MenuWidget(); + + /*! + Add new submenu to menu. It is possible to have many submenus with the + same title. + \param title Name of new submenu which will be displayed in submenu tab. + \param widget Widget of the submenu. + */ + void addSubMenu(QString title, QWidget* widget); + + /*! + Remove submenu from menu. It will remove first menu with passed title. + /param title Name of submeny which will be removed. + */ + void removeSubMenu(QString title); + +protected: + MenuTabWidget* tabWidget; + QWidget* createWidget(QWidget *parent); +}; + +#endif // MENUWIDGET_H diff --git a/trunk/src/base/gui/SearchBarWidget.cpp b/trunk/src/base/gui/SearchBarWidget.cpp index ecd9e86..374e22a 100644 --- a/trunk/src/base/gui/SearchBarWidget.cpp +++ b/trunk/src/base/gui/SearchBarWidget.cpp @@ -54,6 +54,7 @@ SearchBarWidget::SearchBarWidget(Backbone* backbone, QWidget *parent) : this, SLOT(clearSearchWordToolButtonClicked())); + //connects request to backbone connect(this, SIGNAL(searchForTranslations(QString)), backbone, SLOT(search(QString))); @@ -116,6 +117,8 @@ void SearchBarWidget::initializeUI() { searchingProgressBar = new QProgressBar(); + //progress bar have minimum and maximum values set to 0, which will effect + //with "I'm alive" bar searchingProgressBar->setMinimum(0); searchingProgressBar->setMaximum(0); searchingProgressBar->hide(); diff --git a/trunk/src/base/gui/SearchBarWidget.h b/trunk/src/base/gui/SearchBarWidget.h index 548d966..1c71672 100644 --- a/trunk/src/base/gui/SearchBarWidget.h +++ b/trunk/src/base/gui/SearchBarWidget.h @@ -32,8 +32,8 @@ //! Displays search bar /*! - Contains line edit field to input word which user would to find, and buttons - to browse search history. + Contains line edit field to input word which user would like to find + and buttons to browse search history. */ class SearchBarWidget : public QWidget { Q_OBJECT diff --git a/trunk/src/base/gui/TranslationWidget.cpp b/trunk/src/base/gui/TranslationWidget.cpp index e4e68bd..711f677 100644 --- a/trunk/src/base/gui/TranslationWidget.cpp +++ b/trunk/src/base/gui/TranslationWidget.cpp @@ -35,10 +35,9 @@ TranslationWidget::TranslationWidget(Backbone *backbone, QWidget *parent): initializeUI(); } -void TranslationWidget::show(QModelIndex index) { +void TranslationWidget::show(QModelIndex ) { QWidget::show(); - qDebug()<data(index); } void TranslationWidget::initializeUI() { diff --git a/trunk/src/base/gui/TranslationWidget.h b/trunk/src/base/gui/TranslationWidget.h index febedc1..721f702 100644 --- a/trunk/src/base/gui/TranslationWidget.h +++ b/trunk/src/base/gui/TranslationWidget.h @@ -29,6 +29,10 @@ #include #include "../backbone/backbone.h" +//! Displays translation of word found in dictionaries +/*! + Display many translation of word, formatted as html. +*/ class TranslationWidget : public QWidget { Q_OBJECT public: @@ -37,6 +41,7 @@ public: Q_SIGNALS: public Q_SLOTS: + //! Request to show translation of word passed as QModelIndex from word list void show(QModelIndex); private: @@ -44,7 +49,6 @@ private: QTextEdit* translationTextEdit; QVBoxLayout* verticalLayout; - void initializeUI(); }; diff --git a/trunk/src/base/gui/WordListWidget.cpp b/trunk/src/base/gui/WordListWidget.cpp index 7b0a79e..24f1706 100644 --- a/trunk/src/base/gui/WordListWidget.cpp +++ b/trunk/src/base/gui/WordListWidget.cpp @@ -32,8 +32,6 @@ WordListWidget::WordListWidget(Backbone *backbone, QWidget *parent): wordListModel = new QStringListModel(); setModel(wordListModel); - - setAttribute(Qt::WA_Maemo5StackedWindow); } void WordListWidget::addWord(QString word) { diff --git a/trunk/src/base/gui/WordListWidget.h b/trunk/src/base/gui/WordListWidget.h index 0f2a6a8..430e698 100644 --- a/trunk/src/base/gui/WordListWidget.h +++ b/trunk/src/base/gui/WordListWidget.h @@ -30,6 +30,10 @@ #include "../backbone/backbone.h" +//! Displays list of words found in dictionaries +/*! + It allow user to select word to see it's translation or to mark it as "star" + */ class WordListWidget : public QListView { Q_OBJECT public: @@ -37,12 +41,16 @@ public: public Q_SLOTS: + /*! Request to show search results, requested by backbone when it finished + search*/ void showSearchResults(); private: Backbone *backbone; + //words are keeping as QStringListModel which allow to sort them QStringListModel *wordListModel; void addWord(QString word); + //clears all list of words void clear(); }; diff --git a/trunk/src/base/gui/main.cpp b/trunk/src/base/gui/main.cpp index 3928783..892893d 100644 --- a/trunk/src/base/gui/main.cpp +++ b/trunk/src/base/gui/main.cpp @@ -1,3 +1,26 @@ +/******************************************************************************* + + 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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +//Created by Mateusz Półrola + #include #include "MainWindow.h" #include "../backbone/backbone.h" diff --git a/trunk/src/base/mDictionary b/trunk/src/base/mDictionary deleted file mode 100755 index 60e7d43..0000000 Binary files a/trunk/src/base/mDictionary and /dev/null differ