X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Fxdxf%2FXdxfDialog.cpp;h=dbe5ab285345d4bb25b32a68722bdfaccf6997c0;hb=34f8c22d8c25a1c46cb4278814443443ac82909c;hp=b92206f3f3fb5fe2e8d2ab0063f1aea3f3c422c9;hpb=83e95b272e7a38e986577a485de04d8841e047cc;p=mdictionary diff --git a/src/plugins/xdxf/XdxfDialog.cpp b/src/plugins/xdxf/XdxfDialog.cpp index b92206f..dbe5ab2 100644 --- a/src/plugins/xdxf/XdxfDialog.cpp +++ b/src/plugins/xdxf/XdxfDialog.cpp @@ -18,8 +18,10 @@ Copyright 2010 Comarch S.A. *******************************************************************************/ - -//Created by Mateusz Półrola +/*! + \file XdxfDialog.cpp + \author Mateusz Półrola +*/ #include "XdxfDialog.h" #include @@ -27,11 +29,10 @@ XdxfDialog::XdxfDialog(XdxfPlugin *plugin, XdxfDialogType type, QWidget *parent) : - QDialog(parent) { + QDialog(parent) { this->plugin = plugin; this->type = type; - cacheToolTip = tr("Optimize for quicker searches (may take some time)"); accentsToolTip = tr("Strip accents (searching takes more time, but spelling doesn't have to be exact)"); @@ -39,14 +40,12 @@ XdxfDialog::XdxfDialog(XdxfPlugin *plugin, connect(cacheCheckBox, SIGNAL(toggled(bool)), this, SLOT(setGenerateCache(bool))); - connect(accentsCheckBox, SIGNAL(toggled(bool)), this, SLOT(setAccents(bool))); #ifdef Q_WS_MAEMO_5 connect(accentsInfoToolButton, SIGNAL(clicked()), this, SLOT(showAccentsInfo())); - connect(cacheInfoToolButton, SIGNAL(clicked()), this, SLOT(showCacheInfo())); #endif @@ -54,19 +53,17 @@ XdxfDialog::XdxfDialog(XdxfPlugin *plugin, if(type == New) { connect(browseButton, SIGNAL(clicked()), this, SLOT(selectFile())); - connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile())); - connect(&XdxfPlugin::dictDownloader, SIGNAL(fileDownloaded(QString)), this, SLOT(fileDownloaded(QString))); } connect(confirmButton, SIGNAL(clicked()), this, SLOT(accept())); - } + void XdxfDialog::fileDownloaded(QString name) { infoLabel->setText(tr("Dictionary file: %1").arg(XdxfPlugin::dictDownloader.downloadedFile())); _dictionaryFilePath = XdxfPlugin::dictDownloader.downloadedFile(); @@ -139,7 +136,6 @@ void XdxfDialog::initializeUI() { mainVerticalLayout->addLayout(cacheLayout); mainVerticalLayout->addLayout(accentsLayout); - //load old setting if exists if(!plugin) { cacheCheckBox->setChecked(true); @@ -172,16 +168,15 @@ void XdxfDialog::initializeUI() { confirmButton = new QPushButton; mainVerticalLayout->addWidget(confirmButton); - if(type == New) { + if(type == New) confirmButton->setText(tr("Add")); - } - else { + else confirmButton->setText(tr("Save settings")); - } scrollArea = new QScrollArea; scrollArea->setWidget(widget); scrollArea->setWidgetResizable(true); + #ifdef Q_WS_MAEMO_5 scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); #else @@ -206,8 +201,6 @@ void XdxfDialog::initializeUI() { scrollArea->setLineWidth(0); scrollArea->setMidLineWidth(0); scrollArea->setFrameStyle(QFrame::NoFrame); - - } @@ -215,6 +208,7 @@ void XdxfDialog::setAccents(bool accents) { _accents = accents; } + void XdxfDialog::setGenerateCache(bool generate) { _generateCache = generate; @@ -224,10 +218,10 @@ void XdxfDialog::setGenerateCache(bool generate) { } else accentsCheckBox->setChecked(_lastAccents); - accentsCheckBox->setEnabled(!generate); } + void XdxfDialog::selectFile() { QString fileName = QFileDialog::getOpenFileName(this, tr("Select dictionary file"), @@ -235,7 +229,6 @@ void XdxfDialog::selectFile() { tr("XDXF Files (*.xdxf)"), NULL, NULL); - if (!fileName.isEmpty()) { infoLabel->setText(tr("Dictionary file: %1").arg(fileName)); _dictionaryFilePath = fileName; @@ -243,19 +236,20 @@ void XdxfDialog::selectFile() { } } + void XdxfDialog::downloadFile() { XdxfPlugin::dictDownloader.download(this); } + void XdxfDialog::saveSettings() { _settings = new Settings; if(plugin) { foreach(QString key, plugin->settings()->keys()) _settings->setValue(key, plugin->settings()->value(key)); } - else { + else _settings->setValue("path", _dictionaryFilePath); - } if(_generateCache) _settings->setValue("generateCache", "true"); @@ -268,10 +262,10 @@ void XdxfDialog::saveSettings() { _settings->setValue("strip_accents", "false"); } + void XdxfDialog::accept() { if(type == New && _dictionaryFilePath.isEmpty()) { Q_EMIT notify(Notify::Warning, tr("File path is not set")); - return; } @@ -279,15 +273,18 @@ void XdxfDialog::accept() { QDialog::accept(); } + Settings* XdxfDialog::getSettings() { return _settings; } + #ifdef Q_WS_MAEMO_5 void XdxfDialog::showCacheInfo() { Q_EMIT notify(Notify::Warning, cacheToolTip); } + void XdxfDialog::showAccentsInfo() { Q_EMIT notify(Notify::Warning, accentsToolTip); }