From 370fe5ec9c3e2f22386d1fec69d218e5cef7a7ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mateusz=20P=C3=B3=C5=82rola?= Date: Thu, 16 Sep 2010 11:38:28 +0200 Subject: [PATCH] Fixed some focus and activation bugs --- src/mdictionary/gui/DictManagerWidget.cpp | 26 ++++++++++++++++++++++++++ src/mdictionary/gui/DictManagerWidget.h | 1 + src/mdictionary/gui/HistoryListDialog.cpp | 7 ++++++- src/mdictionary/gui/HistoryListDialog.h | 3 +++ src/mdictionary/gui/MainWindow.cpp | 3 +++ src/mdictionary/gui/SettingsWidget.cpp | 4 ++-- 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/mdictionary/gui/DictManagerWidget.cpp b/src/mdictionary/gui/DictManagerWidget.cpp index 4ea996c..4353301 100644 --- a/src/mdictionary/gui/DictManagerWidget.cpp +++ b/src/mdictionary/gui/DictManagerWidget.cpp @@ -86,6 +86,15 @@ void DictManagerWidget::initalizeUI() { connect(dictList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(changed())); + #ifndef Q_WS_MAEMO_5 + connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), + this, SLOT(saveChanges())); + connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), + this, SLOT(itemSelected(QListWidgetItem*))); + connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), + settingsButton, SIGNAL(clicked())); + #endif + refreshDictsList(); #ifndef Q_WS_MAEMO_5 @@ -204,6 +213,7 @@ void DictManagerWidget::addNewDictButtonClicked() { void DictManagerWidget::itemSelected(QListWidgetItem *) { removeDictButton->setEnabled(true); settingsButton->setEnabled(true); + dictList->setFocus(); } void DictManagerWidget::removeButtonClicked() { @@ -248,3 +258,19 @@ void DictManagerWidget::changed() { hide(); } #endif + + +void DictManagerWidget::keyPressEvent(QKeyEvent *e) { + if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { + switch (e->key()) { + case Qt::Key_Escape: + reject(); + break; + default: + e->ignore(); + return; + } + } else { + e->ignore(); + } +} diff --git a/src/mdictionary/gui/DictManagerWidget.h b/src/mdictionary/gui/DictManagerWidget.h index eec621c..ab7c9cc 100644 --- a/src/mdictionary/gui/DictManagerWidget.h +++ b/src/mdictionary/gui/DictManagerWidget.h @@ -52,6 +52,7 @@ public: protected: void showEvent(QShowEvent *e); void hideEvent(QHideEvent *e); + void keyPressEvent(QKeyEvent *e); Q_SIGNALS: //! Emitted when hiding widget, it will save states of dictionaries diff --git a/src/mdictionary/gui/HistoryListDialog.cpp b/src/mdictionary/gui/HistoryListDialog.cpp index a9d4765..7e58372 100644 --- a/src/mdictionary/gui/HistoryListDialog.cpp +++ b/src/mdictionary/gui/HistoryListDialog.cpp @@ -53,7 +53,7 @@ HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent): setMinimumHeight(300); - connect(historyListWidget, SIGNAL(clicked(QModelIndex)), + connect(historyListWidget, SIGNAL(activated(QModelIndex)), this, SLOT(itemClicked(QModelIndex))); } @@ -72,3 +72,8 @@ QString HistoryListDialog::selectedWord() { int HistoryListDialog::selectedRow() { return _selectedRow; } + +int HistoryListDialog::exec() { + historyListWidget->setFocus(); + QDialog::exec(); +} diff --git a/src/mdictionary/gui/HistoryListDialog.h b/src/mdictionary/gui/HistoryListDialog.h index 20bf354..5d3c78c 100644 --- a/src/mdictionary/gui/HistoryListDialog.h +++ b/src/mdictionary/gui/HistoryListDialog.h @@ -52,6 +52,9 @@ public: //! \returns row number of selected word int selectedRow(); +public Q_SLOTS: + int exec(); + private Q_SLOTS: void itemClicked(QModelIndex); diff --git a/src/mdictionary/gui/MainWindow.cpp b/src/mdictionary/gui/MainWindow.cpp index 9d2ae5a..b7e4dca 100644 --- a/src/mdictionary/gui/MainWindow.cpp +++ b/src/mdictionary/gui/MainWindow.cpp @@ -231,6 +231,8 @@ void MainWindow::wordListReady() { setExactSearch(false); } } + + wordListWidget->setFocus(); } bool MainWindow::checkExactSearch( @@ -255,6 +257,7 @@ void MainWindow::translationsReady() { #endif Q_EMIT showTranslation(backbone->xmls()); + wordListWidget->setFocus(); #ifdef Q_WS_MAEMO_5 notifyManager->screenChanged(); #endif diff --git a/src/mdictionary/gui/SettingsWidget.cpp b/src/mdictionary/gui/SettingsWidget.cpp index 7b7173e..68bafaf 100644 --- a/src/mdictionary/gui/SettingsWidget.cpp +++ b/src/mdictionary/gui/SettingsWidget.cpp @@ -100,8 +100,8 @@ void SettingsWidget::initalizeUI() { checkBoxesLabel = new QLabel(tr("Search in:"),this); - searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"),this); - searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"),this); + searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks")); + searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries")); verticalLayout->addSpacing(20); verticalLayout->addWidget(checkBoxesLabel); -- 1.7.9.5