diff options
author | axis <qt-info@nokia.com> | 2009-04-24 11:34:15 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-04-24 11:34:15 (GMT) |
commit | 8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (patch) | |
tree | a17e1a767a89542ab59907462206d7dcf2e504b2 /examples/designer | |
download | Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.zip Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.gz Qt-8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76.tar.bz2 |
Long live Qt for S60!
Diffstat (limited to 'examples/designer')
45 files changed, 3863 insertions, 0 deletions
diff --git a/examples/designer/README b/examples/designer/README new file mode 100644 index 0000000..fb9443c --- /dev/null +++ b/examples/designer/README @@ -0,0 +1,37 @@ +Qt Designer is a capable graphical user interface designer that lets you +create and configure forms without writing code. GUIs created with +Qt Designer can be compiled into an application or created at run-time. + + +Some of the examples in this directory can be run from the example launcher; +others can only be used from within Qt Designer. + +Documentation for these examples can be found via the "Tutorial and Examples" +link in the main Qt documentation. + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/designer/calculatorbuilder/calculatorbuilder.pro b/examples/designer/calculatorbuilder/calculatorbuilder.pro new file mode 100644 index 0000000..e08220a --- /dev/null +++ b/examples/designer/calculatorbuilder/calculatorbuilder.pro @@ -0,0 +1,16 @@ +#! [0] +CONFIG += uitools + +HEADERS = calculatorform.h +RESOURCES = calculatorbuilder.qrc +SOURCES = calculatorform.cpp \ + main.cpp +#! [0] + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/designer/calculatorbuilder +sources.files = $$SOURCES $$HEADERS $$RESOURCES *.ui *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/designer/calculatorbuilder +INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/designer/calculatorbuilder/calculatorbuilder.qrc b/examples/designer/calculatorbuilder/calculatorbuilder.qrc new file mode 100644 index 0000000..19b3905 --- /dev/null +++ b/examples/designer/calculatorbuilder/calculatorbuilder.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/forms"> + <file>calculatorform.ui</file> +</qresource> +</RCC> diff --git a/examples/designer/calculatorbuilder/calculatorform.cpp b/examples/designer/calculatorbuilder/calculatorform.cpp new file mode 100644 index 0000000..92d75c5 --- /dev/null +++ b/examples/designer/calculatorbuilder/calculatorform.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +//! [0] +#include <QtUiTools> +//! [0] +#include <QtGui> + +#include "calculatorform.h" + +//! [1] +CalculatorForm::CalculatorForm(QWidget *parent) + : QWidget(parent) +{ + QUiLoader loader; + + QFile file(":/forms/calculatorform.ui"); + file.open(QFile::ReadOnly); + QWidget *formWidget = loader.load(&file, this); + file.close(); +//! [1] + +//! [2] + ui_inputSpinBox1 = qFindChild<QSpinBox*>(this, "inputSpinBox1"); + ui_inputSpinBox2 = qFindChild<QSpinBox*>(this, "inputSpinBox2"); + ui_outputWidget = qFindChild<QLabel*>(this, "outputWidget"); +//! [2] + +//! [3] + QMetaObject::connectSlotsByName(this); +//! [3] + +//! [4] + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(formWidget); + setLayout(layout); + + setWindowTitle(tr("Calculator Builder")); +} +//! [4] + +//! [5] +void CalculatorForm::on_inputSpinBox1_valueChanged(int value) +{ + ui_outputWidget->setText(QString::number(value + ui_inputSpinBox2->value())); +} +//! [5] //! [6] + +//! [6] //! [7] +void CalculatorForm::on_inputSpinBox2_valueChanged(int value) +{ + ui_outputWidget->setText(QString::number(value + ui_inputSpinBox1->value())); +} +//! [7] diff --git a/examples/designer/calculatorbuilder/calculatorform.h b/examples/designer/calculatorbuilder/calculatorform.h new file mode 100644 index 0000000..8b322b7 --- /dev/null +++ b/examples/designer/calculatorbuilder/calculatorform.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef CALCULATORFORM_H +#define CALCULATORFORM_H + +#include <QWidget> + +QT_BEGIN_NAMESPACE +class QLabel; +class QSpinBox; +QT_END_NAMESPACE + +//! [0] +class CalculatorForm : public QWidget +{ + Q_OBJECT + +public: + CalculatorForm(QWidget *parent = 0); + +private slots: + void on_inputSpinBox1_valueChanged(int value); + void on_inputSpinBox2_valueChanged(int value); + +private: + QSpinBox *ui_inputSpinBox1; + QSpinBox *ui_inputSpinBox2; + QLabel *ui_outputWidget; +}; +//! [0] + +#endif diff --git a/examples/designer/calculatorbuilder/calculatorform.ui b/examples/designer/calculatorbuilder/calculatorform.ui new file mode 100644 index 0000000..dda0e62 --- /dev/null +++ b/examples/designer/calculatorbuilder/calculatorform.ui @@ -0,0 +1,303 @@ +<ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>CalculatorForm</class> + <widget class="QWidget" name="CalculatorForm" > + <property name="objectName" > + <string notr="true" >CalculatorForm</string> + </property> + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>276</width> + <height>98</height> + </rect> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle" > + <string>Calculator Builder</string> + </property> + <layout class="QGridLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <layout class="QHBoxLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <layout class="QVBoxLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label" > + <property name="objectName" > + <string notr="true" >label</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>1</y> + <width>45</width> + <height>19</height> + </rect> + </property> + <property name="text" > + <string>Input 1</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="inputSpinBox1" > + <property name="objectName" > + <string notr="true" >inputSpinBox1</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>26</y> + <width>45</width> + <height>25</height> + </rect> + </property> + <property name="mouseTracking" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="label_3" > + <property name="objectName" > + <string notr="true" >label_3</string> + </property> + <property name="geometry" > + <rect> + <x>54</x> + <y>1</y> + <width>7</width> + <height>52</height> + </rect> + </property> + <property name="text" > + <string>+</string> + </property> + <property name="alignment" > + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label_2" > + <property name="objectName" > + <string notr="true" >label_2</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>1</y> + <width>45</width> + <height>19</height> + </rect> + </property> + <property name="text" > + <string>Input 2</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="inputSpinBox2" > + <property name="objectName" > + <string notr="true" >inputSpinBox2</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>26</y> + <width>45</width> + <height>25</height> + </rect> + </property> + <property name="mouseTracking" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="label_3_2" > + <property name="objectName" > + <string notr="true" >label_3_2</string> + </property> + <property name="geometry" > + <rect> + <x>120</x> + <y>1</y> + <width>7</width> + <height>52</height> + </rect> + </property> + <property name="text" > + <string>=</string> + </property> + <property name="alignment" > + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label_2_2_2" > + <property name="objectName" > + <string notr="true" >label_2_2_2</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>1</y> + <width>37</width> + <height>17</height> + </rect> + </property> + <property name="text" > + <string>Output</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="outputWidget" > + <property name="objectName" > + <string notr="true" >outputWidget</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>24</y> + <width>37</width> + <height>27</height> + </rect> + </property> + <property name="frameShape" > + <enum>QFrame::Box</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Sunken</enum> + </property> + <property name="text" > + <string>0</string> + </property> + <property name="alignment" > + <set>Qt::AlignAbsolute|Qt::AlignBottom|Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignHorizontal_Mask|Qt::AlignJustify|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing|Qt::AlignVCenter|Qt::AlignVertical_Mask</set> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item row="1" column="0" > + <spacer> + <property name="objectName" > + <string notr="true" >verticalSpacer</string> + </property> + <property name="geometry" > + <rect> + <x>85</x> + <y>69</y> + <width>20</width> + <height>20</height> + </rect> + </property> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="1" > + <spacer> + <property name="objectName" > + <string notr="true" >horizontalSpacer</string> + </property> + <property name="geometry" > + <rect> + <x>188</x> + <y>26</y> + <width>79</width> + <height>20</height> + </rect> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> diff --git a/examples/designer/calculatorbuilder/main.cpp b/examples/designer/calculatorbuilder/main.cpp new file mode 100644 index 0000000..56358b8 --- /dev/null +++ b/examples/designer/calculatorbuilder/main.cpp @@ -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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QApplication> + +#include "calculatorform.h" + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(calculatorbuilder); + + QApplication app(argc, argv); + CalculatorForm calculator; + calculator.show(); + return app.exec(); +} diff --git a/examples/designer/calculatorform/calculatorform.cpp b/examples/designer/calculatorform/calculatorform.cpp new file mode 100644 index 0000000..3de2852 --- /dev/null +++ b/examples/designer/calculatorform/calculatorform.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtGui> + +#include "calculatorform.h" + +//! [0] +CalculatorForm::CalculatorForm(QWidget *parent) + : QWidget(parent) +{ + ui.setupUi(this); +} +//! [0] + +//! [1] +void CalculatorForm::on_inputSpinBox1_valueChanged(int value) +{ + ui.outputWidget->setText(QString::number(value + ui.inputSpinBox2->value())); +} +//! [1] + +//! [2] +void CalculatorForm::on_inputSpinBox2_valueChanged(int value) +{ + ui.outputWidget->setText(QString::number(value + ui.inputSpinBox1->value())); +} +//! [2] diff --git a/examples/designer/calculatorform/calculatorform.h b/examples/designer/calculatorform/calculatorform.h new file mode 100644 index 0000000..37f0a18 --- /dev/null +++ b/examples/designer/calculatorform/calculatorform.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef CALCULATORFORM_H +#define CALCULATORFORM_H + +//! [0] +#include "ui_calculatorform.h" +//! [0] + +//! [1] +class CalculatorForm : public QWidget +{ + Q_OBJECT + +public: + CalculatorForm(QWidget *parent = 0); + +private slots: + void on_inputSpinBox1_valueChanged(int value); + void on_inputSpinBox2_valueChanged(int value); + +private: + Ui::CalculatorForm ui; +}; +//! [1] + +#endif diff --git a/examples/designer/calculatorform/calculatorform.pro b/examples/designer/calculatorform/calculatorform.pro new file mode 100644 index 0000000..5a133a9 --- /dev/null +++ b/examples/designer/calculatorform/calculatorform.pro @@ -0,0 +1,15 @@ +#! [0] +HEADERS = calculatorform.h +#! [0] #! [1] +FORMS = calculatorform.ui +#! [1] +SOURCES = calculatorform.cpp \ + main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/designer/calculatorform +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/designer/calculatorform +INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/designer/calculatorform/calculatorform.ui b/examples/designer/calculatorform/calculatorform.ui new file mode 100644 index 0000000..3a95639 --- /dev/null +++ b/examples/designer/calculatorform/calculatorform.ui @@ -0,0 +1,284 @@ +<ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>CalculatorForm</class> + <widget class="QWidget" name="CalculatorForm" > + <property name="objectName" > + <string notr="true" >CalculatorForm</string> + </property> + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle" > + <string>Calculator Form</string> + </property> + <layout class="QGridLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="6" > + <spacer> + <property name="objectName" > + <string notr="true" >horizontalSpacer</string> + </property> + <property name="geometry" > + <rect> + <x>239</x> + <y>9</y> + <width>152</width> + <height>52</height> + </rect> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="4" > + <widget class="QLabel" name="label_3_2" > + <property name="objectName" > + <string notr="true" >label_3_2</string> + </property> + <property name="geometry" > + <rect> + <x>169</x> + <y>9</y> + <width>20</width> + <height>52</height> + </rect> + </property> + <property name="text" > + <string>=</string> + </property> + <property name="alignment" > + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="5" > + <layout class="QVBoxLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label_2_2_2" > + <property name="objectName" > + <string notr="true" >label_2_2_2</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>1</y> + <width>36</width> + <height>17</height> + </rect> + </property> + <property name="text" > + <string>Output</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="outputWidget" > + <property name="objectName" > + <string notr="true" >outputWidget</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>24</y> + <width>36</width> + <height>27</height> + </rect> + </property> + <property name="frameShape" > + <enum>QFrame::Box</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Sunken</enum> + </property> + <property name="text" > + <string>0</string> + </property> + <property name="alignment" > + <set>Qt::AlignAbsolute|Qt::AlignBottom|Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignHorizontal_Mask|Qt::AlignJustify|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing|Qt::AlignVCenter|Qt::AlignVertical_Mask</set> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="2" > + <spacer> + <property name="objectName" > + <string notr="true" >verticalSpacer</string> + </property> + <property name="geometry" > + <rect> + <x>89</x> + <y>67</y> + <width>20</width> + <height>224</height> + </rect> + </property> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="3" > + <layout class="QVBoxLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label_2" > + <property name="objectName" > + <string notr="true" >label_2</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>1</y> + <width>46</width> + <height>19</height> + </rect> + </property> + <property name="text" > + <string>Input 2</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="inputSpinBox2" > + <property name="objectName" > + <string notr="true" >inputSpinBox2</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>26</y> + <width>46</width> + <height>25</height> + </rect> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="1" > + <widget class="QLabel" name="label_3" > + <property name="objectName" > + <string notr="true" >label_3</string> + </property> + <property name="geometry" > + <rect> + <x>63</x> + <y>9</y> + <width>20</width> + <height>52</height> + </rect> + </property> + <property name="text" > + <string>+</string> + </property> + <property name="alignment" > + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="0" column="0" > + <layout class="QVBoxLayout" > + <property name="objectName" > + <string notr="true" /> + </property> + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label" > + <property name="objectName" > + <string notr="true" >label</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>1</y> + <width>46</width> + <height>19</height> + </rect> + </property> + <property name="text" > + <string>Input 1</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="inputSpinBox1" > + <property name="objectName" > + <string notr="true" >inputSpinBox1</string> + </property> + <property name="geometry" > + <rect> + <x>1</x> + <y>26</y> + <width>46</width> + <height>25</height> + </rect> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> diff --git a/examples/designer/calculatorform/main.cpp b/examples/designer/calculatorform/main.cpp new file mode 100644 index 0000000..dcb7366 --- /dev/null +++ b/examples/designer/calculatorform/main.cpp @@ -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 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QApplication> + +#include "calculatorform.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + CalculatorForm calculator; + calculator.show(); + return app.exec(); +} + diff --git a/examples/designer/containerextension/containerextension.pro b/examples/designer/containerextension/containerextension.pro new file mode 100644 index 0000000..9b2b8bc --- /dev/null +++ b/examples/designer/containerextension/containerextension.pro @@ -0,0 +1,28 @@ +#! [0] +TEMPLATE = lib +#! [0] +TARGET = $$qtLibraryTarget($$TARGET) +#! [1] +CONFIG += designer plugin +#! [1] +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer + +#! [2] +HEADERS += multipagewidget.h \ + multipagewidgetplugin.h \ + multipagewidgetcontainerextension.h \ + multipagewidgetextensionfactory.h + +SOURCES += multipagewidget.cpp \ + multipagewidgetplugin.cpp \ + multipagewidgetcontainerextension.cpp \ + multipagewidgetextensionfactory.cpp +#! [2] + +# install +target.path = $$[QT_INSTALL_PLUGINS]/designer +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/designer/containerextension +INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/designer/containerextension/multipagewidget.cpp b/examples/designer/containerextension/multipagewidget.cpp new file mode 100644 index 0000000..5a3697b --- /dev/null +++ b/examples/designer/containerextension/multipagewidget.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtGui> + +#include "multipagewidget.h" + +MultiPageWidget::MultiPageWidget(QWidget *parent) + : QWidget(parent) +{ + comboBox = new QComboBox(); + comboBox->setObjectName("__qt__passive_comboBox"); + stackWidget = new QStackedWidget(); + + connect(comboBox, SIGNAL(activated(int)), + this, SLOT(setCurrentIndex(int))); + + layout = new QVBoxLayout(); + layout->addWidget(comboBox); + layout->addWidget(stackWidget); + setLayout(layout); +} + +QSize MultiPageWidget::sizeHint() const +{ + return QSize(200, 150); +} + +void MultiPageWidget::addPage(QWidget *page) +{ + insertPage(count(), page); +} + +void MultiPageWidget::removePage(int index) +{ + QWidget *widget = stackWidget->widget(index); + stackWidget->removeWidget(widget); + + comboBox->removeItem(index); +} + +int MultiPageWidget::count() const +{ + return stackWidget->count(); +} + +int MultiPageWidget::currentIndex() const +{ + return stackWidget->currentIndex(); +} + +void MultiPageWidget::insertPage(int index, QWidget *page) +{ + page->setParent(stackWidget); + + stackWidget->insertWidget(index, page); + + QString title = page->windowTitle(); + if (title.isEmpty()) { + title = tr("Page %1").arg(comboBox->count() + 1); + page->setWindowTitle(title); + } + comboBox->insertItem(index, title); +} + +void MultiPageWidget::setCurrentIndex(int index) +{ + if (index != currentIndex()) { + stackWidget->setCurrentIndex(index); + comboBox->setCurrentIndex(index); + emit currentIndexChanged(index); + } +} + +QWidget* MultiPageWidget::widget(int index) +{ + return stackWidget->widget(index); +} + +QString MultiPageWidget::pageTitle() const +{ + if (const QWidget *currentWidget = stackWidget->currentWidget()) + return currentWidget->windowTitle(); + return QString(); +} + +void MultiPageWidget::setPageTitle(QString const &newTitle) +{ + comboBox->setItemText(currentIndex(), newTitle); + if (QWidget *currentWidget = stackWidget->currentWidget()) + currentWidget->setWindowTitle(newTitle); + emit pageTitleChanged(newTitle); +} diff --git a/examples/designer/containerextension/multipagewidget.h b/examples/designer/containerextension/multipagewidget.h new file mode 100644 index 0000000..77a09c5 --- /dev/null +++ b/examples/designer/containerextension/multipagewidget.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef MULTIPAGEWIDGET_H +#define MULTIPAGEWIDGET_H + +#include <QWidget> + +QT_BEGIN_NAMESPACE +class QComboBox; +class QStackedWidget; +class QVBoxLayout; +QT_END_NAMESPACE + +//! [0] +class MultiPageWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex) + Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED false) + +public: + MultiPageWidget(QWidget *parent = 0); + + QSize sizeHint() const; + + int count() const; + int currentIndex() const; + QWidget *widget(int index); + QString pageTitle() const; + +public slots: + void addPage(QWidget *page); + void insertPage(int index, QWidget *page); + void removePage(int index); + void setPageTitle(QString const &newTitle); + void setCurrentIndex(int index); + +signals: + void currentIndexChanged(int index); + void pageTitleChanged(const QString &title); + +private: + QStackedWidget *stackWidget; + QComboBox *comboBox; + QVBoxLayout *layout; +}; +//! [0] + +#endif diff --git a/examples/designer/containerextension/multipagewidgetcontainerextension.cpp b/examples/designer/containerextension/multipagewidgetcontainerextension.cpp new file mode 100644 index 0000000..b61da3d --- /dev/null +++ b/examples/designer/containerextension/multipagewidgetcontainerextension.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include "multipagewidgetcontainerextension.h" +#include "multipagewidget.h" + +//! [0] +MultiPageWidgetContainerExtension::MultiPageWidgetContainerExtension(MultiPageWidget *widget, + QObject *parent) + :QObject(parent) +{ + myWidget = widget; +} +//! [0] + +//! [1] +void MultiPageWidgetContainerExtension::addWidget(QWidget *widget) +{ + myWidget->addPage(widget); +} +//! [1] + +//! [2] +int MultiPageWidgetContainerExtension::count() const +{ + return myWidget->count(); +} +//! [2] + +//! [3] +int MultiPageWidgetContainerExtension::currentIndex() const +{ + return myWidget->currentIndex(); +} +//! [3] + +//! [4] +void MultiPageWidgetContainerExtension::insertWidget(int index, QWidget *widget) +{ + myWidget->insertPage(index, widget); +} +//! [4] + +//! [5] +void MultiPageWidgetContainerExtension::remove(int index) +{ + myWidget->removePage(index); +} +//! [5] + +//! [6] +void MultiPageWidgetContainerExtension::setCurrentIndex(int index) +{ + myWidget->setCurrentIndex(index); +} +//! [6] + +//! [7] +QWidget* MultiPageWidgetContainerExtension::widget(int index) const +{ + return myWidget->widget(index); +} +//! [7] diff --git a/examples/designer/containerextension/multipagewidgetcontainerextension.h b/examples/designer/containerextension/multipagewidgetcontainerextension.h new file mode 100644 index 0000000..661146e --- /dev/null +++ b/examples/designer/containerextension/multipagewidgetcontainerextension.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef MULTIPAGEWIDGETCONTAINEREXTENSION_H +#define MULTIPAGEWIDGETCONTAINEREXTENSION_H + +#include <QtDesigner/QDesignerContainerExtension> + +QT_BEGIN_NAMESPACE +class QExtensionManager; +QT_END_NAMESPACE +class MultiPageWidget; + +//! [0] +class MultiPageWidgetContainerExtension: public QObject, + public QDesignerContainerExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerContainerExtension) + +public: + MultiPageWidgetContainerExtension(MultiPageWidget *widget, QObject *parent); + + void addWidget(QWidget *widget); + int count() const; + int currentIndex() const; + void insertWidget(int index, QWidget *widget); + void remove(int index); + void setCurrentIndex(int index); + QWidget *widget(int index) const; + +private: + MultiPageWidget *myWidget; +}; +//! [0] + +#endif diff --git a/examples/designer/containerextension/multipagewidgetextensionfactory.cpp b/examples/designer/containerextension/multipagewidgetextensionfactory.cpp new file mode 100644 index 0000000..4a1e81b --- /dev/null +++ b/examples/designer/containerextension/multipagewidgetextensionfactory.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include "multipagewidgetextensionfactory.h" +#include "multipagewidgetcontainerextension.h" +#include "multipagewidget.h" + +//! [0] +MultiPageWidgetExtensionFactory::MultiPageWidgetExtensionFactory(QExtensionManager *parent) + : QExtensionFactory(parent) +{} +//! [0] + +//! [1] +QObject *MultiPageWidgetExtensionFactory::createExtension(QObject *object, + const QString &iid, + QObject *parent) const +{ + MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(object); + + if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) { + return new MultiPageWidgetContainerExtension(widget, parent); + } else { + return 0; + } +} +//! [1] diff --git a/examples/designer/containerextension/multipagewidgetextensionfactory.h b/examples/designer/containerextension/multipagewidgetextensionfactory.h new file mode 100644 index 0000000..9a96b37 --- /dev/null +++ b/examples/designer/containerextension/multipagewidgetextensionfactory.h @@ -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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef MULTIPAGEWIDGETEXTENSIONFACTORY_H +#define MULTIPAGEWIDGETEXTENSIONFACTORY_H + +#include <QtDesigner/QExtensionFactory> + +QT_BEGIN_NAMESPACE +class QExtensionManager; +QT_END_NAMESPACE + +//! [0] +class MultiPageWidgetExtensionFactory: public QExtensionFactory +{ + Q_OBJECT + +public: + MultiPageWidgetExtensionFactory(QExtensionManager *parent = 0); + +protected: + QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; +}; +//! [0] + +#endif diff --git a/examples/designer/containerextension/multipagewidgetplugin.cpp b/examples/designer/containerextension/multipagewidgetplugin.cpp new file mode 100644 index 0000000..c09ed3a --- /dev/null +++ b/examples/designer/containerextension/multipagewidgetplugin.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtDesigner/QExtensionFactory> +#include <QtDesigner/QExtensionManager> +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QDesignerFormWindowInterface> +#include <QtDesigner/QDesignerContainerExtension> +#include <QtDesigner/QDesignerPropertySheetExtension> + +#include <QIcon> +#include <QtPlugin> + +#include "multipagewidget.h" +#include "multipagewidgetplugin.h" +#include "multipagewidgetextensionfactory.h" + +//! [0] +MultiPageWidgetPlugin::MultiPageWidgetPlugin(QObject *parent) + :QObject(parent) +{ + initialized = false; +} + +QString MultiPageWidgetPlugin::name() const +{ + return QLatin1String("MultiPageWidget"); +} + +QString MultiPageWidgetPlugin::group() const +{ + return QLatin1String("Display Widgets [Examples]"); +} + +QString MultiPageWidgetPlugin::toolTip() const +{ + return QString(); +} + +QString MultiPageWidgetPlugin::whatsThis() const +{ + return QString(); +} + +QString MultiPageWidgetPlugin::includeFile() const +{ + return QLatin1String("multipagewidget.h"); +} + +QIcon MultiPageWidgetPlugin::icon() const +{ + return QIcon(); +} + +//! [0] //! [1] +bool MultiPageWidgetPlugin::isContainer() const +{ + return true; +} + +//! [1] //! [2] +QWidget *MultiPageWidgetPlugin::createWidget(QWidget *parent) +{ + MultiPageWidget *widget = new MultiPageWidget(parent); + connect(widget, SIGNAL(currentIndexChanged(int)), + this, SLOT(currentIndexChanged(int))); + connect(widget, SIGNAL(pageTitleChanged(const QString &)), + this, SLOT(pageTitleChanged(const QString &))); + return widget; +} + +//! [2] //! [3] +bool MultiPageWidgetPlugin::isInitialized() const +{ + return initialized; +} +//! [3] + +//! [4] +void MultiPageWidgetPlugin::initialize(QDesignerFormEditorInterface *formEditor) +{ + if (initialized) + return; +//! [4] + +//! [5] + QExtensionManager *manager = formEditor->extensionManager(); +//! [5] //! [6] + QExtensionFactory *factory = new MultiPageWidgetExtensionFactory(manager); + + Q_ASSERT(manager != 0); + manager->registerExtensions(factory, Q_TYPEID(QDesignerContainerExtension)); + + initialized = true; +} +//! [6] + +//! [7] +QString MultiPageWidgetPlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"MultiPageWidget\" name=\"multipagewidget\">\ + <widget class=\"QWidget\" name=\"page\" />\ + </widget>\ + <customwidgets>\ + <customwidget>\ + <class>MultiPageWidget</class>\ + <extends>QWidget</extends>\ + <addpagemethod>addPage</addpagemethod>\ + </customwidget>\ + </customwidgets>\ +</ui>"); +} +//! [7] + +//! [8] +void MultiPageWidgetPlugin::currentIndexChanged(int index) +{ + Q_UNUSED(index); + MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(sender()); +//! [8] //! [9] + if (widget) { + QDesignerFormWindowInterface *form = QDesignerFormWindowInterface::findFormWindow(widget); + if (form) + form->emitSelectionChanged(); + } +} +//! [9] + +//! [10] +void MultiPageWidgetPlugin::pageTitleChanged(const QString &title) +{ + Q_UNUSED(title); + MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(sender()); +//! [10] //! [11] + if (widget) { + QWidget *page = widget->widget(widget->currentIndex()); + QDesignerFormWindowInterface *form; + form = QDesignerFormWindowInterface::findFormWindow(widget); +//! [11] + if (form) { +//! [12] + QDesignerFormEditorInterface *editor = form->core(); + QExtensionManager *manager = editor->extensionManager(); +//! [12] //! [13] + QDesignerPropertySheetExtension *sheet; + sheet = qt_extension<QDesignerPropertySheetExtension*>(manager, page); + const int propertyIndex = sheet->indexOf(QLatin1String("windowTitle")); + sheet->setChanged(propertyIndex, true); + } + } +} + +//! [13] + +//! [14] +Q_EXPORT_PLUGIN2(containerextension, MultiPageWidgetPlugin) +//! [14] diff --git a/examples/designer/containerextension/multipagewidgetplugin.h b/examples/designer/containerextension/multipagewidgetplugin.h new file mode 100644 index 0000000..1431c8a --- /dev/null +++ b/examples/designer/containerextension/multipagewidgetplugin.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +//! [0] +#ifndef MULTIPAGEWIDGETPLUGIN_H +#define MULTIPAGEWIDGETPLUGIN_H + +#include <QtDesigner/QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE +class QIcon; +class QWidget; +QT_END_NAMESPACE + +class MultiPageWidgetPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + MultiPageWidgetPlugin(QObject *parent = 0); + + QString name() const; + QString group() const; + QString toolTip() const; + QString whatsThis() const; + QString includeFile() const; + QIcon icon() const; + bool isContainer() const; + QWidget *createWidget(QWidget *parent); + bool isInitialized() const; + void initialize(QDesignerFormEditorInterface *formEditor); + QString domXml() const; + +private slots: + void currentIndexChanged(int index); + void pageTitleChanged(const QString &title); + +private: + bool initialized; +}; + +#endif +//! [0] diff --git a/examples/designer/customwidgetplugin/analogclock.cpp b/examples/designer/customwidgetplugin/analogclock.cpp new file mode 100644 index 0000000..28155ba --- /dev/null +++ b/examples/designer/customwidgetplugin/analogclock.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtGui> + +#include "analogclock.h" + +AnalogClock::AnalogClock(QWidget *parent) + : QWidget(parent) +{ + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(update())); + timer->start(1000); + + setWindowTitle(tr("Analog Clock")); + resize(200, 200); +} + +void AnalogClock::paintEvent(QPaintEvent *) +{ + static const QPoint hourHand[3] = { + QPoint(7, 8), + QPoint(-7, 8), + QPoint(0, -40) + }; + static const QPoint minuteHand[3] = { + QPoint(7, 8), + QPoint(-7, 8), + QPoint(0, -70) + }; + + QColor hourColor(127, 0, 127); + QColor minuteColor(0, 127, 127, 191); + + int side = qMin(width(), height()); + QTime time = QTime::currentTime(); + + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + painter.translate(width() / 2, height() / 2); + painter.scale(side / 200.0, side / 200.0); + + painter.setPen(Qt::NoPen); + painter.setBrush(hourColor); + + painter.save(); + painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); + painter.drawConvexPolygon(hourHand, 3); + painter.restore(); + + painter.setPen(hourColor); + + for (int i = 0; i < 12; ++i) { + painter.drawLine(88, 0, 96, 0); + painter.rotate(30.0); + } + + painter.setPen(Qt::NoPen); + painter.setBrush(minuteColor); + + painter.save(); + painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); + painter.drawConvexPolygon(minuteHand, 3); + painter.restore(); + + painter.setPen(minuteColor); + + for (int j = 0; j < 60; ++j) { + if ((j % 5) != 0) + painter.drawLine(92, 0, 96, 0); + painter.rotate(6.0); + } +} diff --git a/examples/designer/customwidgetplugin/analogclock.h b/examples/designer/customwidgetplugin/analogclock.h new file mode 100644 index 0000000..4d843ad --- /dev/null +++ b/examples/designer/customwidgetplugin/analogclock.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef ANALOGCLOCK_H +#define ANALOGCLOCK_H + +#include <QWidget> +#include <QtDesigner/QDesignerExportWidget> + +class QDESIGNER_WIDGET_EXPORT AnalogClock : public QWidget +{ + Q_OBJECT + +public: + AnalogClock(QWidget *parent = 0); + +protected: + void paintEvent(QPaintEvent *event); +}; + +#endif diff --git a/examples/designer/customwidgetplugin/customwidgetplugin.cpp b/examples/designer/customwidgetplugin/customwidgetplugin.cpp new file mode 100644 index 0000000..bcea3b8 --- /dev/null +++ b/examples/designer/customwidgetplugin/customwidgetplugin.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include "analogclock.h" +#include "customwidgetplugin.h" + +#include <QtPlugin> + +//! [0] +AnalogClockPlugin::AnalogClockPlugin(QObject *parent) + : QObject(parent) +{ + initialized = false; +} +//! [0] + +//! [1] +void AnalogClockPlugin::initialize(QDesignerFormEditorInterface * /* core */) +{ + if (initialized) + return; + + initialized = true; +} +//! [1] + +//! [2] +bool AnalogClockPlugin::isInitialized() const +{ + return initialized; +} +//! [2] + +//! [3] +QWidget *AnalogClockPlugin::createWidget(QWidget *parent) +{ + return new AnalogClock(parent); +} +//! [3] + +//! [4] +QString AnalogClockPlugin::name() const +{ + return "AnalogClock"; +} +//! [4] + +//! [5] +QString AnalogClockPlugin::group() const +{ + return "Display Widgets [Examples]"; +} +//! [5] + +//! [6] +QIcon AnalogClockPlugin::icon() const +{ + return QIcon(); +} +//! [6] + +//! [7] +QString AnalogClockPlugin::toolTip() const +{ + return ""; +} +//! [7] + +//! [8] +QString AnalogClockPlugin::whatsThis() const +{ + return ""; +} +//! [8] + +//! [9] +bool AnalogClockPlugin::isContainer() const +{ + return false; +} +//! [9] + +//! [10] +QString AnalogClockPlugin::domXml() const +{ + return "<ui language=\"c++\">\n" + " <widget class=\"AnalogClock\" name=\"analogClock\">\n" +//! [11] + " <property name=\"geometry\">\n" + " <rect>\n" + " <x>0</x>\n" + " <y>0</y>\n" + " <width>100</width>\n" + " <height>100</height>\n" + " </rect>\n" + " </property>\n" +//! [11] + " <property name=\"toolTip\" >\n" + " <string>The current time</string>\n" + " </property>\n" + " <property name=\"whatsThis\" >\n" + " <string>The analog clock widget displays the current time.</string>\n" + " </property>\n" + " </widget>\n" + "</ui>\n"; +} +//! [10] + +//! [12] +QString AnalogClockPlugin::includeFile() const +{ + return "analogclock.h"; +} +//! [12] + +//! [13] +Q_EXPORT_PLUGIN2(customwidgetplugin, AnalogClockPlugin) +//! [13] diff --git a/examples/designer/customwidgetplugin/customwidgetplugin.h b/examples/designer/customwidgetplugin/customwidgetplugin.h new file mode 100644 index 0000000..4438690 --- /dev/null +++ b/examples/designer/customwidgetplugin/customwidgetplugin.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef CUSTOMWIDGETPLUGIN_H +#define CUSTOMWIDGETPLUGIN_H + +#include <QDesignerCustomWidgetInterface> + +//! [0] +class AnalogClockPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + AnalogClockPlugin(QObject *parent = 0); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget *createWidget(QWidget *parent); + void initialize(QDesignerFormEditorInterface *core); + +private: + bool initialized; +}; +//! [0] + +#endif diff --git a/examples/designer/customwidgetplugin/customwidgetplugin.pro b/examples/designer/customwidgetplugin/customwidgetplugin.pro new file mode 100644 index 0000000..6cc376f --- /dev/null +++ b/examples/designer/customwidgetplugin/customwidgetplugin.pro @@ -0,0 +1,23 @@ +#! [0] #! [1] +CONFIG += designer plugin +#! [0] +TARGET = $$qtLibraryTarget($$TARGET) +#! [2] +TEMPLATE = lib +#! [1] #! [2] +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer + +#! [3] +HEADERS = analogclock.h \ + customwidgetplugin.h +SOURCES = analogclock.cpp \ + customwidgetplugin.cpp +#! [3] + +# install +target.path = $$[QT_INSTALL_PLUGINS]/designer +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/designer/customwidgetplugin +INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/designer/designer.pro b/examples/designer/designer.pro new file mode 100644 index 0000000..b7eacc0 --- /dev/null +++ b/examples/designer/designer.pro @@ -0,0 +1,21 @@ +TEMPLATE = subdirs +SUBDIRS = calculatorform + +!static:SUBDIRS += calculatorbuilder \ + containerextension \ + customwidgetplugin \ + taskmenuextension \ + worldtimeclockbuilder \ + worldtimeclockplugin + +# the sun cc compiler has a problem with the include lines for the form.prf +solaris-cc*:SUBDIRS -= calculatorbuilder \ + worldtimeclockbuilder + + +# install +sources.files = README *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/designer +INSTALLS += sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/designer/taskmenuextension/taskmenuextension.pro b/examples/designer/taskmenuextension/taskmenuextension.pro new file mode 100644 index 0000000..89c0c44 --- /dev/null +++ b/examples/designer/taskmenuextension/taskmenuextension.pro @@ -0,0 +1,27 @@ +#! [0] +TEMPLATE = lib +#! [0] +TARGET = $$qtLibraryTarget($$TARGET) +#! [1] +CONFIG += designer plugin +#! [1] +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer + +#! [2] +HEADERS += tictactoe.h \ + tictactoedialog.h \ + tictactoeplugin.h \ + tictactoetaskmenu.h +SOURCES += tictactoe.cpp \ + tictactoedialog.cpp \ + tictactoeplugin.cpp \ + tictactoetaskmenu.cpp +#! [2] + +# install +target.path = $$[QT_INSTALL_PLUGINS]/designer +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/designer/taskmenuextension +INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/designer/taskmenuextension/tictactoe.cpp b/examples/designer/taskmenuextension/tictactoe.cpp new file mode 100644 index 0000000..ba766ccd --- /dev/null +++ b/examples/designer/taskmenuextension/tictactoe.cpp @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtGui> + +#include "tictactoe.h" + +TicTacToe::TicTacToe(QWidget *parent) + : QWidget(parent) +{ +} + +QSize TicTacToe::minimumSizeHint() const +{ + return QSize(200, 200); +} + +QSize TicTacToe::sizeHint() const +{ + return QSize(200, 200); +} + +void TicTacToe::setState(const QString &newState) +{ + turnNumber = 0; + myState = "---------"; + int position = 0; + while (position < 9 && position < newState.length()) { + QChar mark = newState.at(position); + if (mark == Cross || mark == Nought) { + ++turnNumber; + myState.replace(position, 1, mark); + } + position++; + } + update(); +} + +QString TicTacToe::state() const +{ + return myState; +} + +void TicTacToe::clearBoard() +{ + myState = "---------"; + turnNumber = 0; + update(); +} + +void TicTacToe::mousePressEvent(QMouseEvent *event) +{ + if (turnNumber == 9) { + clearBoard(); + update(); + } else { + for (int position = 0; position < 9; ++position) { + QRect cell = cellRect(position / 3, position % 3); + if (cell.contains(event->pos())) { + if (myState.at(position) == Empty) { + if (turnNumber % 2 == 0) + myState.replace(position, 1, Cross); + else + myState.replace(position, 1, Nought); + ++turnNumber; + update(); + } + } + } + } +} + +void TicTacToe::paintEvent(QPaintEvent * /* event */) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + + painter.setPen(QPen(Qt::darkGreen, 1)); + painter.drawLine(cellWidth(), 0, cellWidth(), height()); + painter.drawLine(2 * cellWidth(), 0, 2 * cellWidth(), height()); + painter.drawLine(0, cellHeight(), width(), cellHeight()); + painter.drawLine(0, 2 * cellHeight(), width(), 2 * cellHeight()); + + painter.setPen(QPen(Qt::darkBlue, 2)); + + for (int position = 0; position < 9; ++position) { + QRect cell = cellRect(position / 3, position % 3); + + if (myState.at(position) == Cross) { + painter.drawLine(cell.topLeft(), cell.bottomRight()); + painter.drawLine(cell.topRight(), cell.bottomLeft()); + } else if (myState.at(position) == Nought) { + painter.drawEllipse(cell); + } + } + + painter.setPen(QPen(Qt::yellow, 3)); + + for (int position = 0; position < 9; position = position + 3) { + if (myState.at(position) != Empty + && myState.at(position + 1) == myState.at(position) + && myState.at(position + 2) == myState.at(position)) { + int y = cellRect((position / 3), 0).center().y(); + painter.drawLine(0, y, width(), y); + turnNumber = 9; + } + } + + for (int position = 0; position < 3; ++position) { + if (myState.at(position) != Empty + && myState.at(position + 3) == myState.at(position) + && myState.at(position + 6) == myState.at(position)) { + int x = cellRect(0, position).center().x(); + painter.drawLine(x, 0, x, height()); + turnNumber = 9; + } + } + if (myState.at(0) != Empty && myState.at(4) == myState.at(0) + && myState.at(8) == myState.at(0)) { + painter.drawLine(0, 0, width(), height()); + turnNumber = 9; + } + if (myState.at(2) != Empty && myState.at(4) == myState.at(2) + && myState.at(6) == myState.at(2)) { + painter.drawLine(0, height(), width(), 0); + turnNumber = 9; + } +} + +QRect TicTacToe::cellRect(int row, int column) const +{ + const int HMargin = width() / 30; + const int VMargin = height() / 30; + return QRect(column * cellWidth() + HMargin, + row * cellHeight() + VMargin, + cellWidth() - 2 * HMargin, + cellHeight() - 2 * VMargin); +} diff --git a/examples/designer/taskmenuextension/tictactoe.h b/examples/designer/taskmenuextension/tictactoe.h new file mode 100644 index 0000000..ef3c533 --- /dev/null +++ b/examples/designer/taskmenuextension/tictactoe.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef TICTACTOE_H +#define TICTACTOE_H + +#include <QWidget> + +QT_BEGIN_NAMESPACE +class QRect; +class QSize; +QT_END_NAMESPACE + +//! [0] +class TicTacToe : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QString state READ state WRITE setState) + +public: + TicTacToe(QWidget *parent = 0); + + QSize minimumSizeHint() const; + QSize sizeHint() const; + void setState(const QString &newState); + QString state() const; + void clearBoard(); + +protected: + void mousePressEvent(QMouseEvent *event); + void paintEvent(QPaintEvent *event); + +private: + enum { Empty = '-', Cross = 'X', Nought = 'O' }; + + QRect cellRect(int row, int col) const; + int cellWidth() const { return width() / 3; } + int cellHeight() const { return height() / 3; } + + QString myState; + int turnNumber; +}; +//! [0] + +#endif diff --git a/examples/designer/taskmenuextension/tictactoedialog.cpp b/examples/designer/taskmenuextension/tictactoedialog.cpp new file mode 100644 index 0000000..a9bd16a --- /dev/null +++ b/examples/designer/taskmenuextension/tictactoedialog.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtGui> +#include <QtDesigner> + +#include "tictactoe.h" +#include "tictactoedialog.h" + +//! [0] +TicTacToeDialog::TicTacToeDialog(TicTacToe *tic, QWidget *parent) + : QDialog(parent) +{ + ticTacToe = tic; + editor = new TicTacToe; + editor->setState(ticTacToe->state()); + + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok + | QDialogButtonBox::Cancel + | QDialogButtonBox::Reset); + + connect(buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), + this, SLOT(resetState())); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(saveState())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(editor); + mainLayout->addWidget(buttonBox); + + setLayout(mainLayout); + setWindowTitle(tr("Edit State")); +} +//! [0] + +//! [1] +QSize TicTacToeDialog::sizeHint() const +{ + return QSize(250, 250); +} +//! [1] + +//! [2] +void TicTacToeDialog::resetState() +{ + editor->clearBoard(); +} +//! [2] + +//! [3] +void TicTacToeDialog::saveState() +{ +//! [3] //! [4] + if (QDesignerFormWindowInterface *formWindow + = QDesignerFormWindowInterface::findFormWindow(ticTacToe)) { + formWindow->cursor()->setProperty("state", editor->state()); + } +//! [4] //! [5] + accept(); +} +//! [5] diff --git a/examples/designer/taskmenuextension/tictactoedialog.h b/examples/designer/taskmenuextension/tictactoedialog.h new file mode 100644 index 0000000..55b25d2 --- /dev/null +++ b/examples/designer/taskmenuextension/tictactoedialog.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef TICTACTOEDIALOG_H +#define TICTACTOEDIALOG_H + +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QDialogButtonBox; +QT_END_NAMESPACE +class TicTacToe; + +//! [0] +class TicTacToeDialog : public QDialog +{ + Q_OBJECT + +public: + TicTacToeDialog(TicTacToe *plugin = 0, QWidget *parent = 0); + + QSize sizeHint() const; + +private slots: + void resetState(); + void saveState(); + +private: + TicTacToe *editor; + TicTacToe *ticTacToe; + QDialogButtonBox *buttonBox; +}; +//! [0] + +#endif diff --git a/examples/designer/taskmenuextension/tictactoeplugin.cpp b/examples/designer/taskmenuextension/tictactoeplugin.cpp new file mode 100644 index 0000000..1333090 --- /dev/null +++ b/examples/designer/taskmenuextension/tictactoeplugin.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtDesigner> +#include <QtGui> +#include <QtPlugin> + +#include "tictactoe.h" +#include "tictactoeplugin.h" +#include "tictactoetaskmenu.h" + +//! [0] +TicTacToePlugin::TicTacToePlugin(QObject *parent) + : QObject(parent) +{ + initialized = false; +} + +QString TicTacToePlugin::name() const +{ + return "TicTacToe"; +} + +QString TicTacToePlugin::group() const +{ + return "Display Widgets [Examples]"; +} + +QString TicTacToePlugin::toolTip() const +{ + return ""; +} + +QString TicTacToePlugin::whatsThis() const +{ + return ""; +} + +QString TicTacToePlugin::includeFile() const +{ + return "tictactoe.h"; +} + +QIcon TicTacToePlugin::icon() const +{ + return QIcon(); +} + +bool TicTacToePlugin::isContainer() const +{ + return false; +} + +QWidget *TicTacToePlugin::createWidget(QWidget *parent) +{ + TicTacToe *ticTacToe = new TicTacToe(parent); + ticTacToe->setState("-X-XO----"); + return ticTacToe; +} + +bool TicTacToePlugin::isInitialized() const +{ + return initialized; +} + +//! [0] //! [1] +void TicTacToePlugin::initialize(QDesignerFormEditorInterface *formEditor) +{ +//! [1] //! [2] + if (initialized) + return; + + QExtensionManager *manager = formEditor->extensionManager(); + Q_ASSERT(manager != 0); +//! [2] + +//! [3] + manager->registerExtensions(new TicTacToeTaskMenuFactory(manager), + Q_TYPEID(QDesignerTaskMenuExtension)); + + initialized = true; +} + +QString TicTacToePlugin::domXml() const +{ + return QLatin1String("\ +<ui language=\"c++\">\ + <widget class=\"TicTacToe\" name=\"ticTacToe\"/>\ +</ui>"); +} + +//! [3] + +//! [4] +Q_EXPORT_PLUGIN2(taskmenuextension, TicTacToePlugin) +//! [4] diff --git a/examples/designer/taskmenuextension/tictactoeplugin.h b/examples/designer/taskmenuextension/tictactoeplugin.h new file mode 100644 index 0000000..b51540e --- /dev/null +++ b/examples/designer/taskmenuextension/tictactoeplugin.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +//! [0] +#ifndef TICTACTOEPLUGIN_H +#define TICTACTOEPLUGIN_H + +#include <QDesignerCustomWidgetInterface> + +QT_BEGIN_NAMESPACE +class QIcon; +class QWidget; +QT_END_NAMESPACE + +class TicTacToePlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + TicTacToePlugin(QObject *parent = 0); + + QString name() const; + QString group() const; + QString toolTip() const; + QString whatsThis() const; + QString includeFile() const; + QIcon icon() const; + bool isContainer() const; + QWidget *createWidget(QWidget *parent); + bool isInitialized() const; + void initialize(QDesignerFormEditorInterface *formEditor); + QString domXml() const; + +private: + bool initialized; +}; + +#endif +//! [0] diff --git a/examples/designer/taskmenuextension/tictactoetaskmenu.cpp b/examples/designer/taskmenuextension/tictactoetaskmenu.cpp new file mode 100644 index 0000000..af5401a --- /dev/null +++ b/examples/designer/taskmenuextension/tictactoetaskmenu.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtDesigner> +#include <QtGui> + +#include "tictactoe.h" +#include "tictactoedialog.h" +#include "tictactoetaskmenu.h" + +//! [0] +TicTacToeTaskMenu::TicTacToeTaskMenu(TicTacToe *tic, QObject *parent) + : QObject(parent) +{ + ticTacToe = tic; + + editStateAction = new QAction(tr("Edit State..."), this); + connect(editStateAction, SIGNAL(triggered()), this, SLOT(editState())); +} +//! [0] + +//! [1] +void TicTacToeTaskMenu::editState() +{ + TicTacToeDialog dialog(ticTacToe); + dialog.exec(); +} +//! [1] + +//! [2] +QAction *TicTacToeTaskMenu::preferredEditAction() const +{ + return editStateAction; +} +//! [2] + +//! [3] +QList<QAction *> TicTacToeTaskMenu::taskActions() const +{ + QList<QAction *> list; + list.append(editStateAction); + return list; +} +//! [3] + +//! [4] +TicTacToeTaskMenuFactory::TicTacToeTaskMenuFactory(QExtensionManager *parent) + : QExtensionFactory(parent) +{ +} +//! [4] + +//! [5] +QObject *TicTacToeTaskMenuFactory::createExtension(QObject *object, + const QString &iid, + QObject *parent) const +{ + if (iid != Q_TYPEID(QDesignerTaskMenuExtension)) + return 0; + + if (TicTacToe *tic = qobject_cast<TicTacToe*>(object)) + return new TicTacToeTaskMenu(tic, parent); + + return 0; +} +//! [5] diff --git a/examples/designer/taskmenuextension/tictactoetaskmenu.h b/examples/designer/taskmenuextension/tictactoetaskmenu.h new file mode 100644 index 0000000..4bd3170 --- /dev/null +++ b/examples/designer/taskmenuextension/tictactoetaskmenu.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef TICTACTOETASKMENU_H +#define TICTACTOETASKMENU_H + +#include <QDesignerTaskMenuExtension> +#include <QExtensionFactory> + +QT_BEGIN_NAMESPACE +class QAction; +class QExtensionManager; +QT_END_NAMESPACE +class TicTacToe; + +//! [0] +class TicTacToeTaskMenu : public QObject, public QDesignerTaskMenuExtension +{ + Q_OBJECT + Q_INTERFACES(QDesignerTaskMenuExtension) + +public: + TicTacToeTaskMenu(TicTacToe *tic, QObject *parent); + + QAction *preferredEditAction() const; + QList<QAction *> taskActions() const; + +private slots: + void editState(); + +private: + QAction *editStateAction; + TicTacToe *ticTacToe; +}; +//! [0] + +//! [1] +class TicTacToeTaskMenuFactory : public QExtensionFactory +{ + Q_OBJECT + +public: + TicTacToeTaskMenuFactory(QExtensionManager *parent = 0); + +protected: + QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; +}; +//! [1] + +#endif diff --git a/examples/designer/worldtimeclockbuilder/form.ui b/examples/designer/worldtimeclockbuilder/form.ui new file mode 100644 index 0000000..e5be1d9 --- /dev/null +++ b/examples/designer/worldtimeclockbuilder/form.ui @@ -0,0 +1,162 @@ +<ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>WorldTimeForm</class> + <widget class="QWidget" name="WorldTimeForm" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle" > + <string>World Time Clock</string> + </property> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="WorldTimeClock" name="worldTimeClock" /> + </item> + <item> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label" > + <property name="text" > + <string>Current time:</string> + </property> + </widget> + </item> + <item> + <widget class="QTimeEdit" name="timeEdit" > + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>1</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Set time zone:</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox" > + <property name="maximum" > + <number>12</number> + </property> + <property name="minimum" > + <number>-12</number> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <pixmapfunction></pixmapfunction> + <customwidgets> + <customwidget> + <class>WorldTimeClock</class> + <extends></extends> + <header>worldtimeclock.h</header> + <container>0</container> + <pixmap></pixmap> + </customwidget> + </customwidgets> + <resources/> + <connections> + <connection> + <sender>spinBox</sender> + <signal>valueChanged(int)</signal> + <receiver>worldTimeClock</receiver> + <slot>setTimeZone(int)</slot> + <hints> + <hint type="sourcelabel" > + <x>339</x> + <y>166</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>230</y> + </hint> + </hints> + </connection> + <connection> + <sender>worldTimeClock</sender> + <signal>updated(QTime)</signal> + <receiver>timeEdit</receiver> + <slot>setTime(QTime)</slot> + <hints> + <hint type="sourcelabel" > + <x>141</x> + <y>59</y> + </hint> + <hint type="destinationlabel" > + <x>291</x> + <y>133</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/examples/designer/worldtimeclockbuilder/main.cpp b/examples/designer/worldtimeclockbuilder/main.cpp new file mode 100644 index 0000000..35f7dc0 --- /dev/null +++ b/examples/designer/worldtimeclockbuilder/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +//! [0] +#include <QtUiTools> +//! [0] +#include <QtGui> + +//! [1] +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(worldtimeclockbuilder); + + QApplication app(argc, argv); + + QUiLoader loader; +//! [1] + +//! [2] + QFile file(":/forms/form.ui"); + file.open(QFile::ReadOnly); + + QWidget *widget = loader.load(&file); + + file.close(); + widget->show(); +//! [2] + +//! [3] + return app.exec(); +} +//! [3] diff --git a/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro b/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro new file mode 100644 index 0000000..0123fd1 --- /dev/null +++ b/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro @@ -0,0 +1,13 @@ +#! [0] +CONFIG += uitools +SOURCES = main.cpp +RESOURCES = worldtimeclockbuilder.qrc +#! [0] + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/designer/worldtimeclockbuilder +sources.files = $$SOURCES $$HEADERS $$RESOURCES *.ui *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/designer/worldtimeclockbuilder +INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc b/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc new file mode 100644 index 0000000..89d5ac3 --- /dev/null +++ b/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/forms"> + <file>form.ui</file> +</qresource> +</RCC> diff --git a/examples/designer/worldtimeclockplugin/worldtimeclock.cpp b/examples/designer/worldtimeclockplugin/worldtimeclock.cpp new file mode 100644 index 0000000..77eff54 --- /dev/null +++ b/examples/designer/worldtimeclockplugin/worldtimeclock.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include <QtGui> + +#include "worldtimeclock.h" + +WorldTimeClock::WorldTimeClock(QWidget *parent) + : QWidget(parent) +{ + timeZoneOffset = 0; + + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(update())); + timer->start(1000); + + setWindowTitle(tr("World Time Clock")); + resize(200, 200); +} + +void WorldTimeClock::paintEvent(QPaintEvent *) +{ + static const QPoint hourHand[3] = { + QPoint(7, 8), + QPoint(-7, 8), + QPoint(0, -40) + }; + static const QPoint minuteHand[3] = { + QPoint(7, 8), + QPoint(-7, 8), + QPoint(0, -70) + }; + + QColor hourColor(127, 0, 127); + QColor minuteColor(0, 127, 127, 191); + + int side = qMin(width(), height()); + QTime time = QTime::currentTime(); + time = time.addSecs(timeZoneOffset); + + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + painter.translate(width() / 2, height() / 2); + painter.scale(side / 200.0, side / 200.0); + + painter.setPen(Qt::NoPen); + painter.setBrush(hourColor); + + painter.save(); + painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); + painter.drawConvexPolygon(hourHand, 3); + painter.restore(); + + painter.setPen(hourColor); + + for (int i = 0; i < 12; ++i) { + painter.drawLine(88, 0, 96, 0); + painter.rotate(30.0); + } + + painter.setPen(Qt::NoPen); + painter.setBrush(minuteColor); + + painter.save(); + painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); + painter.drawConvexPolygon(minuteHand, 3); + painter.restore(); + + painter.setPen(minuteColor); + + for (int j = 0; j < 60; ++j) { + if ((j % 5) != 0) + painter.drawLine(92, 0, 96, 0); + painter.rotate(6.0); + } + + emit updated(time); +} + +void WorldTimeClock::setTimeZone(int hourOffset) +{ + timeZoneOffset = qMin(qMax(-12, hourOffset), 12) * 3600; + update(); +} diff --git a/examples/designer/worldtimeclockplugin/worldtimeclock.h b/examples/designer/worldtimeclockplugin/worldtimeclock.h new file mode 100644 index 0000000..7bfe8c5 --- /dev/null +++ b/examples/designer/worldtimeclockplugin/worldtimeclock.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef WORLDTIMECLOCK_H +#define WORLDTIMECLOCK_H + +#include <QTime> +#include <QWidget> +#include <QtDesigner/QDesignerExportWidget> + +//! [0] //! [1] +class QDESIGNER_WIDGET_EXPORT WorldTimeClock : public QWidget +{ + Q_OBJECT +//! [0] + +public: + WorldTimeClock(QWidget *parent = 0); + +public slots: + void setTimeZone(int hourOffset); + +signals: + void updated(QTime currentTime); + +protected: + void paintEvent(QPaintEvent *event); + +private: + int timeZoneOffset; +//! [2] +}; +//! [1] //! [2] + +#endif diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp new file mode 100644 index 0000000..e73c45b --- /dev/null +++ b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.cpp @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#include "worldtimeclock.h" +#include "worldtimeclockplugin.h" + +#include <QtPlugin> + +WorldTimeClockPlugin::WorldTimeClockPlugin(QObject *parent) + : QObject(parent) +{ + initialized = false; +} + +void WorldTimeClockPlugin::initialize(QDesignerFormEditorInterface * /* core */) +{ + if (initialized) + return; + + initialized = true; +} + +bool WorldTimeClockPlugin::isInitialized() const +{ + return initialized; +} + +QWidget *WorldTimeClockPlugin::createWidget(QWidget *parent) +{ + return new WorldTimeClock(parent); +} + +QString WorldTimeClockPlugin::name() const +{ + return "WorldTimeClock"; +} + +QString WorldTimeClockPlugin::group() const +{ + return "Display Widgets [Examples]"; +} + +QIcon WorldTimeClockPlugin::icon() const +{ + return QIcon(); +} + +QString WorldTimeClockPlugin::toolTip() const +{ + return ""; +} + +QString WorldTimeClockPlugin::whatsThis() const +{ + return ""; +} + +bool WorldTimeClockPlugin::isContainer() const +{ + return false; +} + +QString WorldTimeClockPlugin::domXml() const +{ + return "<ui language=\"c++\">\n" + " <widget class=\"WorldTimeClock\" name=\"worldTimeClock\">\n" + " <property name=\"geometry\">\n" + " <rect>\n" + " <x>0</x>\n" + " <y>0</y>\n" + " <width>100</width>\n" + " <height>100</height>\n" + " </rect>\n" + " </property>\n" + " </widget>\n" + "</ui>"; +} + +QString WorldTimeClockPlugin::includeFile() const +{ + return "worldtimeclock.h"; +} + +//! [0] +Q_EXPORT_PLUGIN2(worldtimeclockplugin, WorldTimeClockPlugin) +//! [0] diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h new file mode 100644 index 0000000..87d797a --- /dev/null +++ b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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$ +** 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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$ +** +****************************************************************************/ + +#ifndef WORLDTIMECLOCKPLUGIN_H +#define WORLDTIMECLOCKPLUGIN_H + +#include <QDesignerCustomWidgetInterface> + +//! [0] +class WorldTimeClockPlugin : public QObject, + public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + WorldTimeClockPlugin(QObject *parent = 0); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget *createWidget(QWidget *parent); + void initialize(QDesignerFormEditorInterface *core); + +private: + bool initialized; +}; +//! [0] + +#endif diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro new file mode 100644 index 0000000..5eb133f --- /dev/null +++ b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro @@ -0,0 +1,23 @@ +#! [0] +CONFIG += designer plugin +#! [0] +TARGET = $$qtLibraryTarget($$TARGET) +#! [1] +TEMPLATE = lib +#! [1] +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer + +#! [2] +HEADERS = worldtimeclock.h \ + worldtimeclockplugin.h +SOURCES = worldtimeclock.cpp \ + worldtimeclockplugin.cpp +#! [2] + +# install +target.path = $$[QT_INSTALL_PLUGINS]/designer +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/designer/worldtimeclockplugin +INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) |