Partialy refactorized, fixed some bugs
[mdictionary] / trunk / src / base / gui / SettingsWidget.cpp
index ce21f4f..25ccc90 100644 (file)
@@ -19,7 +19,8 @@
 
 *******************************************************************************/
 
-//Created by Mateusz Półrola
+//! \file SettingsWidget.cpp
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #include "SettingsWidget.h"
 #include <QDebug>
@@ -31,26 +32,34 @@ SettingsWidget::SettingsWidget(GUIInterface *parent) :
 
     setWindowTitle(tr("Settings"));
 
+    initalizeUI();
+}
+
+void SettingsWidget::initalizeUI() {
     verticalLayout = new QVBoxLayout;
     setLayout(verticalLayout);
 
     historySizeSpinBox = new QSpinBox;
     searchResultSizeSpinBox = new QSpinBox;
+
     limitTip = "Limit maximal number of finded words, affect only when "
-                "searching in file.";
+                "searching in file";
     searchResultSizeSpinBox->setToolTip(limitTip);
 
-    spinBoxesFormLayout = new QFormLayout;
 
+    spinBoxesFormLayout = new QFormLayout;
     spinBoxesFormLayout->addRow(tr("Search result size"),
                                 searchResultSizeSpinBox);
-
     spinBoxesFormLayout->addRow(tr("History size"),
                                 historySizeSpinBox);
 
     searchResultSizeSpinBox->setMinimum(0);
+    searchResultSizeSpinBox->setSpecialValueText(tr("Unlimited"));
     historySizeSpinBox->setMinimum(1);
 
+    searchResultSizeSpinBox->setMaximum(500);
+    historySizeSpinBox->setMaximum(50);
+
     #ifdef Q_WS_MAEMO_5
         verticalLayout->addSpacing(20);
     #endif
@@ -97,6 +106,7 @@ void SettingsWidget::showEvent(QShowEvent *e) {
    #ifndef Q_WS_MAEMO_5
        _save = false;
    #endif
+
    settings = guiInterface->settings();
 
    historySizeSpinBox->setValue(
@@ -123,10 +133,12 @@ void SettingsWidget::hideEvent(QHideEvent *e) {
     QDialog::hideEvent(e);
 
     #ifndef Q_WS_MAEMO_5
-    if(settings && _save) {
+        if(settings && _save) {
     #else
-    if(settings && _changed &&
-            QMessageBox::question(this, tr("Save"), tr("Do you want to save changes?"),
+        if(settings && _changed &&
+           QMessageBox::question(this,
+                                 tr("Save"),
+                                 tr("Do you want to save changes?"),
              QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
 
     #endif