different ways
\param QString text of the notification
*/
- void notify(Notify::NotifyType, QString);
+ void notify(Notify::NotifyType, QString, QWidget* parent = 0);
protected:
#define DICTDIALOG_H
#include <QObject>
+#include "Notify.h"
class Settings;
\param parent parent widget on which dialog will be displayed
*/
virtual void changeSettings(QWidget *parent = 0) = 0;
+
+Q_SIGNALS:
+ void notify(Notify::NotifyType, QString, QWidget* parent = 0);
};
#endif // DICTDIALOG_H
dict->setHash(++_dictNum); // Hash must be uniqe in every session but not between
_dicts[dict] = active;
connect(dict, SIGNAL(settingsChanged()), this, SLOT(dictUpdated()));
- connect(dict, SIGNAL(notify(Notify::NotifyType,QString)), this,
- SIGNAL(notify(Notify::NotifyType,QString)));
+ connect(dict, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)), this,
+ SIGNAL(notify(Notify::NotifyType,QString, QWidget*)));
}
}
if(!exists) {
_plugins.append(plugin);
plugin->retranslate();
+ connect(plugin, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)),
+ this, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)));
}
}
}
different ways
\param QString text of the notification
*/
- void notify(Notify::NotifyType, QString);
+ void notify(Notify::NotifyType, QString, QWidget*parent = 0);
private Q_SLOTS:
void bookmarksListReady();
#include "DictTypeSelectDialog.h"
#include <QDebug>
#include "../../include/DictDialog.h"
+#include "MenuWidget.h"
DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
QDialog(parent) {
#endif
CommonDictInterface* selectedPlugin =
- DictTypeSelectDialog::addNewDict(guiInterface->getPlugins(),this);
+ DictTypeSelectDialog::addNewDict(
+ guiInterface->getPlugins(),
+ menuWidget->applicationMenu());
+
if(selectedPlugin != NULL) {
Settings* settings =
- selectedPlugin->dictDialog()->addNewDictionary(this);
+ selectedPlugin->dictDialog()->addNewDictionary(menuWidget->applicationMenu());
if(settings != NULL) {
CommonDictInterface* newDict = selectedPlugin->getNew(settings);
#endif
QList<QListWidgetItem*> selected = dictListWidget->selectedItems();
if(selected.count() > 0) {
- dictsHash[selected[0]]->dictDialog()->changeSettings(this);
+ dictsHash[selected[0]]->dictDialog()->changeSettings(menuWidget->applicationMenu());
}
refreshDictsList();
}
#include <QWidget>
#include <QtGui>
#include "../../include/GUIInterface.h"
+#include "MenuWidget.h"
//! Implements dictionaries management widget
*/
explicit DictManagerWidget(GUIInterface *parent = 0);
+ void setMenuWidget(MenuWidget *w) {menuWidget = w;}
+
protected:
void showEvent(QShowEvent *e);
void hideEvent(QHideEvent *e);
public Q_SLOTS:
+
#ifndef Q_WS_MAEMO_5
void save();
#endif
QPushButton* closeButton;
bool _save;
#endif
+
+ MenuWidget* menuWidget;
};
#endif // DICTMANAGERWIDGET_H
menuWidget->addSubMenu(tr("About"), aboutWidget);
menuBar->addAction(menuWidget);
+
+ dictManagerWidget->setMenuWidget(menuWidget);
#else
dictionariesAction = menuBar->addAction(tr("Dictionaries"));
connect(dictionariesAction, SIGNAL(triggered()),
aboutAction = menuBar->addAction(tr("About"));
connect(aboutAction, SIGNAL(triggered()),
aboutWidget, SLOT(show()));
+
#endif
}
}
-void MainWindow::showNotification(Notify::NotifyType type, QString text) {
- notifyManager->showNotification(type, text);
+void MainWindow::showNotification(Notify::NotifyType type, QString text, QWidget* parent) {
+ notifyManager->showNotification(type, text, parent);
}
void MainWindow::connectBackbone() {
connect(backbone, SIGNAL(searchCanceled()),
this, SIGNAL(setIdle()));
- connect(backbone, SIGNAL(notify(Notify::NotifyType,QString)),
- this, SLOT(showNotification(Notify::NotifyType,QString)));
+ connect(backbone, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)),
+ this, SLOT(showNotification(Notify::NotifyType,QString, QWidget*)));
}
void MainWindow::connectSearchBar() {
\param type type of notification
\param message notification message
*/
- void showNotification(Notify::NotifyType type, QString message);
+ void showNotification(Notify::NotifyType type, QString message, QWidget *parent=0);
private Q_SLOTS:
//! Disables menu
its parent to NULL and prevent it from delete, so we can still use this
widget*/
return tabWidget;
+}
+QWidget* MenuWidget::applicationMenu() {
+ return tabWidget->parentWidget();
}
void MenuWidget::hideMenu() {
tabWidget->parentWidget()->hide();
}
+
+
+void MenuWidget::showMenu() {
+ tabWidget->parentWidget()->show();
+}
*/
void removeSubMenu(QString title);
+ QWidget* applicationMenu();
+
public Q_SLOTS:
/*!
Hides menu
*/
void hideMenu();
+ void showMenu();
+
protected:
MenuTabWidget* tabWidget;
QWidget* createWidget(QWidget *parent);
NotifyManager::NotifyManager(QObject *parent) :
QObject(parent)
{
+
}
}
}
-void NotifyManager::showNotification(Notify::NotifyType type, QString text) {
+void NotifyManager::showNotification(Notify::NotifyType type, QString text, QWidget* parent) {
if(activeNotifies.contains(text)) {
return;
}
+ if(parent == 0)
+ parent = qobject_cast<QWidget*>(this->parent());
#ifdef Q_WS_MAEMO_5
QMaemo5InformationBox* mbox =
- new QMaemo5InformationBox(0);
+ new QMaemo5InformationBox(parent);
- QLabel* infoLabel = new QLabel(text);
+ QLabel* infoLabel = new QLabel(text, mbox);
infoLabel->setAlignment(Qt::AlignCenter);
infoLabel->setWordWrap(true);
+ infoLabel->setMargin(10);
+
mbox->setWidget(infoLabel);
+
#else
QMessageBox* mbox =
- new QMessageBox(qobject_cast<QWidget*>(this->parent()));
+ new QMessageBox(parent);
#endif
+
switch(type) {
case Notify::Info:
mbox->setWindowTitle(tr("Information"));
mbox->setIcon(QMessageBox::Information);
+
#endif
break;
#endif
break;
}
-
activeNotifies.insert(text, mbox);
connect(mbox, SIGNAL(finished(int)), this, SLOT(notificationClosed()));
mbox->exec();
#include <QString>
#include <QDialog>
#include "../../include/Notify.h"
+#include "MenuWidget.h"
//! Manages notifications in applications
/*!
\param text text of notification
\sa Notify::NotifyType
*/
- void showNotification(Notify::NotifyType type, QString text);
+ void showNotification(Notify::NotifyType type, QString text, QWidget*parent=0);
//! Refresh all notifications when stacked widgets changes
void screenChanged();
--- /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 "XdxfDialog.h"
+#include <QDebug>
+
+XdxfDialog::XdxfDialog(XdxfPlugin *plugin,
+ XdxfDialogType type,
+ QWidget *parent) :
+ QDialog(parent) {
+ this->plugin = plugin;
+ this->type = type;
+
+ initializeUI();
+
+ connect(cacheCheckBox, SIGNAL(toggled(bool)),
+ this, SLOT(setGenerateCache(bool)));
+
+ connect(accentsCheckBox, SIGNAL(toggled(bool)),
+ this, SLOT(setAccents(bool)));
+
+ connect(accentsInfoToolButton, SIGNAL(clicked()),
+ this, SLOT(showAccentsInfo()));
+
+ connect(cacheInfoToolButton, SIGNAL(clicked()),
+ this, SLOT(showCacheInfo()));
+
+ if(type == New) {
+ connect(browseButton, SIGNAL(clicked()),
+ this, SLOT(selectFile()));
+
+ connect(addButton, SIGNAL(clicked()),
+ this, SLOT(accept()));
+ }
+ else {
+ connect(saveButton, SIGNAL(clicked()),
+ this, SLOT(accept()));
+ }
+}
+
+
+void XdxfDialog::initializeUI() {
+ mainVerticalLayout = new QVBoxLayout;
+ widget = new QWidget;
+ widget->setLayout(mainVerticalLayout);
+
+ if(type == New) {
+ setWindowTitle(tr("Add new XDXF dictionary"));
+
+
+ browseLayout = new QHBoxLayout;
+ browseButton = new QPushButton(tr("Browse"));
+ browseLabel = new QLabel(tr("Dictionary file: not selected"));
+
+ browseLayout->addWidget(browseLabel, 0, Qt::AlignLeft);
+ browseLayout->addWidget(browseButton, 0, Qt::AlignRight);
+
+ mainVerticalLayout->addLayout(browseLayout);
+ }
+ else {
+ setWindowTitle(tr("XDXF Settings"));
+
+
+ infoLabel = new QLabel;
+
+ infoLabel->setText(tr("Plugin: ") + plugin->type().toUpper() +"\n" +
+ tr("From: ") + plugin->langFrom() + "\n" +
+ tr("To: ") + plugin->langTo() + "\n" +
+ tr("Description: ") + plugin->name() + "\n" +
+ tr("License: ") + plugin->infoNote());
+ infoLabel->setWordWrap(true);
+ mainVerticalLayout->addWidget(infoLabel);
+ }
+
+ accentsCheckBox = new QCheckBox(tr("Strip accents"));
+ accentsInfoToolButton = new QToolButton;
+ accentsInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
+
+ accentsLayout = new QHBoxLayout;
+ accentsLayout->addWidget(accentsCheckBox);
+ accentsLayout->addWidget(accentsInfoToolButton);
+
+
+ cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches"));
+ cacheInfoToolButton = new QToolButton;
+ cacheInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
+
+ cacheLayout = new QHBoxLayout;
+ cacheLayout->addWidget(cacheCheckBox);
+ cacheLayout->addWidget(cacheInfoToolButton);
+
+ mainVerticalLayout->addLayout(cacheLayout);
+ mainVerticalLayout->addLayout(accentsLayout);
+
+
+ //load old setting if exists
+ if(!plugin) {
+ cacheCheckBox->setChecked(true);
+ accentsCheckBox->setChecked(true);
+ accentsCheckBox->setEnabled(false);
+ _generateCache = true;
+ _accents = true;
+ _dictionaryFilePath = "";
+ }
+ else if(plugin && plugin->settings()->value("cached") == "true") {
+ cacheCheckBox->setChecked(true);
+ accentsCheckBox->setChecked(true);
+ accentsCheckBox->setEnabled(false);
+ _generateCache = true;
+ _accents = true;
+ }
+ else {
+ cacheCheckBox->setChecked(false);
+ _generateCache = false;
+
+ if(plugin->settings()->value("strip_accents") == "true") {
+ accentsCheckBox->setChecked(true);
+ _accents = true;
+ }
+ else {
+ accentsCheckBox->setChecked(false);
+ _accents = false;
+ }
+ }
+
+ if(type == New) {
+ addButton = new QPushButton(tr("Add"));
+ mainVerticalLayout->addWidget(addButton);
+ }
+ else {
+ saveButton = new QPushButton(tr("Save settings"));
+ mainVerticalLayout->addWidget(saveButton);
+ }
+
+ scrollArea = new QScrollArea;
+ scrollArea->setWidget(widget);
+ scrollArea->setWidgetResizable(true);
+ scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ layout = new QHBoxLayout;
+ layout->addWidget(scrollArea);
+ setLayout(layout);
+}
+
+
+void XdxfDialog::setAccents(bool accents) {
+ _accents = accents;
+}
+
+void XdxfDialog::setGenerateCache(bool generate) {
+ _generateCache = generate;
+
+ if(generate) {
+ _lastAccents = _accents;
+ accentsCheckBox->setChecked(true);
+ }
+ else
+ accentsCheckBox->setChecked(_lastAccents);
+
+ accentsCheckBox->setEnabled(!generate);
+}
+
+void XdxfDialog::selectFile() {
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Select dictionary file"),
+ _dictionaryFilePath,
+ tr("XDXF Files (*.xdxf)"),
+ NULL,
+ NULL);
+
+ if (!fileName.isEmpty()) {
+ browseLabel->setText(tr("Dictionary file: %1").arg(fileName));
+ _dictionaryFilePath = fileName;
+ }
+}
+
+void XdxfDialog::saveSettings() {
+ _settings = new Settings;
+ if(plugin) {
+ foreach(QString key, plugin->settings()->keys())
+ _settings->setValue(key, plugin->settings()->value(key));
+ }
+ else {
+ _settings->setValue("path", _dictionaryFilePath);
+ }
+
+ if(_generateCache)
+ _settings->setValue("generateCache", "true");
+ else
+ _settings->setValue("generateCache", "false");
+
+ if(_accents)
+ _settings->setValue("strip_accents", "true");
+ else
+ _settings->setValue("strip_accents", "false");
+}
+
+void XdxfDialog::accept() {
+ if(type == New && _dictionaryFilePath.isEmpty()) {
+ Q_EMIT notify(Notify::Warning, tr("File path is not set"), this);
+
+ return;
+ }
+
+ saveSettings();
+ QDialog::accept();
+}
+
+Settings* XdxfDialog::getSettings() {
+ return _settings;
+}
+
+void XdxfDialog::showCacheInfo() {
+ Q_EMIT notify(Notify::Info, tr("Optimize for quicker searches (may take some time)"), this);
+}
+
+void XdxfDialog::showAccentsInfo() {
+ Q_EMIT notify(Notify::Info, tr("Strip accents (searching takes more "
+ "time, but spelling don't have to be exact)"), this);
+}
+
--- /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 XDXFDIALOG_H
+#define XDXFDIALOG_H
+
+#include <QDialog>
+#include "../../include/settings.h"
+#include <QtGui>
+#include "xdxfplugin.h"
+
+class XdxfDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ enum XdxfDialogType {New, Change};
+
+ explicit XdxfDialog(XdxfPlugin* plugin = 0, XdxfDialogType type = New,
+ QWidget *parent = 0);
+
+ Settings* getSettings();
+
+Q_SIGNALS:
+ void notify(Notify::NotifyType, QString, QWidget*);
+
+public Q_SLOTS:
+ void accept();
+
+private Q_SLOTS:
+ void selectFile();
+ void saveSettings();
+ void setGenerateCache(bool);
+ void setAccents(bool);
+
+ void showCacheInfo();
+ void showAccentsInfo();
+
+
+private:
+ void initializeUI();
+
+ QLabel* browseLabel;
+ QPushButton* browseButton;
+ QHBoxLayout* browseLayout;
+
+ QLabel* infoLabel;
+
+ QCheckBox* cacheCheckBox;
+ QCheckBox* accentsCheckBox;
+ QHBoxLayout* cacheLayout;
+ QHBoxLayout* accentsLayout;
+ QToolButton* cacheInfoToolButton;
+ QToolButton* accentsInfoToolButton;
+
+ QPushButton* saveButton;
+ QPushButton* addButton;
+
+ QString _dictionaryFilePath;
+
+ QScrollArea* scrollArea;
+
+ QWidget* widget;
+ QHBoxLayout* layout;
+
+ QVBoxLayout* mainVerticalLayout;
+ bool _generateCache;
+ bool _accents;
+ bool _lastAccents;
+
+ Settings* _settings;
+
+ XdxfPlugin* plugin;
+ XdxfDialogType type;
+};
+
+#endif // XDXFDIALOG_H
#include "XdxfLoadDialog.h"
#include "XdxfSettingsDialog.h"
#include "xdxfplugin.h"
+#include "XdxfDialog.h"
+#include <QDebug>
XdxfDictDialog::XdxfDictDialog(XdxfPlugin *plugin, QObject *parent) :
DictDialog(parent) {
}
Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
- return XdxfLoadDialog::getSettings(parent);
+ qDebug()<<parent;
+ XdxfDialog d(0, XdxfDialog::New, parent);
+
+ connect(&d, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)),
+ this, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)));
+
+ if(d.exec() == QDialog::Accepted) {
+ return d.getSettings();
+ }
+ return 0;
}
void XdxfDictDialog::changeSettings(QWidget * parent) {
- XdxfSettingsDialog::getSettings(plugin, parent);
+ XdxfDialog d(plugin, XdxfDialog::Change, parent);
+
+ connect(&d, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)),
+ this, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)));
+
+ if(d.exec() == QDialog::Accepted) {
+ plugin->setSettings(d.getSettings());
+ }
}
XdxfLoadDialog.cpp \
XdxfDictDialog.cpp \
XdxfSettingsDialog.cpp \
- XdxfCachingDialog.cpp
+ XdxfCachingDialog.cpp \
+ XdxfDialog.cpp
HEADERS += \
../../include/settings.h \
../../include/CommonDictInterface.h \
XdxfSettingsDialog.h \
- XdxfCachingDialog.h
+ XdxfCachingDialog.h \
+ XdxfDialog.h
RESOURCES += \
xdxf.qrc
XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
_langFrom(""), _langTo(""),_name(""), _infoNote("") {
_settings = new Settings();
- _dictDialog = new XdxfDictDialog(this);
+ _dictDialog = new XdxfDictDialog(this, this);
+
+ connect(_dictDialog, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)),
+ this, SIGNAL(notify(Notify::NotifyType,QString, QWidget*)));
+
cachingDialog = new XdxfCachingDialog(this);
+
+
_settings->setValue("type","xdxf");
_icon = QIcon("/usr/share/mdictionary/xdxf.png");
_wordsCount = -1;