# HG changeset patch # User mandel # Date 1244202741 0 # Node ID 2c9ef955a1714909ea819cf10ee1c4fc45854523 # Parent 97650cedf5d7825b658d508c0376221d9ea75c81 add desktop examples diff -r 97650cedf5d7 -r 2c9ef955a171 examples/CMakeLists.txt --- 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 diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/CMakeLists.txt --- /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 diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/screenshot/CMakeLists.txt --- /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 diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/screenshot/build --- /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 diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/screenshot/build.bat --- /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 diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/screenshot/main.d --- /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(); +} diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/screenshot/screenshot.d --- /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; +} diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/CMakeLists.txt --- /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 diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/build --- /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 diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/build.bat --- /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 diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/images/bad.svg --- /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 @@ + + + + + + +Irritant +produit chimique + + + +symbol +signs_and_symbols + + + + +yves GUILLOU + + + + +yves GUILLOU + + + + +yves GUILLOU + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/images/heart.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 @@ + + + + + +Heart Left-Highlight +This is a normal valentines day heart. + + +holiday +valentines + +valentine +hash(0x8a091c0) +hash(0x8a0916c) +signs_and_symbols +hash(0x8a091f0) +day + + + + +Jon Phillips + + + + +Jon Phillips + + + + +Jon Phillips + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/images/trash.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 @@ + + + + + +Keep Tidy Inside + + + + +symbol +bin +signs_and_symbols +clean +rubish +trash +inside +garbage +sign + + + + +Martin Owens + + + + +Martin Owens + + + + +Martin Owens + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + + + diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/main.d --- /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(); +} diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/systray.qrc --- /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 @@ + + + images/bad.svg + images/heart.svg + images/trash.svg + + diff -r 97650cedf5d7 -r 2c9ef955a171 examples/desktop/systray/window.d --- /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 Quit 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; +}