draft of settingWidget qml
authorjakub <jakub.jaszczynski@comarch.com>
Tue, 11 Jan 2011 11:11:41 +0000 (12:11 +0100)
committerjakub <jakub.jaszczynski@comarch.com>
Tue, 11 Jan 2011 11:11:41 +0000 (12:11 +0100)
src/mdictionary/gui/SettingsWidget.cpp
src/mdictionary/gui/SettingsWidget.h
src/mdictionary/gui/TranslationView.cpp
src/mdictionary/mdictionary.pro
src/mdictionary/qml/AboutWidget.qml
src/mdictionary/qml/MySpinBox.qml
src/mdictionary/qml/SettingsWidget.qml [new file with mode: 0644]

index 06226a9..ad16b4c 100644 (file)
 #include "SettingsWidget.h"
 #include <QDebug>
 
-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) {
index f6ada01..b8d9841 100644 (file)
 #include <QWidget>
 #include <QtGui>
 #include <QPushButton>
+#include <QDeclarativeView>
+
 #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;
index 84efd21..d60a2f0 100644 (file)
@@ -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();
index a055f31..fea6334 100644 (file)
@@ -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
index a8e85bc..a600d1b 100644 (file)
@@ -53,12 +53,12 @@ Rectangle {
         onLinkActivated: linkClicked(link);
     }
 
-    MySpinBox {
+  /*  MySpinBox {
         id: test01
-        y:50;
-        x:100;
+        y:20;
+        x:20;
         width: 40
         height: 20;
     }
-
+    */
 }
index e0d536b..c248bbe 100644 (file)
@@ -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(value<minValue)
+            return minValue;
+        return value;
+    }
+
     TextInput {
         id: text_input1
         x: 1
         width: rectangle1.width-15
         height: rectangle1.height*0.6;
-        text: "0"
+        text: "123"
         anchors.centerIn: parent
         validator: IntValidator{bottom: 0; top: 500;}
         transformOrigin: Item.Left
         selectByMouse: true;
         font.pixelSize: rectangle1.height * .5;
         onCursorPositionChanged:  moveCursorSelection(cursorPosition);
-        focus: rectangle1.focus;
- /*       Keys.onPressed: {
-            if ((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
-                rectangle1.enterPressed(text_input1.text)
+        //focus: rectangle1.focus;
+        onTextChanged: rectangle1.valueChange(stringToInt(text_input1.text));
+
+    }
+
+    Timer {
+        id:timerUp;
+        interval: 100;
+        running: false;
+        repeat: true
+        onTriggered:{
+            if(mouseAreaUp.pressedButtons==Qt.LeftButton)
+                text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(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)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+            else
+                running=false;
         }
-*/
     }
 
     Rectangle {
         id: shadeDisable
+        width:  parent.width;
+        height: parent.height;
         anchors.centerIn: parent;
         radius: parent.radius
         color: "grey";
         opacity: 0
-        width:  parent.width;
-        height: parent.height;
     }
 
     Image {
         id: imageUp
         z:4;
+        width: 11;
+        height: 6;
         anchors.right: parent.right
         anchors.top: parent.top
         anchors.rightMargin: 2
         anchors.topMargin: 2
-        width: 11;
-        height: 6;
-
         source: "qrc:/button/up_enable.png";
     }
 
@@ -65,38 +103,38 @@ Rectangle {
 
     MouseArea {
         id: mouseAreaUp
+        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("t1");
-            //rectangle.clicked();
+        onClicked: 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)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+        onPressAndHold:{
+            timerDown.restart;
+            timerDown.running=true;
         }
-
     }
 
-    states: [
+   /* states: [
         State {
             name: "DisableState"; when: rectangle1.enabled==false;
             PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
         }
     ]
+    */
 }
 
diff --git a/src/mdictionary/qml/SettingsWidget.qml b/src/mdictionary/qml/SettingsWidget.qml
new file mode 100644 (file)
index 0000000..df60531
--- /dev/null
@@ -0,0 +1,86 @@
+import Qt 4.7
+
+Rectangle {
+    width: 500
+    height:500
+
+    Text {
+        id: text1
+        x: 36
+        y: 11
+        width: 80
+        height: 20
+        text: "Search result size"
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: text2
+        x: 36
+        y: 83
+        width: 80
+        height: 20
+        text: "History size"
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: text3
+        x: 36
+        y: 131
+        width: 80
+        height: 20
+        text: "Search in:"
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: text4
+        x: 94
+        y: 150
+        width: 80
+        height: 20
+        text: "Bookmarks"
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: text5
+        x: 94
+        y: 177
+        width: 80
+        height: 20
+        text: "Dictionaries"
+        font.pixelSize: 12
+    }
+
+    MySpinBox {
+        id: myspinbox1
+        width: 40
+        height: 20;
+        x: 152
+        y: 9
+    }
+
+    MySpinBox {
+        id: myspinbox2
+        width: 40
+        height: 20;
+        x: 152
+        y: 81
+    }
+
+    Checkbox {
+        id: checkbox1
+        width: 20
+        x: 36
+        y: 157
+    }
+
+    Checkbox {
+        id: checkbox2
+        width: 20
+        x: 36
+        y: 177
+    }
+}