backbone/History.cpp \
gui/HistoryListDialog.cpp \
gui/WordListProxyStyle.cpp \
- backbone/Bookmarks.cpp
+ backbone/Bookmarks.cpp \
+ gui/SettingsWidget.cpp
HEADERS += gui/MainWindow.h \
gui/SearchBarWidget.h \
../includes/GUIInterface.h \
gui/WordListProxyStyle.h \
backbone/Bookmarks.h \
- backbone/BookmarkTranslations.h
+ backbone/BookmarkTranslations.h \
+ gui/SettingsWidget.h
FORMS += gui/MainWindow.ui
refreshDictsList();
+ #ifndef Q_WS_MAEMO_5
+ setMinimumSize(500,300);
+ #endif
}
dictManagerWidget = new DictManagerWidget(this);
dictManagerWidget->hide();
+
+ settingsWidget = new SettingsWidget(this);
+ settingsWidget->hide();
+
#ifdef Q_WS_MAEMO_5
menuWidget = new MenuWidget(this);
+ menuWidget->addSubMenu(tr("Settings"), settingsWidget);
menuWidget->addSubMenu(tr("Dictionaries"), dictManagerWidget);
- menuWidget->addSubMenu(tr("Settings"), new QPushButton("Settings"));
menuWidget->addSubMenu(tr("About"), new QPushButton("About"));
ui->menuBar->addAction(menuWidget);
#else
dictionariesAction = ui->menuBar->addAction(tr("Dictionaries"));
connect(dictionariesAction, SIGNAL(triggered()),
dictManagerWidget, SLOT(show()));
+
+ settingsAction = ui->menuBar->addAction(tr("Settings"));
+ connect(settingsAction, SIGNAL(triggered()),
+ settingsWidget, SLOT(show()));
#endif
}
emit showWordList(searchResult);
}
else {
-
+ #ifndef Q_WS_MAEMO_5
+ emit showWordList(searchResult);
+ #endif
bool foundExactMatch = false;
QHash<QString, QList<Translation*> >::iterator j;
for(j = searchResult.begin(); j != searchResult.end(); j++) {
void MainWindow::historyNext() {
if(backbone->history()->nextAvailable()) {
QString next = backbone->history()->next();
+ #ifndef Q_WS_MAEMO_5
+ setExactSearch(true);
+ #endif
searchBarWidget->searchDelay(next);
}
}
void MainWindow::historyPrev() {
if(backbone->history()->prevAvailable()) {
+ #ifndef Q_WS_MAEMO_5
+ setExactSearch(true);
+ #endif
QString prev = backbone->history()->previous();
searchBarWidget->searchDelay(prev);
}
}
}
+void MainWindow::setSettings(Settings *s) {
+ backbone->setSettings(s);
+}
+
+Settings* MainWindow::settings() {
+ return backbone->settings();
+}
+
void MainWindow::connectBackbone() {
connect(this, SIGNAL(quit()),
backbone, SLOT(quit()));
#include <QMainWindow>
#include "../../includes/GUIInterface.h"
+#include "../../includes/settings.h"
#include "../backbone/backbone.h"
#include "TranslationWidget.h"
#include "WordListWidget.h"
#include "SearchBarWidget.h"
#include "MenuWidget.h"
#include "DictManagerWidget.h"
+#include "SettingsWidget.h"
#include "HistoryListDialog.h"
namespace Ui {
*/
void setExactSearch(bool);
+ Settings* settings();
+
+ void setSettings(Settings*);
+
public Q_SLOTS:
//! Search in exact mode for given word
WordListWidget* wordListWidget;
MenuWidget* menuWidget;
DictManagerWidget* dictManagerWidget;
+ SettingsWidget* settingsWidget;
#ifndef Q_WS_MAEMO_5
QSplitter* splitter;
QAction* dictionariesAction;
//QAction* edit;
- // QAction* settingsAction;
+ QAction* settingsAction;
//QAction* aboutAction;
#endif
#include "MenuWidget.h"
#include <QDebug>
+#include <QtGui>
MenuWidget::MenuWidget(QWidget *parent) :
QWidgetAction(parent) {
}
void MenuWidget::addSubMenu(QString title, QWidget *widget) {
- tabWidget->addTab(widget, title);
+ QScrollArea* sa = new QScrollArea(tabWidget);
+ sa->setWidget(widget);
+ sa->setWidgetResizable(true);
+ sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ tabWidget->addTab(sa, title);
}
--- /dev/null
+/*******************************************************************************
+
+ 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 "SettingsWidget.h"
+
+SettingsWidget::SettingsWidget(GUIInterface *parent) :
+ QDialog(parent)
+{
+ setWindowTitle(tr("Settings"));
+
+ verticalLayout = new QVBoxLayout;
+ setLayout(verticalLayout);
+
+ historySizeSpinBox = new QSpinBox;
+ searchResultSizeSpinBox = new QSpinBox;
+
+ spinBoxesFormLayout = new QFormLayout;
+
+ spinBoxesFormLayout->addRow(tr("Search result size"),
+ searchResultSizeSpinBox);
+
+ spinBoxesFormLayout->addRow(tr("History size"),
+ historySizeSpinBox);
+
+ #ifdef Q_WS_MAEMO_5
+ verticalLayout->addSpacing(20);
+ #endif
+ verticalLayout->addLayout(spinBoxesFormLayout);
+
+
+ checkBoxesLabel = new QLabel(tr("Search in:"));
+
+ searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
+ searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
+
+ verticalLayout->addSpacing(20);
+ verticalLayout->addWidget(checkBoxesLabel);
+ verticalLayout->addWidget(searchInDictionariesCheckBox);
+ verticalLayout->addWidget(searchInBookmarksCheckBox);
+
+ #ifndef Q_WS_MAEMO_5
+ setMinimumWidth(250);
+ setMaximumWidth(250);
+ #endif
+}
+
+void SettingsWidget::showEvent(QShowEvent *e) {
+ settings = guiInterface->getSettings();
+
+ historySizeSpinBox->setValue(
+ settings->value("history_size").toInt());
+
+ searchResultSizeSpinBox->setValue(
+ settings->value("search_limit").toInt());
+
+ if(settings->value("search_bookmarks") == "true")
+ searchInBookmarksCheckBox->setChecked(true);
+ else
+ searchInBookmarksCheckBox->setChecked(false);
+
+ if(settings->value("search_dictionaries") == "true")
+ searchInDictionariesCheckBox->setChecked(true);
+ else
+ searchInDictionariesCheckBox->setChecked(false);
+
+ QDialog::showEvent(e);
+}
+
+void SettingsWidget::hideEvent(QHideEvent *e) {
+ Settings* newSettings;
+ newSettings->setValue("history_size",
+ QString::number(historySizeSpinBox->value()));
+ newSettings->setValue("search_limit",
+ QString::number(searchResultSizeSpinBox->value()));
+
+ if(searchInDictionariesCheckBox->isChecked())
+ newSettings->setValue("search_dictionaries", "true");
+ else
+ newSettings->setValue("search_dictionaries", "false");
+
+ if(searchInBookmarksCheckBox->isChecked())
+ newSettings->setValue("search_bookmarks", "true");
+ else
+ newSettings->setValue("search_bookmarks", "false");
+
+ QString key;
+ foreach(key, newSettings->keys()) {
+ if(settings->value(key) != newSettings->value(key)) {
+ guiInterface->setSettings(newSettings);
+ break;
+ }
+ }
+
+ QDialog::hideEvent(e);
+}
--- /dev/null
+/*******************************************************************************
+
+ 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 SETTINGSWIDGET_H
+#define SETTINGSWIDGET_H
+
+#include <QWidget>
+#include <QtGui>
+#include "../../includes/GUIInterface.h"
+#include "../../includes/settings.h"
+
+class SettingsWidget : public QDialog
+{
+ Q_OBJECT
+public:
+ explicit SettingsWidget(GUIInterface *parent = 0);
+
+protected:
+ void showEvent(QShowEvent *);
+ void hideEvent(QHideEvent *);
+
+private:
+ QSpinBox* historySizeSpinBox;
+ QSpinBox* searchResultSizeSpinBox;
+ QVBoxLayout* verticalLayout;
+ QFormLayout* spinBoxesFormLayout;
+
+ QLabel* checkBoxesLabel;
+ QCheckBox* searchInDictionariesCheckBox;
+ QCheckBox* searchInBookmarksCheckBox;
+
+ GUIInterface* guiInterface;
+ Settings* settings;
+};
+
+#endif // SETTINGSWIDGET_H
QWidget*w = new QWidget;
verticalLayout = new QVBoxLayout(w);
- //verticalLayout->addLayout(horizontalLayout);
verticalLayout->addWidget(textEdit);
+ textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+
this->setWidget(w);
this->setWidgetResizable(true);
setModel(model);
setHeaderHidden(true);
setRootIsDecorated(false);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ setStyle(new WordListProxyStyle);
#ifdef Q_WS_MAEMO_5
checkBoxWidth = 70;
#else
checkBoxWidth = 25;
#endif
-
-
- setStyle(new WordListProxyStyle);
-
}
void WordListWidget::addWord(QString word, int row) {
addWord(i.key(), row++);
}
- setColumnWidth(0, width()-checkBoxWidth - 20);
- setColumnWidth(1, checkBoxWidth);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ resizeColumns();
}
void WordListWidget::wordClicked(QModelIndex index) {
Qt::CheckState state =
Qt::CheckState(index.data(Qt::CheckStateRole).toInt());
- QModelIndex item = selectedIndexes().at(0);
+ QModelIndex item = selectedIndexes().at(0);
+ if(!item.isValid()) return;
if(state == Qt::Checked) {
- qDebug()<<"Added "<<item.data().toString();
emit addBookmark(searchResult[item.data().toString()]);
}
else {
- qDebug()<<"Removed "<<item.data().toString();
emit removeBookmark(searchResult[item.data().toString()]);
}
}
}
void WordListWidget::resizeEvent(QResizeEvent *event) {
- setColumnWidth(0, width()-checkBoxWidth - 20);
- setColumnWidth(1, checkBoxWidth);
+ resizeColumns();
QTreeView::resizeEvent(event);
}
+void WordListWidget::resizeColumns() {
+ setColumnWidth(0, viewport()->width() -checkBoxWidth - 20);
+ setColumnWidth(1, checkBoxWidth);
+}
+
void WordListWidget::lockList() {
setEnabled(false);
}
//! objects
void showTranslation(QList<Translation*>);
+
+ //! Request to add selected word to bookmarks
void addBookmark(QList<Translation*>);
+ //! Request to remove selected word from bookmarks
void removeBookmark(QList<Translation*>);
void addWord(QString word, int row);
QStandardItemModel* model;
int checkBoxWidth;
+ void resizeColumns();
- Qt::CheckState itemState;
QHash<QString, QList<Translation*> > searchResult;
};
#include "translation.h"
#include "CommonDictInterface.h"
+class Settings;
+
//! Interface for different GUIs
/*!
Default base class for all GUIs is QMainWindow
/*! \sa exactSearch() */
void setExactSearch(bool exactSearch);
+ Settings* getSettings() = 0;
+
+ void settings(Settings*) = 0;
+
public Q_SLOTS:
//! Search in exact mode for given word