From ac86fa7a460e6fb10126eb63372d18a5dd1e1f4d Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 4 Jan 2011 13:02:25 +0100 Subject: [PATCH] draft of spinbox --- data/button/down_enable.png | Bin 0 -> 315 bytes data/button/up_enable.png | Bin 0 -> 317 bytes data/gui.qrc | 2 + src/mdictionary/gui/AboutWidget.cpp | 8 +-- src/mdictionary/gui/SearchBarWidget.cpp | 4 +- src/mdictionary/mdictionary.pro | 5 +- src/mdictionary/qml/AboutWidget.qml | 9 +++ src/mdictionary/qml/IconButton.qml | 6 +- src/mdictionary/qml/MySpinBox.qml | 102 +++++++++++++++++++++++++++++++ 9 files changed, 123 insertions(+), 13 deletions(-) create mode 100644 data/button/down_enable.png create mode 100644 data/button/up_enable.png create mode 100644 src/mdictionary/qml/MySpinBox.qml diff --git a/data/button/down_enable.png b/data/button/down_enable.png new file mode 100644 index 0000000000000000000000000000000000000000..8cae7837ca15d8eb9c2a4c2d1c85d372f7e50609 GIT binary patch literal 315 zcmeAS@N?(olHy`uVBq!ia0vp^+(696!3-po-b^_Kq!^2X+?^QKos)S9SF ziz_E5$I#HQxVX5yyu7=+ySKM@(xge#rcIkOXAUzopr0LSF ziz_E5$I#HQxVX5yyu7=+ySKM@(xge#rcIkOXAUirJk`7t)^c3(ZE6+LH!N9=0g+bNj)w9h&r3{{~elF{r5}E*= CQ*B`Y literal 0 HcmV?d00001 diff --git a/data/gui.qrc b/data/gui.qrc index 94cfba9..604d56a 100644 --- a/data/gui.qrc +++ b/data/gui.qrc @@ -27,5 +27,7 @@ button/go-next.png button/go-show.png button/go-clear.png + button/up_enable.png + button/down_enable.png diff --git a/src/mdictionary/gui/AboutWidget.cpp b/src/mdictionary/gui/AboutWidget.cpp index 1d0516e..aeea848 100644 --- a/src/mdictionary/gui/AboutWidget.cpp +++ b/src/mdictionary/gui/AboutWidget.cpp @@ -35,17 +35,11 @@ AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent) resize(380,450); view= new QDeclarativeView(); - view->setSource(QUrl("src/mdictionary/qml/AboutWidget.qml")); + view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/AboutWidget.qml")); view->setResizeMode(QDeclarativeView::SizeRootObjectToView); view->setAlignment(Qt::AlignCenter); view->show(); - /* QDeclarativeView *view2 = new QDeclarativeView(); - view2->setSource(QUrl("src/mdictionary/qml/TranslationView.qml")); - view2->setResizeMode(QDeclarativeView::SizeRootObjectToView); - view2->setAlignment(Qt::AlignCenter); - view2->show(); -*/ mainLayout = new QVBoxLayout; mainLayout->addWidget(view); diff --git a/src/mdictionary/gui/SearchBarWidget.cpp b/src/mdictionary/gui/SearchBarWidget.cpp index 95e2543..9dc1450 100644 --- a/src/mdictionary/gui/SearchBarWidget.cpp +++ b/src/mdictionary/gui/SearchBarWidget.cpp @@ -39,13 +39,13 @@ SearchBarWidget::SearchBarWidget(QWidget *parent) : QWidget(parent) { busyTimer=new QTimer; progressBar = new QDeclarativeView(); - progressBar->setSource(QUrl("src/mdictionary/qml/ProgressBar.qml")); + progressBar->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/ProgressBar.qml")); progressBar->setResizeMode(QDeclarativeView::SizeRootObjectToView); progressBar->setAlignment(Qt::AlignCenter); progressBar->hide(); view= new QDeclarativeView(); - view->setSource(QUrl("src/mdictionary/qml/SearchBarWidget.qml")); + view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/SearchBarWidget.qml")); view->setResizeMode(QDeclarativeView::SizeRootObjectToView); view->setAlignment(Qt::AlignCenter); view->show(); diff --git a/src/mdictionary/mdictionary.pro b/src/mdictionary/mdictionary.pro index 6062abc..a055f31 100644 --- a/src/mdictionary/mdictionary.pro +++ b/src/mdictionary/mdictionary.pro @@ -95,8 +95,8 @@ OTHER_FILES += \ qml/TranslationView.qml \ qml/FlickableWebView.qml \ qml/ScrollBar.qml \ - qml/SpinBox.qml \ - qml/Checkbox.qml + qml/Checkbox.qml \ + qml/MySpinBox.qml target.path = $$BIN_DIR INSTALLS += target @@ -200,6 +200,7 @@ unix { qmls.files += ./qml/FlickableWebView.qml qmls.files += ./qml/ScrollBar.qml qmls.files += ./qml/Checkbox.qml + qmls.files += ./qml/MySpinBox.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 92c6d07..a8e85bc 100644 --- a/src/mdictionary/qml/AboutWidget.qml +++ b/src/mdictionary/qml/AboutWidget.qml @@ -52,4 +52,13 @@ Rectangle { anchors.horizontalCenterOffset: 0 onLinkActivated: linkClicked(link); } + + MySpinBox { + id: test01 + y:50; + x:100; + width: 40 + height: 20; + } + } diff --git a/src/mdictionary/qml/IconButton.qml b/src/mdictionary/qml/IconButton.qml index 7fc32ea..dc749a4 100644 --- a/src/mdictionary/qml/IconButton.qml +++ b/src/mdictionary/qml/IconButton.qml @@ -4,6 +4,8 @@ Rectangle { id: rectangle property alias pathToIcon: image.source; + property int iconWidth:rectangle.width; + property int iconHeight:rectangle.height; signal clicked; radius: 50 @@ -22,8 +24,8 @@ Rectangle { id: image z:4; anchors.centerIn: parent - width: rectangle.width; - height: rectangle.height; + width: iconWidth; + height: iconHeight; } Image { diff --git a/src/mdictionary/qml/MySpinBox.qml b/src/mdictionary/qml/MySpinBox.qml new file mode 100644 index 0000000..e0d536b --- /dev/null +++ b/src/mdictionary/qml/MySpinBox.qml @@ -0,0 +1,102 @@ +import Qt 4.7 + +Rectangle { + id: rectangle1 + radius: 10 + border.color: "#000666"; + property int maxValue:500; + property int minValue:0; + property alias value:text_input1.text + + TextInput { + id: text_input1 + x: 1 + width: rectangle1.width-15 + height: rectangle1.height*0.6; + text: "0" + 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) + } +*/ + } + + Rectangle { + id: shadeDisable + anchors.centerIn: parent; + radius: parent.radius + color: "grey"; + opacity: 0 + width: parent.width; + height: parent.height; + } + + Image { + id: imageUp + z:4; + anchors.right: parent.right + anchors.top: parent.top + anchors.rightMargin: 2 + anchors.topMargin: 2 + width: 11; + height: 6; + + source: "qrc:/button/up_enable.png"; + } + + Image { + id: imageDown + z:4; + width: 11; + height: 6; + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.rightMargin: 2 + anchors.bottomMargin: 2 + source: "qrc:/button/down_enable.png"; + } + + MouseArea { + id: mouseAreaUp + 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(); + } + } + + MouseArea { + id: mouseAreaDown + 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(); + } + + } + + states: [ + State { + name: "DisableState"; when: rectangle1.enabled==false; + PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 } + } + ] +} + -- 1.7.9.5