Mercurial > projects > qtd
changeset 120:2c9ef955a171
add desktop examples
author | mandel |
---|---|
date | Fri, 05 Jun 2009 11:52:21 +0000 |
parents | 97650cedf5d7 |
children | 884f947e6f74 |
files | examples/CMakeLists.txt examples/desktop/CMakeLists.txt examples/desktop/screenshot/CMakeLists.txt examples/desktop/screenshot/build examples/desktop/screenshot/build.bat examples/desktop/screenshot/main.d examples/desktop/screenshot/screenshot.d examples/desktop/systray/CMakeLists.txt examples/desktop/systray/build examples/desktop/systray/build.bat examples/desktop/systray/images/bad.svg examples/desktop/systray/images/heart.svg examples/desktop/systray/images/trash.svg examples/desktop/systray/main.d examples/desktop/systray/systray.qrc examples/desktop/systray/window.d |
diffstat | 16 files changed, 812 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/CMakeLists.txt Fri Jun 05 11:45:37 2009 +0000 +++ b/examples/CMakeLists.txt Fri Jun 05 11:52:21 2009 +0000 @@ -4,4 +4,5 @@ add_subdirectory(mainwindows) add_subdirectory(opengl) add_subdirectory(tutorials) -add_subdirectory(widgets) \ No newline at end of file +add_subdirectory(widgets) +add_subdirectory(desktop) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/CMakeLists.txt Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,1 @@ +add_subdirectory(systray) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/screenshot/CMakeLists.txt Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,1 @@ +build_example(screenshot main.d screenshot.d) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/screenshot/build Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,3 @@ +#! /bin/bash + +dmd main.d screenshot.d -I../../../ -I../../../qt/d1 -L-L../../../lib -L-lqtdgui -L-lqtdcore -L-lQtCore -L-lQtGui -ofscreenshot
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/screenshot/build.bat Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,1 @@ +dmd main.d screenshot.d libqtdcore.lib libqtdgui.lib -I../../../ -I../../../qt/d1 -ofscreenshot \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/screenshot/main.d Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +module main; + + +import qt.gui.QApplication; +import screenshot; + + +int main(string[] args) +{ + scope app = new QApplication(args); + scope screenshot = new Screenshot; + screenshot.show(); + return app.exec(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/screenshot/screenshot.d Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +module screenshot; + + +import qt.gui.QPixmap; +import qt.gui.QWidget; +import qt.gui.QCheckBox; +import qt.gui.QGridLayout; +import qt.gui.QGroupBox; +import qt.gui.QHBoxLayout; +import qt.gui.QLabel; +import qt.gui.QPushButton; +import qt.gui.QSpinBox; +import qt.gui.QVBoxLayout; +import qt.gui.QFileDialog; +import qt.core.QDir; +import qt.core.QTimer; + +import tango.text.convert.Format; +import tango.text.Ascii; + + +class Screenshot : public QWidget +{ +public: + + this() + { + screenshotLabel = new QLabel; + screenshotLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding); + screenshotLabel.setAlignment(Qt.AlignCenter); + screenshotLabel.setMinimumSize(240, 160); + + createOptionsGroupBox(); + createButtonsLayout(); + + mainLayout = new QVBoxLayout; + mainLayout.addWidget(screenshotLabel); + mainLayout.addWidget(optionsGroupBox); + mainLayout.addLayout(buttonsLayout); + setLayout(mainLayout); + + shootScreen(); + delaySpinBox.setValue(5); + + setWindowTitle(tr("Screenshot")); + resize(300, 200); + } + +protected: + + void resizeEvent(QResizeEvent /* event */) + { + QSize scaledSize = originalPixmap.size(); + scaledSize.scale(screenshotLabel.size(), Qt.KeepAspectRatio); + if (!screenshotLabel.pixmap() || scaledSize != screenshotLabel.pixmap().size()) + updateScreenshotLabel(); + } + + private: + + void newScreenshot() + { + if (hideThisWindowCheckBox.isChecked()) + hide(); + newScreenshotButton.setDisabled(true); + + QTimer.singleShot(delaySpinBox.value() * 1000, this, SLOT(shootScreen())); + } + + void saveScreenshot() + { + string format = "png"; + string initialPath = QDir.currentPath() + tr("/untitled.") + format; + + string fileName = QFileDialog.getSaveFileName(this, tr("Save As"), initialPath, + Format(tr("{} Files (*.{});;All Files (*)"), toUpper(format), format)); + if (fileName.length) + originalPixmap.save(fileName, format); + } + + void shootScreen() + { + if (delaySpinBox.value() != 0) + QApplication.beep(); + + originalPixmap = new QPixmap(); // clear image for low memory situations + + // on embedded devices. + originalPixmap = QPixmap.grabWindow(QApplication.desktop().winId()); + updateScreenshotLabel(); + + newScreenshotButton.setDisabled(false); + if (hideThisWindowCheckBox.isChecked()) + show(); + } + + void updateCheckBox() + { + if (delaySpinBox.value() == 0) { + hideThisWindowCheckBox.setDisabled(true); + hideThisWindowCheckBox.setChecked(false); + } + else + hideThisWindowCheckBox.setDisabled(false); + } + +private: + + void createOptionsGroupBox() + { + optionsGroupBox = new QGroupBox(tr("Options")); + + delaySpinBox = new QSpinBox; + delaySpinBox.setSuffix(tr(" s")); + delaySpinBox.setMaximum(60); + delaySpinBox.valueChanged.connect(&this.updateCheckBox); + + delaySpinBoxLabel = new QLabel(tr("Screenshot Delay:")); + + hideThisWindowCheckBox = new QCheckBox(tr("Hide This Window")); + + optionsGroupBoxLayout = new QGridLayout; + optionsGroupBoxLayout.addWidget(delaySpinBoxLabel, 0, 0); + optionsGroupBoxLayout.addWidget(delaySpinBox, 0, 1); + optionsGroupBoxLayout.addWidget(hideThisWindowCheckBox, 1, 0, 1, 2); + optionsGroupBox.setLayout(optionsGroupBoxLayout); + } + + void createButtonsLayout() + { + newScreenshotButton = createButton(tr("New Screenshot"), &this.newScreenshot); + + saveScreenshotButton = createButton(tr("Save Screenshot"), &this.saveScreenshot); + + quitScreenshotButton = createButton(tr("Quit"), &this.close); + + buttonsLayout = new QHBoxLayout; + buttonsLayout.addStretch(); + buttonsLayout.addWidget(newScreenshotButton); + buttonsLayout.addWidget(saveScreenshotButton); + buttonsLayout.addWidget(quitScreenshotButton); + } + + QPushButton createButton(string text, void delegate() slot) + { + QPushButton button = new QPushButton(text); + button.clicked.connect(slot); + return button; + } + + void updateScreenshotLabel() + { + screenshotLabel.setPixmap(originalPixmap.scaled(screenshotLabel.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation)); + } + + QPixmap originalPixmap; + + QLabel screenshotLabel; + QGroupBox optionsGroupBox; + QSpinBox delaySpinBox; + QLabel delaySpinBoxLabel; + QCheckBox hideThisWindowCheckBox; + QPushButton newScreenshotButton; + QPushButton saveScreenshotButton; + QPushButton quitScreenshotButton; + + QVBoxLayout mainLayout; + QGridLayout optionsGroupBoxLayout; + QHBoxLayout buttonsLayout; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/CMakeLists.txt Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,1 @@ +build_example(systray main.d window.d RESOURCES resources.qrc) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/build Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,4 @@ +#! /bin/bash + +../../../tools/drcc/drcc systray.qrc > resources.d +dmd main.d window.d resources.d -I../../../ -I../../../qt/d1 -L-L../../../lib -L-lqtdgui -L-lqtdcore -L-lQtCore -L-lQtGui -ofsystray
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/build.bat Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,2 @@ +../../../tools/drcc/drcc systray.qrc > resources.d +dmd main.d window.d resources.d libqtdcore.lib libqtdgui.lib -I../../../ -I../../../qt/d1 -ofsystray \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/images/bad.svg Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" +"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> +<svg viewBox="-10 -10 178 178" height="177.523" id="svg1" inkscape:version="0.40" sodipodi:docbase="/mnt/donnees/09-Mes_images/Travaux/Travaux vectoriel/pictogrammes/sécu SVG/produits chimiques" sodipodi:docname="XiIrritant.svg" sodipodi:version="0.32" width="155.932" 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://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink"> +<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>Irritant</dc:title> +<dc:description>produit chimique</dc:description> +<dc:subject> +<rdf:Bag> +<rdf:li></rdf:li> +<rdf:li>symbol</rdf:li> +<rdf:li>signs_and_symbols</rdf:li> +</rdf:Bag> +</dc:subject> +<dc:publisher> +<cc:Agent rdf:about="http://www.openclipart.org"> +<dc:title>yves GUILLOU</dc:title> +</cc:Agent> +</dc:publisher> +<dc:creator> +<cc:Agent> +<dc:title>yves GUILLOU</dc:title> +</cc:Agent> +</dc:creator> +<dc:rights> +<cc:Agent> +<dc:title>yves GUILLOU</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> +<sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:current-layer="svg1" inkscape:cx="62.372805" inkscape:cy="34.864537" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="1121" inkscape:window-width="1590" inkscape:window-x="200" inkscape:window-y="0" inkscape:zoom="6.6399849" pagecolor="#ffffff"/> +<defs id="defs2"> +<marker id="ArrowEnd" markerHeight="3" markerUnits="strokeWidth" markerWidth="4" orient="auto" refX="0" refY="5" viewBox="0 0 10 10"> +<path d="M 0 0 L 10 5 L 0 10 z" id="path4"/> +</marker> +<marker id="ArrowStart" markerHeight="3" markerUnits="strokeWidth" markerWidth="4" orient="auto" refX="10" refY="5" viewBox="0 0 10 10"> +<path d="M 10 0 L 0 5 L 10 10 z" id="path6"/> +</marker> +</defs> +<g id="g7"> +<g id="g8"> +<path d="M 155.932 155.932L 155.932 0L 0 0L 0 155.932L 155.932 155.932z" id="path9" style="stroke:none; fill:#000000"/> +<path d="M 150.83 150.83L 150.83 5.1011L 5.1011 5.1011L 5.1011 150.83L 150.83 150.83z" id="path10" style="stroke:none; fill:#ff9900"/> +</g> +<g id="g11"> +<path d="M 140.823 111.783L 44.3677 14.0771L 15.1084 44.1489L 111.564 141.854L 140.823 111.783z" id="path12" style="stroke:none; fill:#000000"/> +<path d="M 111.783 15.1084L 14.0771 111.564L 44.1489 140.823L 141.855 44.3677L 111.783 15.1084z" id="path13" style="stroke:none; fill:#000000"/> +</g> +</g> +</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/images/heart.svg Fri Jun 05 11:52:21 2009 +0000 @@ -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>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/images/trash.svg Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 10, SVG Export Plug-In . SVG Version: 3.0.0 Build 76) --><svg enable-background="new 0 0 347 348" height="348" i:pageBounds="0 792 612 0" i:rulerOrigin="0 0" i:viewOrigin="131 567" overflow="visible" space="preserve" viewBox="-20 -20 387 388" width="347" xmlns="http://www.w3.org/2000/svg" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" xmlns:graph="http://ns.adobe.com/Graphs/1.0/" xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/" xmlns:x="http://ns.adobe.com/Extensibility/1.0/" xmlns:xlink="http://www.w3.org/1999/xlink"> +<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>Keep Tidy Inside</dc:title> +<dc:description></dc:description> +<dc:subject> +<rdf:Bag> +<rdf:li></rdf:li> +<rdf:li>symbol</rdf:li> +<rdf:li>bin</rdf:li> +<rdf:li>signs_and_symbols</rdf:li> +<rdf:li>clean</rdf:li> +<rdf:li>rubish</rdf:li> +<rdf:li>trash</rdf:li> +<rdf:li>inside</rdf:li> +<rdf:li>garbage</rdf:li> +<rdf:li>sign</rdf:li> +</rdf:Bag> +</dc:subject> +<dc:publisher> +<cc:Agent rdf:about="http://www.openclipart.org"> +<dc:title>Martin Owens</dc:title> +</cc:Agent> +</dc:publisher> +<dc:creator> +<cc:Agent> +<dc:title>Martin Owens</dc:title> +</cc:Agent> +</dc:creator> +<dc:rights> +<cc:Agent> +<dc:title>Martin Owens</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> +<g i:dimmedPercent="50" i:knockout="Off" i:layer="yes" i:rgbTrio="#4F008000FFFF" id="Layer_1"> +<path d="M347,174c0,96.098-77.679,174-173.5,174C77.679,348,0,270.098,0,174 C0,77.902,77.679,0,173.5,0C269.321,0,347,77.902,347,174z" fill="#10A040" i:knockout="Off"/> +<path d="M238,53c0,13.807-11.864,25-26.5,25S185,66.807,185,53s11.864-25,26.5-25 S238,39.193,238,53z" fill="#FFFFFF" i:knockout="Off"/> +<path d="M66,175c1.055,6.355,19.333,126.417,19.333,126.417h68.333 c0,0,14.105-122.524,14.333-126.417c6.224-0.622,6.667-13-2-13c-12.164,0-89.205-0.059-98,0S61.167,174.487,66,175z" fill="#FFFFFF" i:knockout="Off"/> +<path d="M78,141c17.292-5.325,24.179-23.532,27-31c14.513,6.596,40.333,12.265,59,8 c3.683,19.419-28.043,19.31-23,37C132.577,145.705,89.404,167.292,78,141z" fill="#FFFFFF" i:knockout="Off"/> +<path d="M103,82l139-1c-0.6,3.421,33.633,57.497,29,67c-4.089,0.418-67,5-67,5 c6.109-9.379-13-43-13-43L103,82z" fill="#FFFFFF" i:knockout="Off"/> +<path d="M270,156l-66-3c0,0-23.565,143.355-24,145s1.855,2.536,3,1s51-82,51-82 s19.754,80.701,20,82s3.721,1.209,4,0S270,156,270,156z" fill="#FFFFFF" i:knockout="Off"/> +</g> +</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/main.d Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +module main; + + +import qt.gui.QMessageBox; +import qt.gui.QApplication; +import qt.gui.QSystemTrayIcon; + +import window; +import resources; + +int main(char[][] args) +{ + auto app = new QApplication(args); + + if (!QSystemTrayIcon.isSystemTrayAvailable()) { + QMessageBox.critical(null, tr("Systray"), tr("I couldn't detect any system tray on this system.")); + return 1; + } + QApplication.setQuitOnLastWindowClosed(false); + + auto window = new Window; + window.show(); + return app.exec(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/systray.qrc Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>images/bad.svg</file> + <file>images/heart.svg</file> + <file>images/trash.svg</file> +</qresource> +</RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/desktop/systray/window.d Fri Jun 05 11:52:21 2009 +0000 @@ -0,0 +1,285 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +module window; + +import qt.gui.QSystemTrayIcon; +import qt.gui.QDialog; +import qt.gui.QAction; +import qt.gui.QCheckBox; +import qt.gui.QComboBox; +import qt.gui.QGroupBox; +import qt.gui.QLabel; +import qt.gui.QLineEdit; +import qt.gui.QMenu; +import qt.gui.QPushButton; +import qt.gui.QSpinBox; +import qt.gui.QTextEdit; +import qt.gui.QVBoxLayout; +import qt.gui.QHBoxLayout; +import qt.gui.QMessageBox; +import qt.gui.QGridLayout; + + +class Window : public QDialog +{ +public: + + this() + { + createIconGroupBox(); + createMessageGroupBox(); + + iconLabel.setMinimumWidth(durationLabel.sizeHint().width()); + + createActions(); + createTrayIcon(); + + showMessageButton.clicked.connect(&this.showMessage); + showIconCheckBox.toggled.connect(&trayIcon.setVisible); + iconComboBox.currentIndexChanged.connect(&this.setIcon); + trayIcon.messageClicked.connect(&this.messageClicked); + trayIcon.activated.connect(&this.iconActivated); + + QVBoxLayout mainLayout = new QVBoxLayout; + mainLayout.addWidget(iconGroupBox); + mainLayout.addWidget(messageGroupBox); + setLayout(mainLayout); + + iconComboBox.setCurrentIndex(1); + trayIcon.show(); + + setWindowTitle(tr("Systray")); + resize(400, 300); + } + + void setVisible(bool visible) + { + minimizeAction.setEnabled(visible); + maximizeAction.setEnabled(!isMaximized()); + restoreAction.setEnabled(isMaximized() || !visible); + QDialog.setVisible(visible); + } + + protected: + + void closeEvent(QCloseEvent event) + { + if (trayIcon.isVisible()) { + QMessageBox.information(this, tr("Systray"), + tr("The program will keep running in the system tray. To terminate the program, " + "choose <b>Quit</b> in the context menu of the system tray entry.")); + hide(); + event.ignore(); + } + } + +private: + + void setIcon(int index) + { + QIcon icon = iconComboBox.itemIcon(index); + trayIcon.setIcon(icon); + setWindowIcon(icon); + + trayIcon.setToolTip(iconComboBox.itemText(index)); + } + + void iconActivated(QSystemTrayIcon.ActivationReason reason) + { + switch (reason) { + case QSystemTrayIcon.Trigger: + case QSystemTrayIcon.DoubleClick: + iconComboBox.setCurrentIndex((iconComboBox.currentIndex() + 1) % iconComboBox.count()); + break; + case QSystemTrayIcon.MiddleClick: + showMessage(); + break; + default: + } + } + + void showMessage() + { + QSystemTrayIcon.MessageIcon icon = cast(QSystemTrayIcon.MessageIcon) + typeComboBox.itemData(typeComboBox.currentIndex()).toInt(); + trayIcon.showMessage(titleEdit.text(), bodyEdit.toPlainText(), icon, durationSpinBox.value() * 1000); + } + + void messageClicked() + { + QMessageBox.information(null, tr("Systray"), + tr("Sorry, I already gave what help I could.\nMaybe you should try asking a human?")); + } + +private: + + void createIconGroupBox() + { + iconGroupBox = new QGroupBox(tr("Tray Icon")); + + iconLabel = new QLabel("Icon:"); + + iconComboBox = new QComboBox; + iconComboBox.addItem(new QIcon(":/images/bad.svg"), tr("Bad")); + iconComboBox.addItem(new QIcon(":/images/heart.svg"), tr("Heart")); + iconComboBox.addItem(new QIcon(":/images/trash.svg"), tr("Trash")); + + showIconCheckBox = new QCheckBox(tr("Show icon")); + showIconCheckBox.setChecked(true); + + QHBoxLayout iconLayout = new QHBoxLayout; + iconLayout.addWidget(iconLabel); + iconLayout.addWidget(iconComboBox); + iconLayout.addStretch(); + iconLayout.addWidget(showIconCheckBox); + iconGroupBox.setLayout(iconLayout); + } + + void createMessageGroupBox() + { + messageGroupBox = new QGroupBox(tr("Balloon Message")); + + typeLabel = new QLabel(tr("Type:")); + + typeComboBox = new QComboBox; + typeComboBox.addItem(tr("None"), new QVariant(cast(ulong) QSystemTrayIcon.NoIcon)); + typeComboBox.addItem(style().standardIcon( + QStyle.SP_MessageBoxInformation), tr("Information"), + new QVariant(cast(ulong) QSystemTrayIcon.Information)); + typeComboBox.addItem(style().standardIcon( + QStyle.SP_MessageBoxWarning), tr("Warning"), + new QVariant(cast(ulong) QSystemTrayIcon.Warning)); + typeComboBox.addItem(style().standardIcon( + QStyle.SP_MessageBoxCritical), tr("Critical"), + new QVariant(cast(ulong) QSystemTrayIcon.Critical)); + typeComboBox.setCurrentIndex(1); + + durationLabel = new QLabel(tr("Duration:")); + + durationSpinBox = new QSpinBox; + durationSpinBox.setRange(5, 60); + durationSpinBox.setSuffix(" s"); + durationSpinBox.setValue(15); + + durationWarningLabel = new QLabel(tr("(some systems might ignore this hint)")); + durationWarningLabel.setIndent(10); + + titleLabel = new QLabel(tr("Title:")); + + titleEdit = new QLineEdit(tr("Cannot connect to network")); + + bodyLabel = new QLabel(tr("Body:")); + + bodyEdit = new QTextEdit; + bodyEdit.setPlainText(tr("Don't believe me. Honestly, I don't have a clue.\nClick this balloon for details.")); + + showMessageButton = new QPushButton(tr("Show Message")); + showMessageButton.setDefault(true); + + QGridLayout messageLayout = new QGridLayout; + messageLayout.addWidget(typeLabel, 0, 0); + messageLayout.addWidget(typeComboBox, 0, 1, 1, 2); + messageLayout.addWidget(durationLabel, 1, 0); + messageLayout.addWidget(durationSpinBox, 1, 1); + messageLayout.addWidget(durationWarningLabel, 1, 2, 1, 3); + messageLayout.addWidget(titleLabel, 2, 0); + messageLayout.addWidget(titleEdit, 2, 1, 1, 4); + messageLayout.addWidget(bodyLabel, 3, 0); + messageLayout.addWidget(bodyEdit, 3, 1, 2, 4); + messageLayout.addWidget(showMessageButton, 5, 4); + messageLayout.setColumnStretch(3, 1); + messageLayout.setRowStretch(4, 1); + messageGroupBox.setLayout(messageLayout); + } + + void createActions() + { + minimizeAction = new QAction(tr("Mi&nimize"), this); + minimizeAction.triggered.connect(&this.hide); + + maximizeAction = new QAction(tr("Ma&ximize"), this); + maximizeAction.triggered.connect(&this.showMaximized); + + restoreAction = new QAction(tr("&Restore"), this); + restoreAction.triggered.connect(&this.showNormal); + + quitAction = new QAction(tr("&Quit"), this); + quitAction.triggered.connect(&QApplication.quit); + } + + void createTrayIcon() + { + trayIconMenu = new QMenu(this); + trayIconMenu.addAction(minimizeAction); + trayIconMenu.addAction(maximizeAction); + trayIconMenu.addAction(restoreAction); + trayIconMenu.addSeparator(); + trayIconMenu.addAction(quitAction); + + trayIcon = new QSystemTrayIcon(this); + trayIcon.setContextMenu(trayIconMenu); + } + + QGroupBox iconGroupBox; + QLabel iconLabel; + QComboBox iconComboBox; + QCheckBox showIconCheckBox; + + QGroupBox messageGroupBox; + QLabel typeLabel; + QLabel durationLabel; + QLabel durationWarningLabel; + QLabel titleLabel; + QLabel bodyLabel; + QComboBox typeComboBox; + QSpinBox durationSpinBox; + QLineEdit titleEdit; + QTextEdit bodyEdit; + QPushButton showMessageButton; + + QAction minimizeAction; + QAction maximizeAction; + QAction restoreAction; + QAction quitAction; + + QSystemTrayIcon trayIcon; + QMenu trayIconMenu; +}