summaryrefslogtreecommitdiffstats
path: root/qt-homescreen-example
diff options
context:
space:
mode:
authorHarald Fernengel <harald.fernengel@nokia.com>2010-02-24 11:42:07 +0100
committerHarald Fernengel <harald.fernengel@nokia.com>2010-02-24 11:42:07 +0100
commita3a2e7e57e29c35127be7776548a8a0f07a0efee (patch)
treef4b95da0b17d88b75246080d2920bd6c9e60c7f6 /qt-homescreen-example
Initial version of Qt for Maemo 5 homescreen widget loader + example
Diffstat (limited to 'qt-homescreen-example')
-rw-r--r--qt-homescreen-example/main.cpp59
-rw-r--r--qt-homescreen-example/qt-homescreen-example.desktop9
-rw-r--r--qt-homescreen-example/qt-homescreen-example.pro12
-rw-r--r--qt-homescreen-example/testwidget.h90
4 files changed, 170 insertions, 0 deletions
diff --git a/qt-homescreen-example/main.cpp b/qt-homescreen-example/main.cpp
new file mode 100644
index 0000000..56d10b3
--- /dev/null
+++ b/qt-homescreen-example/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmaemo5homescreenadaptor.h"
+#include "testwidget.h"
+
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ TestWidget w;
+ QMaemo5HomescreenAdaptor *adaptor = new QMaemo5HomescreenAdaptor(&w);
+ adaptor->setSettingsAvailable(true);
+ QObject::connect(adaptor, SIGNAL(settingsRequested()), &w, SLOT(showSettingsDialog()));
+ w.show();
+
+ app.exec();
+}
+
diff --git a/qt-homescreen-example/qt-homescreen-example.desktop b/qt-homescreen-example/qt-homescreen-example.desktop
new file mode 100644
index 0000000..7b2b52d
--- /dev/null
+++ b/qt-homescreen-example/qt-homescreen-example.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=Qt Desktop Example
+Comment=An example home desktop item
+Type=qt
+X-Path=qt-homescreen-example
+X-Multiple-Instances=false
+X-home-applet-minwidth=100
+X-home-applet-minheight=72
+Name[en_US]=Example Qt Desktop Item
diff --git a/qt-homescreen-example/qt-homescreen-example.pro b/qt-homescreen-example/qt-homescreen-example.pro
new file mode 100644
index 0000000..3ef254f
--- /dev/null
+++ b/qt-homescreen-example/qt-homescreen-example.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+
+SOURCES += main.cpp
+HEADERS += testwidget.h
+
+include(../qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.pri)
+
+desktop.path = /usr/share/applications/hildon-home
+desktop.files = qt-homescreen-example.desktop
+
+target.path = /usr/lib/hildon-desktop
+INSTALLS += target desktop
diff --git a/qt-homescreen-example/testwidget.h b/qt-homescreen-example/testwidget.h
new file mode 100644
index 0000000..9aa5a78
--- /dev/null
+++ b/qt-homescreen-example/testwidget.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TESTWIDGET_H
+#define TESTWIDGET_H
+
+#include <QtGui/qlabel.h>
+#include <QtGui/qinputdialog.h>
+#include <QtGui/qpainter.h>
+
+class TestWidget : public QLabel
+{
+ Q_OBJECT
+
+public:
+ TestWidget()
+ : QLabel(tr("Hello World"))
+ {
+ setAlignment(Qt::AlignCenter);
+ setAttribute(Qt::WA_TranslucentBackground);
+ }
+
+ QSize sizeHint() const
+ {
+ return 2 * QLabel::sizeHint();
+ }
+
+public slots:
+ void showSettingsDialog()
+ {
+ bool isOk;
+ QString newText = QInputDialog::getText(this, tr("New Text"),
+ tr("Please enter a new text:"), QLineEdit::Normal,
+ text(), &isOk);
+ if (isOk)
+ setText(newText);
+ }
+
+protected:
+ void paintEvent(QPaintEvent *event)
+ {
+ QPainter p(this);
+ p.setBrush(QColor(0, 0, 0, 128));
+ p.setPen(Qt::NoPen);
+ p.drawRoundedRect(rect(), 25, 25);
+ p.end();
+
+ QLabel::paintEvent(event);
+ }
+};
+
+#endif