add qml-elements
authorjakub <jakub.jaszczynski@comarch.com>
Tue, 14 Dec 2010 08:36:08 +0000 (09:36 +0100)
committerjakub <jakub.jaszczynski@comarch.com>
Tue, 14 Dec 2010 08:36:08 +0000 (09:36 +0100)
13 files changed:
data/button/buttonCenter.png [new file with mode: 0644]
data/button/buttonLeft.png [new file with mode: 0644]
data/button/buttonR.png [new file with mode: 0644]
data/gui.qrc
src/mdictionary/gui/AboutWidget.cpp
src/mdictionary/gui/AboutWidget.h
src/mdictionary/gui/SearchBarWidget.cpp
src/mdictionary/mdictionary.pro
src/mdictionary/qml/AboutWidget.qml [new file with mode: 0644]
src/mdictionary/qml/Button.qml [new file with mode: 0644]
src/mdictionary/qml/IconButton.qml [new file with mode: 0644]
src/mdictionary/qml/MyTextLineEdit.qml [new file with mode: 0644]
src/mdictionary/qml/SearchBarWidget.qml [new file with mode: 0644]

diff --git a/data/button/buttonCenter.png b/data/button/buttonCenter.png
new file mode 100644 (file)
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 (file)
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 (file)
index 0000000..9a826a3
Binary files /dev/null and b/data/button/buttonR.png differ
index 6133b0d..376f9d7 100644 (file)
         <file>xsl/xsl.xsl</file>
         <file>translations/en_US.qm</file>
         <file>translations/pl_PL.qm</file>
+        <file>button/buttonCenter.png</file>
+        <file>button/buttonLeft.png</file>
+        <file>button/buttonR.png</file>
+        <file>lineEdit/ramkaL.png</file>
+        <file>lineEdit/ramkaR.png</file>
+        <file>lineEdit/ramkaC.png</file>
     </qresource>
 </RCC>
index 72eb839..daae50d 100644 (file)
 
 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 = "<center><h2><u>mDictionary</u></h2></center>";
@@ -58,20 +74,8 @@ AboutWidget::AboutWidget(GUIInterface *parent): QDialog(parent)
                   "&lt;<a href=\"http://www.gnu.org/licenses/\">"
                   "http://www.gnu.org/licenses/</a>&gt;."
                   "</p></font>");
-
-    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);
 }
index 02eb383..8fee222 100644 (file)
@@ -32,6 +32,9 @@
 #include <QDialog>
 #include <QWidget>
 #include <QtGui>
+#include <QDeclarativeView>
+#include <QDesktopServices>
+
 #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;
index 78b1f35..b53d664 100644 (file)
@@ -32,8 +32,7 @@
 #include "HistoryListDialog.h"
 
 
-SearchBarWidget::SearchBarWidget(QWidget *parent) :
-    QWidget(parent) {
+SearchBarWidget::SearchBarWidget(QWidget *parent) : QWidget(parent) {
 
     initializeUI();
 
index 3cc8467..d049501 100644 (file)
@@ -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 (file)
index 0000000..8dbcbd8
--- /dev/null
@@ -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: "<h2><u>mDictionary</u></h2>"
+        anchors.horizontalCenterOffset: 0
+        anchors.horizontalCenter: parent.horizontalCenter
+    }
+
+    Text {
+        id: text2
+        y: 220
+        anchors.horizontalCenter: parent.horizontalCenter
+        textFormat: Text.RichText
+        text: "Maemo/Meego Multilingual Dictionary <br> Copyright 2006-2010, Comarch S.A. <br> <a href=\"http://mdictionary.garage.maemo.org\"> http://mdictionary.garage.maemo.org</a>"
+        anchors.horizontalCenterOffset: 1
+        onLinkActivated: linkClicked(link);
+    }
+
+    Text {
+        id: text3
+        y: 270
+        anchors.horizontalCenter: parent.horizontalCenter
+        text: "<font size=\"small\"><a href=\"https://garage.maemo.org/tracker/?func=add&group_id=58&atid=305\">Report bug</a></font>"
+        anchors.horizontalCenterOffset: 0
+        onLinkActivated: linkClicked(link);
+    }
+
+     Text {
+        id: text4
+        y: 290
+        anchors.horizontalCenter: parent.horizontalCenter
+        text: "<p><font size=\"small\">This program is free software: you can redistribute it and/or modify <br> it under the terms of the GNU General Public License as published by <br> the Free Software Foundation, either version 3 of the License,or <br>(at your option) any later version.<br>This program is distributed in the hope that it will be useful,<br>but WITHOUT ANY WARRANTY; without even the implied warranty of<br> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the <br> GNU General Public License for more details.<br> You should have received a copy of the GNU General Public License<br> along with this program.  If not, see &lt;<a href=\"http://www.gnu.org/licenses/\"> http://www.gnu.org/licenses/</a>&gt;.</p></font>"
+        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 (file)
index 0000000..4151017
--- /dev/null
@@ -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 (file)
index 0000000..948d1b0
--- /dev/null
@@ -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 (file)
index 0000000..36ea2e5
--- /dev/null
@@ -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 (file)
index 0000000..72b2cdb
--- /dev/null
@@ -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";
+        }
+    }
+}