guiInterface = parent;
-/*
#ifndef Q_WS_MAEMO_5
view= new QDeclarativeView();
view->setAlignment(Qt::AlignCenter);
view->show();
+ view->setMinimumWidth(250);
+ view->setMaximumWidth(250);
+ view->setMinimumHeight(view->sizeHint().height());
+ view->setMaximumHeight(view->sizeHint().height());
+
mainLayout = new QVBoxLayout;
mainLayout->addWidget(view);
setLayout(mainLayout);
+ view->setWindowTitle(tr("Settings"));
QGraphicsObject *rootObject = view->rootObject();
- // connect(this, SIGNAL(setUrl(QVariant)),
- // rootObject, SLOT(setUrl(QVariant)));
- view->setWindowTitle(tr("Settings"));
+ connect(this, SIGNAL(setMinHistory(QVariant)),
+ rootObject, SLOT(setMinHistory(QVariant)));
+ connect(this, SIGNAL(setValueHistory(QVariant)),
+ rootObject, SLOT(setValueHistory(QVariant)));
+ connect(this, SIGNAL(setMaxHistory(QVariant)),
+ rootObject, SLOT(setMaxHistory(QVariant)));
+ connect(this, SIGNAL(setMinSearchResult(QVariant)),
+ rootObject, SLOT(setMinSearchResult(QVariant)));
+ connect(this, SIGNAL(setValueSearchResult(QVariant)),
+ rootObject, SLOT(setValueSearchResult(QVariant)));
+ connect(this, SIGNAL(setMaxSearchResult(QVariant)),
+ rootObject, SLOT(setMaxSearchResult(QVariant)));
+ connect(this, SIGNAL(setCheckedBookmarks(QVariant)),
+ rootObject, SLOT(setCheckedBookmarks(QVariant)));
+ connect(this, SIGNAL(setCheckedDictionaries(QVariant)),
+ rootObject, SLOT(setCheckedDictionaries(QVariant)));
+
+ connect(rootObject, SIGNAL(historySizeValueChanged(int)),
+ this, SLOT(historySizeValueChanged(int)));
+ connect(rootObject, SIGNAL(searchResulValueChanged(int)),
+ this, SLOT(searchResulValueChanged(int)));
+ connect(rootObject, SIGNAL(dictionariesCheckBoxChanged(bool)),
+ this, SLOT(dictionariesCheckBoxChanged(bool)));
+ connect(rootObject, SIGNAL(bookmarksCheckBoxChanged(bool)),
+ this, SLOT(bookmarksCheckBoxChanged(bool)));
+ connect(rootObject, SIGNAL(saveButtonClicked()),
+ this, SLOT(save()));
#else
-// */
setWindowTitle(tr("Settings"));
- initalizeUI();
setModal(true);
-//#endif
+#endif
+
+ initalizeUI();
+}
+
+void SettingsWidget::historySizeValueChanged(int value){
+ historyValue = value;
+ changed();
+}
+
+void SettingsWidget::searchResulValueChanged(int value){
+ searchResultValue=value;
+ changed();
+}
+
+void SettingsWidget::dictionariesCheckBoxChanged(bool boolean){
+ dictionariesCheckBox=boolean;
+ changed();
+}
+
+void SettingsWidget::bookmarksCheckBoxChanged(bool boolean){
+ bookmarksCheckBox=boolean;
+ changed();
}
void SettingsWidget::initalizeUI() {
+#ifndef Q_WS_MAEMO_5
+ emit setMinHistory(1);
+ emit setMaxHistory(50);
+ emit setMinHistory(0);
+ emit setMaxHistory(500);
+ settings = 0;
+#else
verticalLayout = new QVBoxLayout;
- setLayout(verticalLayout);
-
historySizeLayout = new QHBoxLayout;
-
historySizeSpinBox = new SpinBox;
+ searchResultLayout = new QHBoxLayout;
+ searchResultSizeSpinBox = new SpinBox;
+ searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
+ searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
+
historySizeSpinBox->setMinimum(1);
historySizeSpinBox->setMaximum(50);
-
historySizeToolTip = tr("Limits maximum number of words saved in history");
+ historySizeLayout->addWidget(historySizeSpinBox);
#ifdef Q_WS_MAEMO_5
historySizeInfoToolButton = new QToolButton;
historySizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
- #endif
-
- historySizeLayout->addWidget(historySizeSpinBox);
- #ifdef Q_WS_MAEMO_5
historySizeLayout->addWidget(historySizeInfoToolButton);
+ searchResultSizeInfoToolButton = new QToolButton;
+ searchResultSizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
#endif
-
-
-
- searchResultLayout = new QHBoxLayout;
-
- searchResultSizeSpinBox = new SpinBox;
searchResultSizeSpinBox->setMinimum(0);
searchResultSizeSpinBox->setMaximum(500);
searchResultSizeSpinBox->setSpecialValueText(tr("Unlimited"));
-
searchResultSizeToolTip = tr("Limits maximum number of found words, affects"
" only when searching in file.");
-
- #ifdef Q_WS_MAEMO_5
- searchResultSizeInfoToolButton = new QToolButton;
- searchResultSizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
- #endif
-
searchResultLayout->addWidget(searchResultSizeSpinBox);
+
#ifdef Q_WS_MAEMO_5
searchResultLayout->addWidget(searchResultSizeInfoToolButton);
#endif
-
-
-
-
spinBoxesFormLayout = new QFormLayout;
- spinBoxesFormLayout->addRow(tr("Search result size"),
- searchResultLayout);
- spinBoxesFormLayout->addRow(tr("History size"),
- historySizeLayout);
-
-
-
+ spinBoxesFormLayout->addRow(tr("Search result size"), searchResultLayout);
+ spinBoxesFormLayout->addRow(tr("History size"), historySizeLayout);
verticalLayout->addLayout(spinBoxesFormLayout);
-
-
checkBoxesLabel = new QLabel(tr("Search in:"),this);
- searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
- searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
-
verticalLayout->addSpacing(20);
verticalLayout->addWidget(checkBoxesLabel);
verticalLayout->addWidget(searchInDictionariesCheckBox);
verticalLayout->addWidget(searchInBookmarksCheckBox);
+ setLayout(verticalLayout);
- connect(historySizeSpinBox, SIGNAL(valueChanged(int)), this,
- SLOT(changed()));
- connect(searchResultSizeSpinBox, SIGNAL(valueChanged(int)), this,
- SLOT(changed()));
- connect(searchInDictionariesCheckBox, SIGNAL(toggled(bool)), this,
- SLOT(changed()));
- connect(searchInBookmarksCheckBox, SIGNAL(toggled(bool)), this,
- SLOT(changed()));
-
+ connect(historySizeSpinBox, SIGNAL(valueChanged(int)),
+ this,SLOT(changed()));
+ connect(searchResultSizeSpinBox, SIGNAL(valueChanged(int)),
+ this,SLOT(changed()));
+ connect(searchInDictionariesCheckBox, SIGNAL(toggled(bool)),
+ this,SLOT(changed()));
+ connect(searchInBookmarksCheckBox, SIGNAL(toggled(bool)),
+ this,SLOT(changed()));
-#ifdef Q_WS_MAEMO_5
+ #ifdef Q_WS_MAEMO_5
connect(searchResultSizeInfoToolButton, SIGNAL(clicked()),
this, SLOT(showSearchResultSizeInfo()));
-
connect(historySizeInfoToolButton, SIGNAL(clicked()),
this, SLOT(showHistorySizeInfo()));
-#else
+ #else
historySizeSpinBox->setToolTip(historySizeToolTip);
searchResultSizeSpinBox->setToolTip(searchResultSizeToolTip);
-#endif
+ #endif
settings = 0;
setMaximumHeight(sizeHint().height());
connect(closeButton, SIGNAL(clicked()), this, SLOT(save()));
#endif
+#endif
}
void SettingsWidget::showEvent(QShowEvent *e) {
-/*
#ifndef Q_WS_MAEMO_5
+ settings = guiInterface->settings();
+
+ emit setValueHistory(settings->value("history_size").toInt());
+ emit setValueSearchResult(settings->value("search_limit").toInt());
+
+ if(settings->value("search_bookmarks") == "true")
+ emit setCheckedBookmarks(true);
+ else
+ emit setCheckedBookmarks(false);
+
+ if(settings->value("search_dictionaries") == "true")
+ emit setCheckedDictionaries(true);
+ else
+ emit setCheckedDictionaries(false);
+
QDialog::showEvent(e);
#else
-//*/
#ifndef Q_WS_MAEMO_5
_save = false;
#endif
searchInDictionariesCheckBox->setChecked(true);
else
searchInDictionariesCheckBox->setChecked(false);
-
- _changed = false;
QDialog::showEvent(e);
-//#endif
+#endif
+ _changed = false;
}
void SettingsWidget::hideEvent(QHideEvent *e) {
QDialog::hideEvent(e);
- #ifndef Q_WS_MAEMO_5
- if(settings && _save) {
- #else
- if(settings && _changed &&
- QMessageBox::question(this,
- tr("Save"),
- tr("Do you want to save changes?"),
- QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
+#ifndef Q_WS_MAEMO_5
+ if(settings && _save) {
+ Settings* newSettings = new Settings;
+ newSettings->setValue("history_size",QString::number(historyValue));
+ newSettings->setValue("search_limit",QString::number(searchResultValue));
+ if(dictionariesCheckBox==true)
+ newSettings->setValue("search_dictionaries", "true");
+ else
+ newSettings->setValue("search_dictionaries", "false");
+
+ if(bookmarksCheckBox==true)
+ newSettings->setValue("search_bookmarks", "true");
+ else
+ newSettings->setValue("search_bookmarks", "false");
+ foreach(QString key, newSettings->keys()) {
+ if(settings->value(key) != newSettings->value(key)) {
+ guiInterface->setSettings(newSettings);
+ break;
+ }
+ }
+ _changed = false;
+ if(settings) {
+ delete settings;
+ settings = 0;
+ }
+ }
+#else
+ if(settings && _changed &&
+ QMessageBox::question(this,
+ tr("Save"),
+ tr("Do you want to save changes?"),
+ QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
- #endif
Settings* newSettings = new Settings;
newSettings->setValue("history_size",
QString::number(historySizeSpinBox->value()));
newSettings->setValue("search_bookmarks", "false");
//setting new settings only if they are different than old ones
- QString key;
- foreach(key, newSettings->keys()) {
+ foreach(QString key, newSettings->keys()) {
if(settings->value(key) != newSettings->value(key)) {
guiInterface->setSettings(newSettings);
break;
}
}
-
}
if(settings) {
delete settings;
settings = 0;
}
_changed = false;
+#endif
}
import Qt 4.7
Rectangle {
- width: 500
- height:500
+ id: rectangle1
+ width: 230
+ height:170
+
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+ color : myPalette.window;
+
+ signal historySizeValueChanged(int intiger);
+ signal searchResulValueChanged(int intiger);
+ signal dictionariesCheckBoxChanged(bool Boolean);
+ signal bookmarksCheckBoxChanged(bool Boolean);
+ signal saveButtonClicked();
+
+ function setMinHistory(intiger){
+ historySpinbox.minValue=intiger;
+ }
+ function setMaxHistory(intiger){
+ historySpinbox.maxValue=intiger;
+ }
+ function setValueHistory(intiger){
+ historySpinbox.value=intiger;
+ }
+
+ function setMaxSearchResult(intiger){
+ searchSpinbox.maxValue=intiger;
+ }
+ function setMinSearchResult(intiger){
+ searchSpinbox.minValue=intiger;
+ }
+ function setValueSearchResult(intiger){
+ searchSpinbox.value=intiger;
+ }
+
+ function setCheckedBookmarks(bool){
+ bookmarkCheckBox.selected=bool;
+ }
+ function setCheckedDictionaries(bool){
+ dictionariesCheckBox.selected=bool;
+ }
Text {
- id: text1
- x: 36
- y: 11
- width: 80
- height: 20
- text: "Search result size"
+ id: textSearch
+ width: 120
+ height: paintedHeight+5;
+ text: qsTr("Search result size")
+ anchors.verticalCenterOffset: 2
+ anchors.left: parent.left
+ anchors.verticalCenter: searchSpinbox.verticalCenter
font.pixelSize: 12
}
Text {
- id: text2
- x: 36
- y: 83
- width: 80
- height: 20
- text: "History size"
+ id: textHistory
+ width: 120
+ height: paintedHeight+5;
+ text: qsTr("History size")
+ anchors.verticalCenterOffset: 2
+ anchors.left: parent.left
+ anchors.verticalCenter: historySpinbox.verticalCenter
font.pixelSize: 12
}
Text {
- id: text3
- x: 36
- y: 131
- width: 80
- height: 20
- text: "Search in:"
+ id: textSearchIn
+ width: 120
+ height: paintedHeight+5;
+ text: qsTr("Search in:")
+ anchors.top: textHistory.bottom
+ anchors.topMargin: 15
+ anchors.left: parent.left
font.pixelSize: 12
}
Text {
- id: text4
- x: 94
- y: 150
- width: 80
+ id: textBookmark
+ width: 120
height: 20
- text: "Bookmarks"
+ text: qsTr("Bookmarks")
+ anchors.verticalCenterOffset: 2
+ anchors.left: bookmarkCheckBox.right
+ anchors.leftMargin: 10
+ anchors.verticalCenter: bookmarkCheckBox.verticalCenter
font.pixelSize: 12
}
Text {
- id: text5
- x: 94
- y: 177
- width: 80
+ id: textDictionaries
+ width: 120
height: 20
- text: "Dictionaries"
+ text: qsTr("Dictionaries")
+ anchors.verticalCenterOffset: 2
+ anchors.left: dictionariesCheckBox.right
+ anchors.leftMargin: 10
+ anchors.verticalCenter: dictionariesCheckBox.verticalCenter
font.pixelSize: 12
}
MySpinBox {
- id: myspinbox1
+ id: searchSpinbox
width: 40
height: 20;
- x: 152
- y: 9
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.left: textSearch.right
+ anchors.leftMargin: 20
+ onValueChange: rectangle1.searchResulValueChanged(intiger);
}
MySpinBox {
- id: myspinbox2
+ id: historySpinbox
width: 40
height: 20;
- x: 152
- y: 81
+ anchors.horizontalCenter: searchSpinbox.horizontalCenter
+ anchors.top: searchSpinbox.bottom
+ anchors.topMargin: 10
+ onValueChange: rectangle1.historySizeValueChanged(intiger);
}
Checkbox {
- id: checkbox1
+ id: bookmarkCheckBox
width: 20
- x: 36
- y: 157
+ height: 20
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ anchors.top: textSearchIn.bottom
+ anchors.topMargin: 0
+ onChanged: rectangle1.bookmarksCheckBoxChanged(selected);
}
Checkbox {
- id: checkbox2
+ id: dictionariesCheckBox
width: 20
- x: 36
- y: 177
+ height: 20
+ anchors.horizontalCenter: bookmarkCheckBox.horizontalCenter
+ anchors.top: bookmarkCheckBox.bottom
+ anchors.topMargin: 3
+ onChanged: rectangle1.dictionariesCheckBoxChanged(selected);
+ }
+
+ Button {
+ id: saveButton
+ width: 66
+ height:26
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 5
+ anchors.right: parent.right
+ anchors.rightMargin: 5
+ textInButton: qsTr("Save")
+ onClicked: rectangle1.saveButtonClicked();
}
}