Some changes in xdxf dialogs
[mdictionary] / src / plugins / xdxf / XdxfSettingsDialog.cpp
index 7143737..fa262a8 100644 (file)
@@ -21,7 +21,7 @@
 
 /*! \file XdxfSettingsDialog.cpp
 */
-//Created by Mateusz Półrola
+
 
 #include "XdxfSettingsDialog.h"
 #include <QDebug>
@@ -30,8 +30,11 @@ XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
     QDialog(parent)
 {
     this->plugin = plugin;
-    verticalLayout = new QVBoxLayout();
-       setLayout(verticalLayout);
+
+    verticalLayout = new QVBoxLayout;
+
+    QWidget* w = new QWidget;
+    w->setLayout(verticalLayout);
 
     setWindowTitle(tr("XDXF Settings"));
 
@@ -41,33 +44,24 @@ XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
     infoLabel->setText(tr("Plugin: ") + plugin->type().toUpper() +"\n" +
                    tr("From: ") + plugin->langFrom() + "\n" +
                    tr("To: ") + plugin->langTo() + "\n" +
-                   tr("Description: ") + plugin->name());
-
-    verticalLayout->addWidget(infoLabel);
-
-    browseLayout = new QHBoxLayout();
-    verticalLayout->addLayout(browseLayout);
-
-    browseButton =  new QPushButton(tr("Browse"));
-    browseLabel = new QLabel(tr("Dictionary file: ") +
-                             plugin->settings()->value("path"));
+                   tr("Description: ") + plugin->name() + "\n" +
+                   tr("License: ") + plugin->infoNote());
+    infoLabel->setWordWrap(true);
 
-    browseLayout->addWidget(browseLabel);
-    browseLayout->addWidget(browseButton,0, Qt::AlignRight);
 
+    verticalLayout->addWidget(infoLabel);
 
-    cacheLayout = new QHBoxLayout();
-    verticalLayout->insertLayout(-1,cacheLayout,0);
-    accentsCheckBox = new QCheckBox(tr("Strip accents \n(searching takes more time, "
-                 "but spelling don't have to be exact)"));
-    verticalLayout->addWidget(accentsCheckBox);
 
+    accentsCheckBox = new QCheckBox(tr("Strip accents"));
+    /*(searching takes more time, "
+                     "but spelling don't have to be exact)*/
     if(plugin->settings()->value("strip_accents") == "true")
         accentsCheckBox->setChecked(true);
     else
         accentsCheckBox->setChecked(false);
 
-    cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches (may take some time)"),this);
+    cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches"));
+/*(may take some time)*/
     if(plugin->settings()->value("cached") == "true") {
         cacheCheckBox->setChecked(true);
         accentsCheckBox->setChecked(true);
@@ -79,16 +73,44 @@ XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
         _generateCache = false;
     }
 
+    accentsToolButton = new QToolButton;
+    cacheToolButton = new QToolButton;
+
+    accentsToolButton->setIcon(QIcon::fromTheme("general_information"));
+    cacheToolButton->setIcon(QIcon::fromTheme("general_information"));
+
+    cacheLayout = new QHBoxLayout;
+    accentsLayout = new QHBoxLayout;
+
+    accentsLayout->addWidget(accentsCheckBox);
+    accentsLayout->addWidget(accentsToolButton);
+
     cacheLayout->addWidget(cacheCheckBox);
+    cacheLayout->addWidget(cacheToolButton);
+
+    verticalLayout->addLayout(cacheLayout);
+    verticalLayout->addLayout(accentsLayout);
+
+
 
     saveButton = new QPushButton(tr("Save settings"));
 
     verticalLayout->addWidget(saveButton);
 
-    setModal(true);
+    scrollArea = new QScrollArea;
+    scrollArea->setWidget(w);
+
+
+    QHBoxLayout* layout = new QHBoxLayout();
+
+    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    scrollArea->setWidgetResizable(true);
+    layout->addWidget(scrollArea);
+    setLayout(layout);
 
-    connect(browseButton, SIGNAL(clicked()),
-            this, SLOT(selectFile()));
+
+
+    setModal(true);
 
     connect(saveButton, SIGNAL(clicked()),
             this, SLOT(accept()));
@@ -108,7 +130,6 @@ void XdxfSettingsDialog::setAccents(bool state) {
     lastAccents = state;
 }
 
-
 void XdxfSettingsDialog::setGenerateCache(bool generate) {
     _generateCache = generate;
 
@@ -124,19 +145,6 @@ bool XdxfSettingsDialog::generateCache() {
     return _generateCache;
 }
 
-void XdxfSettingsDialog::selectFile() {
-    QString fileName = QFileDialog::getOpenFileName(this,
-                                     tr("Select dictionary file"),
-                                     "",
-                                     tr("XDXF Files (*.xdxf)"),
-                                     NULL,
-                                     NULL);
-    if (!fileName.isEmpty()) {
-        browseLabel->setText(tr("Dictionary file: ") + fileName);
-        _dicitonaryFilePath = fileName;
-    }    
-}
-
 QString XdxfSettingsDialog::dicitonaryFilePath() {
     return _dicitonaryFilePath;
 }