diff options
Diffstat (limited to 'examples/dialogs')
53 files changed, 3787 insertions, 0 deletions
diff --git a/examples/dialogs/README b/examples/dialogs/README new file mode 100644 index 0000000..ab0f884 --- /dev/null +++ b/examples/dialogs/README @@ -0,0 +1,40 @@ +Qt includes standard dialogs for many common operations, such as file +selection, printing, and color selection. + +Custom dialogs can also be created for specialized modal or modeless +interactions with users. + + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. + +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/dialogs/classwizard/classwizard.cpp b/examples/dialogs/classwizard/classwizard.cpp new file mode 100644 index 0000000..200d7ac --- /dev/null +++ b/examples/dialogs/classwizard/classwizard.cpp @@ -0,0 +1,431 @@ +/**************************************************************************** +** +** 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 "classwizard.h" + +//! [0] //! [1] +ClassWizard::ClassWizard(QWidget *parent) + : QWizard(parent) +{ + addPage(new IntroPage); + addPage(new ClassInfoPage); + addPage(new CodeStylePage); + addPage(new OutputFilesPage); + addPage(new ConclusionPage); +//! [0] + + setPixmap(QWizard::BannerPixmap, QPixmap(":/images/banner.png")); + setPixmap(QWizard::BackgroundPixmap, QPixmap(":/images/background.png")); + + setWindowTitle(tr("Class Wizard")); +//! [2] +} +//! [1] //! [2] + +//! [3] +void ClassWizard::accept() +//! [3] //! [4] +{ + QByteArray className = field("className").toByteArray(); + QByteArray baseClass = field("baseClass").toByteArray(); + QByteArray macroName = field("macroName").toByteArray(); + QByteArray baseInclude = field("baseInclude").toByteArray(); + + QString outputDir = field("outputDir").toString(); + QString header = field("header").toString(); + QString implementation = field("implementation").toString(); +//! [4] + + QByteArray block; + + if (field("comment").toBool()) { + block += "/*\n"; + block += " " + header.toAscii() + "\n"; + block += "*/\n"; + block += "\n"; + } + if (field("protect").toBool()) { + block += "#ifndef " + macroName + "\n"; + block += "#define " + macroName + "\n"; + block += "\n"; + } + if (field("includeBase").toBool()) { + block += "#include " + baseInclude + "\n"; + block += "\n"; + } + + block += "class " + className; + if (!baseClass.isEmpty()) + block += " : public " + baseClass; + block += "\n"; + block += "{\n"; + + /* qmake ignore Q_OBJECT */ + + if (field("qobjectMacro").toBool()) { + block += " Q_OBJECT\n"; + block += "\n"; + } + block += "public:\n"; + + if (field("qobjectCtor").toBool()) { + block += " " + className + "(QObject *parent = 0);\n"; + } else if (field("qwidgetCtor").toBool()) { + block += " " + className + "(QWidget *parent = 0);\n"; + } else if (field("defaultCtor").toBool()) { + block += " " + className + "();\n"; + if (field("copyCtor").toBool()) { + block += " " + className + "(const " + className + " &other);\n"; + block += "\n"; + block += " " + className + " &operator=" + "(const " + className + + " &other);\n"; + } + } + block += "};\n"; + + if (field("protect").toBool()) { + block += "\n"; + block += "#endif\n"; + } + + QFile headerFile(outputDir + "/" + header); + if (!headerFile.open(QFile::WriteOnly | QFile::Text)) { + QMessageBox::warning(0, QObject::tr("Simple Wizard"), + QObject::tr("Cannot write file %1:\n%2") + .arg(headerFile.fileName()) + .arg(headerFile.errorString())); + return; + } + headerFile.write(block); + + block.clear(); + + if (field("comment").toBool()) { + block += "/*\n"; + block += " " + implementation.toAscii() + "\n"; + block += "*/\n"; + block += "\n"; + } + block += "#include \"" + header.toAscii() + "\"\n"; + block += "\n"; + + if (field("qobjectCtor").toBool()) { + block += className + "::" + className + "(QObject *parent)\n"; + block += " : " + baseClass + "(parent)\n"; + block += "{\n"; + block += "}\n"; + } else if (field("qwidgetCtor").toBool()) { + block += className + "::" + className + "(QWidget *parent)\n"; + block += " : " + baseClass + "(parent)\n"; + block += "{\n"; + block += "}\n"; + } else if (field("defaultCtor").toBool()) { + block += className + "::" + className + "()\n"; + block += "{\n"; + block += " // missing code\n"; + block += "}\n"; + + if (field("copyCtor").toBool()) { + block += "\n"; + block += className + "::" + className + "(const " + className + + " &other)\n"; + block += "{\n"; + block += " *this = other;\n"; + block += "}\n"; + block += "\n"; + block += className + " &" + className + "::operator=(const " + + className + " &other)\n"; + block += "{\n"; + if (!baseClass.isEmpty()) + block += " " + baseClass + "::operator=(other);\n"; + block += " // missing code\n"; + block += " return *this;\n"; + block += "}\n"; + } + } + + QFile implementationFile(outputDir + "/" + implementation); + if (!implementationFile.open(QFile::WriteOnly | QFile::Text)) { + QMessageBox::warning(0, QObject::tr("Simple Wizard"), + QObject::tr("Cannot write file %1:\n%2") + .arg(implementationFile.fileName()) + .arg(implementationFile.errorString())); + return; + } + implementationFile.write(block); + +//! [5] + QDialog::accept(); +//! [5] //! [6] +} +//! [6] + +//! [7] +IntroPage::IntroPage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Introduction")); + setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark1.png")); + + label = new QLabel(tr("This wizard will generate a skeleton C++ class " + "definition, including a few functions. You simply " + "need to specify the class name and set a few " + "options to produce a header file and an " + "implementation file for your new C++ class.")); + label->setWordWrap(true); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(label); + setLayout(layout); +} +//! [7] + +//! [8] //! [9] +ClassInfoPage::ClassInfoPage(QWidget *parent) + : QWizardPage(parent) +{ +//! [8] + setTitle(tr("Class Information")); + setSubTitle(tr("Specify basic information about the class for which you " + "want to generate skeleton source code files.")); + setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo1.png")); + +//! [10] + classNameLabel = new QLabel(tr("&Class name:")); + classNameLineEdit = new QLineEdit; + classNameLabel->setBuddy(classNameLineEdit); + + baseClassLabel = new QLabel(tr("B&ase class:")); + baseClassLineEdit = new QLineEdit; + baseClassLabel->setBuddy(baseClassLineEdit); + + qobjectMacroCheckBox = new QCheckBox(tr("Generate Q_OBJECT ¯o")); + +//! [10] + groupBox = new QGroupBox(tr("C&onstructor")); +//! [9] + + qobjectCtorRadioButton = new QRadioButton(tr("&QObject-style constructor")); + qwidgetCtorRadioButton = new QRadioButton(tr("Q&Widget-style constructor")); + defaultCtorRadioButton = new QRadioButton(tr("&Default constructor")); + copyCtorCheckBox = new QCheckBox(tr("&Generate copy constructor and " + "operator=")); + + defaultCtorRadioButton->setChecked(true); + + connect(defaultCtorRadioButton, SIGNAL(toggled(bool)), + copyCtorCheckBox, SLOT(setEnabled(bool))); + +//! [11] //! [12] + registerField("className*", classNameLineEdit); + registerField("baseClass", baseClassLineEdit); + registerField("qobjectMacro", qobjectMacroCheckBox); +//! [11] + registerField("qobjectCtor", qobjectCtorRadioButton); + registerField("qwidgetCtor", qwidgetCtorRadioButton); + registerField("defaultCtor", defaultCtorRadioButton); + registerField("copyCtor", copyCtorCheckBox); + + QVBoxLayout *groupBoxLayout = new QVBoxLayout; +//! [12] + groupBoxLayout->addWidget(qobjectCtorRadioButton); + groupBoxLayout->addWidget(qwidgetCtorRadioButton); + groupBoxLayout->addWidget(defaultCtorRadioButton); + groupBoxLayout->addWidget(copyCtorCheckBox); + groupBox->setLayout(groupBoxLayout); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(classNameLabel, 0, 0); + layout->addWidget(classNameLineEdit, 0, 1); + layout->addWidget(baseClassLabel, 1, 0); + layout->addWidget(baseClassLineEdit, 1, 1); + layout->addWidget(qobjectMacroCheckBox, 2, 0, 1, 2); + layout->addWidget(groupBox, 3, 0, 1, 2); + setLayout(layout); +//! [13] +} +//! [13] + +//! [14] +CodeStylePage::CodeStylePage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Code Style Options")); + setSubTitle(tr("Choose the formatting of the generated code.")); + setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo2.png")); + + commentCheckBox = new QCheckBox(tr("&Start generated files with a " +//! [14] + "comment")); + commentCheckBox->setChecked(true); + + protectCheckBox = new QCheckBox(tr("&Protect header file against multiple " + "inclusions")); + protectCheckBox->setChecked(true); + + macroNameLabel = new QLabel(tr("&Macro name:")); + macroNameLineEdit = new QLineEdit; + macroNameLabel->setBuddy(macroNameLineEdit); + + includeBaseCheckBox = new QCheckBox(tr("&Include base class definition")); + baseIncludeLabel = new QLabel(tr("Base class include:")); + baseIncludeLineEdit = new QLineEdit; + baseIncludeLabel->setBuddy(baseIncludeLineEdit); + + connect(protectCheckBox, SIGNAL(toggled(bool)), + macroNameLabel, SLOT(setEnabled(bool))); + connect(protectCheckBox, SIGNAL(toggled(bool)), + macroNameLineEdit, SLOT(setEnabled(bool))); + connect(includeBaseCheckBox, SIGNAL(toggled(bool)), + baseIncludeLabel, SLOT(setEnabled(bool))); + connect(includeBaseCheckBox, SIGNAL(toggled(bool)), + baseIncludeLineEdit, SLOT(setEnabled(bool))); + + registerField("comment", commentCheckBox); + registerField("protect", protectCheckBox); + registerField("macroName", macroNameLineEdit); + registerField("includeBase", includeBaseCheckBox); + registerField("baseInclude", baseIncludeLineEdit); + + QGridLayout *layout = new QGridLayout; + layout->setColumnMinimumWidth(0, 20); + layout->addWidget(commentCheckBox, 0, 0, 1, 3); + layout->addWidget(protectCheckBox, 1, 0, 1, 3); + layout->addWidget(macroNameLabel, 2, 1); + layout->addWidget(macroNameLineEdit, 2, 2); + layout->addWidget(includeBaseCheckBox, 3, 0, 1, 3); + layout->addWidget(baseIncludeLabel, 4, 1); + layout->addWidget(baseIncludeLineEdit, 4, 2); +//! [15] + setLayout(layout); +} +//! [15] + +//! [16] +void CodeStylePage::initializePage() +{ + QString className = field("className").toString(); + macroNameLineEdit->setText(className.toUpper() + "_H"); + + QString baseClass = field("baseClass").toString(); + + includeBaseCheckBox->setChecked(!baseClass.isEmpty()); + includeBaseCheckBox->setEnabled(!baseClass.isEmpty()); + baseIncludeLabel->setEnabled(!baseClass.isEmpty()); + baseIncludeLineEdit->setEnabled(!baseClass.isEmpty()); + + if (baseClass.isEmpty()) { + baseIncludeLineEdit->clear(); + } else if (QRegExp("Q[A-Z].*").exactMatch(baseClass)) { + baseIncludeLineEdit->setText("<" + baseClass + ">"); + } else { + baseIncludeLineEdit->setText("\"" + baseClass.toLower() + ".h\""); + } +} +//! [16] + +OutputFilesPage::OutputFilesPage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Output Files")); + setSubTitle(tr("Specify where you want the wizard to put the generated " + "skeleton code.")); + setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo3.png")); + + outputDirLabel = new QLabel(tr("&Output directory:")); + outputDirLineEdit = new QLineEdit; + outputDirLabel->setBuddy(outputDirLineEdit); + + headerLabel = new QLabel(tr("&Header file name:")); + headerLineEdit = new QLineEdit; + headerLabel->setBuddy(headerLineEdit); + + implementationLabel = new QLabel(tr("&Implementation file name:")); + implementationLineEdit = new QLineEdit; + implementationLabel->setBuddy(implementationLineEdit); + + registerField("outputDir*", outputDirLineEdit); + registerField("header*", headerLineEdit); + registerField("implementation*", implementationLineEdit); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(outputDirLabel, 0, 0); + layout->addWidget(outputDirLineEdit, 0, 1); + layout->addWidget(headerLabel, 1, 0); + layout->addWidget(headerLineEdit, 1, 1); + layout->addWidget(implementationLabel, 2, 0); + layout->addWidget(implementationLineEdit, 2, 1); + setLayout(layout); +} + +//! [17] +void OutputFilesPage::initializePage() +{ + QString className = field("className").toString(); + headerLineEdit->setText(className.toLower() + ".h"); + implementationLineEdit->setText(className.toLower() + ".cpp"); + outputDirLineEdit->setText(QDir::convertSeparators(QDir::tempPath())); +} +//! [17] + +ConclusionPage::ConclusionPage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Conclusion")); + setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark2.png")); + + label = new QLabel; + label->setWordWrap(true); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(label); + setLayout(layout); +} + +void ConclusionPage::initializePage() +{ + QString finishText = wizard()->buttonText(QWizard::FinishButton); + finishText.remove('&'); + label->setText(tr("Click %1 to generate the class skeleton.") + .arg(finishText)); +} diff --git a/examples/dialogs/classwizard/classwizard.h b/examples/dialogs/classwizard/classwizard.h new file mode 100644 index 0000000..4808629 --- /dev/null +++ b/examples/dialogs/classwizard/classwizard.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** 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 CLASSWIZARD_H +#define CLASSWIZARD_H + +#include <QWizard> + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QRadioButton; +QT_END_NAMESPACE + +//! [0] +class ClassWizard : public QWizard +{ + Q_OBJECT + +public: + ClassWizard(QWidget *parent = 0); + + void accept(); +}; +//! [0] + +//! [1] +class IntroPage : public QWizardPage +{ + Q_OBJECT + +public: + IntroPage(QWidget *parent = 0); + +private: + QLabel *label; +}; +//! [1] + +//! [2] +class ClassInfoPage : public QWizardPage +{ + Q_OBJECT + +public: + ClassInfoPage(QWidget *parent = 0); + +private: + QLabel *classNameLabel; + QLabel *baseClassLabel; + QLineEdit *classNameLineEdit; + QLineEdit *baseClassLineEdit; + QCheckBox *qobjectMacroCheckBox; + QGroupBox *groupBox; + QRadioButton *qobjectCtorRadioButton; + QRadioButton *qwidgetCtorRadioButton; + QRadioButton *defaultCtorRadioButton; + QCheckBox *copyCtorCheckBox; +}; +//! [2] + +//! [3] +class CodeStylePage : public QWizardPage +{ + Q_OBJECT + +public: + CodeStylePage(QWidget *parent = 0); + +protected: + void initializePage(); + +private: + QCheckBox *commentCheckBox; + QCheckBox *protectCheckBox; + QCheckBox *includeBaseCheckBox; + QLabel *macroNameLabel; + QLabel *baseIncludeLabel; + QLineEdit *macroNameLineEdit; + QLineEdit *baseIncludeLineEdit; +}; +//! [3] + +class OutputFilesPage : public QWizardPage +{ + Q_OBJECT + +public: + OutputFilesPage(QWidget *parent = 0); + +protected: + void initializePage(); + +private: + QLabel *outputDirLabel; + QLabel *headerLabel; + QLabel *implementationLabel; + QLineEdit *outputDirLineEdit; + QLineEdit *headerLineEdit; + QLineEdit *implementationLineEdit; +}; + +class ConclusionPage : public QWizardPage +{ + Q_OBJECT + +public: + ConclusionPage(QWidget *parent = 0); + +protected: + void initializePage(); + +private: + QLabel *label; +}; + +#endif diff --git a/examples/dialogs/classwizard/classwizard.pro b/examples/dialogs/classwizard/classwizard.pro new file mode 100644 index 0000000..15b6029 --- /dev/null +++ b/examples/dialogs/classwizard/classwizard.pro @@ -0,0 +1,10 @@ +HEADERS = classwizard.h +SOURCES = classwizard.cpp \ + main.cpp +RESOURCES = classwizard.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/classwizard +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/classwizard +INSTALLS += target sources diff --git a/examples/dialogs/classwizard/classwizard.qrc b/examples/dialogs/classwizard/classwizard.qrc new file mode 100644 index 0000000..41a5ddc --- /dev/null +++ b/examples/dialogs/classwizard/classwizard.qrc @@ -0,0 +1,11 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>images/background.png</file> + <file>images/banner.png</file> + <file>images/logo1.png</file> + <file>images/logo2.png</file> + <file>images/logo3.png</file> + <file>images/watermark1.png</file> + <file>images/watermark2.png</file> +</qresource> +</RCC> diff --git a/examples/dialogs/classwizard/images/background.png b/examples/dialogs/classwizard/images/background.png Binary files differnew file mode 100644 index 0000000..44c7bad --- /dev/null +++ b/examples/dialogs/classwizard/images/background.png diff --git a/examples/dialogs/classwizard/images/banner.png b/examples/dialogs/classwizard/images/banner.png Binary files differnew file mode 100644 index 0000000..3169152 --- /dev/null +++ b/examples/dialogs/classwizard/images/banner.png diff --git a/examples/dialogs/classwizard/images/logo1.png b/examples/dialogs/classwizard/images/logo1.png Binary files differnew file mode 100644 index 0000000..f9b594a --- /dev/null +++ b/examples/dialogs/classwizard/images/logo1.png diff --git a/examples/dialogs/classwizard/images/logo2.png b/examples/dialogs/classwizard/images/logo2.png Binary files differnew file mode 100644 index 0000000..5dcbd46 --- /dev/null +++ b/examples/dialogs/classwizard/images/logo2.png diff --git a/examples/dialogs/classwizard/images/logo3.png b/examples/dialogs/classwizard/images/logo3.png Binary files differnew file mode 100644 index 0000000..9fd3ea2 --- /dev/null +++ b/examples/dialogs/classwizard/images/logo3.png diff --git a/examples/dialogs/classwizard/images/watermark1.png b/examples/dialogs/classwizard/images/watermark1.png Binary files differnew file mode 100644 index 0000000..0091f5c --- /dev/null +++ b/examples/dialogs/classwizard/images/watermark1.png diff --git a/examples/dialogs/classwizard/images/watermark2.png b/examples/dialogs/classwizard/images/watermark2.png Binary files differnew file mode 100644 index 0000000..3b88f2e --- /dev/null +++ b/examples/dialogs/classwizard/images/watermark2.png diff --git a/examples/dialogs/classwizard/main.cpp b/examples/dialogs/classwizard/main.cpp new file mode 100644 index 0000000..8230695 --- /dev/null +++ b/examples/dialogs/classwizard/main.cpp @@ -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$ +** +****************************************************************************/ + +#include <QApplication> +#include <QTranslator> +#include <QLocale> +#include <QLibraryInfo> + +#include "classwizard.h" + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(classwizard); + + QApplication app(argc, argv); + + QString translatorFileName = QLatin1String("qt_"); + translatorFileName += QLocale::system().name(); + QTranslator *translator = new QTranslator(&app); + if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + app.installTranslator(translator); + + ClassWizard wizard; + wizard.show(); + return app.exec(); +} diff --git a/examples/dialogs/configdialog/configdialog.cpp b/examples/dialogs/configdialog/configdialog.cpp new file mode 100644 index 0000000..f442e10 --- /dev/null +++ b/examples/dialogs/configdialog/configdialog.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** 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 "configdialog.h" +#include "pages.h" + +ConfigDialog::ConfigDialog() +{ + contentsWidget = new QListWidget; + contentsWidget->setViewMode(QListView::IconMode); + contentsWidget->setIconSize(QSize(96, 84)); + contentsWidget->setMovement(QListView::Static); + contentsWidget->setMaximumWidth(128); + contentsWidget->setSpacing(12); + + pagesWidget = new QStackedWidget; + pagesWidget->addWidget(new ConfigurationPage); + pagesWidget->addWidget(new UpdatePage); + pagesWidget->addWidget(new QueryPage); + + QPushButton *closeButton = new QPushButton(tr("Close")); + + createIcons(); + contentsWidget->setCurrentRow(0); + + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + + QHBoxLayout *horizontalLayout = new QHBoxLayout; + horizontalLayout->addWidget(contentsWidget); + horizontalLayout->addWidget(pagesWidget, 1); + + QHBoxLayout *buttonsLayout = new QHBoxLayout; + buttonsLayout->addStretch(1); + buttonsLayout->addWidget(closeButton); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(horizontalLayout); + mainLayout->addStretch(1); + mainLayout->addSpacing(12); + mainLayout->addLayout(buttonsLayout); + setLayout(mainLayout); + + setWindowTitle(tr("Config Dialog")); +} + +void ConfigDialog::createIcons() +{ + QListWidgetItem *configButton = new QListWidgetItem(contentsWidget); + configButton->setIcon(QIcon(":/images/config.png")); + configButton->setText(tr("Configuration")); + configButton->setTextAlignment(Qt::AlignHCenter); + configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + QListWidgetItem *updateButton = new QListWidgetItem(contentsWidget); + updateButton->setIcon(QIcon(":/images/update.png")); + updateButton->setText(tr("Update")); + updateButton->setTextAlignment(Qt::AlignHCenter); + updateButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + QListWidgetItem *queryButton = new QListWidgetItem(contentsWidget); + queryButton->setIcon(QIcon(":/images/query.png")); + queryButton->setText(tr("Query")); + queryButton->setTextAlignment(Qt::AlignHCenter); + queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + connect(contentsWidget, + SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), + this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*))); +} + +void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) +{ + if (!current) + current = previous; + + pagesWidget->setCurrentIndex(contentsWidget->row(current)); +} diff --git a/examples/dialogs/configdialog/configdialog.h b/examples/dialogs/configdialog/configdialog.h new file mode 100644 index 0000000..b09771c --- /dev/null +++ b/examples/dialogs/configdialog/configdialog.h @@ -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$ +** +****************************************************************************/ + +#ifndef CONFIGDIALOG_H +#define CONFIGDIALOG_H + +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QListWidget; +class QListWidgetItem; +class QStackedWidget; +QT_END_NAMESPACE + +class ConfigDialog : public QDialog +{ + Q_OBJECT + +public: + ConfigDialog(); + +public slots: + void changePage(QListWidgetItem *current, QListWidgetItem *previous); + +private: + void createIcons(); + + QListWidget *contentsWidget; + QStackedWidget *pagesWidget; +}; + +#endif diff --git a/examples/dialogs/configdialog/configdialog.pro b/examples/dialogs/configdialog/configdialog.pro new file mode 100644 index 0000000..344a394 --- /dev/null +++ b/examples/dialogs/configdialog/configdialog.pro @@ -0,0 +1,14 @@ +HEADERS = configdialog.h \ + pages.h +SOURCES = configdialog.cpp \ + main.cpp \ + pages.cpp +RESOURCES += configdialog.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/configdialog +sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/configdialog +INSTALLS += target sources +wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib + diff --git a/examples/dialogs/configdialog/configdialog.qrc b/examples/dialogs/configdialog/configdialog.qrc new file mode 100644 index 0000000..31d0d49 --- /dev/null +++ b/examples/dialogs/configdialog/configdialog.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>images/config.png</file> + <file>images/query.png</file> + <file>images/update.png</file> +</qresource> +</RCC> diff --git a/examples/dialogs/configdialog/images/config.png b/examples/dialogs/configdialog/images/config.png Binary files differnew file mode 100644 index 0000000..5c14d5f --- /dev/null +++ b/examples/dialogs/configdialog/images/config.png diff --git a/examples/dialogs/configdialog/images/query.png b/examples/dialogs/configdialog/images/query.png Binary files differnew file mode 100644 index 0000000..ea9e291 --- /dev/null +++ b/examples/dialogs/configdialog/images/query.png diff --git a/examples/dialogs/configdialog/images/update.png b/examples/dialogs/configdialog/images/update.png Binary files differnew file mode 100644 index 0000000..3cb8ba6 --- /dev/null +++ b/examples/dialogs/configdialog/images/update.png diff --git a/examples/dialogs/configdialog/main.cpp b/examples/dialogs/configdialog/main.cpp new file mode 100644 index 0000000..afc5467 --- /dev/null +++ b/examples/dialogs/configdialog/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 "configdialog.h" + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(configdialog); + + QApplication app(argc, argv); + ConfigDialog dialog; + return dialog.exec(); +} diff --git a/examples/dialogs/configdialog/pages.cpp b/examples/dialogs/configdialog/pages.cpp new file mode 100644 index 0000000..27c322a --- /dev/null +++ b/examples/dialogs/configdialog/pages.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** 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 "pages.h" + +ConfigurationPage::ConfigurationPage(QWidget *parent) + : QWidget(parent) +{ + QGroupBox *configGroup = new QGroupBox(tr("Server configuration")); + + QLabel *serverLabel = new QLabel(tr("Server:")); + QComboBox *serverCombo = new QComboBox; + serverCombo->addItem(tr("Qt Software (Australia)")); + serverCombo->addItem(tr("Qt Software (Germany)")); + serverCombo->addItem(tr("Qt Software (Norway)")); + serverCombo->addItem(tr("Qt Software (People's Republic of China)")); + serverCombo->addItem(tr("Qt Software (USA)")); + + QHBoxLayout *serverLayout = new QHBoxLayout; + serverLayout->addWidget(serverLabel); + serverLayout->addWidget(serverCombo); + + QVBoxLayout *configLayout = new QVBoxLayout; + configLayout->addLayout(serverLayout); + configGroup->setLayout(configLayout); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(configGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +UpdatePage::UpdatePage(QWidget *parent) + : QWidget(parent) +{ + QGroupBox *updateGroup = new QGroupBox(tr("Package selection")); + QCheckBox *systemCheckBox = new QCheckBox(tr("Update system")); + QCheckBox *appsCheckBox = new QCheckBox(tr("Update applications")); + QCheckBox *docsCheckBox = new QCheckBox(tr("Update documentation")); + + QGroupBox *packageGroup = new QGroupBox(tr("Existing packages")); + + QListWidget *packageList = new QListWidget; + QListWidgetItem *qtItem = new QListWidgetItem(packageList); + qtItem->setText(tr("Qt")); + QListWidgetItem *qsaItem = new QListWidgetItem(packageList); + qsaItem->setText(tr("QSA")); + QListWidgetItem *teamBuilderItem = new QListWidgetItem(packageList); + teamBuilderItem->setText(tr("Teambuilder")); + + QPushButton *startUpdateButton = new QPushButton(tr("Start update")); + + QVBoxLayout *updateLayout = new QVBoxLayout; + updateLayout->addWidget(systemCheckBox); + updateLayout->addWidget(appsCheckBox); + updateLayout->addWidget(docsCheckBox); + updateGroup->setLayout(updateLayout); + + QVBoxLayout *packageLayout = new QVBoxLayout; + packageLayout->addWidget(packageList); + packageGroup->setLayout(packageLayout); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(updateGroup); + mainLayout->addWidget(packageGroup); + mainLayout->addSpacing(12); + mainLayout->addWidget(startUpdateButton); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +QueryPage::QueryPage(QWidget *parent) + : QWidget(parent) +{ + QGroupBox *packagesGroup = new QGroupBox(tr("Look for packages")); + + QLabel *nameLabel = new QLabel(tr("Name:")); + QLineEdit *nameEdit = new QLineEdit; + + QLabel *dateLabel = new QLabel(tr("Released after:")); + QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate()); + + QCheckBox *releasesCheckBox = new QCheckBox(tr("Releases")); + QCheckBox *upgradesCheckBox = new QCheckBox(tr("Upgrades")); + + QSpinBox *hitsSpinBox = new QSpinBox; + hitsSpinBox->setPrefix(tr("Return up to ")); + hitsSpinBox->setSuffix(tr(" results")); + hitsSpinBox->setSpecialValueText(tr("Return only the first result")); + hitsSpinBox->setMinimum(1); + hitsSpinBox->setMaximum(100); + hitsSpinBox->setSingleStep(10); + + QPushButton *startQueryButton = new QPushButton(tr("Start query")); + + QGridLayout *packagesLayout = new QGridLayout; + packagesLayout->addWidget(nameLabel, 0, 0); + packagesLayout->addWidget(nameEdit, 0, 1); + packagesLayout->addWidget(dateLabel, 1, 0); + packagesLayout->addWidget(dateEdit, 1, 1); + packagesLayout->addWidget(releasesCheckBox, 2, 0); + packagesLayout->addWidget(upgradesCheckBox, 3, 0); + packagesLayout->addWidget(hitsSpinBox, 4, 0, 1, 2); + packagesGroup->setLayout(packagesLayout); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(packagesGroup); + mainLayout->addSpacing(12); + mainLayout->addWidget(startQueryButton); + mainLayout->addStretch(1); + setLayout(mainLayout); +} diff --git a/examples/dialogs/configdialog/pages.h b/examples/dialogs/configdialog/pages.h new file mode 100644 index 0000000..534798f --- /dev/null +++ b/examples/dialogs/configdialog/pages.h @@ -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$ +** +****************************************************************************/ + +#ifndef PAGES_H +#define PAGES_H + +#include <QWidget> + +class ConfigurationPage : public QWidget +{ +public: + ConfigurationPage(QWidget *parent = 0); +}; + +class QueryPage : public QWidget +{ +public: + QueryPage(QWidget *parent = 0); +}; + +class UpdatePage : public QWidget +{ +public: + UpdatePage(QWidget *parent = 0); +}; + +#endif diff --git a/examples/dialogs/dialogs.pro b/examples/dialogs/dialogs.pro new file mode 100644 index 0000000..b9f029a --- /dev/null +++ b/examples/dialogs/dialogs.pro @@ -0,0 +1,17 @@ +TEMPLATE = subdirs +SUBDIRS = classwizard \ + configdialog \ + standarddialogs \ + tabdialog \ + trivialwizard + +!wince*: SUBDIRS += licensewizard \ + extension \ + findfiles + +wince*: SUBDIRS += sipdialog + +# install +sources.files = README *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs +INSTALLS += sources diff --git a/examples/dialogs/extension/extension.pro b/examples/dialogs/extension/extension.pro new file mode 100644 index 0000000..3e56cb9 --- /dev/null +++ b/examples/dialogs/extension/extension.pro @@ -0,0 +1,9 @@ +HEADERS = finddialog.h +SOURCES = finddialog.cpp \ + main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/extension +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/extension +INSTALLS += target sources diff --git a/examples/dialogs/extension/finddialog.cpp b/examples/dialogs/extension/finddialog.cpp new file mode 100644 index 0000000..80c2868 --- /dev/null +++ b/examples/dialogs/extension/finddialog.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** 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 "finddialog.h" + +//! [0] +FindDialog::FindDialog(QWidget *parent) + : QDialog(parent) +{ + label = new QLabel(tr("Find &what:")); + lineEdit = new QLineEdit; + label->setBuddy(lineEdit); + + caseCheckBox = new QCheckBox(tr("Match &case")); + fromStartCheckBox = new QCheckBox(tr("Search from &start")); + fromStartCheckBox->setChecked(true); + +//! [1] + findButton = new QPushButton(tr("&Find")); + findButton->setDefault(true); + + moreButton = new QPushButton(tr("&More")); + moreButton->setCheckable(true); +//! [0] + moreButton->setAutoDefault(false); + + buttonBox = new QDialogButtonBox(Qt::Vertical); + buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); + buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole); +//! [1] + +//! [2] + extension = new QWidget; + + wholeWordsCheckBox = new QCheckBox(tr("&Whole words")); + backwardCheckBox = new QCheckBox(tr("Search &backward")); + searchSelectionCheckBox = new QCheckBox(tr("Search se&lection")); +//! [2] + +//! [3] + connect(moreButton, SIGNAL(toggled(bool)), extension, SLOT(setVisible(bool))); + + QVBoxLayout *extensionLayout = new QVBoxLayout; + extensionLayout->setMargin(0); + extensionLayout->addWidget(wholeWordsCheckBox); + extensionLayout->addWidget(backwardCheckBox); + extensionLayout->addWidget(searchSelectionCheckBox); + extension->setLayout(extensionLayout); +//! [3] + +//! [4] + QHBoxLayout *topLeftLayout = new QHBoxLayout; + topLeftLayout->addWidget(label); + topLeftLayout->addWidget(lineEdit); + + QVBoxLayout *leftLayout = new QVBoxLayout; + leftLayout->addLayout(topLeftLayout); + leftLayout->addWidget(caseCheckBox); + leftLayout->addWidget(fromStartCheckBox); + leftLayout->addStretch(1); + + QGridLayout *mainLayout = new QGridLayout; + mainLayout->setSizeConstraint(QLayout::SetFixedSize); + mainLayout->addLayout(leftLayout, 0, 0); + mainLayout->addWidget(buttonBox, 0, 1); + mainLayout->addWidget(extension, 1, 0, 1, 2); + setLayout(mainLayout); + + setWindowTitle(tr("Extension")); +//! [4] //! [5] + extension->hide(); +} +//! [5] diff --git a/examples/dialogs/extension/finddialog.h b/examples/dialogs/extension/finddialog.h new file mode 100644 index 0000000..4fc7ee5 --- /dev/null +++ b/examples/dialogs/extension/finddialog.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 FINDDIALOG_H +#define FINDDIALOG_H + +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QDialogButtonBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +QT_END_NAMESPACE + +//! [0] +class FindDialog : public QDialog +{ + Q_OBJECT + +public: + FindDialog(QWidget *parent = 0); + +private: + QLabel *label; + QLineEdit *lineEdit; + QCheckBox *caseCheckBox; + QCheckBox *fromStartCheckBox; + QCheckBox *wholeWordsCheckBox; + QCheckBox *searchSelectionCheckBox; + QCheckBox *backwardCheckBox; + QDialogButtonBox *buttonBox; + QPushButton *findButton; + QPushButton *moreButton; + QWidget *extension; +}; +//! [0] + +#endif diff --git a/examples/dialogs/extension/main.cpp b/examples/dialogs/extension/main.cpp new file mode 100644 index 0000000..fa70a55 --- /dev/null +++ b/examples/dialogs/extension/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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 "finddialog.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + FindDialog dialog; + return dialog.exec(); +} diff --git a/examples/dialogs/findfiles/findfiles.pro b/examples/dialogs/findfiles/findfiles.pro new file mode 100644 index 0000000..99be394 --- /dev/null +++ b/examples/dialogs/findfiles/findfiles.pro @@ -0,0 +1,9 @@ +HEADERS = window.h +SOURCES = main.cpp \ + window.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/findfiles +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/findfiles +INSTALLS += target sources diff --git a/examples/dialogs/findfiles/main.cpp b/examples/dialogs/findfiles/main.cpp new file mode 100644 index 0000000..fa8b0ab --- /dev/null +++ b/examples/dialogs/findfiles/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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 "window.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Window window; + window.show(); + return app.exec(); +} diff --git a/examples/dialogs/findfiles/window.cpp b/examples/dialogs/findfiles/window.cpp new file mode 100644 index 0000000..7620a68 --- /dev/null +++ b/examples/dialogs/findfiles/window.cpp @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** 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 "window.h" + +//! [0] +Window::Window(QWidget *parent) + : QDialog(parent) +{ + browseButton = createButton(tr("&Browse..."), SLOT(browse())); + findButton = createButton(tr("&Find"), SLOT(find())); + + fileComboBox = createComboBox(tr("*")); + textComboBox = createComboBox(); + directoryComboBox = createComboBox(QDir::currentPath()); + + fileLabel = new QLabel(tr("Named:")); + textLabel = new QLabel(tr("Containing text:")); + directoryLabel = new QLabel(tr("In directory:")); + filesFoundLabel = new QLabel; + + createFilesTable(); +//! [0] + +//! [1] + QHBoxLayout *buttonsLayout = new QHBoxLayout; + buttonsLayout->addStretch(); + buttonsLayout->addWidget(findButton); + + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget(fileLabel, 0, 0); + mainLayout->addWidget(fileComboBox, 0, 1, 1, 2); + mainLayout->addWidget(textLabel, 1, 0); + mainLayout->addWidget(textComboBox, 1, 1, 1, 2); + mainLayout->addWidget(directoryLabel, 2, 0); + mainLayout->addWidget(directoryComboBox, 2, 1); + mainLayout->addWidget(browseButton, 2, 2); + mainLayout->addWidget(filesTable, 3, 0, 1, 3); + mainLayout->addWidget(filesFoundLabel, 4, 0); + mainLayout->addLayout(buttonsLayout, 5, 0, 1, 3); + setLayout(mainLayout); + + setWindowTitle(tr("Find Files")); + resize(700, 300); +} +//! [1] + +//! [2] +void Window::browse() +{ + QString directory = QFileDialog::getExistingDirectory(this, + tr("Find Files"), QDir::currentPath()); + + if (!directory.isEmpty()) { + if (directoryComboBox->findText(directory) == -1) + directoryComboBox->addItem(directory); + directoryComboBox->setCurrentIndex(directoryComboBox->findText(directory)); + } +} +//! [2] + +static void updateComboBox(QComboBox *comboBox) +{ + if (comboBox->findText(comboBox->currentText()) == -1) + comboBox->addItem(comboBox->currentText()); +} + +//! [3] +void Window::find() +{ + filesTable->setRowCount(0); + + QString fileName = fileComboBox->currentText(); + QString text = textComboBox->currentText(); + QString path = directoryComboBox->currentText(); +//! [3] + + updateComboBox(fileComboBox); + updateComboBox(textComboBox); + updateComboBox(directoryComboBox); + +//! [4] + currentDir = QDir(path); + QStringList files; + if (fileName.isEmpty()) + fileName = "*"; + files = currentDir.entryList(QStringList(fileName), + QDir::Files | QDir::NoSymLinks); + + if (!text.isEmpty()) + files = findFiles(files, text); + showFiles(files); +} +//! [4] + +//! [5] +QStringList Window::findFiles(const QStringList &files, const QString &text) +{ + QProgressDialog progressDialog(this); + progressDialog.setCancelButtonText(tr("&Cancel")); + progressDialog.setRange(0, files.size()); + progressDialog.setWindowTitle(tr("Find Files")); + +//! [5] //! [6] + QStringList foundFiles; + + for (int i = 0; i < files.size(); ++i) { + progressDialog.setValue(i); + progressDialog.setLabelText(tr("Searching file number %1 of %2...") + .arg(i).arg(files.size())); + qApp->processEvents(); +//! [6] + + if (progressDialog.wasCanceled()) + break; + +//! [7] + QFile file(currentDir.absoluteFilePath(files[i])); + + if (file.open(QIODevice::ReadOnly)) { + QString line; + QTextStream in(&file); + while (!in.atEnd()) { + if (progressDialog.wasCanceled()) + break; + line = in.readLine(); + if (line.contains(text)) { + foundFiles << files[i]; + break; + } + } + } + } + return foundFiles; +} +//! [7] + +//! [8] +void Window::showFiles(const QStringList &files) +{ + for (int i = 0; i < files.size(); ++i) { + QFile file(currentDir.absoluteFilePath(files[i])); + qint64 size = QFileInfo(file).size(); + + QTableWidgetItem *fileNameItem = new QTableWidgetItem(files[i]); + fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable); + QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("%1 KB") + .arg(int((size + 1023) / 1024))); + sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); + sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable); + + int row = filesTable->rowCount(); + filesTable->insertRow(row); + filesTable->setItem(row, 0, fileNameItem); + filesTable->setItem(row, 1, sizeItem); + } + filesFoundLabel->setText(tr("%1 file(s) found").arg(files.size()) + + (" (Double click on a file to open it)")); +} +//! [8] + +//! [9] +QPushButton *Window::createButton(const QString &text, const char *member) +{ + QPushButton *button = new QPushButton(text); + connect(button, SIGNAL(clicked()), this, member); + return button; +} +//! [9] + +//! [10] +QComboBox *Window::createComboBox(const QString &text) +{ + QComboBox *comboBox = new QComboBox; + comboBox->setEditable(true); + comboBox->addItem(text); + comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + return comboBox; +} +//! [10] + +//! [11] +void Window::createFilesTable() +{ + filesTable = new QTableWidget(0, 2); + filesTable->setSelectionBehavior(QAbstractItemView::SelectRows); + + QStringList labels; + labels << tr("File Name") << tr("Size"); + filesTable->setHorizontalHeaderLabels(labels); + filesTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); + filesTable->verticalHeader()->hide(); + filesTable->setShowGrid(false); + + connect(filesTable, SIGNAL(cellActivated(int, int)), + this, SLOT(openFileOfItem(int, int))); +} +//! [11] + +//! [12] + +void Window::openFileOfItem(int row, int /* column */) +{ + QTableWidgetItem *item = filesTable->item(row, 0); + + QDesktopServices::openUrl(currentDir.absoluteFilePath(item->text())); +} + +//! [12] + diff --git a/examples/dialogs/findfiles/window.h b/examples/dialogs/findfiles/window.h new file mode 100644 index 0000000..8cd4813 --- /dev/null +++ b/examples/dialogs/findfiles/window.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 WINDOW_H +#define WINDOW_H + +#include <QDialog> +#include <QDir> + +QT_BEGIN_NAMESPACE +class QComboBox; +class QLabel; +class QPushButton; +class QTableWidget; +class QTableWidgetItem; +QT_END_NAMESPACE + +//! [0] +class Window : public QDialog +{ + Q_OBJECT + +public: + Window(QWidget *parent = 0); + +private slots: + void browse(); + void find(); + void openFileOfItem(int row, int column); + +private: + QStringList findFiles(const QStringList &files, const QString &text); + void showFiles(const QStringList &files); + QPushButton *createButton(const QString &text, const char *member); + QComboBox *createComboBox(const QString &text = QString()); + void createFilesTable(); + + QComboBox *fileComboBox; + QComboBox *textComboBox; + QComboBox *directoryComboBox; + QLabel *fileLabel; + QLabel *textLabel; + QLabel *directoryLabel; + QLabel *filesFoundLabel; + QPushButton *browseButton; + QPushButton *findButton; + QTableWidget *filesTable; + + QDir currentDir; +}; +//! [0] + +#endif diff --git a/examples/dialogs/licensewizard/images/logo.png b/examples/dialogs/licensewizard/images/logo.png Binary files differnew file mode 100644 index 0000000..56f17a3 --- /dev/null +++ b/examples/dialogs/licensewizard/images/logo.png diff --git a/examples/dialogs/licensewizard/images/watermark.png b/examples/dialogs/licensewizard/images/watermark.png Binary files differnew file mode 100644 index 0000000..124a050 --- /dev/null +++ b/examples/dialogs/licensewizard/images/watermark.png diff --git a/examples/dialogs/licensewizard/licensewizard.cpp b/examples/dialogs/licensewizard/licensewizard.cpp new file mode 100644 index 0000000..30b4165 --- /dev/null +++ b/examples/dialogs/licensewizard/licensewizard.cpp @@ -0,0 +1,360 @@ +/**************************************************************************** +** +** 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 "licensewizard.h" + +//! [0] //! [1] //! [2] +LicenseWizard::LicenseWizard(QWidget *parent) + : QWizard(parent) +{ +//! [0] + setPage(Page_Intro, new IntroPage); + setPage(Page_Evaluate, new EvaluatePage); + setPage(Page_Register, new RegisterPage); + setPage(Page_Details, new DetailsPage); + setPage(Page_Conclusion, new ConclusionPage); +//! [1] + + setStartId(Page_Intro); +//! [2] + +//! [3] +#ifndef Q_WS_MAC +//! [3] //! [4] + setWizardStyle(ModernStyle); +#endif +//! [4] //! [5] + setOption(HaveHelpButton, true); +//! [5] //! [6] + setPixmap(QWizard::LogoPixmap, QPixmap(":/images/logo.png")); + +//! [7] + connect(this, SIGNAL(helpRequested()), this, SLOT(showHelp())); +//! [7] + + setWindowTitle(tr("License Wizard")); +//! [8] +} +//! [6] //! [8] + +//! [9] //! [10] +void LicenseWizard::showHelp() +//! [9] //! [11] +{ + static QString lastHelpMessage; + + QString message; + + switch (currentId()) { + case Page_Intro: + message = tr("The decision you make here will affect which page you " + "get to see next."); + break; +//! [10] //! [11] + case Page_Evaluate: + message = tr("Make sure to provide a valid email address, such as " + "toni.buddenbrook@example.de."); + break; + case Page_Register: + message = tr("If you don't provide an upgrade key, you will be " + "asked to fill in your details."); + break; + case Page_Details: + message = tr("Make sure to provide a valid email address, such as " + "thomas.gradgrind@example.co.uk."); + break; + case Page_Conclusion: + message = tr("You must accept the terms and conditions of the " + "license to proceed."); + break; +//! [12] //! [13] + default: + message = tr("This help is likely not to be of any help."); + } +//! [12] + + if (lastHelpMessage == message) + message = tr("Sorry, I already gave what help I could. " + "Maybe you should try asking a human?"); + +//! [14] + QMessageBox::information(this, tr("License Wizard Help"), message); +//! [14] + + lastHelpMessage = message; +//! [15] +} +//! [13] //! [15] + +//! [16] +IntroPage::IntroPage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Introduction")); + setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png")); + + topLabel = new QLabel(tr("This wizard will help you register your copy of " + "<i>Super Product One</i>™ or start " + "evaluating the product.")); + topLabel->setWordWrap(true); + + registerRadioButton = new QRadioButton(tr("&Register your copy")); + evaluateRadioButton = new QRadioButton(tr("&Evaluate the product for 30 " + "days")); + registerRadioButton->setChecked(true); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(topLabel); + layout->addWidget(registerRadioButton); + layout->addWidget(evaluateRadioButton); + setLayout(layout); +} +//! [16] //! [17] + +//! [18] +int IntroPage::nextId() const +//! [17] //! [19] +{ + if (evaluateRadioButton->isChecked()) { + return LicenseWizard::Page_Evaluate; + } else { + return LicenseWizard::Page_Register; + } +} +//! [18] //! [19] + +//! [20] +EvaluatePage::EvaluatePage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Evaluate <i>Super Product One</i>™")); + setSubTitle(tr("Please fill both fields. Make sure to provide a valid " + "email address (e.g., john.smith@example.com).")); + + nameLabel = new QLabel(tr("N&ame:")); + nameLineEdit = new QLineEdit; +//! [20] + nameLabel->setBuddy(nameLineEdit); + + emailLabel = new QLabel(tr("&Email address:")); + emailLineEdit = new QLineEdit; + emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this)); + emailLabel->setBuddy(emailLineEdit); + +//! [21] + registerField("evaluate.name*", nameLineEdit); + registerField("evaluate.email*", emailLineEdit); +//! [21] + + QGridLayout *layout = new QGridLayout; + layout->addWidget(nameLabel, 0, 0); + layout->addWidget(nameLineEdit, 0, 1); + layout->addWidget(emailLabel, 1, 0); + layout->addWidget(emailLineEdit, 1, 1); + setLayout(layout); +//! [22] +} +//! [22] + +//! [23] +int EvaluatePage::nextId() const +{ + return LicenseWizard::Page_Conclusion; +} +//! [23] + +RegisterPage::RegisterPage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Register Your Copy of <i>Super Product One</i>™")); + setSubTitle(tr("If you have an upgrade key, please fill in " + "the appropriate field.")); + + nameLabel = new QLabel(tr("N&ame:")); + nameLineEdit = new QLineEdit; + nameLabel->setBuddy(nameLineEdit); + + upgradeKeyLabel = new QLabel(tr("&Upgrade key:")); + upgradeKeyLineEdit = new QLineEdit; + upgradeKeyLabel->setBuddy(upgradeKeyLineEdit); + + registerField("register.name*", nameLineEdit); + registerField("register.upgradeKey", upgradeKeyLineEdit); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(nameLabel, 0, 0); + layout->addWidget(nameLineEdit, 0, 1); + layout->addWidget(upgradeKeyLabel, 1, 0); + layout->addWidget(upgradeKeyLineEdit, 1, 1); + setLayout(layout); +} + +//! [24] +int RegisterPage::nextId() const +{ + if (upgradeKeyLineEdit->text().isEmpty()) { + return LicenseWizard::Page_Details; + } else { + return LicenseWizard::Page_Conclusion; + } +} +//! [24] + +DetailsPage::DetailsPage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Fill In Your Details")); + setSubTitle(tr("Please fill all three fields. Make sure to provide a valid " + "email address (e.g., tanaka.aya@example.co.jp).")); + + companyLabel = new QLabel(tr("&Company name:")); + companyLineEdit = new QLineEdit; + companyLabel->setBuddy(companyLineEdit); + + emailLabel = new QLabel(tr("&Email address:")); + emailLineEdit = new QLineEdit; + emailLineEdit->setValidator(new QRegExpValidator(QRegExp(".*@.*"), this)); + emailLabel->setBuddy(emailLineEdit); + + postalLabel = new QLabel(tr("&Postal address:")); + postalLineEdit = new QLineEdit; + postalLabel->setBuddy(postalLineEdit); + + registerField("details.company*", companyLineEdit); + registerField("details.email*", emailLineEdit); + registerField("details.postal*", postalLineEdit); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(companyLabel, 0, 0); + layout->addWidget(companyLineEdit, 0, 1); + layout->addWidget(emailLabel, 1, 0); + layout->addWidget(emailLineEdit, 1, 1); + layout->addWidget(postalLabel, 2, 0); + layout->addWidget(postalLineEdit, 2, 1); + setLayout(layout); +} + +//! [25] +int DetailsPage::nextId() const +{ + return LicenseWizard::Page_Conclusion; +} +//! [25] + +ConclusionPage::ConclusionPage(QWidget *parent) + : QWizardPage(parent) +{ + setTitle(tr("Complete Your Registration")); + setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/watermark.png")); + + bottomLabel = new QLabel; + bottomLabel->setWordWrap(true); + + agreeCheckBox = new QCheckBox(tr("I agree to the terms of the license")); + + registerField("conclusion.agree*", agreeCheckBox); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(bottomLabel); + layout->addWidget(agreeCheckBox); + setLayout(layout); +} + +//! [26] +int ConclusionPage::nextId() const +{ + return -1; +} +//! [26] + +//! [27] +void ConclusionPage::initializePage() +{ + QString licenseText; + + if (wizard()->hasVisitedPage(LicenseWizard::Page_Evaluate)) { + licenseText = tr("<u>Evaluation License Agreement:</u> " + "You can use this software for 30 days and make one " + "backup, but you are not allowed to distribute it."); + } else if (wizard()->hasVisitedPage(LicenseWizard::Page_Details)) { + licenseText = tr("<u>First-Time License Agreement:</u> " + "You can use this software subject to the license " + "you will receive by email."); + } else { + licenseText = tr("<u>Upgrade License Agreement:</u> " + "This software is licensed under the terms of your " + "current license."); + } + bottomLabel->setText(licenseText); +} +//! [27] + +//! [28] +void ConclusionPage::setVisible(bool visible) +{ + QWizardPage::setVisible(visible); + + if (visible) { +//! [29] + wizard()->setButtonText(QWizard::CustomButton1, tr("&Print")); + wizard()->setOption(QWizard::HaveCustomButton1, true); + connect(wizard(), SIGNAL(customButtonClicked(int)), + this, SLOT(printButtonClicked())); +//! [29] + } else { + wizard()->setOption(QWizard::HaveCustomButton1, false); + disconnect(wizard(), SIGNAL(customButtonClicked(int)), + this, SLOT(printButtonClicked())); + } +} +//! [28] + +void ConclusionPage::printButtonClicked() +{ + QPrinter printer; + QPrintDialog dialog(&printer, this); + if (dialog.exec()) + QMessageBox::warning(this, tr("Print License"), + tr("As an environmentally friendly measure, the " + "license text will not actually be printed.")); +} diff --git a/examples/dialogs/licensewizard/licensewizard.h b/examples/dialogs/licensewizard/licensewizard.h new file mode 100644 index 0000000..bcf22a2 --- /dev/null +++ b/examples/dialogs/licensewizard/licensewizard.h @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** 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 LICENSEWIZARD_H +#define LICENSEWIZARD_H + +#include <QWizard> + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QLabel; +class QLineEdit; +class QRadioButton; +QT_END_NAMESPACE + +//! [0] //! [1] +class LicenseWizard : public QWizard +{ +//! [0] + Q_OBJECT + +public: +//! [2] + enum { Page_Intro, Page_Evaluate, Page_Register, Page_Details, + Page_Conclusion }; +//! [2] + + LicenseWizard(QWidget *parent = 0); + +private slots: + void showHelp(); +//! [3] +}; +//! [1] //! [3] + +//! [4] +class IntroPage : public QWizardPage +{ + Q_OBJECT + +public: + IntroPage(QWidget *parent = 0); + + int nextId() const; + +private: + QLabel *topLabel; + QRadioButton *registerRadioButton; + QRadioButton *evaluateRadioButton; +}; +//! [4] + +//! [5] +class EvaluatePage : public QWizardPage +{ + Q_OBJECT + +public: + EvaluatePage(QWidget *parent = 0); + + int nextId() const; + +private: + QLabel *nameLabel; + QLabel *emailLabel; + QLineEdit *nameLineEdit; + QLineEdit *emailLineEdit; +}; +//! [5] + +class RegisterPage : public QWizardPage +{ + Q_OBJECT + +public: + RegisterPage(QWidget *parent = 0); + + int nextId() const; + +private: + QLabel *nameLabel; + QLabel *upgradeKeyLabel; + QLineEdit *nameLineEdit; + QLineEdit *upgradeKeyLineEdit; +}; + +class DetailsPage : public QWizardPage +{ + Q_OBJECT + +public: + DetailsPage(QWidget *parent = 0); + + int nextId() const; + +private: + QLabel *companyLabel; + QLabel *emailLabel; + QLabel *postalLabel; + QLineEdit *companyLineEdit; + QLineEdit *emailLineEdit; + QLineEdit *postalLineEdit; +}; + +//! [6] +class ConclusionPage : public QWizardPage +{ + Q_OBJECT + +public: + ConclusionPage(QWidget *parent = 0); + + void initializePage(); + int nextId() const; + void setVisible(bool visible); + +private slots: + void printButtonClicked(); + +private: + QLabel *bottomLabel; + QCheckBox *agreeCheckBox; +}; +//! [6] + +#endif diff --git a/examples/dialogs/licensewizard/licensewizard.pro b/examples/dialogs/licensewizard/licensewizard.pro new file mode 100644 index 0000000..fd5e37c --- /dev/null +++ b/examples/dialogs/licensewizard/licensewizard.pro @@ -0,0 +1,10 @@ +HEADERS = licensewizard.h +SOURCES = licensewizard.cpp \ + main.cpp +RESOURCES = licensewizard.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/licensewizard +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/licensewizard +INSTALLS += target sources diff --git a/examples/dialogs/licensewizard/licensewizard.qrc b/examples/dialogs/licensewizard/licensewizard.qrc new file mode 100644 index 0000000..b069938 --- /dev/null +++ b/examples/dialogs/licensewizard/licensewizard.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>images/logo.png</file> + <file>images/watermark.png</file> +</qresource> +</RCC> diff --git a/examples/dialogs/licensewizard/main.cpp b/examples/dialogs/licensewizard/main.cpp new file mode 100644 index 0000000..9d10032 --- /dev/null +++ b/examples/dialogs/licensewizard/main.cpp @@ -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$ +** +****************************************************************************/ + +#include <QApplication> +#include <QTranslator> +#include <QLocale> +#include <QLibraryInfo> + +#include "licensewizard.h" + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(licensewizard); + + QApplication app(argc, argv); + + QString translatorFileName = QLatin1String("qt_"); + translatorFileName += QLocale::system().name(); + QTranslator *translator = new QTranslator(&app); + if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + app.installTranslator(translator); + + LicenseWizard wizard; + wizard.show(); + return app.exec(); +} diff --git a/examples/dialogs/sipdialog/dialog.cpp b/examples/dialogs/sipdialog/dialog.cpp new file mode 100644 index 0000000..9f1b9ad --- /dev/null +++ b/examples/dialogs/sipdialog/dialog.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 <QtGui> + +#include "dialog.h" + +//! [Dialog constructor part1] +Dialog::Dialog() +{ + desktopGeometry = QApplication::desktop()->availableGeometry(0); + + setWindowTitle(tr("SIP Dialog Example")); + QScrollArea *scrollArea = new QScrollArea(this); + QGroupBox *groupBox = new QGroupBox(scrollArea); + groupBox->setTitle(tr("SIP Dialog Example")); + QGridLayout *gridLayout = new QGridLayout(groupBox); + groupBox->setLayout(gridLayout); +//! [Dialog constructor part1] + +//! [Dialog constructor part2] + QLineEdit* lineEdit = new QLineEdit(groupBox); + lineEdit->setText(tr("Open and close the SIP")); + lineEdit->setMinimumWidth(220); + + QLabel* label = new QLabel(groupBox); + label->setText(tr("This dialog resizes if the SIP is opened")); + label->setMinimumWidth(220); + + QPushButton* button = new QPushButton(groupBox); + button->setText(tr("Close Dialog")); + button->setMinimumWidth(220); +//! [Dialog constructor part2] + +//! [Dialog constructor part3] + if (desktopGeometry.height() < 400) + gridLayout->setVerticalSpacing(80); + else + gridLayout->setVerticalSpacing(150); + + gridLayout->addWidget(label); + gridLayout->addWidget(lineEdit); + gridLayout->addWidget(button); +//! [Dialog constructor part3] + +//! [Dialog constructor part4] + scrollArea->setWidget(groupBox); + QHBoxLayout* layout = new QHBoxLayout(); + layout->addWidget(scrollArea); + setLayout(layout); + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +//! [Dialog constructor part4] + +//! [Dialog constructor part5] + connect(button, SIGNAL(pressed()), + qApp, SLOT(closeAllWindows())); + connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), + this, SLOT(desktopResized(int))); +} +//! [Dialog constructor part5] + +//! [desktopResized() function] +void Dialog::desktopResized(int screen) +{ + if (screen != 0) + return; + reactToSIP(); +} +//! [desktopResized() function] + +//! [reactToSIP() function] +void Dialog::reactToSIP() +{ + QRect availableGeometry = QApplication::desktop()->availableGeometry(0); + + if (desktopGeometry.width() == availableGeometry.width()) { + if (desktopGeometry.height() > availableGeometry.height()) { + setWindowState(windowState() & ~Qt::WindowMaximized); + setGeometry(availableGeometry); + } else { + setWindowState(windowState() | Qt::WindowMaximized); + } + } + desktopGeometry = availableGeometry; +} +//! [reactToSIP() function] diff --git a/examples/dialogs/sipdialog/dialog.h b/examples/dialogs/sipdialog/dialog.h new file mode 100644 index 0000000..ffcc926 --- /dev/null +++ b/examples/dialogs/sipdialog/dialog.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 DIALOG_H +#define DIALOG_H + +#include <QDialog> + +//! [Dialog header] +class Dialog : public QDialog +{ + Q_OBJECT + +public: + Dialog(); + void reactToSIP(); + +private: + QRect desktopGeometry; + +public slots: + void desktopResized(int screen); +}; +//! [Dialog header] + +#endif diff --git a/examples/dialogs/sipdialog/main.cpp b/examples/dialogs/sipdialog/main.cpp new file mode 100644 index 0000000..5fcbfd8 --- /dev/null +++ b/examples/dialogs/sipdialog/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 <QtGui> + +#include "dialog.h" + +//! [main() function] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Dialog dialog; + dialog.exec(); +} +//! [main() function] diff --git a/examples/dialogs/sipdialog/sipdialog.pro b/examples/dialogs/sipdialog/sipdialog.pro new file mode 100644 index 0000000..69667eb --- /dev/null +++ b/examples/dialogs/sipdialog/sipdialog.pro @@ -0,0 +1,12 @@ +HEADERS = dialog.h +SOURCES = main.cpp \ + dialog.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/sipdialog +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/sipdialog +INSTALLS += target sources +wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib + + diff --git a/examples/dialogs/standarddialogs/dialog.cpp b/examples/dialogs/standarddialogs/dialog.cpp new file mode 100644 index 0000000..0fe1f7e --- /dev/null +++ b/examples/dialogs/standarddialogs/dialog.cpp @@ -0,0 +1,390 @@ +/**************************************************************************** +** +** 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 "dialog.h" + +#define MESSAGE \ + Dialog::tr("<p>Message boxes have a caption, a text, " \ + "and any number of buttons, each with standard or custom texts." \ + "<p>Click a button to close the message box. Pressing the Esc button " \ + "will activate the detected escape button (if any).") + +Dialog::Dialog(QWidget *parent) + : QDialog(parent) +{ + errorMessageDialog = new QErrorMessage(this); + + int frameStyle = QFrame::Sunken | QFrame::Panel; + + integerLabel = new QLabel; + integerLabel->setFrameStyle(frameStyle); + QPushButton *integerButton = + new QPushButton(tr("QInputDialog::get&Integer()")); + + doubleLabel = new QLabel; + doubleLabel->setFrameStyle(frameStyle); + QPushButton *doubleButton = + new QPushButton(tr("QInputDialog::get&Double()")); + + itemLabel = new QLabel; + itemLabel->setFrameStyle(frameStyle); + QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()")); + + textLabel = new QLabel; + textLabel->setFrameStyle(frameStyle); + QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()")); + + colorLabel = new QLabel; + colorLabel->setFrameStyle(frameStyle); + QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()")); + + fontLabel = new QLabel; + fontLabel->setFrameStyle(frameStyle); + QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()")); + + directoryLabel = new QLabel; + directoryLabel->setFrameStyle(frameStyle); + QPushButton *directoryButton = + new QPushButton(tr("QFileDialog::getE&xistingDirectory()")); + + openFileNameLabel = new QLabel; + openFileNameLabel->setFrameStyle(frameStyle); + QPushButton *openFileNameButton = + new QPushButton(tr("QFileDialog::get&OpenFileName()")); + + openFileNamesLabel = new QLabel; + openFileNamesLabel->setFrameStyle(frameStyle); + QPushButton *openFileNamesButton = + new QPushButton(tr("QFileDialog::&getOpenFileNames()")); + + saveFileNameLabel = new QLabel; + saveFileNameLabel->setFrameStyle(frameStyle); + QPushButton *saveFileNameButton = + new QPushButton(tr("QFileDialog::get&SaveFileName()")); + + criticalLabel = new QLabel; + criticalLabel->setFrameStyle(frameStyle); + QPushButton *criticalButton = + new QPushButton(tr("QMessageBox::critica&l()")); + + informationLabel = new QLabel; + informationLabel->setFrameStyle(frameStyle); + QPushButton *informationButton = + new QPushButton(tr("QMessageBox::i&nformation()")); + + questionLabel = new QLabel; + questionLabel->setFrameStyle(frameStyle); + QPushButton *questionButton = + new QPushButton(tr("QMessageBox::&question()")); + + warningLabel = new QLabel; + warningLabel->setFrameStyle(frameStyle); + QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); + + errorLabel = new QLabel; + errorLabel->setFrameStyle(frameStyle); + QPushButton *errorButton = + new QPushButton(tr("QErrorMessage::show&M&essage()")); + + connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); + connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); + connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); + connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); + connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); + connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); + connect(directoryButton, SIGNAL(clicked()), + this, SLOT(setExistingDirectory())); + connect(openFileNameButton, SIGNAL(clicked()), + this, SLOT(setOpenFileName())); + connect(openFileNamesButton, SIGNAL(clicked()), + this, SLOT(setOpenFileNames())); + connect(saveFileNameButton, SIGNAL(clicked()), + this, SLOT(setSaveFileName())); + connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); + connect(informationButton, SIGNAL(clicked()), + this, SLOT(informationMessage())); + connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); + connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); + connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); + + native = new QCheckBox(this); + native->setText("Use native file dialog."); + native->setChecked(true); +#ifndef Q_WS_WIN +#ifndef Q_OS_MAC + native->hide(); +#endif +#endif + QGridLayout *layout = new QGridLayout; + layout->setColumnStretch(1, 1); + layout->setColumnMinimumWidth(1, 250); + layout->addWidget(integerButton, 0, 0); + layout->addWidget(integerLabel, 0, 1); + layout->addWidget(doubleButton, 1, 0); + layout->addWidget(doubleLabel, 1, 1); + layout->addWidget(itemButton, 2, 0); + layout->addWidget(itemLabel, 2, 1); + layout->addWidget(textButton, 3, 0); + layout->addWidget(textLabel, 3, 1); + layout->addWidget(colorButton, 4, 0); + layout->addWidget(colorLabel, 4, 1); + layout->addWidget(fontButton, 5, 0); + layout->addWidget(fontLabel, 5, 1); + layout->addWidget(directoryButton, 6, 0); + layout->addWidget(directoryLabel, 6, 1); + layout->addWidget(openFileNameButton, 7, 0); + layout->addWidget(openFileNameLabel, 7, 1); + layout->addWidget(openFileNamesButton, 8, 0); + layout->addWidget(openFileNamesLabel, 8, 1); + layout->addWidget(saveFileNameButton, 9, 0); + layout->addWidget(saveFileNameLabel, 9, 1); + layout->addWidget(criticalButton, 10, 0); + layout->addWidget(criticalLabel, 10, 1); + layout->addWidget(informationButton, 11, 0); + layout->addWidget(informationLabel, 11, 1); + layout->addWidget(questionButton, 12, 0); + layout->addWidget(questionLabel, 12, 1); + layout->addWidget(warningButton, 13, 0); + layout->addWidget(warningLabel, 13, 1); + layout->addWidget(errorButton, 14, 0); + layout->addWidget(errorLabel, 14, 1); + layout->addWidget(native, 15, 0); + setLayout(layout); + + setWindowTitle(tr("Standard Dialogs")); +} + +void Dialog::setInteger() +{ +//! [0] + bool ok; + int i = QInputDialog::getInteger(this, tr("QInputDialog::getInteger()"), + tr("Percentage:"), 25, 0, 100, 1, &ok); + if (ok) + integerLabel->setText(tr("%1%").arg(i)); +//! [0] +} + +void Dialog::setDouble() +{ +//! [1] + bool ok; + double d = QInputDialog::getDouble(this, tr("QInputDialog::getDouble()"), + tr("Amount:"), 37.56, -10000, 10000, 2, &ok); + if (ok) + doubleLabel->setText(QString("$%1").arg(d)); +//! [1] +} + +void Dialog::setItem() +{ +//! [2] + QStringList items; + items << tr("Spring") << tr("Summer") << tr("Fall") << tr("Winter"); + + bool ok; + QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"), + tr("Season:"), items, 0, false, &ok); + if (ok && !item.isEmpty()) + itemLabel->setText(item); +//! [2] +} + +void Dialog::setText() +{ +//! [3] + bool ok; + QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"), + tr("User name:"), QLineEdit::Normal, + QDir::home().dirName(), &ok); + if (ok && !text.isEmpty()) + textLabel->setText(text); +//! [3] +} + +void Dialog::setColor() +{ + QColor color = QColorDialog::getColor(Qt::green, this); + if (color.isValid()) { + colorLabel->setText(color.name()); + colorLabel->setPalette(QPalette(color)); + colorLabel->setAutoFillBackground(true); + } +} + +void Dialog::setFont() +{ + bool ok; + QFont font = QFontDialog::getFont(&ok, QFont(fontLabel->text()), this); + if (ok) { + fontLabel->setText(font.key()); + fontLabel->setFont(font); + } +} + +void Dialog::setExistingDirectory() +{ + QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly; + if (!native->isChecked()) + options |= QFileDialog::DontUseNativeDialog; + QString directory = QFileDialog::getExistingDirectory(this, + tr("QFileDialog::getExistingDirectory()"), + directoryLabel->text(), + options); + if (!directory.isEmpty()) + directoryLabel->setText(directory); +} + +void Dialog::setOpenFileName() +{ + QFileDialog::Options options; + if (!native->isChecked()) + options |= QFileDialog::DontUseNativeDialog; + QString selectedFilter; + QString fileName = QFileDialog::getOpenFileName(this, + tr("QFileDialog::getOpenFileName()"), + openFileNameLabel->text(), + tr("All Files (*);;Text Files (*.txt)"), + &selectedFilter, + options); + if (!fileName.isEmpty()) + openFileNameLabel->setText(fileName); +} + +void Dialog::setOpenFileNames() +{ + QFileDialog::Options options; + if (!native->isChecked()) + options |= QFileDialog::DontUseNativeDialog; + QString selectedFilter; + QStringList files = QFileDialog::getOpenFileNames( + this, tr("QFileDialog::getOpenFileNames()"), + openFilesPath, + tr("All Files (*);;Text Files (*.txt)"), + &selectedFilter, + options); + if (files.count()) { + openFilesPath = files[0]; + openFileNamesLabel->setText(QString("[%1]").arg(files.join(", "))); + } +} + +void Dialog::setSaveFileName() +{ + QFileDialog::Options options; + if (!native->isChecked()) + options |= QFileDialog::DontUseNativeDialog; + QString selectedFilter; + QString fileName = QFileDialog::getSaveFileName(this, + tr("QFileDialog::getSaveFileName()"), + saveFileNameLabel->text(), + tr("All Files (*);;Text Files (*.txt)"), + &selectedFilter, + options); + if (!fileName.isEmpty()) + saveFileNameLabel->setText(fileName); +} + +void Dialog::criticalMessage() +{ + QMessageBox::StandardButton reply; + reply = QMessageBox::critical(this, tr("QMessageBox::critical()"), + MESSAGE, + QMessageBox::Abort | QMessageBox::Retry | QMessageBox::Ignore); + if (reply == QMessageBox::Abort) + criticalLabel->setText(tr("Abort")); + else if (reply == QMessageBox::Retry) + criticalLabel->setText(tr("Retry")); + else + criticalLabel->setText(tr("Ignore")); +} + +void Dialog::informationMessage() +{ + QMessageBox::StandardButton reply; + reply = QMessageBox::information(this, tr("QMessageBox::information()"), MESSAGE); + if (reply == QMessageBox::Ok) + informationLabel->setText(tr("OK")); + else + informationLabel->setText(tr("Escape")); +} + +void Dialog::questionMessage() +{ + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this, tr("QMessageBox::question()"), + MESSAGE, + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); + if (reply == QMessageBox::Yes) + questionLabel->setText(tr("Yes")); + else if (reply == QMessageBox::No) + questionLabel->setText(tr("No")); + else + questionLabel->setText(tr("Cancel")); +} + +void Dialog::warningMessage() +{ + QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"), + MESSAGE, 0, this); + msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole); + msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole); + if (msgBox.exec() == QMessageBox::AcceptRole) + warningLabel->setText(tr("Save Again")); + else + warningLabel->setText(tr("Continue")); + +} + +void Dialog::errorMessage() +{ + errorMessageDialog->showMessage( + tr("This dialog shows and remembers error messages. " + "If the checkbox is checked (as it is by default), " + "the shown message will be shown again, " + "but if the user unchecks the box the message " + "will not appear again if QErrorMessage::showMessage() " + "is called with the same message.")); + errorLabel->setText(tr("If the box is unchecked, the message " + "won't appear again.")); +} diff --git a/examples/dialogs/standarddialogs/dialog.h b/examples/dialogs/standarddialogs/dialog.h new file mode 100644 index 0000000..35f0b05 --- /dev/null +++ b/examples/dialogs/standarddialogs/dialog.h @@ -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$ +** +****************************************************************************/ + +#ifndef DIALOG_H +#define DIALOG_H + +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QLabel; +class QErrorMessage; +QT_END_NAMESPACE + +class Dialog : public QDialog +{ + Q_OBJECT + +public: + Dialog(QWidget *parent = 0); + +private slots: + void setInteger(); + void setDouble(); + void setItem(); + void setText(); + void setColor(); + void setFont(); + void setExistingDirectory(); + void setOpenFileName(); + void setOpenFileNames(); + void setSaveFileName(); + void criticalMessage(); + void informationMessage(); + void questionMessage(); + void warningMessage(); + void errorMessage(); + +private: + QCheckBox *native; + QLabel *integerLabel; + QLabel *doubleLabel; + QLabel *itemLabel; + QLabel *textLabel; + QLabel *colorLabel; + QLabel *fontLabel; + QLabel *directoryLabel; + QLabel *openFileNameLabel; + QLabel *openFileNamesLabel; + QLabel *saveFileNameLabel; + QLabel *criticalLabel; + QLabel *informationLabel; + QLabel *questionLabel; + QLabel *warningLabel; + QLabel *errorLabel; + QErrorMessage *errorMessageDialog; + + QString openFilesPath; +}; + +#endif diff --git a/examples/dialogs/standarddialogs/main.cpp b/examples/dialogs/standarddialogs/main.cpp new file mode 100644 index 0000000..3b7ed8b --- /dev/null +++ b/examples/dialogs/standarddialogs/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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 <QTranslator> +#include <QLocale> +#include <QLibraryInfo> + +#include "dialog.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QString translatorFileName = QLatin1String("qt_"); + translatorFileName += QLocale::system().name(); + QTranslator *translator = new QTranslator(&app); + if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + app.installTranslator(translator); + + Dialog dialog; + return dialog.exec(); +} diff --git a/examples/dialogs/standarddialogs/standarddialogs.pro b/examples/dialogs/standarddialogs/standarddialogs.pro new file mode 100644 index 0000000..6bfa6bf --- /dev/null +++ b/examples/dialogs/standarddialogs/standarddialogs.pro @@ -0,0 +1,11 @@ +HEADERS = dialog.h +SOURCES = dialog.cpp \ + main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/standarddialogs +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/standarddialogs +INSTALLS += target sources +wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib + diff --git a/examples/dialogs/tabdialog/main.cpp b/examples/dialogs/tabdialog/main.cpp new file mode 100644 index 0000000..04f3b33 --- /dev/null +++ b/examples/dialogs/tabdialog/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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 "tabdialog.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QString fileName; + + if (argc >= 2) + fileName = argv[1]; + else + fileName = "."; + + TabDialog tabdialog(fileName); + return tabdialog.exec(); +} diff --git a/examples/dialogs/tabdialog/tabdialog.cpp b/examples/dialogs/tabdialog/tabdialog.cpp new file mode 100644 index 0000000..189d085 --- /dev/null +++ b/examples/dialogs/tabdialog/tabdialog.cpp @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** 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 "tabdialog.h" + +//! [0] +TabDialog::TabDialog(const QString &fileName, QWidget *parent) + : QDialog(parent) +{ + QFileInfo fileInfo(fileName); + + tabWidget = new QTabWidget; + tabWidget->addTab(new GeneralTab(fileInfo), tr("General")); + tabWidget->addTab(new PermissionsTab(fileInfo), tr("Permissions")); + tabWidget->addTab(new ApplicationsTab(fileInfo), tr("Applications")); +//! [0] + +//! [1] //! [2] + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok +//! [1] //! [3] + | QDialogButtonBox::Cancel); + + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); +//! [2] //! [3] + +//! [4] + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(tabWidget); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); +//! [4] + +//! [5] + setWindowTitle(tr("Tab Dialog")); +} +//! [5] + +//! [6] +GeneralTab::GeneralTab(const QFileInfo &fileInfo, QWidget *parent) + : QWidget(parent) +{ + QLabel *fileNameLabel = new QLabel(tr("File Name:")); + QLineEdit *fileNameEdit = new QLineEdit(fileInfo.fileName()); + + QLabel *pathLabel = new QLabel(tr("Path:")); + QLabel *pathValueLabel = new QLabel(fileInfo.absoluteFilePath()); + pathValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + + QLabel *sizeLabel = new QLabel(tr("Size:")); + qlonglong size = fileInfo.size()/1024; + QLabel *sizeValueLabel = new QLabel(tr("%1 K").arg(size)); + sizeValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + + QLabel *lastReadLabel = new QLabel(tr("Last Read:")); + QLabel *lastReadValueLabel = new QLabel(fileInfo.lastRead().toString()); + lastReadValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + + QLabel *lastModLabel = new QLabel(tr("Last Modified:")); + QLabel *lastModValueLabel = new QLabel(fileInfo.lastModified().toString()); + lastModValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(fileNameLabel); + mainLayout->addWidget(fileNameEdit); + mainLayout->addWidget(pathLabel); + mainLayout->addWidget(pathValueLabel); + mainLayout->addWidget(sizeLabel); + mainLayout->addWidget(sizeValueLabel); + mainLayout->addWidget(lastReadLabel); + mainLayout->addWidget(lastReadValueLabel); + mainLayout->addWidget(lastModLabel); + mainLayout->addWidget(lastModValueLabel); + mainLayout->addStretch(1); + setLayout(mainLayout); +} +//! [6] + +//! [7] +PermissionsTab::PermissionsTab(const QFileInfo &fileInfo, QWidget *parent) + : QWidget(parent) +{ + QGroupBox *permissionsGroup = new QGroupBox(tr("Permissions")); + + QCheckBox *readable = new QCheckBox(tr("Readable")); + if (fileInfo.isReadable()) + readable->setChecked(true); + + QCheckBox *writable = new QCheckBox(tr("Writable")); + if ( fileInfo.isWritable() ) + writable->setChecked(true); + + QCheckBox *executable = new QCheckBox(tr("Executable")); + if ( fileInfo.isExecutable() ) + executable->setChecked(true); + + QGroupBox *ownerGroup = new QGroupBox(tr("Ownership")); + + QLabel *ownerLabel = new QLabel(tr("Owner")); + QLabel *ownerValueLabel = new QLabel(fileInfo.owner()); + ownerValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + + QLabel *groupLabel = new QLabel(tr("Group")); + QLabel *groupValueLabel = new QLabel(fileInfo.group()); + groupValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + + QVBoxLayout *permissionsLayout = new QVBoxLayout; + permissionsLayout->addWidget(readable); + permissionsLayout->addWidget(writable); + permissionsLayout->addWidget(executable); + permissionsGroup->setLayout(permissionsLayout); + + QVBoxLayout *ownerLayout = new QVBoxLayout; + ownerLayout->addWidget(ownerLabel); + ownerLayout->addWidget(ownerValueLabel); + ownerLayout->addWidget(groupLabel); + ownerLayout->addWidget(groupValueLabel); + ownerGroup->setLayout(ownerLayout); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(permissionsGroup); + mainLayout->addWidget(ownerGroup); + mainLayout->addStretch(1); + setLayout(mainLayout); +} +//! [7] + +//! [8] +ApplicationsTab::ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent) + : QWidget(parent) +{ + QLabel *topLabel = new QLabel(tr("Open with:")); + + QListWidget *applicationsListBox = new QListWidget; + QStringList applications; + + for (int i = 1; i <= 30; ++i) + applications.append(tr("Application %1").arg(i)); + applicationsListBox->insertItems(0, applications); + + QCheckBox *alwaysCheckBox; + + if (fileInfo.suffix().isEmpty()) + alwaysCheckBox = new QCheckBox(tr("Always use this application to " + "open this type of file")); + else + alwaysCheckBox = new QCheckBox(tr("Always use this application to " + "open files with the extension '%1'").arg(fileInfo.suffix())); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(topLabel); + layout->addWidget(applicationsListBox); + layout->addWidget(alwaysCheckBox); + setLayout(layout); +} +//! [8] diff --git a/examples/dialogs/tabdialog/tabdialog.h b/examples/dialogs/tabdialog/tabdialog.h new file mode 100644 index 0000000..b22997d --- /dev/null +++ b/examples/dialogs/tabdialog/tabdialog.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** 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 TABDIALOG_H +#define TABDIALOG_H + +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QDialogButtonBox; +class QFileInfo; +class QTabWidget; +QT_END_NAMESPACE + +//! [0] +class GeneralTab : public QWidget +{ + Q_OBJECT + +public: + GeneralTab(const QFileInfo &fileInfo, QWidget *parent = 0); +}; +//! [0] + + +//! [1] +class PermissionsTab : public QWidget +{ + Q_OBJECT + +public: + PermissionsTab(const QFileInfo &fileInfo, QWidget *parent = 0); +}; +//! [1] + + +//! [2] +class ApplicationsTab : public QWidget +{ + Q_OBJECT + +public: + ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent = 0); +}; +//! [2] + + +//! [3] +class TabDialog : public QDialog +{ + Q_OBJECT + +public: + TabDialog(const QString &fileName, QWidget *parent = 0); + +private: + QTabWidget *tabWidget; + QDialogButtonBox *buttonBox; +}; +//! [3] + +#endif diff --git a/examples/dialogs/tabdialog/tabdialog.pro b/examples/dialogs/tabdialog/tabdialog.pro new file mode 100644 index 0000000..3239a72 --- /dev/null +++ b/examples/dialogs/tabdialog/tabdialog.pro @@ -0,0 +1,10 @@ +HEADERS = tabdialog.h +SOURCES = main.cpp \ + tabdialog.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/tabdialog +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/tabdialog +INSTALLS += target sources +wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib diff --git a/examples/dialogs/trivialwizard/trivialwizard.cpp b/examples/dialogs/trivialwizard/trivialwizard.cpp new file mode 100644 index 0000000..128bce7 --- /dev/null +++ b/examples/dialogs/trivialwizard/trivialwizard.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** 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 <QTranslator> +#include <QLocale> +#include <QLibraryInfo> + +//! [0] //! [1] +QWizardPage *createIntroPage() +{ + QWizardPage *page = new QWizardPage; + page->setTitle("Introduction"); + + QLabel *label = new QLabel("This wizard will help you register your copy " + "of Super Product Two."); + label->setWordWrap(true); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(label); + page->setLayout(layout); + + return page; +} +//! [0] + +//! [2] +QWizardPage *createRegistrationPage() +//! [1] //! [3] +{ +//! [3] + QWizardPage *page = new QWizardPage; + page->setTitle("Registration"); + page->setSubTitle("Please fill both fields."); + + QLabel *nameLabel = new QLabel("Name:"); + QLineEdit *nameLineEdit = new QLineEdit; + + QLabel *emailLabel = new QLabel("Email address:"); + QLineEdit *emailLineEdit = new QLineEdit; + + QGridLayout *layout = new QGridLayout; + layout->addWidget(nameLabel, 0, 0); + layout->addWidget(nameLineEdit, 0, 1); + layout->addWidget(emailLabel, 1, 0); + layout->addWidget(emailLineEdit, 1, 1); + page->setLayout(layout); + + return page; +//! [4] +} +//! [2] //! [4] + +//! [5] //! [6] +QWizardPage *createConclusionPage() +//! [5] //! [7] +{ +//! [7] + QWizardPage *page = new QWizardPage; + page->setTitle("Conclusion"); + + QLabel *label = new QLabel("You are now successfully registered. Have a " + "nice day!"); + label->setWordWrap(true); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(label); + page->setLayout(layout); + + return page; +//! [8] +} +//! [6] //! [8] + +//! [9] //! [10] +int main(int argc, char *argv[]) +//! [9] //! [11] +{ + QApplication app(argc, argv); + + QString translatorFileName = QLatin1String("qt_"); + translatorFileName += QLocale::system().name(); + QTranslator *translator = new QTranslator(&app); + if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + app.installTranslator(translator); + + + QWizard wizard; + wizard.addPage(createIntroPage()); + wizard.addPage(createRegistrationPage()); + wizard.addPage(createConclusionPage()); + + wizard.setWindowTitle("Trivial Wizard"); + wizard.show(); + + return app.exec(); +} +//! [10] //! [11] diff --git a/examples/dialogs/trivialwizard/trivialwizard.pro b/examples/dialogs/trivialwizard/trivialwizard.pro new file mode 100644 index 0000000..970e12f --- /dev/null +++ b/examples/dialogs/trivialwizard/trivialwizard.pro @@ -0,0 +1,7 @@ +SOURCES = trivialwizard.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/trivialwizard +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/trivialwizard +INSTALLS += target sources |