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 /*! \file XdxfLoadDialog.cpp
24 //Created by Mateusz Półrola
26 #include "XdxfLoadDialog.h"
28 XdxfLoadDialog::XdxfLoadDialog(QWidget *parent) :
30 verticalLayout = new QVBoxLayout(this);
31 setLayout(verticalLayout);
33 setWindowTitle(tr("Add new XDXF dictionary"));
35 browseLayout = new QHBoxLayout(this);
36 verticalLayout->addLayout(browseLayout);
38 browseButton = new QPushButton(tr("Browse"),this);
39 browseLabel = new QLabel(tr("Dictionary file: not selected"),this);
41 browseLayout->addWidget(browseLabel);
42 browseLayout->addWidget(browseButton,0, Qt::AlignRight);
45 cacheLayout = new QHBoxLayout(this);
46 verticalLayout->addLayout(cacheLayout);
48 cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches (may take some time)"),this);
49 cacheCheckBox->setChecked(true);
50 cacheLayout->addWidget(cacheCheckBox);
52 addButton = new QPushButton(tr("Add"),this);
54 verticalLayout->addWidget(addButton);
58 connect(browseButton, SIGNAL(clicked()),
59 this, SLOT(selectFile()));
61 connect(addButton, SIGNAL(clicked()),
62 this, SLOT(addDictionary()));
64 _dicitonaryFilePath = QString();
67 void XdxfLoadDialog::selectFile() {
68 QString fileName = QFileDialog::getOpenFileName(this,
69 tr("Select dictionary file"),
71 tr("XDXF Files (*.xdxf)"),
74 if (!fileName.isEmpty()) {
75 browseLabel->setText(tr("Dictionary file: ") + fileName);
76 _dicitonaryFilePath = fileName;
80 void XdxfLoadDialog::addDictionary() {
81 _generateCache = cacheCheckBox->isChecked();
82 if(!_dicitonaryFilePath.isEmpty()) {
90 QString XdxfLoadDialog::dicitonaryFilePath() {
91 return _dicitonaryFilePath;
94 bool XdxfLoadDialog::generateCache() {
95 return _generateCache;
98 Settings* XdxfLoadDialog::getSettings(QWidget *parent) {
99 XdxfLoadDialog loadDialog(parent);
100 Settings* settings = new Settings;
102 if(loadDialog.exec()==QDialog::Accepted) {
103 settings->setValue("path", loadDialog.dicitonaryFilePath());
104 if(loadDialog.generateCache()) {
105 settings->setValue("generateCache", "true");
108 settings->setValue("generateCache", "false");