projects
/
mdictionary
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'qml' of ssh://drop.maemo.org/git/mdictionary into qml
[mdictionary]
/
src
/
mdictionary
/
gui
/
MainWindow.cpp
diff --git
a/src/mdictionary/gui/MainWindow.cpp
b/src/mdictionary/gui/MainWindow.cpp
index
6039f08
..
e5a0b61
100644
(file)
--- a/
src/mdictionary/gui/MainWindow.cpp
+++ b/
src/mdictionary/gui/MainWindow.cpp
@@
-19,8
+19,11
@@
*******************************************************************************/
*******************************************************************************/
-//! \file MainWindow.cpp
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+/*! \file MainWindow.cpp
+ \brief Implements interface for GUI
+
+ \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+*/
#include "MainWindow.h"
#include <QtGui>
#include "MainWindow.h"
#include <QtGui>
@@
-47,11
+50,14
@@
MainWindow::MainWindow(Backbone *backbone, QWidget *parent):
setExactSearch(false);
setExactSearch(false);
+ setMinimumSize(750, 400);
+
showMaximized();
showMaximized();
+
+ searchBarWidget->setFocus();
}
MainWindow::~MainWindow() {
}
MainWindow::~MainWindow() {
-
}
}
@@
-62,9
+68,6
@@
void MainWindow::initializeUI() {
#endif
#endif
- 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
/*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
@@
-72,6
+75,12
@@
void MainWindow::initializeUI() {
it segfaults*/
translationWidget = new TranslationWidget(this);
it segfaults*/
translationWidget = new TranslationWidget(this);
+
+
+
+ setWindowIcon(QIcon(":/icons/64x64/mdictionary.png"));
+ setWindowTitle("mDictionary");
+
mainLayout = new QVBoxLayout();
QWidget* w = new QWidget();
w->setLayout(mainLayout);
mainLayout = new QVBoxLayout();
QWidget* w = new QWidget();
w->setLayout(mainLayout);
@@
-80,11
+89,11
@@
void MainWindow::initializeUI() {
menuBar = new QMenuBar();
setMenuBar(menuBar);
menuBar = new QMenuBar();
setMenuBar(menuBar);
+ notifyManager = new NotifyManager(this);
+
initializeSearchWidgets();
initializeMenu();
initializeSearchWidgets();
initializeMenu();
-
- notifyManager = new NotifyManager(this);
}
void MainWindow::initializeSearchWidgets() {
}
void MainWindow::initializeSearchWidgets() {
@@
-106,8
+115,9
@@
void MainWindow::initializeSearchWidgets() {
splitter->addWidget(welcomeScreenWidget);
splitter->setStretchFactor(1, 150);
splitter->addWidget(welcomeScreenWidget);
splitter->setStretchFactor(1, 150);
- mainLayout->addWidget(splitter);
- mainLayout->addWidget(searchBarWidget);
+ mainLayout->addWidget(splitter, 1);
+
+ mainLayout->addWidget(searchBarWidget,0, Qt::AlignBottom);
#endif
}
#endif
}
@@
-123,16
+133,19
@@
void MainWindow::initializeMenu() {
menuWidget->addSubMenu(tr("About"), aboutWidget);
menuBar->addAction(menuWidget);
menuWidget->addSubMenu(tr("About"), aboutWidget);
menuBar->addAction(menuWidget);
+
+ connect(menuWidget, SIGNAL(setApplicationMenu(QWidget*)),
+ notifyManager, SLOT(setMenu(QWidget*)));
#else
#else
- dictionariesAction = menuBar->addAction(tr("Dictionaries"));
+ dictionariesAction = menuBar->addAction(tr("&Dictionaries"));
connect(dictionariesAction, SIGNAL(triggered()),
dictManagerWidget, SLOT(show()));
connect(dictionariesAction, SIGNAL(triggered()),
dictManagerWidget, SLOT(show()));
- settingsAction = menuBar->addAction(tr("Settings"));
+ settingsAction = menuBar->addAction(tr("&Settings"));
connect(settingsAction, SIGNAL(triggered()),
settingsWidget, SLOT(show()));
connect(settingsAction, SIGNAL(triggered()),
settingsWidget, SLOT(show()));
- QMenu* m = menuBar->addMenu(tr("Bookmarks"));
+ QMenu* m = menuBar->addMenu(tr("&Bookmarks"));
bookmarksShowAllAction = new QAction(tr("Show all"), m);
bookmarksRemoveAllAction = new QAction(tr("Remove all"), m);
bookmarksShowAllAction = new QAction(tr("Show all"), m);
bookmarksRemoveAllAction = new QAction(tr("Remove all"), m);
@@
-140,9
+153,10
@@
void MainWindow::initializeMenu() {
m->addAction(bookmarksShowAllAction);
m->addAction(bookmarksRemoveAllAction);
m->addAction(bookmarksShowAllAction);
m->addAction(bookmarksRemoveAllAction);
- aboutAction = menuBar->addAction(tr("About"));
+ aboutAction = menuBar->addAction(tr("&About"));
connect(aboutAction, SIGNAL(triggered()),
aboutWidget, SLOT(show()));
connect(aboutAction, SIGNAL(triggered()),
aboutWidget, SLOT(show()));
+
#endif
}
#endif
}
@@
-153,6
+167,9
@@
void MainWindow::initializeMenuWidgets() {
settingsWidget = new SettingsWidget(this);
settingsWidget->hide();
settingsWidget = new SettingsWidget(this);
settingsWidget->hide();
+ connect(settingsWidget, SIGNAL(notify(Notify::NotifyType,QString)),
+ this, SLOT(showNotification(Notify::NotifyType,QString)));
+
bookmarksWidget = new BookmarksWidget(this);
bookmarksWidget->hide();
bookmarksWidget = new BookmarksWidget(this);
bookmarksWidget->hide();
@@
-218,6
+235,8
@@
void MainWindow::wordListReady() {
setExactSearch(false);
}
}
setExactSearch(false);
}
}
+
+ wordListWidget->setFocus();
}
bool MainWindow::checkExactSearch(
}
bool MainWindow::checkExactSearch(
@@
-241,8
+260,11
@@
void MainWindow::translationsReady() {
hideWelcomeScreen();
#endif
hideWelcomeScreen();
#endif
- Q_EMIT showTranslation(backbone->htmls());
- notifyManager->screenChanged();
+ Q_EMIT showTranslation(backbone->xmls());
+ wordListWidget->setFocus();
+ #ifdef Q_WS_MAEMO_5
+ notifyManager->screenChanged();
+ #endif
}
}
@@
-273,10
+295,16
@@
QHash<CommonDictInterface*, bool> MainWindow::getDictionaries() {
return backbone->getDictionaries();
}
return backbone->getDictionaries();
}
-
+/**/
void MainWindow::search(QString word) {
setExactSearch(false);
searchBarWidget->search(word);
void MainWindow::search(QString word) {
setExactSearch(false);
searchBarWidget->search(word);
+ #ifdef Q_WS_MAEMO_5
+ if(translationWidget->isVisible()) {
+ translationWidget->hide();
+ update();
+ }
+ #endif
}
void MainWindow::searchExact(QString word) {
}
void MainWindow::searchExact(QString word) {
@@
-344,16
+372,11
@@
void MainWindow::enableMenu() {
}
void MainWindow::showHistory(QPoint p) {
}
void MainWindow::showHistory(QPoint p) {
-
- HistoryListDialog historyDialog(backbone->history()->list(), searchBarWidget);
-
+ HistoryListDialog historyDialog(backbone->history()->list(), this );// searchBarWidget);
#ifndef Q_WS_MAEMO_5
#ifndef Q_WS_MAEMO_5
- QPoint newPos = mapFromGlobal(p);
- newPos.setY(searchBarWidget->pos().y() -
- historyDialog.sizeHint().height());
- newPos.setX(width() - historyDialog.sizeHint().width());
-
- historyDialog.move(newPos);
+ p.setX(p.x() - historyDialog.sizeHint().width() + 5);
+ p.setY(p.y() - historyDialog.sizeHint().height() - 80);
+ historyDialog.move(p);
#endif
if(historyDialog.exec() == QDialog::Accepted) {
#endif
if(historyDialog.exec() == QDialog::Accepted) {
@@
-401,7
+424,7
@@
void MainWindow::connectBackbone() {
backbone, SLOT(search(QString)));
connect(this, SIGNAL(searchTranslations(QList<Translation*>)),
backbone, SLOT(search(QString)));
connect(this, SIGNAL(searchTranslations(QList<Translation*>)),
- backbone, SLOT(searchHtml(QList<Translation*>)));
+ backbone, SLOT(searchXml(QList<Translation*>)));
connect(this, SIGNAL(stopSearching()),
backbone, SLOT(stopSearching()));
connect(this, SIGNAL(stopSearching()),
backbone, SLOT(stopSearching()));
@@
-422,14
+445,14
@@
void MainWindow::connectBackbone() {
connect(backbone, SIGNAL(ready()),
this, SIGNAL(setIdle()));
connect(backbone, SIGNAL(ready()),
this, SIGNAL(setIdle()));
- connect(backbone, SIGNAL(htmlReady()),
+ connect(backbone, SIGNAL(xmlReady()),
this, SIGNAL(setIdle()));
connect(backbone, SIGNAL(ready()),
this, SLOT(wordListReady()));
this, SIGNAL(setIdle()));
connect(backbone, SIGNAL(ready()),
this, SLOT(wordListReady()));
- connect(backbone, SIGNAL(htmlReady()),
+ connect(backbone, SIGNAL(xmlReady()),
this, SLOT(translationsReady()));
connect(backbone, SIGNAL(searchCanceled()),
this, SLOT(translationsReady()));
connect(backbone, SIGNAL(searchCanceled()),
@@
-437,6
+460,16
@@
void MainWindow::connectBackbone() {
connect(backbone, SIGNAL(notify(Notify::NotifyType,QString)),
this, SLOT(showNotification(Notify::NotifyType,QString)));
connect(backbone, SIGNAL(notify(Notify::NotifyType,QString)),
this, SLOT(showNotification(Notify::NotifyType,QString)));
+
+ connect(backbone, SIGNAL(closeOk()),
+ this, SLOT(close()));
+
+
+ //connect(wordListWidget, SIGNAL(addBookmark(QList<Translation*>)),
+ // this, SIGNAL(setBusy()));
+
+ //connect(backbone, SIGNAL(bookmarkReady()),
+ // this, SIGNAL(setIdle()));
}
void MainWindow::connectSearchBar() {
}
void MainWindow::connectSearchBar() {
@@
-500,12
+533,14
@@
void MainWindow::connectTranslationWidget() {
#ifdef Q_WS_MAEMO_5
connect(translationWidget, SIGNAL(search(QString)),
this, SLOT(search(QString)));
#ifdef Q_WS_MAEMO_5
connect(translationWidget, SIGNAL(search(QString)),
this, SLOT(search(QString)));
+
+ connect(translationWidget, SIGNAL(notify(Notify::NotifyType, QString)),
+ this, SLOT(showNotification(Notify::NotifyType,QString)));
#else
connect(translationWidget, SIGNAL(search(QString)),
this, SLOT(searchExact(QString)));
#endif
#else
connect(translationWidget, SIGNAL(search(QString)),
this, SLOT(searchExact(QString)));
#endif
-
}
void MainWindow::connectDictManager() {
}
void MainWindow::connectDictManager() {
@@
-531,7
+566,7
@@
void MainWindow::connectMenu() {
void MainWindow::connectBookmarksWidget() {
#ifdef Q_WS_MAEMO_5
void MainWindow::connectBookmarksWidget() {
#ifdef Q_WS_MAEMO_5
- //after removing bookmarks we search for them once again to clear word list
+ //after removing bookmarks we search for them once again to clear the words list
connect(bookmarksWidget, SIGNAL(removeAllBookmarks()),
this, SLOT(removeBookmarks()));
connect(bookmarksWidget, SIGNAL(removeAllBookmarks()),
this, SLOT(removeBookmarks()));
@@
-561,11
+596,11
@@
void MainWindow::removeBookmarks() {
par = this;
#endif
if(QMessageBox::question(par, tr("Delete all bookmarks"),
par = this;
#endif
if(QMessageBox::question(par, tr("Delete all bookmarks"),
- tr("Do you want to delete all bookmarks? (This action cannot be revoked)"),
- QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) {
+ tr("Do you want to delete all bookmarks? (This action cannot be revoked, and will clear current word list)"),
+ QMessageBox::Yes, QMessageBox::Cancel) == QMessageBox::Yes) {
backbone->removeAllBookmarks();
backbone->removeAllBookmarks();
- if(searchString.size())
- backbone->search(searchString);
-
+ ((WordListWidget*)wordListWidget)->clear();
}
}
+
+
}
}