Port WelcomeScreenWidget to qml. add instalation rules for qml file
authorMarcin Kaźmierczak <marcin@marcin-desktop.(none)>
Thu, 9 Dec 2010 15:47:16 +0000 (16:47 +0100)
committerMarcin Kaźmierczak <marcin@marcin-desktop.(none)>
Thu, 9 Dec 2010 15:47:16 +0000 (16:47 +0100)
debian/mdictionary.install
mdictionary.pri
mdictionary.pro
src/mdictionary/gui/WelcomeScreenWidget.cpp
src/mdictionary/gui/WelcomeScreenWidget.h
src/mdictionary/mdictionary.pro
src/mdictionary/qml/WelcomeScreenWidget.qml [new file with mode: 0644]

index b67ebf1..c8871a9 100644 (file)
@@ -7,4 +7,5 @@ usr/lib/mdictionary/plugins/eng-us.xdxf
 usr/lib/mdictionary/plugins/eng-thai.xdxf
 usr/share/mdictionary/xdxf.png
 usr/share/mdictionary/css/
+usr/share/mdictionary/qml/
 usr/share/applications/hildon/mdictionary.desktop
index ab81e07..8e319e9 100644 (file)
@@ -17,6 +17,7 @@ isEmpty(DATA_DIR):DATA_DIR=$$INSTALL_PREFIX/share/mdictionary
 isEmpty(LIBS_DIR):LIBS_DIR=$$INSTALL_PREFIX/lib/mdictionary
 isEmpty(PLUGINS_DIR):PLUGINS_DIR=$$INSTALL_PREFIX/lib/mdictionary/plugins
 isEmpty(DOCS_DIR):DOCS_DIR=$$INSTALL_PREFIX/share/doc/mdictionary
+#isEmpty(QMLS_DIR):QMLS_DIR=$$DATA_DIR/qml
 
 DEFINES += MDICTIONARY_VERSION=\\\"$$VERSION\\\"
 DEFINES += MDICTIONARY_INSTALL_PREFIX=\\\"$$INSTALL_PREFIX\\\"
index c4d2a13..477639b 100644 (file)
@@ -20,4 +20,5 @@ message("Binary directory: "$$BIN_DIR)
 message("Data directory: "$$DATA_DIR)
 message("Plugins directory: "$$PLUGINS_DIR)
 message("Documentation directory: "$$DOCS_DIR)
+#message("Qml directory: "$$QMLS_DIR)
 
index 43efb09..f2ec62c 100644 (file)
@@ -37,22 +37,29 @@ WelcomeScreenWidget::WelcomeScreenWidget(QWidget *parent) :
     mainLayout = new QVBoxLayout(this);
     setLayout(mainLayout);
 
-    imageLabel = new QLabel(this);
-    mainLabel = new QLabel(infoNote, this);
+    qmlView = new QDeclarativeView;
+    qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/WelcomeScreenWidget.qml"));
 
-    mainLayout->addStretch(0);
-    mainLayout->addWidget(imageLabel, 0, Qt::AlignCenter);
-    mainLayout->addWidget(mainLabel, 0, Qt::AlignCenter);
-    mainLayout->addStretch(0);
+    mainLayout->addWidget(qmlView, 0, Qt::AlignCenter);
 
-    QImage img(":/icons/logo/mdictionary.png");
-    imageLabel->setPixmap(QPixmap::fromImage(img));
-    imageLabel->resize(imageLabel->pixmap()->size());
+    //stary kod:
+    //imageLabel = new QLabel(this);
+    //mainLabel = new QLabel(infoNote, this);
+
+    //mainLayout->addStretch(0);
+    //mainLayout->addWidget(imageLabel, 0, Qt::AlignCenter);
+    //mainLayout->addWidget(mainLabel, 0, Qt::AlignCenter);
+    //mainLayout->addStretch(0);
+
+    //QImage img(":/icons/logo/mdictionary.png");
+    //imageLabel->setPixmap(QPixmap::fromImage(img));
+    //imageLabel->resize(imageLabel->pixmap()->size());
 
 
     //mainLabel->setWordWrap(true);
+    //koniec kodu
 
     #ifdef Q_WS_MAEMO_5
-        mainLayout->addSpacing(20);
+        //mainLayout->addSpacing(20);
     #endif
 }
index 449570c..6e82a87 100644 (file)
@@ -30,6 +30,9 @@
 #include <QWidget>
 #include <QScrollArea>
 #include <QtGui>
+#include <QtDeclarative/QDeclarativeView>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeContext>
 
 //! Displays welcome screen with logo and name of application
 class WelcomeScreenWidget : public QScrollArea
@@ -41,6 +44,11 @@ public:
 private:
     QVBoxLayout* mainLayout;
     QLabel* mainLabel, * licenseLabel, *imageLabel;
+
+    QDeclarativeView* qmlView;
+    QDeclarativeEngine* engine;
+    QDeclarativeContext* context;
+    QWidget* widget;
 };
 
 #endif // WELCOMESCREENWIDGET_H
index 3cc8467..9d67737 100644 (file)
@@ -9,7 +9,8 @@ QT = core \
     xmlpatterns \
     sql \
     dbus \
-    webkit
+    webkit \
+    declarative
 
 maemo5:QT += maemo5
 
@@ -75,10 +76,14 @@ RESOURCES += ../../data/gui.qrc
 TRANSLATIONS += pl_PL.ts \
                 en_US.ts
 
+OTHER_FILES += \
+   qml/WelcomeScreenWidget.qml
+
 target.path = $$BIN_DIR
 INSTALLS += target
 
 unix { 
+        #icons and misc
        maemo5 {
                desktop.path = $$SHARE_DIR/applications/hildon
                icon64.path = $$SHARE_DIR/icons/hicolor/64x64/hildon
@@ -95,6 +100,7 @@ unix {
     shared.files += ../../data/icons/16x16/staron.png
     shared.files += ../../data/xsl/mask.png
 
+    #css
     meego {
         css.path = $$DATA_DIR/css
         css.files += ../../data/css_meego/style.css
@@ -108,6 +114,7 @@ unix {
         css.files += ../../data/css_desktop/style.css
     }
 
+    #css images
     meego {
        css_images.path = $$DATA_DIR/css/images
         css_images.files += ../../data/css_meego/images/header-background.png
@@ -144,12 +151,28 @@ unix {
         css_images.files += ../../data/css_desktop/images/key-background.png
     }
 
+    #services
     service.path = $$SHARE_DIR/dbus-1/services
     service.files += ../../data/other/com.comarch.mdictionary.service
+
+    #qmls (stub)
+    meego {
+        qmls.path = $$DATA_DIR/qml
+        qmls.files += ./qml/WelcomeScreenWidget.qml
+    }
+    else:maemo5 {
+        qmls.path = $$DATA_DIR/qml
+        qmls.files += ./qml/WelcomeScreenWidget.qml
+    }
+    else {
+        qmls.path = $$DATA_DIR/qml
+        qmls.files += ./qml/WelcomeScreenWidget.qml
+    }
        
-    INSTALLS += desktop icon64 shared service css css_images
+    INSTALLS += desktop icon64 shared service css css_images qmls
 }
 
 
 check.commands = echo 'No check here'
 QMAKE_EXTRA_TARGETS += check
+
diff --git a/src/mdictionary/qml/WelcomeScreenWidget.qml b/src/mdictionary/qml/WelcomeScreenWidget.qml
new file mode 100644 (file)
index 0000000..b24542e
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary 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.
+
+    mDictionary 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 mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+/*!
+    author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
+import Qt 4.7
+
+Rectangle {
+    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+
+    id: rectangle1
+    width: (helloText.width > logo.width) ? (helloText.width) : (logo.width)
+    height: logo.height + helloText.height
+    color: myPalette.window
+    anchors.fill: parent
+
+        Image {
+            id: logo
+            source: "qrc:/icons/logo/mdictionary.png"
+//            width: 240
+//            height: 200
+            anchors.horizontalCenter: parent.horizontalCenter
+            fillMode: Image.PreserveAspectFit
+            anchors.top: parent.top
+        }
+
+        Text {
+            id: helloText
+            text: qsTr("<center><h1>Welcome in mDictionary!</h1></center>")
+            anchors.bottom: parent.bottom
+        }
+
+}