From dfed50eedc532f1136575c876c46a7eb104a37e5 Mon Sep 17 00:00:00 2001 From: Malte Marquarding Date: Thu, 18 Nov 2010 11:03:11 +1100 Subject: [PATCH] Initial upload --- appeventlistener.cpp | 38 +++++++ appeventlistener.hpp | 24 +++++ data/quick-widgets | 11 ++ data/quick-widgets-48x48.png | Bin 0 -> 1586 bytes data/quick-widgets-48x48.png.en | 38 +++++++ data/quick-widgets.desktop | 9 ++ data/quick-widgets.png | Bin 0 -> 2137 bytes data/quick-widgets.svg | 112 +++++++++++++++++++ debian/changelog | 11 ++ debian/compat | 1 + debian/control | 54 ++++++++++ debian/copyright | 24 +++++ debian/dirs | 4 + debian/postinst | 6 ++ debian/prerm | 4 + debian/rules | 96 +++++++++++++++++ main.cpp | 61 +++++++++++ quick-widgets.pro | 49 +++++++++ quick-widgets.pro.user | 228 +++++++++++++++++++++++++++++++++++++++ quickwidget.cpp | 119 ++++++++++++++++++++ quickwidget.hpp | 63 +++++++++++ quickwidgetsettings.cpp | 45 ++++++++ quickwidgetsettings.hpp | 26 +++++ quickwidgetsettings.ui | 171 +++++++++++++++++++++++++++++ 24 files changed, 1194 insertions(+) create mode 100644 appeventlistener.cpp create mode 100644 appeventlistener.hpp create mode 100644 data/quick-widgets create mode 100644 data/quick-widgets-48x48.png create mode 100644 data/quick-widgets-48x48.png.en create mode 100644 data/quick-widgets.desktop create mode 100644 data/quick-widgets.png create mode 100644 data/quick-widgets.svg create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/postinst create mode 100644 debian/prerm create mode 100755 debian/rules create mode 100644 main.cpp create mode 100644 quick-widgets.pro create mode 100644 quick-widgets.pro.user create mode 100644 quickwidget.cpp create mode 100644 quickwidget.hpp create mode 100644 quickwidgetsettings.cpp create mode 100644 quickwidgetsettings.hpp create mode 100644 quickwidgetsettings.ui diff --git a/appeventlistener.cpp b/appeventlistener.cpp new file mode 100644 index 0000000..4dfdd81 --- /dev/null +++ b/appeventlistener.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +#include "appeventlistener.hpp" +#include "quickwidgetsettings.hpp" + +static AppEventListener *_instance = NULL; + +AppEventListener* AppEventListener::instance() +{ + if (_instance == NULL) + _instance = new AppEventListener(QCoreApplication::instance()); + + return _instance; +} + +AppEventListener::AppEventListener(QObject *parent) : + QObject(parent) +{ + // Connect to the QtSingleApplication's event + QObject::connect(QtSingleApplication::instance(), SIGNAL(messageReceived(const QString&)), this, SLOT(receiveMessage(const QString&))); +} + +void AppEventListener::receiveMessage(const QString& message) +{ + if (message == APP_MESSAGE_ADDWIDGET) + { + qDebug() << "TTTTTTEEEEST"; + QuickWidgetSettings settings; + settings.exec(); + } + else if (message == APP_MESSAGE_CLOSE) + { + ((QApplication*)sender())->quit(); + } +} + diff --git a/appeventlistener.hpp b/appeventlistener.hpp new file mode 100644 index 0000000..9b5e76e --- /dev/null +++ b/appeventlistener.hpp @@ -0,0 +1,24 @@ +#ifndef APPEVENTLISTENER_HPP +#define APPEVENTLISTENER_HPP + +#include + +#define APP_MESSAGE_ADDWIDGET "Add widget" +#define APP_MESSAGE_CLOSE "Close" + +class AppEventListener : public QObject +{ + Q_OBJECT + +private: + explicit AppEventListener(QObject *parent = 0); + +public: + static AppEventListener *instance(); + +public slots: + void receiveMessage(const QString& message); + +}; + +#endif // APPEVENTLISTENER_HPP diff --git a/data/quick-widgets b/data/quick-widgets new file mode 100644 index 0000000..9004490 --- /dev/null +++ b/data/quick-widgets @@ -0,0 +1,11 @@ +description "starts Quick Widgets" + +start on started hildon-desktop + +respawn + +console none + +script + exec su - user -c "exec /opt/quick-widgets/quick-widgets in-background" +end script diff --git a/data/quick-widgets-48x48.png b/data/quick-widgets-48x48.png new file mode 100644 index 0000000000000000000000000000000000000000..17640cb54f23633641d225a19eeec2c87922c8ff GIT binary patch literal 1586 zcmV-22F>}2P)gr?ow_4&p!^9c?RAYXT?`#1M8#%qCf~+e1uZ zOdupApfmlRl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XJ+eW;m!gJcNWUh3)uosW}gsW zijzv!-m71pS|*>#BVHA8xXeRp*<_aJY?O`c221ys%*MGSHWC{cMT6K(48t&N4Sz5r z;Neb%9L}9j(m7-Y4%tCIldl;CIXy={lgH_HmYlDK(ydS|6wzZk(dj5kw_^848eIf# z?NlmoI8fK%X6@InFRoW!q!_UN*j(Ur_;>!KrF1JeT~3m7Ns>!RGyLu4wnQBQ$g0eV zub!Zgt9bFMgi$cKbL9@{l{9Y2&A|8oYCuImAQ?-t@b3jYogRWCL0)<56$If~XI@)e z<8Jyc1E&YfcLe|ermjqpTs9X)f#E>io)z*1^F?eMPQ|%-?73B!09Ioh^3Gjh>|0~p zzj~kOOq5Um`f15YDFp_KQYly??KoA8)N!(J8f7p*6)lqv?++Fp5lua%r zx&7Ylvh)L|4sh`7LF@6B1l$I6z?RM>Iz^7WafIN>AbM0M6-|*{&k~=Fqxw}w-WaJk zio3in2FC~K?B6=Y1x5lC^To22pF?smI6hc5lQ>;Y2FI)4`SJ$0*tsSchJhB=eg^z% zm%i?byMMb&;$ebA=MND)5o~5v_43EiL}=0f}x4fhcvkx_=bEO z|N3!8E{xP%1vZ&0!0)Vwvb)1tSi1=P9%#?+<9jCu{5&)fdV6zXwae27fp;-)jXw`O zz`Q(tV|zwL0RXhHCIJ_KZv*Fm0igOuU3-xS7BO#)zX!Y@nh2Gzih%zCLORJdlyUUh P00000NkvXXu0mjf@@Mhx literal 0 HcmV?d00001 diff --git a/data/quick-widgets.svg b/data/quick-widgets.svg new file mode 100644 index 0000000..b98e93c --- /dev/null +++ b/data/quick-widgets.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + QML + + + + + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..11ce80f --- /dev/null +++ b/debian/changelog @@ -0,0 +1,11 @@ +quick-widgets (0.1.1) unstable; urgency=low + + * Packaging changes + + -- Malte Marquarding Thu, 18 Nov 2010 10:27:43 +1100 + +quick-widgets (0.1.0) unstable; urgency=low + + * Initial public release. + + -- Malte Marquarding Thu, 18 Nov 2010 10:27:43 +1100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..923087c --- /dev/null +++ b/debian/control @@ -0,0 +1,54 @@ +Source: quick-widgets +Section: user/desktop +Priority: extra +Maintainer: Malte Marquarding +Build-Depends: debhelper (>= 5), libqt4-dev, libhildon-extras1-dev (>=0.9.5), q-extras-dev (>=1.0.5) +Standards-Version: 3.7.3 +Homepage: http://quick-widgets.garage.maemo.org/ + +Package: quick-widgets +Architecture: any +Depends: ${shlibs:Depends}, libhildon-extras1, q-extras (>=1.0.5) +XB-Maemo-Display-Name: Quick Widgets +Description: This application simplifies running Qt Quick applications as + home desktop widgets. It only needs the file. Thanks to Timur Kristóf (Venemo) + for doing all the had work in q-extras. + This application is licensed under LGPL. +XB-Maemo-Icon-26: + iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgI + fAhkiAAAAAlwSFlzAAAUwwAAFMMBFXBNQgAAABl0RVh0U29mdHdhcmUAd3d3 + Lmlua3NjYXBlLm9yZ5vuPBoAAAWvSURBVGiB7ZrPUxNnGMc/u9mFBEhIIIEA + oUakDlQdZ5yJIv1xqaeOPfVWneJM/4UeOr10eu30L+gpjr301kuntT20DuJA + HR1tK1RrAigQxBB2ScwmWbLbQ0xiTCAkJKAz/Z6S99332e/n3ed9933fRDBN + k0vfXToCfAO8DTh4tZUEbgJfBC8GbwkTVyZ8wN9A58H6qlkZYFwEvuL1Mw/Q + AnwtAuONimhkjUaF2q3GRMDbiEih6yGmvp1C1/RGhNut2kRA2GuU0GSIuV/m + UCMq08HpfYUQ9xogNBli7te5wvf9htgTQOh60bxFtuDsdwL7C1E3QOh6Lm0g + Zz5wIcDZT8/iPuwGnkNcbj5EXQCVzLuH3LnPFwNFiJX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HzI3WZrwogtUroKZ1UPEUqniqt + FEFZUmh1tpb1dDKaRE/rZLNZ4mtxADKpDMmNJKZgYnPZ2FzeZGNhA6lVwu61 + NwfAf9qPsqxgmuW56RpwMT85j2AK9Iz2FFIgk8iQWE7QM9zDwMmBwvXqgkq3 + vxvHgANjy+DR5CMWbywW5vymALR1tdHWtf3G3u62M39tnuhfUdp729GTOokn + CboGuxg9P4pkK4ZfnlnGc8SD+2huu6qtacTCMdxvVt++3v/xfslT7j/Zj+uw + qzpANXlGPHR4O1CXVLSohqZpWFosHPvoGKJYOj/4Tvlo6y52Rv+pfuxee0mZ + 94SXlo7iltbmseEL+Mru++I1JedCe1VKSXH3+7t4T3g5NH6oESGrSgSeNiqY + 1WnFP+4ncjfCyq2VRoXdSSkJ+AMYblTE3hO9SDYJh29f/jNyWwS+BLRqV9ai + 7uFuZGvTTzkM4HMxeDH4EBgDfgdSOzZ5NaSTy5r3gxeDk/8BCkGAHh5D9sIA + AAAASUVORK5CYII= + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..4859e8d --- /dev/null +++ b/debian/copyright @@ -0,0 +1,24 @@ +Upstream Author(s): + + Malte Marquarding + +Copyright: + + Copyright (C) 2010, Malte Marquarding + +License: + + This package is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This package 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..04f51e1 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,4 @@ +opt/quick-widgets +usr/share/applications/hildon +usr/share/pixmaps +etc/event.d diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..0832f84 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,6 @@ +#!/bin/sh +chmod +x /opt/quick-widgets/quick-widgets +echo "Quick Widgets install done" +echo "Starting Quick Widgets..." +start --quiet quick-widgets + diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..ac1a54e --- /dev/null +++ b/debian/prerm @@ -0,0 +1,4 @@ +#!/bin/sh +echo "Killing Quick widgets if it is running" +if [ ! -z "$(pidof quick-widgets)" ]; then stop quick-widgets; fi +if [ ! -z "$(pidof quick-widgets)" ]; then killall -9 quick-widgets; fi diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..e0e6660 --- /dev/null +++ b/debian/rules @@ -0,0 +1,96 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + + + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + qmake + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/quick-widgets.sgml > quick-widgets.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/quick-widgets. + $(MAKE) INSTALL_ROOT="$(CURDIR)/debian/quick-widgets" install + cp "$(CURDIR)/build/quick-widgets" "$(CURDIR)/debian/quick-widgets/opt/quick-widgets/" + cp "$(CURDIR)/data/quick-widgets" "$(CURDIR)/debian/quick-widgets/etc/event.d/" + cp "$(CURDIR)/data/quick-widgets.desktop" "$(CURDIR)/debian/quick-widgets/usr/share/applications/hildon/" + cp "$(CURDIR)/data/quick-widgets.png" "$(CURDIR)/debian/quick-widgets/usr/share/pixmaps/" + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..082d8b8 --- /dev/null +++ b/main.cpp @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include "quickwidget.hpp" +#include "quickwidgetsettings.hpp" +#include "appeventlistener.hpp" + +int main(int argc, char *argv[]) +{ + QApplication::setApplicationName("Quick Widgets"); + QApplication::setOrganizationName("Marquarding"); + // APP_VERSION and APP_BETA are defined in the .pro file + QApplication::setApplicationVersion(QString(APP_VERSION) +#if APP_BETA + + " beta" +#endif + ); + + QtSingleApplication app(argc, argv); + qDebug() << "Launched quick widgets app"; + + if (app.isRunning()) + { + qDebug() << "Another instance of the app is running."; + if (app.arguments().contains("in-background")) + { + qDebug() << "Closing that other instance."; + app.sendMessage(APP_MESSAGE_CLOSE); + } + else + { + qDebug() << "Asking it to offer to create a new widget."; + app.sendMessage(APP_MESSAGE_ADDWIDGET); + return 0; + } + } + + app.setQuitOnLastWindowClosed(false); + AppEventListener::instance(); + + if (app.arguments().contains("forget-widgets")) + { + qDebug() << "We were asked to forget all widgets!"; + QeMaemo5DynamicWidgetHelper::globalInstance()->forgetAllWidgets(); + } + else + { + qDebug() << "Restoring all widgets"; + QeMaemo5DynamicWidgetHelper::globalInstance()->restoreWidgets(); + } + + if (!app.arguments().contains("in-background")) + { + // setting for new widget + QuickWidgetSettings settingsDialog; + settingsDialog.exec(); + //app.sendMessage(APP_MESSAGE_ADDWIDGET); + } + return app.exec(); +} diff --git a/quick-widgets.pro b/quick-widgets.pro new file mode 100644 index 0000000..019ded9 --- /dev/null +++ b/quick-widgets.pro @@ -0,0 +1,49 @@ +QT += core gui maemo5 declarative + +TARGET = quick-widgets +TEMPLATE = app +VERSION = 0.1.0 + +DEFINES += APP_VERSION=\\\"$$VERSION\\\" +DEFINES += APP_BETA + +HEADERS += \ + quickwidget.hpp \ + quickwidgetsettings.hpp \ + appeventlistener.hpp + +SOURCES += \ + main.cpp\ + quickwidget.cpp \ + quickwidgetsettings.cpp \ + appeventlistener.cpp + +FORMS += \ + quickwidgetsettings.ui + +OTHER_FILES += \ + data/quick-widgets.desktop \ + data/quick-widgets-widget.desktop \ + data/quick-widgets + +# data/quick-widgets.png +# data/quick-widgets-48x48.png + +CONFIG += link_pkgconfig +PKGCONFIG += hildon-extras-1 q-extras + +# All generated files should go to the same directory +OBJECTS_DIR = build +MOC_DIR = build +UI_DIR = build +DESTDIR = build + +# Targets for debian source and binary package creation +debian-src.commands = dpkg-buildpackage -S -sa -r -us -uc -d +debian-bin.commands = dpkg-buildpackage -b -r -uc -d +debian-all.depends = debian-src debian-bin + +# Clean all but Makefile +compiler_clean.commands = -$(DEL_FILE) $(TARGET) + +QMAKE_EXTRA_TARGETS += debian-all debian-src debian-bin compiler_clean diff --git a/quick-widgets.pro.user b/quick-widgets.pro.user new file mode 100644 index 0000000..9a83c73 --- /dev/null +++ b/quick-widgets.pro.user @@ -0,0 +1,228 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + System + + + + ProjectExplorer.Project.Target.0 + + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + + + qmake + QtProjectManager.QMakeBuildStep + + -spec + /targets/FREMANTLE_X86/usr/share/qt4/mkspecs/linux-g++ + + + + Make + Qt4ProjectManager.MakeStep + false + + debug + + /usr/local/bin/sbox-make + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + /usr/local/bin/sbox-make + + 1 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 10 + /scratchbox/users/mar637/home/mar637/scratchbox/quick-widgets-build + 13 + 0 + false + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + /usr/local/bin/sbox-make + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + /usr/local/bin/sbox-make + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /scratchbox/users/mar637/home/mar637/scratchbox/quick-widgets-build-desktop + 13 + 0 + true + + 2 + + quick-widgets + Qt4ProjectManager.Qt4RunConfiguration + 2 + + quick-widgets.pro + false + false + + false + false + + + 1 + + + + ProjectExplorer.Project.Target.1 + + Maemo + Qt4ProjectManager.Target.MaemoDeviceTarget + 0 + 0 + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + + true + + Qt4ProjectManager.MaemoPackageCreationStep + + true + + + 0.0.1 + + 3 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /scratchbox/users/mar637/home/mar637/scratchbox/quick-widgets-build-maemo + 9 + 9 + true + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + + true + + Qt4ProjectManager.MaemoPackageCreationStep + + true + + + 0.0.1 + + 3 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /scratchbox/users/mar637/home/mar637/scratchbox/quick-widgets-build-maemo + 9 + 9 + true + + 2 + + quick-widgets.pro + New Maemo Run Configuration + Qt4ProjectManager.MaemoRunConfiguration + + 1 + + + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 4 + + diff --git a/quickwidget.cpp b/quickwidget.cpp new file mode 100644 index 0000000..63c9563 --- /dev/null +++ b/quickwidget.cpp @@ -0,0 +1,119 @@ +#include +#include +#include +#include +#include +#include +#include "quickwidget.hpp" + +#define SETTING_QUICK_FILE "QuickWidgetFile" +#define SETTING_QUICK_SIZE "QuickWidgetSize" +#define SETTING_SAVE_WAITINTERVAL 3000 + +static Atom onCurrentHomescreenAtom; +static bool _atomsInitialized = false; + +QuickWidget *QuickWidget::createAndShowNew(const QString& fileName, const QSize& size) +{ + QuickWidget *widget = new QuickWidget; + widget->initView(fileName, size); + widget->show(); + QeMaemo5DynamicWidgetHelper::globalInstance()->registerWidget(widget); + return widget; +} + +void QuickWidget::initView(const QString& fileName, const QSize& size) +{ + size_ = size; + saveSetting(SETTING_QUICK_FILE, fileName); + saveSetting(SETTING_QUICK_SIZE, size_); + view_->setSource(QUrl::fromLocalFile(fileName)); + if ( view_->status() == QDeclarativeView::Error) { + errorWidget(); + } + else if (size_.isValid()) + { + // use given fixed size and scale to it + qDebug() << "scaling"; + view_->setResizeMode(QDeclarativeView::SizeRootObjectToView); + } + else + { + size_ = view_->sceneRect().size().toSize(); + } + view_->setFixedSize(size_); + view_->show(); +} + + +QuickWidget::QuickWidget(QWidget *parent) + : QeMaemo5DynamicHomescreenWidget(true, parent), + size_(QSize()), + view_(0) +{ + if (!_atomsInitialized) { + onCurrentHomescreenAtom = XInternAtom(QX11Info::display(), + "_HILDON_APPLET_ON_CURRENT_DESKTOP", + false); + _atomsInitialized = true; + } + view_ = new QDeclarativeView(this); + view_->setStyleSheet("background:transparent"); + view_->setAttribute(Qt::WA_TranslucentBackground); + wrapper_ = new QuickWidgetWrapper(this); + view_->rootContext()->setContextProperty("runtime", wrapper_); + +} + +QuickWidget::~QuickWidget() +{ + delete wrapper_; +} + +bool QuickWidget::x11Event(XEvent *event) +{ + bool passon = QeMaemo5DynamicHomescreenWidget::x11Event(event); + + if (event->xclient.message_type == onCurrentHomescreenAtom) + { + bool visible = isVisibleOnCurrentHomescreen() ; + if (visible != wrapper_->onHomeScreen()) + { + wrapper_->setOnHomeScreen(visible); + } + } + return passon; +} + +bool QuickWidget::restoreWidgetState() +{ + QString fileName = loadSetting(SETTING_QUICK_FILE).toString(); + QSize size = loadSetting(SETTING_QUICK_SIZE, QSize()).value(); + initView(fileName, size); + return true; +} + +void QuickWidget::errorWidget() +{ + const QList& errs = view_->errors(); + qDebug() << errs; + QByteArray errmsg; + QTextStream qts(&errmsg); + qts << "import Qt 4.7" << endl + << "Rectangle { width: 200; height: txt.height; color: \"#ff0000\"; radius: 8" << endl + << "Text { id: txt; anchors.centerIn: parent; text: \""; + for (int i = 0; i < errs.size(); ++i) { + qts << errs.at(i).toString().replace(QString("\""), QString("\\\"")) << +endl; + } + qts << "\"; font.pixelSize: 15; wrapMode: Text.Wrap; width: parent.width-20}" << endl + << "}" << endl; + qDebug() << errmsg; + QDeclarativeComponent component(view_->engine()); + component.setData(errmsg, QUrl()); + qDebug() << component.errorString(); + QDeclarativeItem *errwdgt = + qobject_cast(component.create(view_->rootContext())); + view_->scene()->addItem(errwdgt); + size_ = QSize(errwdgt->width(), errwdgt->height()); +} diff --git a/quickwidget.hpp b/quickwidget.hpp new file mode 100644 index 0000000..f0a6bd2 --- /dev/null +++ b/quickwidget.hpp @@ -0,0 +1,63 @@ +#ifndef QUICKWIDGET_HPP +#define QUICKWIDGET_HPP + +#include +#include +#include + +class QDeclarativeView; +class QuickWidgetWrapper; + + +class QuickWidget : public QeMaemo5DynamicHomescreenWidget +{ + Q_OBJECT + +private: + void initView(const QString& fileName, const QSize& size=QSize()); + QSize size_; + QDeclarativeView* view_; + QuickWidgetWrapper* wrapper_; + +protected: +// void showSettingsDialog(); + bool restoreWidgetState(); + void errorWidget(); + bool x11Event(XEvent *event); + +public: + static QuickWidget *createAndShowNew(const QString& fileName, const QSize& size=QSize()); + + explicit QuickWidget(QWidget *parent = 0); + Q_INVOKABLE bool onHomescreen() { return isVisibleOnCurrentHomescreen(); } + ~QuickWidget(); + +}; + +class QuickWidgetWrapper : public QObject +{ + Q_OBJECT + +public: + QuickWidgetWrapper(QuickWidget *owner) : m_owner(owner) {;} + Q_PROPERTY(bool isActiveWindow READ onHomeScreen NOTIFY onHomeScreenChanged); + + bool onHomeScreen() const { return homeScreen; } + + void setOnHomeScreen(bool active) + { + if (active == homeScreen) + return; + homeScreen = active; + emit onHomeScreenChanged(); + } + +Q_SIGNALS: + void onHomeScreenChanged(); + +private: + QuickWidget *m_owner; + bool homeScreen; +}; + +#endif // QuickWidget_HPP diff --git a/quickwidgetsettings.cpp b/quickwidgetsettings.cpp new file mode 100644 index 0000000..22f2650 --- /dev/null +++ b/quickwidgetsettings.cpp @@ -0,0 +1,45 @@ +#include +#include "quickwidgetsettings.hpp" +#include "quickwidget.hpp" +#include "ui_quickwidgetsettings.h" + +QuickWidgetSettings::QuickWidgetSettings(QWidget *parent) : + QDialog(parent), + ui(new Ui::QuickWidgetSettings) +{ + ui->setupUi(this); + connect(ui->fileButton, SIGNAL(clicked()), this, SLOT(getQml())); +} + +QuickWidgetSettings::~QuickWidgetSettings() +{ + delete ui; +} + +void QuickWidgetSettings::accept() { + QFile f(ui->fileEdit->text()); + QSize size; + if (ui->sizingCheckBox->isChecked()) { + bool wok, hok; + int width = ui->widthEdit->text().toInt(&wok); + int height = ui->heightEdit->text().toInt(&hok); + if ( wok && hok && width < 800 && width > 10 && height < 400 && height > 10) { + size.setWidth(width); + size.setHeight(height); + } + } + if (f.exists()) + { + QuickWidget::createAndShowNew(ui->fileEdit->text(), size); + } + + QDialog::accept(); +} + +void QuickWidgetSettings::getQml() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), + QDir::homePath(), + tr("QML files (*.qml)")); + ui->fileEdit->setText(fileName); +} diff --git a/quickwidgetsettings.hpp b/quickwidgetsettings.hpp new file mode 100644 index 0000000..8a6f977 --- /dev/null +++ b/quickwidgetsettings.hpp @@ -0,0 +1,26 @@ +#ifndef QUICKWIDGETSETTINGS_H +#define QUICKWIDGETSETTINGS_H + +#include + +namespace Ui { + class QuickWidgetSettings; +} + +class QuickWidgetSettings : public QDialog +{ + Q_OBJECT + +public slots: + void accept(); + void getQml(); + +public: + explicit QuickWidgetSettings(QWidget *parent = 0); + ~QuickWidgetSettings(); + +private: + Ui::QuickWidgetSettings *ui; +}; + +#endif // QUICKWIDGETSETTINGS_H diff --git a/quickwidgetsettings.ui b/quickwidgetsettings.ui new file mode 100644 index 0000000..74b15be --- /dev/null +++ b/quickwidgetsettings.ui @@ -0,0 +1,171 @@ + + + QuickWidgetSettings + + + + 0 + 0 + 800 + 400 + + + + QtQuick Widget Selection + + + + + 20 + 310 + 751 + 61 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 10 + 10 + 771 + 261 + + + + + + + + + qml + + + + + + + + + + + + Fixed Size + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 13 + 20 + + + + + + + + false + + + + + + + x + + + Qt::AlignCenter + + + + + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + sizingCheckBox + toggled(bool) + widthEdit + setEnabled(bool) + + + 180 + 120 + + + 120 + 156 + + + + + sizingCheckBox + toggled(bool) + heightEdit + setEnabled(bool) + + + 180 + 120 + + + 257 + 156 + + + + + buttonBox + accepted() + QuickWidgetSettings + accept() + + + 395 + 310 + + + 399 + 199 + + + + + -- 1.7.9.5