From f106801717e7c5485338655cd6ffe5f314fac27c Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 11 Jan 2011 12:11:41 +0100 Subject: [PATCH] draft of settingWidget qml --- src/mdictionary/gui/SettingsWidget.cpp | 37 ++++++++++-- src/mdictionary/gui/SettingsWidget.h | 7 +++ src/mdictionary/gui/TranslationView.cpp | 2 +- src/mdictionary/mdictionary.pro | 20 ++++++- src/mdictionary/qml/AboutWidget.qml | 8 +-- src/mdictionary/qml/MySpinBox.qml | 94 ++++++++++++++++++++++--------- src/mdictionary/qml/SettingsWidget.qml | 86 ++++++++++++++++++++++++++++ 7 files changed, 214 insertions(+), 40 deletions(-) create mode 100644 src/mdictionary/qml/SettingsWidget.qml diff --git a/src/mdictionary/gui/SettingsWidget.cpp b/src/mdictionary/gui/SettingsWidget.cpp index 06226a9..ad16b4c 100644 --- a/src/mdictionary/gui/SettingsWidget.cpp +++ b/src/mdictionary/gui/SettingsWidget.cpp @@ -27,16 +27,35 @@ #include "SettingsWidget.h" #include -SettingsWidget::SettingsWidget(GUIInterface *parent) : - QDialog(parent) -{ - guiInterface = parent; +SettingsWidget::SettingsWidget(GUIInterface *parent) : QDialog(parent) { - setWindowTitle(tr("Settings")); +guiInterface = parent; - initalizeUI(); +/* +#ifndef Q_WS_MAEMO_5 + + view= new QDeclarativeView(); + view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/SettingsWidget.qml")); + view->setResizeMode(QDeclarativeView::SizeRootObjectToView); + view->setAlignment(Qt::AlignCenter); + view->show(); + + mainLayout = new QVBoxLayout; + mainLayout->addWidget(view); + setLayout(mainLayout); + + QGraphicsObject *rootObject = view->rootObject(); + + // connect(this, SIGNAL(setUrl(QVariant)), + // rootObject, SLOT(setUrl(QVariant))); + view->setWindowTitle(tr("Settings")); +#else +// */ + setWindowTitle(tr("Settings")); + initalizeUI(); setModal(true); +//#endif } void SettingsWidget::initalizeUI() { @@ -152,6 +171,11 @@ void SettingsWidget::initalizeUI() { void SettingsWidget::showEvent(QShowEvent *e) { +/* +#ifndef Q_WS_MAEMO_5 + QDialog::showEvent(e); +#else +//*/ #ifndef Q_WS_MAEMO_5 _save = false; #endif @@ -176,6 +200,7 @@ void SettingsWidget::showEvent(QShowEvent *e) { _changed = false; QDialog::showEvent(e); +//#endif } void SettingsWidget::hideEvent(QHideEvent *e) { diff --git a/src/mdictionary/gui/SettingsWidget.h b/src/mdictionary/gui/SettingsWidget.h index f6ada01..b8d9841 100644 --- a/src/mdictionary/gui/SettingsWidget.h +++ b/src/mdictionary/gui/SettingsWidget.h @@ -30,10 +30,13 @@ #include #include #include +#include + #include "../../include/GUIInterface.h" #include "../../include/settings.h" #include "SpinBox.h" + /*! Shows settings that user can change. It allows to change limit of searches and limit of history. @@ -72,6 +75,10 @@ private Q_SLOTS: private: void initalizeUI(); + + QVBoxLayout* mainLayout; + QDeclarativeView *view; + SpinBox* historySizeSpinBox; SpinBox* searchResultSizeSpinBox; QVBoxLayout* verticalLayout; diff --git a/src/mdictionary/gui/TranslationView.cpp b/src/mdictionary/gui/TranslationView.cpp index 84efd21..d60a2f0 100644 --- a/src/mdictionary/gui/TranslationView.cpp +++ b/src/mdictionary/gui/TranslationView.cpp @@ -36,7 +36,7 @@ TranslationView::TranslationView(QWidget *parent) : QWebView(parent) { #ifndef Q_WS_MAEMO_5 view= new QDeclarativeView(); - view->setSource(QUrl("src/mdictionary/qml/TranslationView.qml")); + view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/TranslationView.qml")); view->setResizeMode(QDeclarativeView::SizeRootObjectToView); view->setAlignment(Qt::AlignCenter); view->show(); diff --git a/src/mdictionary/mdictionary.pro b/src/mdictionary/mdictionary.pro index a055f31..fea6334 100644 --- a/src/mdictionary/mdictionary.pro +++ b/src/mdictionary/mdictionary.pro @@ -96,7 +96,8 @@ OTHER_FILES += \ qml/FlickableWebView.qml \ qml/ScrollBar.qml \ qml/Checkbox.qml \ - qml/MySpinBox.qml + qml/MySpinBox.qml \ + qml/SettingsWidget.qml target.path = $$BIN_DIR INSTALLS += target @@ -178,6 +179,22 @@ unix { meego { qmls.path = $$DATA_DIR/qml qmls.files += ./qml/WelcomeScreenWidget.qml + qmls.files += ./qml/Button.qml + qmls.files += ./qml/AboutWidget.qml + qmls.files += ./qml/SearchBarWidget.qml + qmls.files += ./qml/IconButton.qml + qmls.files += ./qml/MyTextLineEdit.qml + qmls.files += ./qml/ProgressBar.qml + qmls.files += ./qml/ElementsListView.qml + qmls.files += ./qml/DictTypeSelectDialog.qml + qmls.files += ./qml/DictManagerWidget.qml + qmls.files += ./qml/WordListWidget.qml + qmls.files += ./qml/TranslationView.qml + qmls.files += ./qml/FlickableWebView.qml + qmls.files += ./qml/ScrollBar.qml + qmls.files += ./qml/Checkbox.qml + qmls.files += ./qml/MySpinBox.qml + qmls.files += ./qml/SettingsWidget.qml } else:maemo5 { qmls.path = $$DATA_DIR/qml @@ -201,6 +218,7 @@ unix { qmls.files += ./qml/ScrollBar.qml qmls.files += ./qml/Checkbox.qml qmls.files += ./qml/MySpinBox.qml + qmls.files += ./qml/SettingsWidget.qml } INSTALLS += desktop icon64 shared service css css_images qmls diff --git a/src/mdictionary/qml/AboutWidget.qml b/src/mdictionary/qml/AboutWidget.qml index a8e85bc..a600d1b 100644 --- a/src/mdictionary/qml/AboutWidget.qml +++ b/src/mdictionary/qml/AboutWidget.qml @@ -53,12 +53,12 @@ Rectangle { onLinkActivated: linkClicked(link); } - MySpinBox { + /* MySpinBox { id: test01 - y:50; - x:100; + y:20; + x:20; width: 40 height: 20; } - + */ } diff --git a/src/mdictionary/qml/MySpinBox.qml b/src/mdictionary/qml/MySpinBox.qml index e0d536b..c248bbe 100644 --- a/src/mdictionary/qml/MySpinBox.qml +++ b/src/mdictionary/qml/MySpinBox.qml @@ -8,46 +8,84 @@ Rectangle { property int minValue:0; property alias value:text_input1.text + signal valueChange(int intiger); + + function stringToInt(string){ + var value=0; + var pow10=1; + for (var i=string.length-1;i>=0;i--){ + value+=(string.charCodeAt(i)-48)*pow10; + pow10= pow10*10; + } + if(value>maxValue) + return maxValue; + if(valuemaxValue)?(maxValue):(stringToInt(text_input1.text)+1); + else + running=false; + } + } + + Timer { + id:timerDown; + interval: 100; + running: false; + repeat: true + onTriggered:{ + if(mouseAreaDown.pressedButtons==Qt.LeftButton) + text_input1.text=((stringToInt(text_input1.text)-1)maxValue)?(maxValue):(stringToInt(text_input1.text)+1); + onPressAndHold:{ + timerUp.restart; + timerUp.running=true; } } MouseArea { id: mouseAreaDown + z:5 + width: 13; + height: rectangle1.height/2; anchors.right: parent.right - anchors.top: parent.top - anchors.rightMargin: 2 - anchors.topMargin: 2 - width: 11; - height: rectangle1/2; - onClicked: { - console.log("t2"); - //rectangle.clicked(); + anchors.bottom: parent.bottom + onClicked: text_input1.text=((stringToInt(text_input1.text)-1)