From 5fc81a4ae588b2616381820b99a09b5f0669bc01 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marcin=20Ka=C5=BAmierczak?= Date: Thu, 9 Dec 2010 16:47:16 +0100 Subject: [PATCH] Port WelcomeScreenWidget to qml. add instalation rules for qml file --- debian/mdictionary.install | 1 + mdictionary.pri | 1 + mdictionary.pro | 1 + src/mdictionary/gui/WelcomeScreenWidget.cpp | 27 ++++++++------ src/mdictionary/gui/WelcomeScreenWidget.h | 8 +++++ src/mdictionary/mdictionary.pro | 27 ++++++++++++-- src/mdictionary/qml/WelcomeScreenWidget.qml | 52 +++++++++++++++++++++++++++ 7 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 src/mdictionary/qml/WelcomeScreenWidget.qml diff --git a/debian/mdictionary.install b/debian/mdictionary.install index b67ebf1..c8871a9 100644 --- a/debian/mdictionary.install +++ b/debian/mdictionary.install @@ -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 diff --git a/mdictionary.pri b/mdictionary.pri index ab81e07..8e319e9 100644 --- a/mdictionary.pri +++ b/mdictionary.pri @@ -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\\\" diff --git a/mdictionary.pro b/mdictionary.pro index c4d2a13..477639b 100644 --- a/mdictionary.pro +++ b/mdictionary.pro @@ -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) diff --git a/src/mdictionary/gui/WelcomeScreenWidget.cpp b/src/mdictionary/gui/WelcomeScreenWidget.cpp index 43efb09..f2ec62c 100644 --- a/src/mdictionary/gui/WelcomeScreenWidget.cpp +++ b/src/mdictionary/gui/WelcomeScreenWidget.cpp @@ -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 } diff --git a/src/mdictionary/gui/WelcomeScreenWidget.h b/src/mdictionary/gui/WelcomeScreenWidget.h index 449570c..6e82a87 100644 --- a/src/mdictionary/gui/WelcomeScreenWidget.h +++ b/src/mdictionary/gui/WelcomeScreenWidget.h @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include //! 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 diff --git a/src/mdictionary/mdictionary.pro b/src/mdictionary/mdictionary.pro index 3cc8467..9d67737 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 @@ -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 index 0000000..b24542e --- /dev/null +++ b/src/mdictionary/qml/WelcomeScreenWidget.qml @@ -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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ +/*! + author: Marcin Kaźmierczak +*/ + +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("

Welcome in mDictionary!

") + anchors.bottom: parent.bottom + } + +} -- 1.7.9.5