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 "XdxfLoadDialog.h"
26 XdxfLoadDialog::XdxfLoadDialog(QWidget *parent) :
28 verticalLayout = new QVBoxLayout;
29 setLayout(verticalLayout);
31 setWindowTitle(tr("Add new XDXF dictionary"));
33 browseLayout = new QHBoxLayout;
34 verticalLayout->addLayout(browseLayout);
36 browseButton = new QPushButton(tr("Browse"));
37 browseLabel = new QLabel(tr("Dictionary file: not selected"));
39 browseLayout->addWidget(browseLabel);
40 browseLayout->addWidget(browseButton,0, Qt::AlignRight);
43 cacheLayout = new QHBoxLayout;
44 verticalLayout->addLayout(cacheLayout);
46 cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches (may take some time)"));
47 cacheCheckBox->setChecked(true);
48 cacheLayout->addWidget(cacheCheckBox);
50 addButton = new QPushButton(tr("Add"));
52 verticalLayout->addWidget(addButton);
56 connect(browseButton, SIGNAL(clicked()),
57 this, SLOT(selectFile()));
59 connect(addButton, SIGNAL(clicked()),
60 this, SLOT(addDictionary()));
62 _dicitonaryFilePath = QString();
65 void XdxfLoadDialog::selectFile() {
66 QString fileName = QFileDialog::getOpenFileName(this,
67 tr("Select dictionary file"),
69 tr("XDXF Files (*.xdxf)"),
72 if (!fileName.isEmpty()) {
73 browseLabel->setText(tr("Dictionary file: ") + fileName);
74 _dicitonaryFilePath = fileName;
78 void XdxfLoadDialog::addDictionary() {
79 _generateCache = cacheCheckBox->isChecked();
83 QString XdxfLoadDialog::dicitonaryFilePath() {
84 return _dicitonaryFilePath;
87 bool XdxfLoadDialog::generateCache() {
88 return _generateCache;
91 Settings* XdxfLoadDialog::getSettings(QWidget *parent) {
92 XdxfLoadDialog loadDialog(parent);
93 Settings* settings = new Settings;
95 if(loadDialog.exec()==QDialog::Accepted) {
96 settings->setValue("path", loadDialog.dicitonaryFilePath());
97 if(loadDialog.generateCache()) {
98 settings->setValue("cache", "true");
101 settings->setValue("cache", "false");