summaryrefslogtreecommitdiffstats
path: root/demos/embedded/desktopservices
diff options
context:
space:
mode:
Diffstat (limited to 'demos/embedded/desktopservices')
-rw-r--r--demos/embedded/desktopservices/contenttab.cpp110
-rw-r--r--demos/embedded/desktopservices/contenttab.h68
-rw-r--r--demos/embedded/desktopservices/data/Explosion.wavbin0 -> 18427 bytes
-rw-r--r--demos/embedded/desktopservices/data/designer.pngbin0 -> 4205 bytes
-rw-r--r--demos/embedded/desktopservices/data/monkey_on_64x64.pngbin0 -> 3479 bytes
-rw-r--r--demos/embedded/desktopservices/data/sax.mp3bin0 -> 417844 bytes
-rw-r--r--demos/embedded/desktopservices/desktopservices.pro23
-rw-r--r--demos/embedded/desktopservices/desktopservices.qrc8
-rw-r--r--demos/embedded/desktopservices/desktopwidget.cpp56
-rw-r--r--demos/embedded/desktopservices/desktopwidget.h41
-rw-r--r--demos/embedded/desktopservices/linktab.cpp49
-rw-r--r--demos/embedded/desktopservices/linktab.h53
-rw-r--r--demos/embedded/desktopservices/main.cpp26
-rw-r--r--demos/embedded/desktopservices/resources/browser.pngbin0 -> 2739 bytes
-rw-r--r--demos/embedded/desktopservices/resources/heart.svg55
-rw-r--r--demos/embedded/desktopservices/resources/message.pngbin0 -> 2234 bytes
-rw-r--r--demos/embedded/desktopservices/resources/music.pngbin0 -> 2322 bytes
-rw-r--r--demos/embedded/desktopservices/resources/photo.pngbin0 -> 2430 bytes
18 files changed, 489 insertions, 0 deletions
diff --git a/demos/embedded/desktopservices/contenttab.cpp b/demos/embedded/desktopservices/contenttab.cpp
new file mode 100644
index 0000000..1abb051
--- /dev/null
+++ b/demos/embedded/desktopservices/contenttab.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+// EXTERNAL INCLUDES
+#include <QKeyEvent>
+#include <QListWidget>
+#include <QVBoxLayout>
+#include <QFileInfoList>
+#include <QListWidgetItem>
+
+// INTERNAL INCLUDES
+
+// CLASS HEADER
+#include "contenttab.h"
+
+
+// CONSTRUCTORS & DESTRUCTORS
+ContentTab::ContentTab(QWidget *parent) :
+ QListWidget(parent)
+{
+ setDragEnabled(false);
+ setIconSize(QSize(45, 45));
+}
+
+ContentTab::~ContentTab()
+{
+}
+
+// NEW PUBLIC METHODS
+void ContentTab::init(const QDesktopServices::StandardLocation &location,
+ const QString &icon)
+{
+ setContentDir(location);
+ setIcon(icon);
+
+ connect(this, SIGNAL(itemClicked(QListWidgetItem *)),
+ this, SLOT(openItem(QListWidgetItem *)));
+
+ populateListWidget();
+}
+
+// NEW PROTECTED METHODS
+void ContentTab::setContentDir(const QDesktopServices::StandardLocation &location)
+{
+ m_ContentDir.setPath(QDesktopServices::storageLocation(location));
+}
+
+void ContentTab::setIcon(const QString &icon)
+{
+ m_Icon = QIcon(icon);
+}
+
+void ContentTab::populateListWidget()
+{
+ QFileInfoList fileList = m_ContentDir.entryInfoList(QStringList(), QDir::Files, QDir::Time);
+ foreach(QFileInfo item, fileList) {
+ new QListWidgetItem(m_Icon, itemName(item), this);
+ }
+}
+
+QString ContentTab::itemName(const QFileInfo &item)
+{
+ return QString(item.baseName() + "." + item.completeSuffix());
+}
+
+QUrl ContentTab::itemUrl(QListWidgetItem *item)
+{
+ return QUrl("file:///" + m_ContentDir.absolutePath() + "/" + item->text());
+}
+
+void ContentTab::keyPressEvent(QKeyEvent *event)
+{
+ switch(event->key()) {
+ case Qt::Key_Up:
+ if(currentRow() == 0) {
+ setCurrentRow(count()-1);
+ } else {
+ setCurrentRow(currentRow()-1);
+ }
+ break;
+ case Qt::Key_Down:
+ if(currentRow() == (count()-1)) {
+ setCurrentRow(0);
+ } else {
+ setCurrentRow(currentRow()+1);
+ }
+ break;
+ case Qt::Key_Select:
+ openItem(currentItem());
+ default:
+ QListWidget::keyPressEvent(event);
+ break;
+ }
+}
+
+// NEW SLOTS
+void ContentTab::openItem(QListWidgetItem *item)
+{
+ QDesktopServices::openUrl(itemUrl(item));
+}
+
+// End of File
diff --git a/demos/embedded/desktopservices/contenttab.h b/demos/embedded/desktopservices/contenttab.h
new file mode 100644
index 0000000..bfbb044
--- /dev/null
+++ b/demos/embedded/desktopservices/contenttab.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONTENTTAB_H_
+#define CONTENTTAB_H_
+
+// EXTERNAL INCLUDES
+#include <QDir>
+#include <QUrl>
+#include <QIcon>
+#include <QFileInfo>
+#include <QListWidget>
+#include <QDesktopServices>
+
+// INTERNAL INCLUDES
+
+// FORWARD DECLARATIONS
+class QListWidgetItem;
+
+// CLASS DECLARATION
+
+/**
+* ContentTab class.
+*
+* This class implements general purpose tab for media files.
+*/
+class ContentTab : public QListWidget
+{
+ Q_OBJECT
+
+public: // Constructors & Destructors
+ ContentTab(QWidget *parent);
+ virtual ~ContentTab();
+
+public: // New Methods
+ virtual void init(const QDesktopServices::StandardLocation &location,
+ const QString &icon);
+
+protected: // New Methods
+ virtual void setContentDir(const QDesktopServices::StandardLocation &location);
+ virtual void setIcon(const QString &icon);
+ virtual void populateListWidget();
+ virtual QString itemName(const QFileInfo &item);
+ virtual QUrl itemUrl(QListWidgetItem *item);
+
+protected:
+ void keyPressEvent(QKeyEvent *event);
+
+public slots: // New Slots
+ virtual void openItem(QListWidgetItem *item);
+
+protected: // Owned variables
+ QDir m_ContentDir;
+ QIcon m_Icon;
+};
+
+
+#endif // CONTENTTAB_H_
+
+// End of File
diff --git a/demos/embedded/desktopservices/data/Explosion.wav b/demos/embedded/desktopservices/data/Explosion.wav
new file mode 100644
index 0000000..7b140b1
--- /dev/null
+++ b/demos/embedded/desktopservices/data/Explosion.wav
Binary files differ
diff --git a/demos/embedded/desktopservices/data/designer.png b/demos/embedded/desktopservices/data/designer.png
new file mode 100644
index 0000000..0988fce
--- /dev/null
+++ b/demos/embedded/desktopservices/data/designer.png
Binary files differ
diff --git a/demos/embedded/desktopservices/data/monkey_on_64x64.png b/demos/embedded/desktopservices/data/monkey_on_64x64.png
new file mode 100644
index 0000000..990f604
--- /dev/null
+++ b/demos/embedded/desktopservices/data/monkey_on_64x64.png
Binary files differ
diff --git a/demos/embedded/desktopservices/data/sax.mp3 b/demos/embedded/desktopservices/data/sax.mp3
new file mode 100644
index 0000000..0a078b1
--- /dev/null
+++ b/demos/embedded/desktopservices/data/sax.mp3
Binary files differ
diff --git a/demos/embedded/desktopservices/desktopservices.pro b/demos/embedded/desktopservices/desktopservices.pro
new file mode 100644
index 0000000..32cb6d9
--- /dev/null
+++ b/demos/embedded/desktopservices/desktopservices.pro
@@ -0,0 +1,23 @@
+TEMPLATE = app
+TARGET =
+INCLUDEPATH += .
+
+HEADERS += desktopwidget.h contenttab.h linktab.h
+SOURCES += desktopwidget.cpp contenttab.cpp linktab.cpp main.cpp
+
+RESOURCES += desktopservices.qrc
+
+music.sources = data/*.mp3 data/*.wav
+music.path = /data/sounds/
+
+image.sources = data/*.png
+image.path = /data/images/
+
+DEPLOYMENT += music image
+
+include($$QT_SOURCE_TREE/demos/demobase.pri)
+
+symbian {
+ TARGET.UID3 = 0xA000C611
+ ICON = ./resources/heart.svg
+}
diff --git a/demos/embedded/desktopservices/desktopservices.qrc b/demos/embedded/desktopservices/desktopservices.qrc
new file mode 100644
index 0000000..d36205d
--- /dev/null
+++ b/demos/embedded/desktopservices/desktopservices.qrc
@@ -0,0 +1,8 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>resources/music.png</file>
+ <file>resources/photo.png</file>
+ <file>resources/browser.png</file>
+ <file>resources/message.png</file>
+</qresource>
+</RCC>
diff --git a/demos/embedded/desktopservices/desktopwidget.cpp b/demos/embedded/desktopservices/desktopwidget.cpp
new file mode 100644
index 0000000..17243cf
--- /dev/null
+++ b/demos/embedded/desktopservices/desktopwidget.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+// EXTERNAL INCLUDES
+#include <QTabWidget>
+#include <QVBoxLayout>
+#include <QDesktopServices>
+
+// INTERNAL INCLUDES
+#include "linktab.h"
+#include "contenttab.h"
+
+// CLASS HEADER
+#include "desktopwidget.h"
+
+// CONSTRUCTORS & DESTRUCTORS
+DesktopWidget::DesktopWidget(QWidget *parent) : QWidget(parent)
+
+{
+ QTabWidget *tabWidget = new QTabWidget(this);
+
+ // Images
+ ContentTab* imageTab = new ContentTab(tabWidget);
+ imageTab->init(QDesktopServices::PicturesLocation, ":/resources/photo.png");
+ tabWidget->addTab(imageTab, tr("Images"));
+
+ // Music
+ ContentTab* musicTab = new ContentTab(tabWidget);
+ musicTab->init(QDesktopServices::MusicLocation, ":/resources/music.png");
+ tabWidget->addTab(musicTab, tr("Music"));
+
+ // Links
+ LinkTab* othersTab = new LinkTab(tabWidget);;
+ // Given icon file will be overriden by LinkTab
+ othersTab->init(QDesktopServices::PicturesLocation, "");
+ tabWidget->addTab(othersTab, tr("Links"));
+
+ // Layout
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(tabWidget);
+ setLayout(layout);
+}
+
+DesktopWidget::~DesktopWidget()
+{
+}
+
+// End of file
diff --git a/demos/embedded/desktopservices/desktopwidget.h b/demos/embedded/desktopservices/desktopwidget.h
new file mode 100644
index 0000000..5b74e48
--- /dev/null
+++ b/demos/embedded/desktopservices/desktopwidget.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DESKTOPWIDGET_H_
+#define DESKTOPWIDGET_H_
+
+// EXTERNAL INCLUDES
+#include <QWidget>
+
+// INTERNAL INCLUDES
+
+// FORWARD DECLARATIONS
+class QTabWidget;
+
+// CLASS DECLARATION
+/**
+* DesktopWidget class.
+*
+* Implements the main top level widget for QDesktopServices demo app.
+*/
+class DesktopWidget : public QWidget
+{
+ Q_OBJECT
+
+public: // Constructors & Destructors
+ DesktopWidget(QWidget *parent);
+ ~DesktopWidget();
+
+};
+
+#endif // DESKTOPWIDGET_H_
+
+// End of file
diff --git a/demos/embedded/desktopservices/linktab.cpp b/demos/embedded/desktopservices/linktab.cpp
new file mode 100644
index 0000000..0d5bea7
--- /dev/null
+++ b/demos/embedded/desktopservices/linktab.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+// EXTERNAL INCLUDES
+#include <QUrl>
+#include <QListWidgetItem>
+
+// INTERNAL INCLUDES
+
+// CLASS HEADER
+#include "linktab.h"
+
+LinkTab::LinkTab(QWidget *parent) :
+ ContentTab(parent)
+{
+}
+
+LinkTab::~LinkTab()
+{
+}
+
+void LinkTab::populateListWidget()
+{
+ m_WebItem = new QListWidgetItem(QIcon(":/resources/browser.png"), tr("Launch Browser"), this);
+ m_MailToItem = new QListWidgetItem(QIcon(":/resources/message.png"), tr("New e-mail"), this);
+}
+
+QUrl LinkTab::itemUrl(QListWidgetItem *item)
+{
+ if(m_WebItem == item) {
+ return QUrl(tr("http://www.qtsoftware.com"));
+ } else if(m_MailToItem == item) {
+ return QUrl(tr("mailto:qts60-feedback@trolltech.com?subject=QtS60 feedback&body=Hello"));
+ } else {
+ // We should never endup here
+ Q_ASSERT(false);
+ return QUrl();
+ }
+}
+
+// End of file
diff --git a/demos/embedded/desktopservices/linktab.h b/demos/embedded/desktopservices/linktab.h
new file mode 100644
index 0000000..02ad494
--- /dev/null
+++ b/demos/embedded/desktopservices/linktab.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LINKTAB_H_
+#define LINKTAB_H_
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include "contenttab.h"
+
+// FORWARD DECLARATIONS
+class QWidget;
+class QListWidgetItem;
+
+// CLASS DECLARATION
+
+/**
+* LinkTab class.
+*
+* This class implements tab for opening http and mailto links.
+*/
+class LinkTab : public ContentTab
+{
+ Q_OBJECT
+
+public: // Constructors & Destructors
+ LinkTab(QWidget *parent);
+ ~LinkTab();
+
+protected: // Derived Methods
+ virtual void populateListWidget();
+ virtual QUrl itemUrl(QListWidgetItem *item);
+
+private: // Used variables
+ QListWidgetItem *m_WebItem;
+ QListWidgetItem *m_MailToItem;
+
+private: // Owned variables
+
+};
+
+#endif // CONTENTTAB_H_
+
+// End of File
diff --git a/demos/embedded/desktopservices/main.cpp b/demos/embedded/desktopservices/main.cpp
new file mode 100644
index 0000000..32e22ae
--- /dev/null
+++ b/demos/embedded/desktopservices/main.cpp
@@ -0,0 +1,26 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "desktopwidget.h"
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(desktopservices);
+
+ QApplication app(argc, argv);
+ DesktopWidget* myWidget = new DesktopWidget(0);
+ myWidget->showMaximized();
+
+ return app.exec();
+}
+
+// End of file
diff --git a/demos/embedded/desktopservices/resources/browser.png b/demos/embedded/desktopservices/resources/browser.png
new file mode 100644
index 0000000..28561e1
--- /dev/null
+++ b/demos/embedded/desktopservices/resources/browser.png
Binary files differ
diff --git a/demos/embedded/desktopservices/resources/heart.svg b/demos/embedded/desktopservices/resources/heart.svg
new file mode 100644
index 0000000..ba5f050
--- /dev/null
+++ b/demos/embedded/desktopservices/resources/heart.svg
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) --><svg viewBox="100 200 550 500" height="595.27559pt" id="svg1" inkscape:version="0.40+cvs" sodipodi:docbase="C:\Documents and Settings\Jon Phillips\My Documents\projects\clipart-project\submissions" sodipodi:docname="heart-left-highlight.svg" sodipodi:version="0.32" width="595.27559pt" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
+<metadata>
+<rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<cc:Work rdf:about="">
+<dc:title>Heart Left-Highlight</dc:title>
+<dc:description>This is a normal valentines day heart.</dc:description>
+<dc:subject>
+<rdf:Bag>
+<rdf:li>holiday</rdf:li>
+<rdf:li>valentines</rdf:li>
+<rdf:li></rdf:li>
+<rdf:li>valentine</rdf:li>
+<rdf:li>hash(0x8a091c0)</rdf:li>
+<rdf:li>hash(0x8a0916c)</rdf:li>
+<rdf:li>signs_and_symbols</rdf:li>
+<rdf:li>hash(0x8a091f0)</rdf:li>
+<rdf:li>day</rdf:li>
+</rdf:Bag>
+</dc:subject>
+<dc:publisher>
+<cc:Agent rdf:about="http://www.openclipart.org">
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:publisher>
+<dc:creator>
+<cc:Agent>
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:creator>
+<dc:rights>
+<cc:Agent>
+<dc:title>Jon Phillips</dc:title>
+</cc:Agent>
+</dc:rights>
+<dc:date></dc:date>
+<dc:format>image/svg+xml</dc:format>
+<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+<cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/>
+<dc:language>en</dc:language>
+</cc:Work>
+<cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
+<cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+<cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+</cc:License>
+</rdf:RDF>
+</metadata>
+<defs id="defs3"/>
+<sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:current-layer="layer1" inkscape:cx="549.40674" inkscape:cy="596.00159" inkscape:document-units="px" inkscape:guide-bbox="true" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="615" inkscape:window-width="866" inkscape:window-x="88" inkscape:window-y="116" inkscape:zoom="0.35000000" pagecolor="#ffffff" showguides="true"/>
+<g id="layer1" inkscape:groupmode="layer" inkscape:label="Layer 1">
+<path d="M 263.41570,235.14588 C 197.17570,235.14588 143.41575,288.90587 143.41575,355.14588 C 143.41575,489.90139 279.34890,525.23318 371.97820,658.45392 C 459.55244,526.05056 600.54070,485.59932 600.54070,355.14588 C 600.54070,288.90588 546.78080,235.14587 480.54070,235.14588 C 432.49280,235.14588 391.13910,263.51631 371.97820,304.33338 C 352.81740,263.51630 311.46370,235.14587 263.41570,235.14588 z " id="path7" sodipodi:nodetypes="ccccccc" style="fill:#e60000;fill-opacity:1.0000000;stroke:#000000;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/>
+<path d="M 265.00000,253.59375 C 207.04033,253.59375 160.00000,300.63407 160.00000,358.59375 C 160.00000,476.50415 278.91857,507.43251 359.96875,624.00000 C 366.52868,614.08205 220.00000,478.47309 220.00000,378.59375 C 220.00000,320.63407 267.04033,273.59375 325.00000,273.59375 C 325.50453,273.59375 325.99718,273.64912 326.50000,273.65625 C 309.22436,261.07286 288.00557,253.59374 265.00000,253.59375 z " id="path220" sodipodi:nodetypes="ccccccc" style="fill:#e6e6e6;fill-opacity:0.64556962;stroke:none;stroke-width:18.700001;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"/>
+</g>
+</svg>
diff --git a/demos/embedded/desktopservices/resources/message.png b/demos/embedded/desktopservices/resources/message.png
new file mode 100644
index 0000000..e30052b
--- /dev/null
+++ b/demos/embedded/desktopservices/resources/message.png
Binary files differ
diff --git a/demos/embedded/desktopservices/resources/music.png b/demos/embedded/desktopservices/resources/music.png
new file mode 100644
index 0000000..11a57bb
--- /dev/null
+++ b/demos/embedded/desktopservices/resources/music.png
Binary files differ
diff --git a/demos/embedded/desktopservices/resources/photo.png b/demos/embedded/desktopservices/resources/photo.png
new file mode 100644
index 0000000..5ba15c1
--- /dev/null
+++ b/demos/embedded/desktopservices/resources/photo.png
Binary files differ