From: jakub Date: Tue, 14 Dec 2010 08:36:08 +0000 (+0100) Subject: add qml-elements X-Git-Url: http://git.maemo.org/git/?p=mdictionary;a=commitdiff_plain;h=be63f2df3539bacf2ee5bf0a4f21eee5c0a18314 add qml-elements --- diff --git a/data/button/buttonCenter.png b/data/button/buttonCenter.png new file mode 100644 index 0000000..ce01680 Binary files /dev/null and b/data/button/buttonCenter.png differ diff --git a/data/button/buttonLeft.png b/data/button/buttonLeft.png new file mode 100644 index 0000000..bc7fdd1 Binary files /dev/null and b/data/button/buttonLeft.png differ diff --git a/data/button/buttonR.png b/data/button/buttonR.png new file mode 100644 index 0000000..9a826a3 Binary files /dev/null and b/data/button/buttonR.png differ diff --git a/data/gui.qrc b/data/gui.qrc index 6133b0d..376f9d7 100644 --- a/data/gui.qrc +++ b/data/gui.qrc @@ -11,5 +11,11 @@ xsl/xsl.xsl translations/en_US.qm translations/pl_PL.qm + button/buttonCenter.png + button/buttonLeft.png + button/buttonR.png + lineEdit/ramkaL.png + lineEdit/ramkaR.png + lineEdit/ramkaC.png diff --git a/src/mdictionary/gui/AboutWidget.cpp b/src/mdictionary/gui/AboutWidget.cpp index 72eb839..daae50d 100644 --- a/src/mdictionary/gui/AboutWidget.cpp +++ b/src/mdictionary/gui/AboutWidget.cpp @@ -29,6 +29,22 @@ AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent) { + setWindowTitle(tr("About")); + +#ifndef Q_WS_MAEMO_5 + resize(380,450); + mainLayout = new QVBoxLayout; + view= new QDeclarativeView(); + mainLayout->addWidget(view); + view->setSource(QUrl("src/mdictionary/qml/AboutWidget.qml")); + view->setResizeMode(QDeclarativeView::SizeRootObjectToView); + view->setAlignment(Qt::AlignCenter); + view->show(); + + QGraphicsObject *rootObject = view->rootObject(); + connect(rootObject, SIGNAL(linkClicked(QString)), this, SLOT(openUrl(QString))); + this->setLayout(mainLayout); +#else setModal(true); QString infoNote, licenseNote, comarchNote; infoNote = "

mDictionary

"; @@ -58,20 +74,8 @@ AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent) "<" "http://www.gnu.org/licenses/>." "

"); - - setWindowTitle(tr("About")); mainLayout = new QVBoxLayout; - /*on desktop we place all content in scroll area, on maemo by default all - widgets that are in menu are placed in scroll area created by menu, so we - don't have to do it here*/ - #ifndef Q_WS_MAEMO_5 - scrollLayout = new QVBoxLayout; - scroll = new QScrollArea; - w = new QWidget(this); - #endif - - imageLabel = new QLabel; mainLabel = new QLabel; licenseLabel = new QLabel; @@ -96,18 +100,11 @@ AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent) mainLayout->addWidget(mainLabel, 0, Qt::AlignHCenter); mainLayout->addWidget(licenseLabel, 0, Qt::AlignHCenter); - //add content to scroll area, and remove fram from it - #ifndef Q_WS_MAEMO_5 - w->setLayout(mainLayout); - scroll->setWidget(w); - scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scrollLayout->addWidget(scroll, 0, Qt::AlignHCenter); - this->setLayout(scrollLayout); - w->setMinimumSize(img.width()*1.6, img.height()*2.45); - scroll->setLineWidth(0); - scroll->setMidLineWidth(0); - scroll->setFrameStyle(QFrame::NoFrame);; - #else - setLayout(mainLayout); - #endif + setLayout(mainLayout); +#endif +} + + +void AboutWidget::openUrl(QString url){ + QDesktopServices::openUrl(url); } diff --git a/src/mdictionary/gui/AboutWidget.h b/src/mdictionary/gui/AboutWidget.h index 02eb383..8fee222 100644 --- a/src/mdictionary/gui/AboutWidget.h +++ b/src/mdictionary/gui/AboutWidget.h @@ -32,6 +32,9 @@ #include #include #include +#include +#include + #include "../../include/GUIInterface.h" class AboutWidget : public QDialog @@ -39,7 +42,13 @@ class AboutWidget : public QDialog Q_OBJECT public: AboutWidget(GUIInterface *parent = 0); + +private slots: + void openUrl(QString url); + private: + QDeclarativeView *view; + QVBoxLayout* mainLayout; QVBoxLayout *scrollLayout; QLabel* mainLabel, * licenseLabel, *imageLabel; diff --git a/src/mdictionary/gui/SearchBarWidget.cpp b/src/mdictionary/gui/SearchBarWidget.cpp index 78b1f35..b53d664 100644 --- a/src/mdictionary/gui/SearchBarWidget.cpp +++ b/src/mdictionary/gui/SearchBarWidget.cpp @@ -32,8 +32,7 @@ #include "HistoryListDialog.h" -SearchBarWidget::SearchBarWidget(QWidget *parent) : - QWidget(parent) { +SearchBarWidget::SearchBarWidget(QWidget *parent) : QWidget(parent) { initializeUI(); diff --git a/src/mdictionary/mdictionary.pro b/src/mdictionary/mdictionary.pro index 3cc8467..d049501 100644 --- a/src/mdictionary/mdictionary.pro +++ b/src/mdictionary/mdictionary.pro @@ -9,7 +9,8 @@ QT = core \ xmlpatterns \ sql \ dbus \ - webkit + webkit \ + declarative maemo5:QT += maemo5 @@ -153,3 +154,10 @@ unix { check.commands = echo 'No check here' QMAKE_EXTRA_TARGETS += check + +OTHER_FILES += \ + qml/Button.qml \ + qml/AboutWidget.qml \ + qml/SearchBarWidget.qml \ + qml/IconButton.qml \ + qml/MyTextLineEdit.qml diff --git a/src/mdictionary/qml/AboutWidget.qml b/src/mdictionary/qml/AboutWidget.qml new file mode 100644 index 0000000..8dbcbd8 --- /dev/null +++ b/src/mdictionary/qml/AboutWidget.qml @@ -0,0 +1,73 @@ +import Qt 4.7 +import QtWebKit 1.0 + +Rectangle { + id: item + width: 400; + height: 400; + opacity: 1 + anchors.fill: parent + + SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } + color : myPalette.window; + + signal linkClicked(string link); + + Image { + id: image1 + anchors.horizontalCenter: parent.horizontalCenter + source: "qrc:/icons/logo/mdictionary.png" + } + + Text { + id: text1 + y: 200 + text: "

mDictionary

" + anchors.horizontalCenterOffset: 0 + anchors.horizontalCenter: parent.horizontalCenter + } + + Text { + id: text2 + y: 220 + anchors.horizontalCenter: parent.horizontalCenter + textFormat: Text.RichText + text: "Maemo/Meego Multilingual Dictionary
Copyright 2006-2010, Comarch S.A.
http://mdictionary.garage.maemo.org" + anchors.horizontalCenterOffset: 1 + onLinkActivated: linkClicked(link); + } + + Text { + id: text3 + y: 270 + anchors.horizontalCenter: parent.horizontalCenter + text: "Report bug" + anchors.horizontalCenterOffset: 0 + onLinkActivated: linkClicked(link); + } + + Text { + id: text4 + y: 290 + anchors.horizontalCenter: parent.horizontalCenter + text: "

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see < http://www.gnu.org/licenses/>.

" + anchors.horizontalCenterOffset: 0 + onLinkActivated: linkClicked(link); + } + + MyTextLineEdit{ + id: myTextLineEdit + x: 50 + y: 32 + width: 120 + height: 30 + } + + /*SearchBarWidget { + id: searchbarwidget1 + x: 0 + y: 32 + } + */ + +} diff --git a/src/mdictionary/qml/Button.qml b/src/mdictionary/qml/Button.qml new file mode 100644 index 0000000..4151017 --- /dev/null +++ b/src/mdictionary/qml/Button.qml @@ -0,0 +1,74 @@ +import Qt 4.7 + +BorderImage { + id: button + property alias textInButton: buttonText.text + signal clicked + opacity: 1 + + border { left: 10; top: 10; right: 10; bottom: 10 } + + MouseArea { + id: mouseArea + anchors.centerIn: parent; + width: ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107) + height: parent.height + onClicked: { + button.clicked(); + } + } + + Text { + z:1 + id: buttonText + anchors.centerIn: parent; + font.pixelSize: parent.height * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + Rectangle { + id: shade + anchors.centerIn: parent; + radius: parent.height*.4; + color: "black"; + opacity: 0 + width: parent.width//((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) + height: parent.height + } + + Image { + id: image1 + width: (35*parent.height)/107 + height: parent.height + anchors.left: parent.left + anchors.leftMargin: (parent.width - ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)))/2 + source: "qrc:/button/buttonLeft.png" + } + + Image { + id: image3 + width: ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)) - ((70*parent.height)/107) + height: parent.height + anchors.horizontalCenter: parent.horizontalCenter + source: "qrc:/button/buttonCenter.png" + } + + Image { + id: image2 + width: (35*parent.height)/107 + height: parent.height + anchors.right: parent.right + anchors.rightMargin: (parent.width - ((parent.width > buttonText.text.length*buttonText.font.pixelSize*.8) ? (parent.width) : (buttonText.text.length*buttonText.font.pixelSize*.60)))/2 + source: "qrc:/button/buttonR.png" + } + + states: [ + State { + name: "pressed"; when: mouseArea.pressed == true + PropertyChanges { target: shade; opacity: 0.4 } + PropertyChanges { target: image1; opacity: 0.5 } + PropertyChanges { target: image3; opacity: 0.5 } + PropertyChanges { target: image2; opacity: 0.5 } + } + ] +} diff --git a/src/mdictionary/qml/IconButton.qml b/src/mdictionary/qml/IconButton.qml new file mode 100644 index 0000000..948d1b0 --- /dev/null +++ b/src/mdictionary/qml/IconButton.qml @@ -0,0 +1,88 @@ +import Qt 4.7 + +Rectangle { + id: rectangle + + property alias pathToIcon: image.source; + + signal clicked; + + Image { + id: image + z:1; + anchors.centerIn: parent + width: rectangle.width; + height: rectangle.height; + } + + + MouseArea { + id: mouseArea + anchors.centerIn: parent; + width: rectangle.width + (70*parent.height)/107; + height: rectangle.height; + onClicked: { + rectangle.clicked(); + } + } + + Image { + id: image1 + width: (35*parent.height)/107 + height: parent.height + anchors.left: parent.left + anchors.leftMargin: - (35*parent.height)/107 + source: "qrc:/button/buttonLeft.png" + } + + Image { + id: image3 + width: parent.width + height: parent.height + anchors.horizontalCenter: parent.horizontalCenter + source: "qrc:/button/buttonCenter.png" + } + + + Image { + id: image2 + width: (35*parent.height)/107 + height: parent.height + anchors.right: parent.right + anchors.rightMargin: - (35*parent.height)/107 + source: "qrc:/button/buttonR.png" + } + + Rectangle { + id: shade + anchors.centerIn: parent; + color: "black"; + radius: 20; + opacity: 1; + width: rectangle.width+(70*parent.height)/107; + height: rectangle.height; + } + + states: [ + State { + name: "enable"; + when: (mouseArea.pressed == false && rectangle.enabled == true); + PropertyChanges { target: shade; + opacity: 0; } + }, + State { + name: "disable"; + when: (rectangle.enabled == false); + PropertyChanges { target: shade; + color: "black"; + opacity: .5; } + }, + State { + name: "clicked"; + when: (mouseArea.pressed == true && rectangle.enabled == true); + PropertyChanges { target: shade; + color: "#fffead" + opacity: 0.5; } + } + ] +} diff --git a/src/mdictionary/qml/MyTextLineEdit.qml b/src/mdictionary/qml/MyTextLineEdit.qml new file mode 100644 index 0000000..36ea2e5 --- /dev/null +++ b/src/mdictionary/qml/MyTextLineEdit.qml @@ -0,0 +1,20 @@ +import Qt 4.7 + +Rectangle { + id: rectangle1 + radius: 10 + border.color: "#000666" + + + TextInput { + id: text_input1 + width: rectangle1.width -20 + height: rectangle1.height*0.6; + text: "textInput" + transformOrigin: Item.Left + anchors.centerIn: parent + selectByMouse: true; + font.pixelSize: rectangle1.height * .5; + onCursorPositionChanged: moveCursorSelection(cursorPosition); + } +} diff --git a/src/mdictionary/qml/SearchBarWidget.qml b/src/mdictionary/qml/SearchBarWidget.qml new file mode 100644 index 0000000..72b2cdb --- /dev/null +++ b/src/mdictionary/qml/SearchBarWidget.qml @@ -0,0 +1,32 @@ +import Qt 4.7 + +Rectangle { + id: rectangle1 + width: 500 + height: 40 + + SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } + color : myPalette.window; + + TextInput { + id: text_input + y: 10 + width: 350 + height: 20 + + color: "#000000" + text: "textInput" + anchors.left: parent.left + anchors.leftMargin: 15 + font.pixelSize: 12 + + IconButton { + id: iconbutton; + width:20; + height:20; + anchors.right: parent.right + enabled: true; + pathToIcon: "/home/jakub/go-previous.png"; + } + } +}