1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
22 //Created by Mateusz Półrola
24 #include "XdxfSettingsDialog.h"
26 XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
29 this->plugin = plugin;
30 verticalLayout = new QVBoxLayout;
31 setLayout(verticalLayout);
33 setWindowTitle(tr("XDXF Settings"));
36 infoLabel = new QLabel;
38 infoLabel->setText(tr("Plugin type: ") + plugin->type() +"\n" +
39 tr("From: ") + plugin->langFrom() + "\n" +
40 tr("To: ") + plugin->langTo() + "\n" +
41 tr("Description: ") + plugin->name());
43 verticalLayout->addWidget(infoLabel);
45 browseLayout = new QHBoxLayout;
46 verticalLayout->addLayout(browseLayout);
48 browseButton = new QPushButton(tr("Browse"));
49 browseLabel = new QLabel(tr("Dictionary file: ") +
50 plugin->settings()->value("path"));
52 browseLayout->addWidget(browseLabel);
53 browseLayout->addWidget(browseButton,0, Qt::AlignRight);
56 cacheLayout = new QHBoxLayout;
57 verticalLayout->addLayout(cacheLayout);
59 cacheButton = new QPushButton(tr("Cache"));
60 if(plugin->settings()->value("Cached") == "true") {
61 cacheButton->setEnabled(false);
64 cacheLayout->addWidget(cacheButton);
66 saveButton = new QPushButton(tr("Save settings"));
68 verticalLayout->addWidget(saveButton);
72 connect(browseButton, SIGNAL(clicked()),
73 this, SLOT(selectFile()));
75 connect(saveButton, SIGNAL(clicked()),
76 this, SLOT(accept()));
78 _dicitonaryFilePath = plugin->settings()->value("path");
81 void XdxfSettingsDialog::selectFile() {
82 QString fileName = QFileDialog::getOpenFileName(this,
83 tr("Select dictionary file"),
85 tr("XDXF Files (*.xdxf)"),
88 if (!fileName.isEmpty()) {
89 browseLabel->setText(tr("Dictionary file: ") + fileName);
90 _dicitonaryFilePath = fileName;
94 QString XdxfSettingsDialog::dicitonaryFilePath() {
95 return _dicitonaryFilePath;
98 Settings* XdxfSettingsDialog::getSettings(XdxfPlugin *plugin,
100 XdxfSettingsDialog settingsDialog(plugin, parent);
103 if(settingsDialog.exec()==QDialog::Accepted) {
104 Settings* settings = new Settings;
105 foreach(QString key, plugin->settings()->keys())
106 settings->setValue(key, plugin->settings()->value(key));
107 settings->setValue("path", settingsDialog.dicitonaryFilePath());
108 plugin->setSettings(settings);