diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:46:57 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-20 13:49:28 +0100 |
commit | 76c0be34cd4ff4564693162fa7528463e23ce9d8 (patch) | |
tree | f165b7bc319548fb0082365411a871028f92e89e /tests/manual | |
parent | 27b4fe96b59e9e63d1e570e802c072e9afdfb2d4 (diff) | |
parent | 36cb3f3f655a9090c82de609010cbfb88651a0f3 (diff) |
Merge branch 'dev' into stable
This starts Qt 5.1 release cycle
Conflicts:
src/gui/text/qfontdatabase.cpp
src/gui/text/qharfbuzz_copy_p.h
src/widgets/kernel/qapplication.cpp
src/widgets/kernel/qcoreapplication.cpp
Change-Id: I72fbf83ab3c2206aeea1b089428b0fc2a89bd62b
Diffstat (limited to 'tests/manual')
44 files changed, 2344 insertions, 105 deletions
diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 4417253930..185dbe123e 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -49,9 +49,9 @@ BearerEx::BearerEx(QWidget* parent) : QMainWindow(parent) { setupUi(this); - + createMenus(); - + connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), this, SLOT(configurationsUpdateCompleted())); connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(QNetworkConfiguration)), this, SLOT(configurationAdded(QNetworkConfiguration))); @@ -79,19 +79,19 @@ void BearerEx::showConfigurations() { listWidget->clear(); QListWidgetItem* listItem; - + QNetworkConfiguration defaultConfig = m_NetworkConfigurationManager.defaultConfiguration(); if (defaultConfig.type() == QNetworkConfiguration::UserChoice) { listItem = new QListWidgetItem(); QFont font = listItem->font(); font.setBold(true); font.setUnderline(true); - listItem->setFont(font); + listItem->setFont(font); listItem->setText(" UserChoice"); listItem->setData(Qt::UserRole, QVariant::fromValue(defaultConfig)); listWidget->addItem(listItem); } - + QList<QNetworkConfiguration> configurations = m_NetworkConfigurationManager.allConfigurations(); for (int i=0; i<configurations.count(); i++) { @@ -102,7 +102,7 @@ void BearerEx::showConfigurations() } else if (configurations[i].type() == QNetworkConfiguration::ServiceNetwork) { text.append("(SNAP,"); } - + if ((configurations[i].state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { text.append("Act) "); } else if ((configurations[i].state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) { @@ -111,12 +111,12 @@ void BearerEx::showConfigurations() text.append("Def) "); } text.append(configurations[i].name()); - + if (defaultConfig.isValid() && defaultConfig == configurations[i]) { QFont font = listItem->font(); font.setBold(true); font.setUnderline(true); - listItem->setFont(font); + listItem->setFont(font); } listItem->setText(text); listItem->setData(Qt::UserRole, QVariant::fromValue(configurations[i])); @@ -151,7 +151,7 @@ void BearerEx::on_createSessionButton_clicked() QListWidgetItem* item = listWidget->currentItem(); if (!item) { return; - } + } QNetworkConfiguration networkConfiguration = qvariant_cast<QNetworkConfiguration>(item->data(Qt::UserRole)); int newTabIndex = mainTabWidget->count(); SessionTab* newTab = new SessionTab(&networkConfiguration,&m_NetworkConfigurationManager,eventListWidget,newTabIndex-1); @@ -184,7 +184,7 @@ void BearerEx::onlineStateChanged(bool isOnline) QListWidgetItem* listItem = new QListWidgetItem(); QFont font = listItem->font(); font.setBold(true); - listItem->setFont(font); + listItem->setFont(font); if (isOnline) { listItem->setText(QString("> Online")); } else { @@ -231,7 +231,7 @@ DetailedInfoDialog::DetailedInfoDialog(QNetworkConfiguration* apNetworkConfigura tableWidget->setColumnCount(2); int rowCount = 2; - + if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) { rowCount = rowCount + apNetworkConfiguration->children().count(); } @@ -274,7 +274,7 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration, connect(m_NetworkSession, SIGNAL(opened()), this, SLOT(opened())); connect(m_NetworkSession, SIGNAL(closed()), this, SLOT(closed())); connect(m_NetworkSession, SIGNAL(error(QNetworkSession::SessionError)), this, SLOT(error(QNetworkSession::SessionError))); - + if (apNetworkConfiguration->type() == QNetworkConfiguration::InternetAccessPoint) { snapLabel->hide(); snapLineEdit->hide(); @@ -342,7 +342,7 @@ void SessionTab::on_openSessionButton_clicked() { m_NetworkSession->open(); if (m_NetworkSession->isOpen()) { - newState(m_NetworkSession->state()); + newState(m_NetworkSession->state()); } } @@ -350,7 +350,7 @@ void SessionTab::on_closeSessionButton_clicked() { m_NetworkSession->close(); if (!m_NetworkSession->isOpen()) { - newState(m_NetworkSession->state()); + newState(m_NetworkSession->state()); } } @@ -414,10 +414,10 @@ void SessionTab::opened() QListWidgetItem* listItem = new QListWidgetItem(); QFont font = listItem->font(); font.setBold(true); - listItem->setFont(font); + listItem->setFont(font); listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Opened")); m_eventListWidget->addItem(listItem); - + QVariant identifier = m_NetworkSession->sessionProperty("ActiveConfiguration"); if (!identifier.isNull()) { QString configId = identifier.toString(); @@ -445,7 +445,7 @@ void SessionTab::closed() QListWidgetItem* listItem = new QListWidgetItem(); QFont font = listItem->font(); font.setBold(true); - listItem->setFont(font); + listItem->setFont(font); listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Closed")); m_eventListWidget->addItem(listItem); } @@ -492,10 +492,10 @@ void SessionTab::on_dataObjectChanged(const QString &newObjectType) } -void SessionTab::stateChanged(QNetworkSession::State state) +void SessionTab::stateChanged(QNetworkSession::State state) { newState(state); - + QListWidgetItem* listItem = new QListWidgetItem(); listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+stateString(state)); m_eventListWidget->addItem(listItem); @@ -527,7 +527,7 @@ void SessionTab::error(QNetworkSession::SessionError error) QListWidgetItem* listItem = new QListWidgetItem(); QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Close); - + QString errorString; switch (error) { @@ -549,7 +549,7 @@ void SessionTab::error(QNetworkSession::SessionError error) } listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+errorString); m_eventListWidget->addItem(listItem); - + msgBox.setText(errorString); msgBox.exec(); } diff --git a/tests/manual/bearerex/bearerex.h b/tests/manual/bearerex/bearerex.h index 5ec2e17060..8de2b1d41d 100644 --- a/tests/manual/bearerex/bearerex.h +++ b/tests/manual/bearerex/bearerex.h @@ -88,7 +88,7 @@ private Q_SLOTS: void configurationAdded(const QNetworkConfiguration& config); void configurationRemoved(const QNetworkConfiguration& config); void onlineStateChanged(bool isOnline); - void configurationChanged(const QNetworkConfiguration & config); + void configurationChanged(const QNetworkConfiguration & config); private: QNetworkConfigurationManager m_NetworkConfigurationManager; @@ -112,8 +112,8 @@ public: SessionTab(QNetworkConfiguration* apNetworkConfiguration = 0, QNetworkConfigurationManager* configManager = 0, QListWidget* eventListWidget = 0, int index = 0, BearerEx* parent = 0); ~SessionTab(); - - QString stateString(QNetworkSession::State state); + + QString stateString(QNetworkSession::State state); private Q_SLOTS: void on_createQNetworkAccessManagerButton_clicked(); @@ -125,7 +125,7 @@ private Q_SLOTS: void on_dataObjectChanged(const QString& newObjectType); void on_alrButton_clicked(); void finished(quint32 errorCode, qint64 dataReceived, QString errorType); - + void newConfigurationActivated(); void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless); void stateChanged(QNetworkSession::State state); diff --git a/tests/manual/bearerex/xqlistwidget.cpp b/tests/manual/bearerex/xqlistwidget.cpp index 556d9e400f..cb03f6e9bf 100644 --- a/tests/manual/bearerex/xqlistwidget.cpp +++ b/tests/manual/bearerex/xqlistwidget.cpp @@ -42,7 +42,7 @@ #include "xqlistwidget.h" XQListWidget::XQListWidget(QWidget* parent) : QListWidget(parent) -{ +{ } void XQListWidget::keyPressEvent(QKeyEvent* event) @@ -59,7 +59,7 @@ void XQListWidget::keyPressEvent(QKeyEvent* event) focusNextChild(); break; } - default: + default: { QListWidget::keyPressEvent(event); } diff --git a/tests/manual/bearerex/xqlistwidget.h b/tests/manual/bearerex/xqlistwidget.h index b23dfb5735..80aecceb0b 100644 --- a/tests/manual/bearerex/xqlistwidget.h +++ b/tests/manual/bearerex/xqlistwidget.h @@ -48,8 +48,8 @@ class XQListWidget: public QListWidget { public: - XQListWidget(QWidget* parent = 0); - + XQListWidget(QWidget* parent = 0); + protected: void keyPressEvent(QKeyEvent* event); }; diff --git a/tests/manual/dialogs/colordialogpanel.cpp b/tests/manual/dialogs/colordialogpanel.cpp new file mode 100644 index 0000000000..695e37a4c7 --- /dev/null +++ b/tests/manual/dialogs/colordialogpanel.cpp @@ -0,0 +1,261 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "colordialogpanel.h" + +#include <QGroupBox> +#include <QCheckBox> +#include <QPushButton> +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QMessageBox> +#include <QSortFilterProxyModel> +#include <QComboBox> +#include <QTimer> +#include <QDebug> + +// SVG color keyword names provided by the World Wide Web Consortium +static inline QStringList svgColorNames() +{ + return QStringList() + << "aliceblue" << "antiquewhite" << "aqua" << "aquamarine" << "azure" << "beige" << "bisque" + << "black" << "blanchedalmond" << "blue" << "blueviolet" << "brown" << "burlywood" << "cadetblue" + << "chartreuse" << "chocolate" << "coral" << "cornflowerblue" << "cornsilk" << "crimson" << "cyan" + << "darkblue" << "darkcyan" << "darkgoldenrod" << "darkgray" << "darkgreen" << "darkgrey" + << "darkkhaki" << "darkmagenta" << "darkolivegreen" << "darkorange" << "darkorchid" << "darkred" + << "darksalmon" << "darkseagreen" << "darkslateblue" << "darkslategray" << "darkslategrey" + << "darkturquoise" << "darkviolet" << "deeppink" << "deepskyblue" << "dimgray" << "dimgrey" + << "dodgerblue" << "firebrick" << "floralwhite" << "forestgreen" << "fuchsia" << "gainsboro" + << "ghostwhite" << "gold" << "goldenrod" << "gray" << "grey" << "green" << "greenyellow" + << "honeydew" << "hotpink" << "indianred" << "indigo" << "ivory" << "khaki" << "lavender" + << "lavenderblush" << "lawngreen" << "lemonchiffon" << "lightblue" << "lightcoral" << "lightcyan" + << "lightgoldenrodyellow" << "lightgray" << "lightgreen" << "lightgrey" << "lightpink" + << "lightsalmon" << "lightseagreen" << "lightskyblue" << "lightslategray" << "lightslategrey" + << "lightsteelblue" << "lightyellow" << "lime" << "limegreen" << "linen" << "magenta" + << "maroon" << "mediumaquamarine" << "mediumblue" << "mediumorchid" << "mediumpurple" + << "mediumseagreen" << "mediumslateblue" << "mediumspringgreen" << "mediumturquoise" + << "mediumvioletred" << "midnightblue" << "mintcream" << "mistyrose" << "moccasin" + << "navajowhite" << "navy" << "oldlace" << "olive" << "olivedrab" << "orange" << "orangered" + << "orchid" << "palegoldenrod" << "palegreen" << "paleturquoise" << "palevioletred" + << "papayawhip" << "peachpuff" << "peru" << "pink" << "plum" << "powderblue" << "purple" << "red" + << "rosybrown" << "royalblue" << "saddlebrown" << "salmon" << "sandybrown" << "seagreen" + << "seashell" << "sienna" << "silver" << "skyblue" << "slateblue" << "slategray" << "slategrey" + << "snow" << "springgreen" << "steelblue" << "tan" << "teal" << "thistle" << "tomato" + << "turquoise" << "violet" << "wheat" << "white" << "whitesmoke" << "yellow" << "yellowgreen"; +} + +static inline QPushButton *addButton(const QString &description, QVBoxLayout *layout, + QObject *receiver, const char *slotFunc) +{ + QPushButton *button = new QPushButton(description); + QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc); + layout->addWidget(button); + return button; +} + +class ColorProxyModel : public QSortFilterProxyModel +{ +public: + ColorProxyModel(QObject *parent = 0) : QSortFilterProxyModel(parent) + { + } + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const + { + if (role == Qt::DisplayRole) { + QString name = data(index, Qt::EditRole).toString(); + return tr("%1 (%2)").arg(name, QColor(name).name()); + } + if (role == Qt::DecorationRole) + return QColor(data(index, Qt::EditRole).toString()); + return QSortFilterProxyModel::data(index, role); + } +}; + +ColorDialogPanel::ColorDialogPanel(QWidget *parent) + : QWidget(parent) + , m_colorComboBox(new QComboBox) + , m_showAlphaChannel(new QCheckBox(tr("Show alpha channel"))) + , m_noButtons(new QCheckBox(tr("Don't display OK/Cancel buttons"))) + , m_dontUseNativeDialog(new QCheckBox(tr("Don't use native dialog"))) +{ + // Options + QGroupBox *optionsGroupBox = new QGroupBox(tr("Options"), this); + QVBoxLayout *optionsLayout = new QVBoxLayout(optionsGroupBox); + optionsLayout->addWidget(m_showAlphaChannel); + optionsLayout->addWidget(m_noButtons); + optionsLayout->addWidget(m_dontUseNativeDialog); + + // Color + QGroupBox *colorGroupBox = new QGroupBox(tr("Color"), this); + QVBoxLayout *colorLayout = new QVBoxLayout(colorGroupBox); + colorLayout->addWidget(m_colorComboBox); + m_colorComboBox->addItems(svgColorNames()); + m_colorComboBox->setEditable(true); + + QAbstractItemModel *sourceModel = m_colorComboBox->model(); + ColorProxyModel* proxyModel = new ColorProxyModel(m_colorComboBox); + proxyModel->setSourceModel(sourceModel); + sourceModel->setParent(proxyModel); + m_colorComboBox->setModel(proxyModel); + + // Buttons + QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show")); + QVBoxLayout *buttonsLayout = new QVBoxLayout(buttonsGroupBox); + addButton(tr("Exec modal"), buttonsLayout, this, SLOT(execModal())); + addButton(tr("Show modal"), buttonsLayout, this, SLOT(showModal())); + m_deleteModalDialogButton = + addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog())); + addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal())); + m_deleteNonModalDialogButton = + addButton(tr("Delete non-modal"), buttonsLayout, this, SLOT(deleteNonModalDialog())); + addButton(tr("Restore defaults"), buttonsLayout, this, SLOT(restoreDefaults())); + buttonsLayout->addStretch(); + + // Main layout + QHBoxLayout *mainLayout = new QHBoxLayout(this); + QVBoxLayout *leftLayout = new QVBoxLayout; + leftLayout->addWidget(optionsGroupBox); + leftLayout->addWidget(colorGroupBox); + leftLayout->addStretch(); + mainLayout->addLayout(leftLayout); + mainLayout->addWidget(buttonsGroupBox); + + enableDeleteModalDialogButton(); + enableDeleteNonModalDialogButton(); + restoreDefaults(); +} + +void ColorDialogPanel::execModal() +{ + QColorDialog dialog(this); + applySettings(&dialog); + connect(&dialog, SIGNAL(accepted()), this, SLOT(accepted())); + dialog.setWindowTitle(tr("Modal Color Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR))); + dialog.exec(); +} + +void ColorDialogPanel::showModal() +{ + if (m_modalDialog.isNull()) { + static int n = 0; + m_modalDialog = new QColorDialog(this); + m_modalDialog->setModal(true); + connect(m_modalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted())); + m_modalDialog->setWindowTitle(tr("Modal Color Dialog #%1 Qt %2") + .arg(++n) + .arg(QLatin1String(QT_VERSION_STR))); + enableDeleteModalDialogButton(); + } + applySettings(m_modalDialog); + m_modalDialog->show(); +} + +void ColorDialogPanel::showNonModal() +{ + if (m_nonModalDialog.isNull()) { + static int n = 0; + m_nonModalDialog = new QColorDialog(this); + connect(m_nonModalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted())); + m_nonModalDialog->setWindowTitle(tr("Non-Modal Color Dialog #%1 Qt %2") + .arg(++n) + .arg(QLatin1String(QT_VERSION_STR))); + enableDeleteNonModalDialogButton(); + } + applySettings(m_nonModalDialog); + m_nonModalDialog->show(); +} + +void ColorDialogPanel::deleteNonModalDialog() +{ + if (!m_nonModalDialog.isNull()) + delete m_nonModalDialog; + enableDeleteNonModalDialogButton(); +} + +void ColorDialogPanel::deleteModalDialog() +{ + if (!m_modalDialog.isNull()) + delete m_modalDialog; + enableDeleteModalDialogButton(); +} + +void ColorDialogPanel::accepted() +{ + const QColorDialog *d = qobject_cast<const QColorDialog *>(sender()); + Q_ASSERT(d); + m_result.clear(); + QDebug(&m_result).nospace() + << "Current color: " << d->currentColor() + << "\nSelected color: " << d->selectedColor(); + QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent. +} + +void ColorDialogPanel::showAcceptedResult() +{ + QMessageBox::information(this, tr("Color Dialog Accepted"), m_result, QMessageBox::Ok); +} + +void ColorDialogPanel::restoreDefaults() +{ + QColorDialog d; + m_showAlphaChannel->setChecked(d.testOption(QColorDialog::ShowAlphaChannel)); + m_noButtons->setChecked(d.testOption(QColorDialog::NoButtons)); + m_dontUseNativeDialog->setChecked(d.testOption(QColorDialog::DontUseNativeDialog)); +} + +void ColorDialogPanel::enableDeleteNonModalDialogButton() +{ + m_deleteNonModalDialogButton->setEnabled(!m_nonModalDialog.isNull()); +} + +void ColorDialogPanel::enableDeleteModalDialogButton() +{ + m_deleteModalDialogButton->setEnabled(!m_modalDialog.isNull()); +} + +void ColorDialogPanel::applySettings(QColorDialog *d) const +{ + d->setOption(QColorDialog::ShowAlphaChannel, m_showAlphaChannel->isChecked()); + d->setOption(QColorDialog::NoButtons, m_noButtons->isChecked()); + d->setOption(QColorDialog::DontUseNativeDialog, m_dontUseNativeDialog->isChecked()); + d->setCurrentColor(QColor(m_colorComboBox->itemData(m_colorComboBox->currentIndex(), Qt::EditRole).toString())); +} diff --git a/tests/manual/dialogs/colordialogpanel.h b/tests/manual/dialogs/colordialogpanel.h new file mode 100644 index 0000000000..bcd2cf6e52 --- /dev/null +++ b/tests/manual/dialogs/colordialogpanel.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef COLORDIALOGPANEL_H +#define COLORDIALOGPANEL_H + +#include <QPointer> +#include <QColorDialog> + +class QComboBox; +class QCheckBox; +class QPushButton; + +class ColorDialogPanel : public QWidget +{ + Q_OBJECT +public: + explicit ColorDialogPanel(QWidget *parent = 0); + +public slots: + void execModal(); + void showModal(); + void showNonModal(); + void deleteNonModalDialog(); + void deleteModalDialog(); + void accepted(); + void showAcceptedResult(); + void restoreDefaults(); + +private slots: + void enableDeleteNonModalDialogButton(); + void enableDeleteModalDialogButton(); + +private: + void applySettings(QColorDialog *d) const; + + QComboBox *m_colorComboBox; + QCheckBox *m_showAlphaChannel; + QCheckBox *m_noButtons; + QCheckBox *m_dontUseNativeDialog; + QPushButton *m_deleteNonModalDialogButton; + QPushButton *m_deleteModalDialogButton; + QString m_result; + QPointer<QColorDialog> m_modalDialog; + QPointer<QColorDialog> m_nonModalDialog; +}; + +#endif // COLORDIALOGPANEL_H diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro index ff916d3854..4ed200ab7f 100644 --- a/tests/manual/dialogs/dialogs.pro +++ b/tests/manual/dialogs/dialogs.pro @@ -4,5 +4,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = dialogs TEMPLATE = app -SOURCES += main.cpp filedialogpanel.cpp -HEADERS += filedialogpanel.h +SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp \ + wizardpanel.cpp +HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h \ + wizardpanel.h diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp index 66a5201db0..636e65b684 100644 --- a/tests/manual/dialogs/filedialogpanel.cpp +++ b/tests/manual/dialogs/filedialogpanel.cpp @@ -44,6 +44,7 @@ #include <QGridLayout> #include <QVBoxLayout> #include <QHBoxLayout> +#include <QGridLayout> #include <QFormLayout> #include <QSpacerItem> #include <QGroupBox> @@ -105,11 +106,13 @@ inline void setComboBoxValue(QComboBox *c, int v) c->setCurrentIndex(c->findData(QVariant(v))); } -static inline void addButton(const QString &description, QBoxLayout *layout, QObject *receiver, const char *slotFunc) +static inline QPushButton *addButton(const QString &description, QGridLayout *layout, + int &row, int column, QObject *receiver, const char *slotFunc) { QPushButton *button = new QPushButton(description); QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc); - layout->addWidget(button); + layout->addWidget(button, row++, column); + return button; } // A line edit for editing the label fields of the dialog, keeping track of whether it has @@ -159,6 +162,8 @@ FileDialogPanel::FileDialogPanel(QWidget *parent) , m_selectedFileName(new QLineEdit(this)) , m_nameFilters(new QPlainTextEdit) , m_selectedNameFilter(new QLineEdit(this)) + , m_deleteNonModalDialogButton(0) + , m_deleteModalDialogButton(0) { // Options QGroupBox *optionsGroupBox = new QGroupBox(tr("Options")); @@ -197,19 +202,24 @@ FileDialogPanel::FileDialogPanel(QWidget *parent) labelsLayout->addRow(tr("Reject label:"), m_labelLineEdits.back()); // Buttons - QVBoxLayout *buttonLayout = new QVBoxLayout; - buttonLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); - addButton(tr("Show modal"), buttonLayout, this, SLOT(showModal())); - addButton(tr("Show non-modal"), buttonLayout, this, SLOT(showNonModal())); - addButton(tr("getOpenFileName"), buttonLayout, this, SLOT(getOpenFileName())); - addButton(tr("getOpenFileNames"), buttonLayout, this, SLOT(getOpenFileNames())); - addButton(tr("getSaveFileName"), buttonLayout, this, SLOT(getSaveFileName())); - addButton(tr("getExistingDirectory"), buttonLayout, this, SLOT(getExistingDirectory())); - addButton(tr("Restore defaults"), buttonLayout, this, SLOT(restoreDefaults())); QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show")); - QHBoxLayout *buttonsGroupLayout = new QHBoxLayout(buttonsGroupBox); - buttonsGroupLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored)); - buttonsGroupLayout->addLayout(buttonLayout); + QGridLayout *buttonLayout = new QGridLayout(buttonsGroupBox); + int row = 0; + int column = 0; + addButton(tr("Exec modal"), buttonLayout, row, column, this, SLOT(execModal())); + addButton(tr("Show modal"), buttonLayout, row, column, this, SLOT(showModal())); + m_deleteModalDialogButton = + addButton(tr("Delete modal"), buttonLayout, row, column, this, SLOT(deleteModalDialog())); + addButton(tr("Show non-modal"), buttonLayout, row, column, this, SLOT(showNonModal())); + m_deleteNonModalDialogButton = + addButton(tr("Delete non-modal"), buttonLayout, row, column, this, SLOT(deleteNonModalDialog())); + row = 0; + column++; + addButton(tr("getOpenFileName"), buttonLayout, row, column, this, SLOT(getOpenFileName())); + addButton(tr("getOpenFileNames"), buttonLayout, row, column, this, SLOT(getOpenFileNames())); + addButton(tr("getSaveFileName"), buttonLayout, row, column, this, SLOT(getSaveFileName())); + addButton(tr("getExistingDirectory"), buttonLayout, row, column, this, SLOT(getExistingDirectory())); + addButton(tr("Restore defaults"), buttonLayout, row, column, this, SLOT(restoreDefaults())); // Main layout QGridLayout *gridLayout = new QGridLayout(this); @@ -218,26 +228,76 @@ FileDialogPanel::FileDialogPanel(QWidget *parent) gridLayout->addWidget(labelsGroupBox, 1, 0); gridLayout->addWidget(buttonsGroupBox, 1, 1); + enableDeleteModalDialogButton(); + enableDeleteNonModalDialogButton(); restoreDefaults(); } -void FileDialogPanel::showModal() +void FileDialogPanel::execModal() { QFileDialog dialog(this); applySettings(&dialog); + connect(&dialog, SIGNAL(accepted()), this, SLOT(accepted())); dialog.setWindowTitle(tr("Modal File Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR))); dialog.exec(); } +void FileDialogPanel::showModal() +{ + if (m_modalDialog.isNull()) { + static int n = 0; + m_modalDialog = new QFileDialog(this); + m_modalDialog->setModal(true); + connect(m_modalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted())); + m_modalDialog->setWindowTitle(tr("Modal File Dialog #%1 Qt %2") + .arg(++n) + .arg(QLatin1String(QT_VERSION_STR))); + enableDeleteModalDialogButton(); + } + applySettings(m_modalDialog); + m_modalDialog->show(); +} + void FileDialogPanel::showNonModal() { - QFileDialog *dialog = new QFileDialog(this); - dialog->setAttribute(Qt::WA_DeleteOnClose); - applySettings(dialog); - dialog->setWindowTitle(tr("Non-Modal File Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR))); - dialog->show(); + if (m_nonModalDialog.isNull()) { + static int n = 0; + m_nonModalDialog = new QFileDialog(this); + connect(m_nonModalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted())); + m_nonModalDialog->setWindowTitle(tr("Non-Modal File Dialog #%1 Qt %2") + .arg(++n) + .arg(QLatin1String(QT_VERSION_STR))); + enableDeleteNonModalDialogButton(); + } + applySettings(m_nonModalDialog); + m_nonModalDialog->show(); +} + +void FileDialogPanel::deleteNonModalDialog() +{ + if (!m_nonModalDialog.isNull()) + delete m_nonModalDialog; + enableDeleteNonModalDialogButton(); } +void FileDialogPanel::deleteModalDialog() +{ + if (!m_modalDialog.isNull()) + delete m_modalDialog; + enableDeleteModalDialogButton(); +} + +void FileDialogPanel::enableDeleteNonModalDialogButton() +{ + m_deleteNonModalDialogButton->setEnabled(!m_nonModalDialog.isNull()); +} + +void FileDialogPanel::enableDeleteModalDialogButton() +{ + m_deleteModalDialogButton->setEnabled(!m_modalDialog.isNull()); +} + + QString FileDialogPanel::filterString() const { return m_nameFilters->toPlainText().trimmed().replace(QLatin1String("\n"), QLatin1String(";;")); @@ -340,7 +400,9 @@ void FileDialogPanel::applySettings(QFileDialog *d) const d->setFileMode(comboBoxValue<QFileDialog::FileMode>(m_fileMode)); d->setOptions(options()); d->setDefaultSuffix(m_defaultSuffix->text().trimmed()); - d->setDirectory(m_directory->text().trimmed()); + const QString directory = m_directory->text().trimmed(); + if (!directory.isEmpty()) + d->setDirectory(directory); const QString file = m_selectedFileName->text().trimmed(); if (!file.isEmpty()) d->selectFile(file); @@ -350,7 +412,6 @@ void FileDialogPanel::applySettings(QFileDialog *d) const d->selectNameFilter(filter); foreach (LabelLineEdit *l, m_labelLineEdits) l->apply(d); - connect(d, SIGNAL(accepted()), this, SLOT(accepted())); } void FileDialogPanel::accepted() diff --git a/tests/manual/dialogs/filedialogpanel.h b/tests/manual/dialogs/filedialogpanel.h index 699d917e4d..7ee7cb3f60 100644 --- a/tests/manual/dialogs/filedialogpanel.h +++ b/tests/manual/dialogs/filedialogpanel.h @@ -44,7 +44,9 @@ #include <QGroupBox> #include <QFileDialog> +#include <QPointer> +class QPushButton; class QCheckBox; class QComboBox; class QLineEdit; @@ -58,8 +60,11 @@ public: explicit FileDialogPanel(QWidget *parent = 0); public slots: + void execModal(); void showModal(); void showNonModal(); + void deleteNonModalDialog(); + void deleteModalDialog(); void getOpenFileNames(); void getOpenFileName(); void getSaveFileName(); @@ -68,6 +73,10 @@ public slots: void showAcceptedResult(); void restoreDefaults(); +private slots: + void enableDeleteNonModalDialogButton(); + void enableDeleteModalDialogButton(); + private: QString filterString() const; QFileDialog::Options options() const; @@ -87,7 +96,11 @@ private: QList<LabelLineEdit *> m_labelLineEdits; QPlainTextEdit *m_nameFilters; QLineEdit *m_selectedNameFilter; + QPushButton *m_deleteNonModalDialogButton; + QPushButton *m_deleteModalDialogButton; QString m_result; + QPointer<QFileDialog> m_modalDialog; + QPointer<QFileDialog> m_nonModalDialog; }; #endif // FILEDIALOGPANEL_H diff --git a/tests/manual/dialogs/fontdialogpanel.cpp b/tests/manual/dialogs/fontdialogpanel.cpp new file mode 100644 index 0000000000..2bdbb0625a --- /dev/null +++ b/tests/manual/dialogs/fontdialogpanel.cpp @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "fontdialogpanel.h" + +#include <QGroupBox> +#include <QCheckBox> +#include <QPushButton> +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QMessageBox> +#include <QFontComboBox> +#include <QDoubleSpinBox> +#include <QTimer> +#include <QDebug> + +static inline QPushButton *addButton(const QString &description, QVBoxLayout *layout, + QObject *receiver, const char *slotFunc) +{ + QPushButton *button = new QPushButton(description); + QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc); + layout->addWidget(button); + return button; +} + +FontDialogPanel::FontDialogPanel(QWidget *parent) + : QWidget(parent) + , m_fontFamilyBox(new QFontComboBox) + , m_fontSizeBox(new QDoubleSpinBox) + , m_noButtons(new QCheckBox(tr("Don't display OK/Cancel buttons"))) + , m_dontUseNativeDialog(new QCheckBox(tr("Don't use native dialog"))) +{ + // Options + QGroupBox *optionsGroupBox = new QGroupBox(tr("Options"), this); + QVBoxLayout *optionsLayout = new QVBoxLayout(optionsGroupBox); + optionsLayout->addWidget(m_noButtons); + optionsLayout->addWidget(m_dontUseNativeDialog); + + // Font + QGroupBox *fontGroupBox = new QGroupBox(tr("Font"), this); + QHBoxLayout *fontLayout = new QHBoxLayout(fontGroupBox); + fontLayout->addWidget(m_fontFamilyBox); + fontLayout->addWidget(m_fontSizeBox); + m_fontSizeBox->setValue(QFont().pointSizeF()); + + // Buttons + QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show")); + QVBoxLayout *buttonsLayout = new QVBoxLayout(buttonsGroupBox); + addButton(tr("Exec modal"), buttonsLayout, this, SLOT(execModal())); + addButton(tr("Show modal"), buttonsLayout, this, SLOT(showModal())); + m_deleteModalDialogButton = + addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog())); + addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal())); + m_deleteNonModalDialogButton = + addButton(tr("Delete non-modal"), buttonsLayout, this, SLOT(deleteNonModalDialog())); + addButton(tr("Restore defaults"), buttonsLayout, this, SLOT(restoreDefaults())); + buttonsLayout->addStretch(); + + // Main layout + QHBoxLayout *mainLayout = new QHBoxLayout(this); + QVBoxLayout *leftLayout = new QVBoxLayout; + leftLayout->addWidget(optionsGroupBox); + leftLayout->addWidget(fontGroupBox); + leftLayout->addStretch(); + mainLayout->addLayout(leftLayout); + mainLayout->addWidget(buttonsGroupBox); + + enableDeleteModalDialogButton(); + enableDeleteNonModalDialogButton(); + restoreDefaults(); +} + +void FontDialogPanel::execModal() +{ + QFontDialog dialog(this); + applySettings(&dialog); + connect(&dialog, SIGNAL(accepted()), this, SLOT(accepted())); + dialog.setWindowTitle(tr("Modal Font Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR))); + dialog.exec(); +} + +void FontDialogPanel::showModal() +{ + if (m_modalDialog.isNull()) { + static int n = 0; + m_modalDialog = new QFontDialog(this); + m_modalDialog->setModal(true); + connect(m_modalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted())); + m_modalDialog->setWindowTitle(tr("Modal Font Dialog #%1 Qt %2") + .arg(++n) + .arg(QLatin1String(QT_VERSION_STR))); + enableDeleteModalDialogButton(); + } + applySettings(m_modalDialog); + m_modalDialog->show(); +} + +void FontDialogPanel::showNonModal() +{ + if (m_nonModalDialog.isNull()) { + static int n = 0; + m_nonModalDialog = new QFontDialog(this); + connect(m_nonModalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted())); + m_nonModalDialog->setWindowTitle(tr("Non-Modal Font Dialog #%1 Qt %2") + .arg(++n) + .arg(QLatin1String(QT_VERSION_STR))); + enableDeleteNonModalDialogButton(); + } + applySettings(m_nonModalDialog); + m_nonModalDialog->show(); +} + +void FontDialogPanel::deleteNonModalDialog() +{ + if (!m_nonModalDialog.isNull()) + delete m_nonModalDialog; + enableDeleteNonModalDialogButton(); +} + +void FontDialogPanel::deleteModalDialog() +{ + if (!m_modalDialog.isNull()) + delete m_modalDialog; + enableDeleteModalDialogButton(); +} + +void FontDialogPanel::accepted() +{ + const QFontDialog *d = qobject_cast<const QFontDialog *>(sender()); + Q_ASSERT(d); + m_result.clear(); + QDebug(&m_result).nospace() + << "Current font: " << d->currentFont() + << "\nSelected font: " << d->selectedFont(); + QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent. +} + +void FontDialogPanel::showAcceptedResult() +{ + QMessageBox::information(this, tr("Color Dialog Accepted"), m_result, QMessageBox::Ok); +} + +void FontDialogPanel::restoreDefaults() +{ + QFontDialog d; + m_noButtons->setChecked(d.testOption(QFontDialog::NoButtons)); + m_dontUseNativeDialog->setChecked(d.testOption(QFontDialog::DontUseNativeDialog)); + m_fontFamilyBox->setCurrentFont(QFont()); + m_fontSizeBox->setValue(QFont().pointSizeF()); +} + +void FontDialogPanel::enableDeleteNonModalDialogButton() +{ + m_deleteNonModalDialogButton->setEnabled(!m_nonModalDialog.isNull()); +} + +void FontDialogPanel::enableDeleteModalDialogButton() +{ + m_deleteModalDialogButton->setEnabled(!m_modalDialog.isNull()); +} + +void FontDialogPanel::applySettings(QFontDialog *d) const +{ + d->setOption(QFontDialog::NoButtons, m_noButtons->isChecked()); + d->setOption(QFontDialog::DontUseNativeDialog, m_dontUseNativeDialog->isChecked()); + + QFont font = m_fontFamilyBox->currentFont(); + font.setPointSizeF(m_fontSizeBox->value()); + d->setCurrentFont(font); +} diff --git a/tests/manual/dialogs/fontdialogpanel.h b/tests/manual/dialogs/fontdialogpanel.h new file mode 100644 index 0000000000..92f2b7313f --- /dev/null +++ b/tests/manual/dialogs/fontdialogpanel.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FONTDIALOGPANEL_H +#define FONTDIALOGPANEL_H + +#include <QPointer> +#include <QFontDialog> + +class QCheckBox; +class QPushButton; +class QFontComboBox; +class QDoubleSpinBox; + +class FontDialogPanel : public QWidget +{ + Q_OBJECT +public: + explicit FontDialogPanel(QWidget *parent = 0); + +public slots: + void execModal(); + void showModal(); + void showNonModal(); + void deleteNonModalDialog(); + void deleteModalDialog(); + void accepted(); + void showAcceptedResult(); + void restoreDefaults(); + +private slots: + void enableDeleteNonModalDialogButton(); + void enableDeleteModalDialogButton(); + +private: + void applySettings(QFontDialog *d) const; + + QFontComboBox *m_fontFamilyBox; + QDoubleSpinBox *m_fontSizeBox; + QCheckBox *m_noButtons; + QCheckBox *m_dontUseNativeDialog; + QPushButton *m_deleteNonModalDialogButton; + QPushButton *m_deleteModalDialogButton; + QString m_result; + QPointer<QFontDialog> m_modalDialog; + QPointer<QFontDialog> m_nonModalDialog; +}; + +#endif // FONTDIALOGPANEL_H diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp index c1ea7b0d8f..86e6c90b3f 100644 --- a/tests/manual/dialogs/main.cpp +++ b/tests/manual/dialogs/main.cpp @@ -40,6 +40,9 @@ ****************************************************************************/ #include "filedialogpanel.h" +#include "colordialogpanel.h" +#include "fontdialogpanel.h" +#include "wizardpanel.h" #include <QMainWindow> #include <QApplication> @@ -50,7 +53,6 @@ #include <QKeySequence> // Test for dialogs, allowing to play with all dialog options for implementing native dialogs. -// Currently, only QFileDialog is implemented. // Compiles with Qt 4.8 and Qt 5. class MainWindow : public QMainWindow { @@ -68,6 +70,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QTabWidget *tabWidget = new QTabWidget; tabWidget->addTab(new FileDialogPanel, tr("QFileDialog")); + tabWidget->addTab(new ColorDialogPanel, tr("QColorDialog")); + tabWidget->addTab(new FontDialogPanel, tr("QFontDialog")); + tabWidget->addTab(new WizardPanel, tr("QWizard")); setCentralWidget(tabWidget); } diff --git a/tests/manual/dialogs/wizardpanel.cpp b/tests/manual/dialogs/wizardpanel.cpp new file mode 100644 index 0000000000..1306062426 --- /dev/null +++ b/tests/manual/dialogs/wizardpanel.cpp @@ -0,0 +1,361 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "wizardpanel.h" + +#include <QWizard> +#include <QWizardPage> +#include <QVBoxLayout> +#include <QGridLayout> +#include <QRadioButton> +#include <QPushButton> +#include <QCheckBox> +#include <QButtonGroup> +#include <QSpacerItem> +#include <QGroupBox> +#include <QLabel> +#include <QStyle> +#include <QIcon> +#include <QImage> +#include <QPainter> +#include <QFont> +#include <QFontMetrics> +#include <QHash> + +static QIcon coloredIcon(const Qt::GlobalColor color) +{ + QImage image(QSize(24, 24), QImage::Format_RGB32); + image.fill(color); + return QIcon(QPixmap::fromImage(image)); +} + +static QPixmap pixmapWithText(const QString &text, const QColor color) +{ + QFont font; + QFontMetrics metric(font); + QRect rectangle = metric.boundingRect(text); + rectangle.setBottomRight(rectangle.bottomRight() + QPoint(20, 20)); + QImage image(rectangle.size(), QImage::Format_RGB32); + image.fill(color); + QPainter painter(&image); + painter.setFont(font); + painter.drawText(rectangle, Qt::AlignHCenter | Qt::AlignVCenter, text); + return QPixmap::fromImage(image); +} + +// A radio-group control for QWizard::WizardStyle. +class WizardStyleControl : public QGroupBox +{ + Q_OBJECT +public: + WizardStyleControl(QWidget *parent = 0); + + void setWizardStyle(int style); + QWizard::WizardStyle wizardStyle() const; + +signals: + void wizardStyleChanged(int); + +private: + QButtonGroup *m_group; +}; + +WizardStyleControl::WizardStyleControl(QWidget *parent) + : QGroupBox(tr("Style"), parent) + , m_group(new QButtonGroup(this)) +{ + m_group->setExclusive(true); + connect(m_group, SIGNAL(buttonClicked(int)), this, SIGNAL(wizardStyleChanged(int))); + QVBoxLayout *vLayout = new QVBoxLayout(this); + QRadioButton *radioButton = new QRadioButton(tr("None/OS Default"), this); + m_group->addButton(radioButton, QWizard::NStyles); + vLayout->addWidget(radioButton); + radioButton = new QRadioButton(tr("ClassicStyle"), this); + m_group->addButton(radioButton, QWizard::ClassicStyle); + vLayout->addWidget(radioButton); + radioButton = new QRadioButton(tr("ModernStyle"), this); + m_group->addButton(radioButton, QWizard::ModernStyle); + vLayout->addWidget(radioButton); + radioButton = new QRadioButton(tr("MacStyle"), this); + m_group->addButton(radioButton, QWizard::MacStyle); + vLayout->addWidget(radioButton); + radioButton = new QRadioButton(tr("AeroStyle"), this); + m_group->addButton(radioButton, QWizard::AeroStyle); + vLayout->addWidget(radioButton); + vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + + setWizardStyle(style()->styleHint(QStyle::SH_WizardStyle)); +} + +QWizard::WizardStyle WizardStyleControl::wizardStyle() const +{ + return static_cast<QWizard::WizardStyle>(m_group->checkedId()); +} + +void WizardStyleControl::setWizardStyle(int wizardStyle) +{ + if (wizardStyle < 0 || wizardStyle > QWizard::NStyles) + wizardStyle = QWizard::NStyles; + QAbstractButton *button = m_group->button(wizardStyle); + Q_ASSERT(button); + const bool blocked = m_group->blockSignals(true); + button->setChecked(true); + m_group->blockSignals(blocked); +} + +// A control with checkboxes for QWizard::WizardOption. +class WizardOptionsControl : public QGroupBox +{ +public: + explicit WizardOptionsControl(QWidget *parent = 0); + + QWizard::WizardOption wizardOptions() const; + void setWizardOptions(int options); + +private: + typedef QHash<int, QCheckBox *> CheckBoxHash; + + void addCheckBox(QVBoxLayout *layout, int flag, const QString &title); + + CheckBoxHash m_checkBoxes; +}; + +WizardOptionsControl::WizardOptionsControl(QWidget *parent) + : QGroupBox(tr("Options"), parent) +{ + QVBoxLayout *vLayout = new QVBoxLayout(this); + addCheckBox(vLayout, QWizard::IndependentPages, QLatin1String("IndependentPages")); + addCheckBox(vLayout, QWizard::IgnoreSubTitles, QLatin1String("IgnoreSubTitles")); + addCheckBox(vLayout, QWizard::ExtendedWatermarkPixmap, QLatin1String("ExtendedWatermarkPixmap")); + addCheckBox(vLayout, QWizard::NoDefaultButton, QLatin1String("NoDefaultButton")); + addCheckBox(vLayout, QWizard::NoBackButtonOnStartPage, QLatin1String("NoBackButtonOnStartPage")); + addCheckBox(vLayout, QWizard::NoBackButtonOnLastPage, QLatin1String("NoBackButtonOnLastPage")); + addCheckBox(vLayout, QWizard::DisabledBackButtonOnLastPage, QLatin1String("DisabledBackButtonOnLastPage")); + addCheckBox(vLayout, QWizard::HaveNextButtonOnLastPage, QLatin1String("HaveNextButtonOnLastPage")); + addCheckBox(vLayout, QWizard::HaveFinishButtonOnEarlyPages, QLatin1String("HaveFinishButtonOnEarlyPages")); + addCheckBox(vLayout, QWizard::NoCancelButton, QLatin1String("NoCancelButton")); + addCheckBox(vLayout, QWizard::CancelButtonOnLeft, QLatin1String("CancelButtonOnLeft")); + addCheckBox(vLayout, QWizard::HaveHelpButton, QLatin1String("HaveHelpButton")); + addCheckBox(vLayout, QWizard::HelpButtonOnRight, QLatin1String("HelpButtonOnRight")); + addCheckBox(vLayout, QWizard::HaveCustomButton1, QLatin1String("HaveCustomButton1")); + addCheckBox(vLayout, QWizard::HaveCustomButton2, QLatin1String("HaveCustomButton2")); + addCheckBox(vLayout, QWizard::HaveCustomButton3, QLatin1String("HaveCustomButton3")); + vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); +} + +void WizardOptionsControl::addCheckBox(QVBoxLayout *layout, int flag, const QString &title) +{ + QCheckBox *checkBox = new QCheckBox(title, this); + layout->addWidget(checkBox); + m_checkBoxes.insert(flag, checkBox); +} + +QWizard::WizardOption WizardOptionsControl::wizardOptions() const +{ + int result = 0; + typedef CheckBoxHash::const_iterator ConstIterator; + const ConstIterator cend = m_checkBoxes.constEnd(); + for (ConstIterator it = m_checkBoxes.constBegin(); it != cend; ++it) + if (it.value()->isChecked()) + result |= it.key(); + return static_cast<QWizard::WizardOption>(result); +} + +void WizardOptionsControl::setWizardOptions(int options) +{ + typedef CheckBoxHash::iterator Iterator; + const Iterator end = m_checkBoxes.end(); + for (Iterator it = m_checkBoxes.begin(); it != end; ++it) + it.value()->setChecked(options & it.key()); +} + +// A test wizard with a slot to change its style. +class Wizard : public QWizard { + Q_OBJECT +public: + explicit Wizard(QWidget *parent = 0, Qt::WindowFlags flags = 0); + +public slots: + void changeWizardStyle(int newStyle); +}; + +void Wizard::changeWizardStyle(int newStyle) +{ + if (newStyle >= 0 && newStyle < int(QWizard::NStyles)) + setWizardStyle(static_cast<QWizard::WizardStyle>(newStyle)); +} + +// A test wizard page with a WizardStyleControl. +class WizardPage : public QWizardPage +{ +public: + explicit WizardPage(const QString &title, QWidget *parent = 0); + + void initializePage(); + +private: + WizardStyleControl *m_styleControl; + bool m_firstTimeShown; +}; + +WizardPage::WizardPage(const QString &title, QWidget *parent) + : QWizardPage(parent) + , m_styleControl(new WizardStyleControl(this)) + , m_firstTimeShown(true) +{ + setTitle(title); + setSubTitle(title + QLatin1String(" SubTitle")); + QVBoxLayout *vLayout = new QVBoxLayout(this); + vLayout->addWidget(m_styleControl); +} + +void WizardPage::initializePage() +{ + m_styleControl->setWizardStyle(wizard()->wizardStyle()); + if (m_firstTimeShown) { + m_firstTimeShown = false; + connect(m_styleControl, SIGNAL(wizardStyleChanged(int)), + wizard(), SLOT(changeWizardStyle(int))); + } +} + +Wizard::Wizard(QWidget *parent, Qt::WindowFlags flags) + : QWizard(parent, flags) +{ + setWindowIcon(coloredIcon(Qt::red)); + setWindowTitle(QLatin1String("Wizard ") + QLatin1String(QT_VERSION_STR)); + addPage(new WizardPage(tr("Page 1"), this)); + addPage(new WizardPage(tr("Page 2"), this)); + addPage(new WizardPage(tr("Page 3"), this)); +} + +// A dialog using a Wizard as child widget (emulating Qt Designer). +class WizardEmbeddingDialog : public QDialog { +public: + explicit WizardEmbeddingDialog(QWidget *parent = 0); + + Wizard *wizard() const { return m_wizard; } + +private: + Wizard *m_wizard; +}; + +WizardEmbeddingDialog::WizardEmbeddingDialog(QWidget *parent) + : QDialog(parent) + , m_wizard(new Wizard) +{ + setWindowTitle(QString::fromLatin1("Dialog Embedding QWizard %1").arg(QT_VERSION_STR)); + QGridLayout *gridLayout = new QGridLayout(this); + gridLayout->addWidget(new QLabel(tr("Above wizard")), 0, 0, 1, 3); + gridLayout->addWidget(new QLabel(tr("Left of wizard")), 1, 0); + m_wizard->setObjectName(QLatin1String("EmbeddedWizard")); + m_wizard->setParent(this, Qt::Widget); + gridLayout->addWidget(m_wizard, 1, 1); + gridLayout->addWidget(new QLabel(tr("Right of wizard")), 1, 2); + gridLayout->addWidget(new QLabel(tr("Below wizard")), 2, 0, 1, 3); +} + +WizardPanel::WizardPanel(QWidget *parent) + : QWidget(parent) + , m_styleControl(new WizardStyleControl(this)) + , m_optionsControl(new WizardOptionsControl(this)) +{ + { + QWizard wizard; + m_optionsControl->setWizardOptions(wizard.options()); + m_styleControl->setWizardStyle(wizard.wizardStyle()); + } + + QGridLayout *gridLayout = new QGridLayout(this); + gridLayout->addWidget(m_optionsControl, 0, 0, 2, 1); + gridLayout->addWidget(m_styleControl, 0, 1); + QGroupBox *buttonGroupBox = new QGroupBox(this); + QVBoxLayout *vLayout = new QVBoxLayout(buttonGroupBox); + QPushButton *button = new QPushButton(tr("Show modal"), this); + connect(button, SIGNAL(clicked()), this, SLOT(showModal())); + vLayout->addWidget(button); + button = new QPushButton(tr("Show non-modal"), this); + connect(button, SIGNAL(clicked()), this, SLOT(showNonModal())); + vLayout->addWidget(button); + button = new QPushButton(tr("Show embedded"), this); + button->setToolTip(tr("Test QWizard's behavior when used as a widget child.")); + connect(button, SIGNAL(clicked()), this, SLOT(showEmbedded())); + vLayout->addWidget(button); + vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); + gridLayout->addWidget(buttonGroupBox, 1, 1); +} + +void WizardPanel::showModal() +{ + Wizard wizard(this); + applyParameters(&wizard); + wizard.exec(); +} + +void WizardPanel::showNonModal() +{ + Wizard *wizard = new Wizard(this); + applyParameters(wizard); + wizard->setModal(false); + wizard->setAttribute(Qt::WA_DeleteOnClose); + wizard->show(); +} + +void WizardPanel::showEmbedded() +{ + WizardEmbeddingDialog *dialog = new WizardEmbeddingDialog(this); + applyParameters(dialog->wizard()); + dialog->setModal(false); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); +} + +void WizardPanel::applyParameters(QWizard *wizard) const +{ + wizard->setWizardStyle(m_styleControl->wizardStyle()); + wizard->setOptions(m_optionsControl->wizardOptions()); + wizard->setPixmap(QWizard::WatermarkPixmap, pixmapWithText(QLatin1String("Watermark"), QColor(Qt::blue).lighter())); + wizard->setPixmap(QWizard::LogoPixmap, pixmapWithText(QLatin1String("Logo"), Qt::green)); + wizard->setPixmap(QWizard::BannerPixmap, pixmapWithText(QLatin1String("Banner"), Qt::green)); + wizard->setPixmap(QWizard::BackgroundPixmap, pixmapWithText(QLatin1String("Background"), QColor(Qt::red).lighter())); +} + +#include "wizardpanel.moc" diff --git a/tests/manual/dialogs/wizardpanel.h b/tests/manual/dialogs/wizardpanel.h new file mode 100644 index 0000000000..0a4ec8e467 --- /dev/null +++ b/tests/manual/dialogs/wizardpanel.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WIZARDPANEL_H +#define WIZARDPANEL_H + +#include <QWidget> + +class WizardStyleControl; +class WizardOptionsControl; +class QWizard; + +class WizardPanel : public QWidget +{ + Q_OBJECT +public: + explicit WizardPanel(QWidget *parent = 0); + +public slots: + void showModal(); + void showNonModal(); + void showEmbedded(); + +private: + void applyParameters(QWizard *wizard) const; + + WizardStyleControl *m_styleControl; + WizardOptionsControl *m_optionsControl; +}; + +#endif // WIZARDPANEL_H diff --git a/tests/manual/filetest/main.cpp b/tests/manual/filetest/main.cpp index 9d94265df7..2f7c5cdd06 100644 --- a/tests/manual/filetest/main.cpp +++ b/tests/manual/filetest/main.cpp @@ -46,6 +46,7 @@ #include <QDir> #include <iostream> +#include <string> static const char usage1[] = "\nTests various file functionality in Qt\n\n" @@ -58,11 +59,46 @@ static const char usage2[] =" [KEYWORD] [ARGUMENTS]\n\n" " rmr DIR remove directory recursively\n" " using QDir::removeRecursively\n"; +static inline std::string permissions(QFile::Permissions permissions) +{ + std::string result(10, '-'); + if (permissions & QFile::ReadOwner) + result[1] = 'r'; + if (permissions & QFile::WriteOwner) + result[2] = 'w'; + if (permissions & QFile::ExeOwner) + result[3] = 'x'; + if (permissions & QFile::ReadGroup) + result[4] = 'r'; + if (permissions & QFile::WriteGroup) + result[5] = 'w'; + if (permissions & QFile::ExeGroup) + result[6] = 'x'; + if (permissions & QFile::ReadOther) + result[7] = 'r'; + if (permissions & QFile::WriteOther) + result[8] = 'w'; + if (permissions & QFile::ExeOther) + result[9] = 'x'; + return result; +} + +static inline std::string permissions(const QFileInfo &fi) +{ + std::string result = permissions(fi.permissions()); + if (fi.isSymLink()) + result[0] = 'l'; + else if (fi.isDir()) + result[0] = 'd'; + return result; +} + static int ls(int argCount, char **args) { for (int i = 0 ; i < argCount; ++i) { const QFileInfo fi(QString::fromLocal8Bit(args[i])); - std::cout << QDir::toNativeSeparators(fi.absoluteFilePath()).toStdString() << ' ' << fi.size(); + std::cout << QDir::toNativeSeparators(fi.absoluteFilePath()).toStdString() << ' ' << fi.size() + << ' ' << permissions(fi); if (fi.exists()) std::cout << " [exists]"; if (fi.isFile()) @@ -73,6 +109,7 @@ static int ls(int argCount, char **args) } if (fi.isDir()) std::cout << " [dir]"; + std::cout << std::endl; } return 0; @@ -110,12 +147,18 @@ static int rm(const char *fileName) static int rmr(const char *dirName) { +#if QT_VERSION < 0x050000 + Q_UNUSED(dirName) + return 1; +#else QDir dir(QString::fromLocal8Bit(dirName)); if (!dir.removeRecursively()) { qWarning().nospace() << "Failed to remove " << dir.absolutePath(); return -1; } + return 0; +#endif } int main(int argc, char *argv[]) diff --git a/tests/manual/inputmethodhints/inputmethodhints.h b/tests/manual/inputmethodhints/inputmethodhints.h index 09c6ca41f5..ce1724280f 100644 --- a/tests/manual/inputmethodhints/inputmethodhints.h +++ b/tests/manual/inputmethodhints/inputmethodhints.h @@ -52,7 +52,7 @@ class inputmethodhints : public QMainWindow public: inputmethodhints(QWidget *parent = 0); ~inputmethodhints(); - + public slots: void checkboxChanged(int); diff --git a/tests/manual/lance/lance.pro b/tests/manual/lance/lance.pro index 177ca0e40e..430c9196e6 100644 --- a/tests/manual/lance/lance.pro +++ b/tests/manual/lance/lance.pro @@ -1,5 +1,6 @@ LANCELOT_DIR = $$PWD/../../auto/other/lancelot CONFIG+=console moc +CONFIG -= app_bundle TEMPLATE = app INCLUDEPATH += . $$LANCELOT_DIR QT += core-private gui-private widgets printsupport diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 525f596d0e..1169ea6a27 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -20,6 +20,7 @@ qlocale \ qnetworkaccessmanager/qget \ qnetworkconfigurationmanager \ qnetworkreply \ +qpainfo \ qscreen \ qssloptions \ qtabletevent \ @@ -34,11 +35,14 @@ windowflags \ windowgeometry \ windowmodality \ widgetgrab \ +xembed-raster \ +xembed-widgets \ dialogs !contains(QT_CONFIG, openssl):!contains(QT_CONFIG, openssl-linked):SUBDIRS -= qssloptions -# disable some tests on wince because of missing dependencies -wince*:SUBDIRS -= \ - lance windowmodality \ - network_remote_stresstest network_stresstest +win32 { + SUBDIRS -= network_remote_stresstest network_stresstest + # disable some tests on wince because of missing dependencies + wince*:SUBDIRS -= lance windowmodality +} diff --git a/tests/manual/qcursor/grab_override/mainwindow.h b/tests/manual/qcursor/grab_override/mainwindow.h index c105e22850..eaf4b95615 100644 --- a/tests/manual/qcursor/grab_override/mainwindow.h +++ b/tests/manual/qcursor/grab_override/mainwindow.h @@ -64,11 +64,11 @@ private slots: private: void keyPressEvent(QKeyEvent* event); - + Ui::MainWindow *ui; QTimer *timer; int override; - + QCursor ccurs; QCursor bcurs; }; diff --git a/tests/manual/qlocale/calendar.cpp b/tests/manual/qlocale/calendar.cpp index d91e181461..d7ac33e6a4 100644 --- a/tests/manual/qlocale/calendar.cpp +++ b/tests/manual/qlocale/calendar.cpp @@ -397,9 +397,9 @@ void CalendarWidget::createTextFormatsGroupBox() QComboBox *CalendarWidget::createColorComboBox() { QComboBox *comboBox = new QComboBox; - comboBox->addItem(tr("Red"), Qt::red); - comboBox->addItem(tr("Blue"), Qt::blue); - comboBox->addItem(tr("Black"), Qt::black); - comboBox->addItem(tr("Magenta"), Qt::magenta); + comboBox->addItem(tr("Red"), QColor(Qt::red)); + comboBox->addItem(tr("Blue"), QColor(Qt::blue)); + comboBox->addItem(tr("Black"), QColor(Qt::black)); + comboBox->addItem(tr("Magenta"), QColor(Qt::magenta)); return comboBox; } diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp index feb07b4c7d..2f47985261 100644 --- a/tests/manual/qnetworkreply/main.cpp +++ b/tests/manual/qnetworkreply/main.cpp @@ -49,7 +49,7 @@ #include <QtNetwork/qsslconfiguration.h> #include "../../auto/network-settings.h" -#ifdef QT_BUILD_INTERNAL +#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) #include "private/qsslsocket_p.h" #endif @@ -147,6 +147,9 @@ void tst_qnetworkreply::setSslConfiguration_data() void tst_qnetworkreply::setSslConfiguration() { +#ifdef QT_NO_SSL + QSKIP("SSL is not enabled."); +#else QFETCH(QUrl, url); QNetworkRequest request(url); QSslConfiguration conf = request.sslConfiguration(); @@ -171,6 +174,7 @@ void tst_qnetworkreply::setSslConfiguration() QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError); } #endif +#endif // QT_NO_SSL } QTEST_MAIN(tst_qnetworkreply) diff --git a/tests/manual/qpainfo/main.cpp b/tests/manual/qpainfo/main.cpp new file mode 100644 index 0000000000..6b712304a0 --- /dev/null +++ b/tests/manual/qpainfo/main.cpp @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QStyleHints> +#include <QLibraryInfo> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> +#include <qpa/qplatformtheme.h> +#include <QScreen> +#include <QStringList> +#include <QVariant> +#include <QFont> +#include <QSysInfo> +#include <QLibraryInfo> +#include <QStandardPaths> +#include <QDir> + +#include <iostream> +#include <string> + +std::ostream &operator<<(std::ostream &str, const QSize &s) +{ + str << s.width() << 'x' << s.height(); + return str; +} + +std::ostream &operator<<(std::ostream &str, const QSizeF &s) +{ + str << s.width() << 'x' << s.height(); + return str; +} + +std::ostream &operator<<(std::ostream &str, const QRect &r) +{ + str << r.size() << '+' << r.x() << '+' << r.y(); + return str; +} + +std::ostream &operator<<(std::ostream &str, const QStringList &l) +{ + for (int i = 0; i < l.size(); ++i) { + if (i) + str << ','; + str << l.at(i).toStdString(); + } + return str; +} + +static QStringList toNativeSeparators(QStringList in) +{ + for (int i = 0; i < in.size(); ++i) + in[i] = QDir::toNativeSeparators(in.at(i)); + return in; +} + +#define DUMP_CAPABILITY(integration, capability) \ + if (platformIntegration->hasCapability(QPlatformIntegration::capability)) \ + std::cout << ' ' << #capability; + +#define DUMP_STANDARDPATH(location) \ + std::cout << " " << #location << ": \"" \ + << QStandardPaths::displayName(QStandardPaths::location).toStdString() << '"' \ + << ' ' << toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::location)) << '\n'; + +#define DUMP_LIBRARYPATH(loc) \ + std::cout << " " << #loc << ": " << QDir::toNativeSeparators(QLibraryInfo::location(QLibraryInfo::loc)).toStdString() << '\n'; + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); + std::cout << "Qt " << QT_VERSION_STR << " on \"" << QGuiApplication::platformName().toStdString() << "\" " + << QSysInfo::WordSize << " bit/" + << (QSysInfo::ByteOrder == QSysInfo::LittleEndian ? "little endian" : "big endian") << '/' + << (QLibraryInfo::isDebugBuild() ? "debug" : "release") + << '\n'; + +#if defined(Q_OS_WIN) + std::cout << std::hex << "Windows version: 0x" << QSysInfo::windowsVersion() << std::dec << '\n'; +#elif defined(Q_OS_MAC) + std::cout << std::hex << "Mac OS version: 0x" << QSysInfo::macVersion() << std::dec << '\n'; +#endif + + std::cout << "\nLibrary info:\n"; + DUMP_LIBRARYPATH(PrefixPath) + DUMP_LIBRARYPATH(DocumentationPath) + DUMP_LIBRARYPATH(HeadersPath) + DUMP_LIBRARYPATH(LibrariesPath) + DUMP_LIBRARYPATH(LibraryExecutablesPath) + DUMP_LIBRARYPATH(BinariesPath) + DUMP_LIBRARYPATH(PluginsPath) + DUMP_LIBRARYPATH(ImportsPath) + DUMP_LIBRARYPATH(Qml2ImportsPath) + DUMP_LIBRARYPATH(ArchDataPath) + DUMP_LIBRARYPATH(DataPath) + DUMP_LIBRARYPATH(TranslationsPath) + DUMP_LIBRARYPATH(ExamplesPath) + DUMP_LIBRARYPATH(TestsPath) + + std::cout << "\nStandard paths:\n"; + DUMP_STANDARDPATH(DesktopLocation) + DUMP_STANDARDPATH(DocumentsLocation) + DUMP_STANDARDPATH(FontsLocation) + DUMP_STANDARDPATH(ApplicationsLocation) + DUMP_STANDARDPATH(MusicLocation) + DUMP_STANDARDPATH(MoviesLocation) + DUMP_STANDARDPATH(PicturesLocation) + DUMP_STANDARDPATH(TempLocation) + DUMP_STANDARDPATH(HomeLocation) + DUMP_STANDARDPATH(DataLocation) + DUMP_STANDARDPATH(CacheLocation) + DUMP_STANDARDPATH(GenericDataLocation) + DUMP_STANDARDPATH(RuntimeLocation) + DUMP_STANDARDPATH(ConfigLocation) + DUMP_STANDARDPATH(DownloadLocation) + DUMP_STANDARDPATH(GenericCacheLocation) + + std::cout << "\nPlatform capabilities:"; + DUMP_CAPABILITY(platformIntegration, ThreadedPixmaps) + DUMP_CAPABILITY(platformIntegration, OpenGL) + DUMP_CAPABILITY(platformIntegration, ThreadedOpenGL) + DUMP_CAPABILITY(platformIntegration, SharedGraphicsCache) + DUMP_CAPABILITY(platformIntegration, BufferQueueingOpenGL) + DUMP_CAPABILITY(platformIntegration, WindowMasks) + DUMP_CAPABILITY(platformIntegration, MultipleWindows) + DUMP_CAPABILITY(platformIntegration, ApplicationState) + DUMP_CAPABILITY(platformIntegration, ForeignWindows) + std::cout << '\n'; + + const QStyleHints *styleHints = QGuiApplication::styleHints(); + std::cout << "\nStyle hints: mouseDoubleClickInterval=" << styleHints->mouseDoubleClickInterval() << " startDragDistance=" + << styleHints->startDragDistance() << " startDragTime=" << styleHints->startDragTime() + << " startDragVelocity=" << styleHints->startDragVelocity() << " keyboardInputInterval=" << styleHints->keyboardInputInterval() + << " keyboardAutoRepeatRate=" << styleHints->keyboardAutoRepeatRate() << " cursorFlashTime=" << styleHints->cursorFlashTime() + << " showIsFullScreen=" << styleHints->showIsFullScreen() << " passwordMaskDelay=" << styleHints->passwordMaskDelay() + << " fontSmoothingGamma=" << styleHints->fontSmoothingGamma() << " useRtlExtensions=" << styleHints->useRtlExtensions() << '\n'; + + const QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme(); + std::cout << "\nTheme:\n Styles: " << platformTheme->themeHint(QPlatformTheme::StyleNames).toStringList(); + const QString iconTheme = platformTheme->themeHint(QPlatformTheme::SystemIconThemeName).toString(); + if (!iconTheme.isEmpty()) { + std::cout << "\n Icon theme: " << iconTheme.toStdString() + << ", " << platformTheme->themeHint(QPlatformTheme::SystemIconFallbackThemeName).toString().toStdString() + << " from " << platformTheme->themeHint(QPlatformTheme::IconThemeSearchPaths).toStringList() << '\n'; + } + if (const QFont *systemFont = platformTheme->font()) + std::cout << " System font: \"" << systemFont->family().toStdString() << "\" " << systemFont->pointSize() << '\n'; + if (platformTheme->usePlatformNativeDialog(QPlatformTheme::FileDialog)) + std::cout << " Native file dialog\n"; + if (platformTheme->usePlatformNativeDialog(QPlatformTheme::ColorDialog)) + std::cout << " Native color dialog\n"; + if (platformTheme->usePlatformNativeDialog(QPlatformTheme::FontDialog)) + std::cout << " Native font dialog\n"; + + const QList<QScreen*> screens = QGuiApplication::screens(); + const int screenCount = screens.size(); + std::cout << "\nScreens: " << screenCount << '\n'; + for (int s = 0; s < screenCount; ++s) { + const QScreen *screen = screens.at(s); + std::cout << (screen == QGuiApplication::primaryScreen() ? '*' : ' ') + << '#' << ' ' << s << " \"" << screen->name().toStdString() << '"' + << "\n Geometry: " << screen->geometry() << " Available: " << screen->availableGeometry(); + if (screen->geometry() != screen->virtualGeometry()) + std::cout << "\n Virtual geometry: " << screen->virtualGeometry() << " Available: " << screen->availableVirtualGeometry(); + if (screen->virtualSiblings().size() > 1) + std::cout << "\n " << screen->virtualSiblings().size() << " virtual siblings"; + std::cout << "\n Physical size: " << screen->physicalSize() << " mm" + << " Refresh: " << screen->refreshRate() << " Hz" + << "\n Physical DPI: " << screen->physicalDotsPerInchX() + << ',' << screen->physicalDotsPerInchY() + << " Logical DPI: " << screen->logicalDotsPerInchX() + << ',' << screen->logicalDotsPerInchY() + << "\n DevicePixelRatio: " << screen->devicePixelRatio() + << " Primary orientation: " << screen->primaryOrientation() + << "\n Orientation: " << screen->orientation() + << " OrientationUpdateMask: " << screen->orientationUpdateMask() + << "\n\n"; + } + return 0; +} diff --git a/tests/manual/qpainfo/qpainfo.pro b/tests/manual/qpainfo/qpainfo.pro new file mode 100644 index 0000000000..374f951300 --- /dev/null +++ b/tests/manual/qpainfo/qpainfo.pro @@ -0,0 +1,7 @@ +TEMPLATE = app +TARGET = qpainfo +CONFIG+=console +CONFIG -= app_bundle +QT = core-private gui-private + +SOURCES += main.cpp diff --git a/tests/manual/qtouchevent/touchwidget.cpp b/tests/manual/qtouchevent/touchwidget.cpp index 68206aad22..e2834203f7 100644 --- a/tests/manual/qtouchevent/touchwidget.cpp +++ b/tests/manual/qtouchevent/touchwidget.cpp @@ -122,7 +122,7 @@ bool TouchWidget::event(QEvent *event) case QEvent::MouseButtonRelease: seenMouseRelease = true; if (closeWindowOnMouseRelease) - window()->close(); + window()->close(); if (acceptMouseRelease) { event->accept(); return true; diff --git a/tests/manual/repaint/mainwindow/main.cpp b/tests/manual/repaint/mainwindow/main.cpp index 173f81de06..eb3096a59c 100644 --- a/tests/manual/repaint/mainwindow/main.cpp +++ b/tests/manual/repaint/mainwindow/main.cpp @@ -47,16 +47,16 @@ int main(int argc, char **argv) QApplication app(argc, argv); QMainWindow mainWindow; - + mainWindow.setCentralWidget(new StaticWidget()); mainWindow.setStatusBar(new QStatusBar()); - + QDockWidget *dockWidget = new QDockWidget(); dockWidget->setWidget(new StaticWidget()); mainWindow.addDockWidget(Qt::LeftDockWidgetArea, dockWidget); - + QToolBar *toolBar = new QToolBar(); - + toolBar->addWidget(new StaticWidget())->setVisible(true);; toolBar->addWidget(new QSpinBox())->setVisible(true);; @@ -64,6 +64,6 @@ int main(int argc, char **argv) mainWindow.resize(600, 400); mainWindow.show(); - + return app.exec(); } diff --git a/tests/manual/repaint/scrollarea/main.cpp b/tests/manual/repaint/scrollarea/main.cpp index 44b43c30f7..6102ab8ee8 100644 --- a/tests/manual/repaint/scrollarea/main.cpp +++ b/tests/manual/repaint/scrollarea/main.cpp @@ -42,7 +42,6 @@ #include <QtWidgets> #include "../shared/shared.h" - int main(int argc, char **argv) { QApplication app(argc, argv); @@ -57,8 +56,7 @@ int main(int argc, char **argv) scrollView.resize(600, 400); scrollView.show(); - - + return app.exec(); } diff --git a/tests/manual/repaint/splitter/main.cpp b/tests/manual/repaint/splitter/main.cpp index 5ee1e19402..2c01053ae1 100644 --- a/tests/manual/repaint/splitter/main.cpp +++ b/tests/manual/repaint/splitter/main.cpp @@ -53,6 +53,6 @@ int main(int argc, char **argv) splitter.resize(600, 400); splitter.show(); - + return app.exec(); } diff --git a/tests/manual/repaint/tableview/main.cpp b/tests/manual/repaint/tableview/main.cpp index 442b1668e0..71f8209d6d 100644 --- a/tests/manual/repaint/tableview/main.cpp +++ b/tests/manual/repaint/tableview/main.cpp @@ -45,7 +45,7 @@ class CellWidget : public QWidget { public: - CellWidget (QWidget *parent = 0) : QWidget(parent) { } + CellWidget(QWidget *parent = 0) : QWidget(parent) {} void paintEvent(QPaintEvent * event) { static int value = 200; @@ -69,8 +69,7 @@ int main(int argc, char **argv) tableWidget.setCellWidget(row, col, new CellWidget()); tableWidget.resize(400, 600); tableWidget.show(); - - + return app.exec(); } diff --git a/tests/manual/repaint/task141091/main.cpp b/tests/manual/repaint/task141091/main.cpp index d2b0f76606..b5b6ae92d7 100644 --- a/tests/manual/repaint/task141091/main.cpp +++ b/tests/manual/repaint/task141091/main.cpp @@ -45,11 +45,12 @@ class MyWidget : public QWidget { public: - MyWidget() : QWidget() { - - + MyWidget() : QWidget() + { setAttribute(Qt::WA_OpaquePaintEvent); - setAttribute(Qt::WA_StaticContents); } + setAttribute(Qt::WA_StaticContents); + } + protected: void paintEvent(QPaintEvent *e) { qDebug() << e->rect(); } }; @@ -60,4 +61,4 @@ int main(int argc, char **argv) MyWidget w; w.show(); return a.exec(); -}
\ No newline at end of file +} diff --git a/tests/manual/repaint/widget/main.cpp b/tests/manual/repaint/widget/main.cpp index 520b3e22f5..22011a160c 100644 --- a/tests/manual/repaint/widget/main.cpp +++ b/tests/manual/repaint/widget/main.cpp @@ -108,24 +108,24 @@ protected: QPushButton * resizeButton; QPushButton * movebutton; QPushButton * moveResizebutton; - QPushButton * scrollbutton; + QPushButton * scrollbutton; }; int main(int argc, char **argv) { QApplication app(argc, argv); - + TopLevel bc; bc.resize(500, 500); c = new Child(&bc); c->move(100, 100); c->resize(100, 100); - + QWidget *gc = new StaticWidget(c); gc->move(20, 20); gc->resize(50,50); - + bc.show(); return app.exec(); diff --git a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp index 7a8c1d159d..b5aeb023f4 100644 --- a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp +++ b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp @@ -99,6 +99,9 @@ int main(int argc, char *argv[]) m.setRowCount(500); m.setColumnCount(250); tv.setModel(&m); + tv.setSelectionMode(QAbstractItemView::SingleSelection); + // Comment in the line below to test selection with keyboard (space) + // tv.setEditTriggers(QAbstractItemView::NoEditTriggers); SomeHandler handler(tv.horizontalHeader(), &tv); tv.horizontalHeader()->setDefaultSectionSize(30); tv.show(); diff --git a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp index 186203e7d8..aec2479239 100644 --- a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp +++ b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp @@ -60,11 +60,12 @@ public: class MyGraphicsView : public QGraphicsView { - + Q_OBJECT public: - MyGraphicsView() : QGraphicsView() + MyGraphicsView(QWidget *w, QLabel *l) : QGraphicsView(w), rubberbandLabel(l) { setDragMode(QGraphicsView::RubberBandDrag); + connect(this, SIGNAL(rubberBandChanged(QRect, QPointF, QPointF)), this, SLOT(updateRubberbandInfo(QRect, QPointF, QPointF))); } protected: void mouseMoveEvent(QMouseEvent *event) @@ -81,26 +82,46 @@ protected: if (yglobal > bottomPos) verticalScrollBar()->setValue(verticalScrollBar()->value() + 10); } + +protected slots: + void updateRubberbandInfo(QRect r, QPointF from, QPointF to) + { + QString textToShow; + QDebug s(&textToShow); + s << r << from << to; + rubberbandLabel->setText(textToShow); + } +protected: + QLabel *rubberbandLabel; }; int main(int argc, char *argv[]) { QApplication app(argc, argv); - MyGraphicsView v; + + QWidget w; + w.setLayout(new QVBoxLayout); + QLabel *l = new QLabel(&w); + MyGraphicsView *v = new MyGraphicsView(&w, l); + + w.layout()->addWidget(v); + w.layout()->addWidget(l); QGraphicsScene s(0.0, 0.0, 5000.0, 5000.0); - v.setScene(&s); - v.setInteractive(true); - v.setRubberBandSelectionMode(Qt::IntersectsItemBoundingRect); - s.addRect( (qreal) 0.0, 0.0, 1000.0, 50.0, QPen(),QBrush(QColor(0,0,255))); + v->setScene(&s); + v->setInteractive(true); + v->setRubberBandSelectionMode(Qt::IntersectsItemBoundingRect); for (int u = 0; u < 100; ++u) - for (int v = 0; v < 100; ++v) { + for (int n = 0; n < 100; ++n) { MyGraphicsItem *item = new MyGraphicsItem(); - item->setRect(QRectF(v * 80.0, u * 80.0, 50.0, 20.0)); + item->setRect(QRectF(n * 80.0, u * 80.0, 50.0, 20.0)); s.addItem(item); } - v.show(); + + w.show(); app.exec(); return 0; } + +#include "rubberbandtest.moc" diff --git a/tests/manual/windowflags/controls.cpp b/tests/manual/windowflags/controls.cpp index cad84617fc..422656ff03 100644 --- a/tests/manual/windowflags/controls.cpp +++ b/tests/manual/windowflags/controls.cpp @@ -123,8 +123,10 @@ Qt::WindowFlags HintControl::hints() const flags |= Qt::WindowMinimizeButtonHint; if (windowMaximizeButtonCheckBox->isChecked()) flags |= Qt::WindowMaximizeButtonHint; +#if QT_VERSION >= 0x050000 if (windowFullscreenButtonCheckBox->isChecked()) flags |= Qt::WindowFullscreenButtonHint; +#endif if (windowCloseButtonCheckBox->isChecked()) flags |= Qt::WindowCloseButtonHint; if (windowContextHelpButtonCheckBox->isChecked()) @@ -153,7 +155,9 @@ void HintControl::setHints(Qt::WindowFlags flags) windowSystemMenuCheckBox->setChecked(flags & Qt::WindowSystemMenuHint); windowMinimizeButtonCheckBox->setChecked(flags & Qt::WindowMinimizeButtonHint); windowMaximizeButtonCheckBox->setChecked(flags & Qt::WindowMaximizeButtonHint); +#if QT_VERSION >= 0x050000 windowFullscreenButtonCheckBox->setChecked(flags & Qt::WindowFullscreenButtonHint); +#endif windowCloseButtonCheckBox->setChecked(flags & Qt::WindowCloseButtonHint); windowContextHelpButtonCheckBox->setChecked(flags & Qt::WindowContextHelpButtonHint); windowShadeButtonCheckBox->setChecked(flags & Qt::WindowShadeButtonHint); diff --git a/tests/manual/windowgeometry/controllerwidget.cpp b/tests/manual/windowgeometry/controllerwidget.cpp index 8340b90654..d8c74ef8a3 100644 --- a/tests/manual/windowgeometry/controllerwidget.cpp +++ b/tests/manual/windowgeometry/controllerwidget.cpp @@ -311,7 +311,7 @@ public: , m_backingStore(new QBackingStore(this)) { setObjectName(QStringLiteral("window")); - setWindowTitle(tr("TestWindow")); + setTitle(tr("TestWindow")); } protected: @@ -363,9 +363,9 @@ private: virtual QPoint objectMapToGlobal(const QObject *o, const QPoint &p) const { return static_cast<const QWindow *>(o)->mapToGlobal(p); } virtual Qt::WindowFlags objectWindowFlags(const QObject *o) const - { return static_cast<const QWindow *>(o)->windowFlags(); } + { return static_cast<const QWindow *>(o)->flags(); } virtual void setObjectWindowFlags(QObject *o, Qt::WindowFlags f) - { static_cast<QWindow *>(o)->setWindowFlags(f); } + { static_cast<QWindow *>(o)->setFlags(f); } WindowStateControl *m_stateControl; }; @@ -374,7 +374,7 @@ WindowControl::WindowControl(QWindow *w ) : BaseWindowControl(w) , m_stateControl(new WindowStateControl(WindowStateControl::WantVisibleCheckBox | WindowStateControl::WantMinimizeRadioButton)) { - setTitle(w->windowTitle()); + setTitle(w->title()); QGroupBox *stateGroupBox = new QGroupBox(tr("State")); QVBoxLayout *l = new QVBoxLayout(stateGroupBox); l->addWidget(m_stateControl); @@ -454,7 +454,7 @@ ControllerWidget::ControllerWidget(QWidget *parent) #if QT_VERSION >= 0x050000 x += 300; - m_testWindow->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint + m_testWindow->setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowTitleHint | Qt::WindowFullscreenButtonHint); m_testWindow->setFramePosition(QPoint(x, y)); @@ -467,7 +467,7 @@ ControllerWidget::ControllerWidget(QWidget *parent) m_testWindow->showFullScreen(); else m_testWindow->show(); - m_testWindow->setWindowTitle(tr("TestWindow")); + m_testWindow->setTitle(tr("TestWindow")); #endif QWidget *central = new QWidget ; diff --git a/tests/manual/xembed-raster/gtk-embedder.py b/tests/manual/xembed-raster/gtk-embedder.py new file mode 100755 index 0000000000..bd19789f84 --- /dev/null +++ b/tests/manual/xembed-raster/gtk-embedder.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +############################################################################# +## +## Copyright (C) 2013 Canonical Ltd. +## Contact: http://www.qt-project.org/legal +## +## This file is part of the test suite of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and Digia. For licensing terms and +## conditions see http://qt.digia.com/licensing. For further information +## use the contact form at http://qt.digia.com/contact-us. +## +## 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, Digia gives you certain additional +## rights. These rights are described in the Digia Qt LGPL Exception +## version 1.1, 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. +## +## +## $QT_END_LICENSE$ +## +############################################################################# + +from gi.repository import Gtk +from subprocess import Popen + +window = Gtk.Window() + +box = Gtk.VBox(False, 0) +window.add(box) + +child = None +def on_button_clicked(button, socket): + global child + child = Popen(['./rasterwindow', str(socket.get_id())]) + +button = Gtk.Button("Press me to embed a Qt client") +box.pack_start(button, False, False, 0) + +socket = Gtk.Socket() +socket.set_size_request(200, 200) +box.add(socket) + +button.connect("clicked", on_button_clicked, socket) +window.connect("destroy", Gtk.main_quit) + +def plugged_event(widget): + print("A window was embedded!") + +socket.connect("plug-added", plugged_event) + +window.show_all() +Gtk.main() +if child: + child.terminate() diff --git a/tests/manual/xembed-raster/main.cpp b/tests/manual/xembed-raster/main.cpp new file mode 100644 index 0000000000..dc5fb8a5ca --- /dev/null +++ b/tests/manual/xembed-raster/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rasterwindow.h" +#include <QDebug> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + QStringList args = app.arguments(); + + WId winId = 0; + if (args.count() > 1) { + bool ok; + winId = args[1].toUInt(&ok); + Q_ASSERT(ok); + } + + RasterWindow window; + window.show(); + + QWindow *foreign = QWindow::fromWinId(winId); + Q_ASSERT(foreign != 0); + + window.setParent(foreign); + + return app.exec(); +} diff --git a/tests/manual/xembed-raster/rasterwindow.cpp b/tests/manual/xembed-raster/rasterwindow.cpp new file mode 100644 index 0000000000..cad5081280 --- /dev/null +++ b/tests/manual/xembed-raster/rasterwindow.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rasterwindow.h" + +RasterWindow::RasterWindow(QWindow *parent) + : QWindow(parent) + , m_update_pending(false) +{ + m_backingStore = new QBackingStore(this); + create(); + + setGeometry(100, 100, 300, 200); +} + + +bool RasterWindow::event(QEvent *event) +{ + if (event->type() == QEvent::UpdateRequest) { + m_update_pending = false; + renderNow(); + return true; + } + return QWindow::event(event); +} + +void RasterWindow::renderLater() +{ + if (!m_update_pending) { + m_update_pending = true; + QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); + } +} + +void RasterWindow::resizeEvent(QResizeEvent *resizeEvent) +{ + m_backingStore->resize(resizeEvent->size()); + if (isExposed()) + renderNow(); +} + +void RasterWindow::exposeEvent(QExposeEvent *) +{ + if (isExposed()) { + renderNow(); + } +} + +void RasterWindow::renderNow() +{ + if (!isExposed()) + return; + + QRect rect(0, 0, width(), height()); + m_backingStore->beginPaint(rect); + + QPaintDevice *device = m_backingStore->paintDevice(); + QPainter painter(device); + + painter.fillRect(0, 0, width(), height(), Qt::white); + render(&painter); + + m_backingStore->endPaint(); + m_backingStore->flush(rect); +} + +void RasterWindow::render(QPainter *painter) +{ + painter->drawText(QRectF(0, 0, width(), height()), Qt::AlignCenter, QStringLiteral("QWindow")); +} diff --git a/tests/manual/xembed-raster/rasterwindow.h b/tests/manual/xembed-raster/rasterwindow.h new file mode 100644 index 0000000000..3fed06d7de --- /dev/null +++ b/tests/manual/xembed-raster/rasterwindow.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef RASTERWINDOW_H +#define RASTERWINDOW_H + +#include <QtGui> + +class RasterWindow : public QWindow +{ + Q_OBJECT +public: + explicit RasterWindow(QWindow *parent = 0); + + virtual void render(QPainter *painter); + +public slots: + void renderLater(); + void renderNow(); + +protected: + bool event(QEvent *event); + + void resizeEvent(QResizeEvent *event); + void exposeEvent(QExposeEvent *event); + +private: + QBackingStore *m_backingStore; + bool m_update_pending; +}; + +#endif // RASTERWINDOW_H diff --git a/tests/manual/xembed-raster/xembed-raster.pro b/tests/manual/xembed-raster/xembed-raster.pro new file mode 100644 index 0000000000..adaf9c4d25 --- /dev/null +++ b/tests/manual/xembed-raster/xembed-raster.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET= rasterwindow +QT += gui + +SOURCES += \ + main.cpp \ + rasterwindow.cpp +HEADERS += \ + rasterwindow.h diff --git a/tests/manual/xembed-widgets/gtk-embedder.py b/tests/manual/xembed-widgets/gtk-embedder.py new file mode 100755 index 0000000000..bcb9813441 --- /dev/null +++ b/tests/manual/xembed-widgets/gtk-embedder.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +############################################################################# +## +## Copyright (C) 2013 Canonical Ltd. +## Contact: http://www.qt-project.org/legal +## +## This file is part of the test suite of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and Digia. For licensing terms and +## conditions see http://qt.digia.com/licensing. For further information +## use the contact form at http://qt.digia.com/contact-us. +## +## 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, Digia gives you certain additional +## rights. These rights are described in the Digia Qt LGPL Exception +## version 1.1, 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. +## +## +## $QT_END_LICENSE$ +## +############################################################################# + +from gi.repository import Gtk +from subprocess import Popen + +window = Gtk.Window() + +box = Gtk.VBox(False, 0) +window.add(box) + +child = None +def on_button_clicked(button, socket): + global child + child = Popen(['./lineedits', str(socket.get_id())]) + +button = Gtk.Button("Press me to embed a Qt client") +box.pack_start(button, False, False, 0) + +entry = Gtk.Entry() +box.pack_start(entry, False, False, 0) + +socket = Gtk.Socket() +socket.set_size_request(200, 200) +box.add(socket) + +button.connect("clicked", on_button_clicked, socket) +window.connect("destroy", Gtk.main_quit) + +def plugged_event(widget): + print("A window was embedded!") + +socket.connect("plug-added", plugged_event) + +window.show_all() +Gtk.main() +if child: + child.terminate() diff --git a/tests/manual/xembed-widgets/main.cpp b/tests/manual/xembed-widgets/main.cpp new file mode 100644 index 0000000000..fbd9773b61 --- /dev/null +++ b/tests/manual/xembed-widgets/main.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QDebug> +#include <QWindow> + +#include "window.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QStringList args = app.arguments(); + + WId winId = 0; + if (args.count() > 1) { + bool ok; + winId = args[1].toUInt(&ok); + Q_ASSERT(ok); + } + + Window window; + window.show(); + + QWindow *foreign = QWindow::fromWinId(winId); + Q_ASSERT(foreign != 0); + + window.windowHandle()->setParent(foreign); + + return app.exec(); +} diff --git a/tests/manual/xembed-widgets/window.cpp b/tests/manual/xembed-widgets/window.cpp new file mode 100644 index 0000000000..92eccf50ba --- /dev/null +++ b/tests/manual/xembed-widgets/window.cpp @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtWidgets> + +#include "window.h" + +Window::Window() +{ + QGroupBox *echoGroup = new QGroupBox(tr("Echo")); + + QLabel *echoLabel = new QLabel(tr("Mode:")); + QComboBox *echoComboBox = new QComboBox; + echoComboBox->addItem(tr("Normal")); + echoComboBox->addItem(tr("Password")); + echoComboBox->addItem(tr("PasswordEchoOnEdit")); + echoComboBox->addItem(tr("No Echo")); + + echoLineEdit = new QLineEdit; + echoLineEdit->setFocus(); + + QGroupBox *validatorGroup = new QGroupBox(tr("Validator")); + + QLabel *validatorLabel = new QLabel(tr("Type:")); + QComboBox *validatorComboBox = new QComboBox; + validatorComboBox->addItem(tr("No validator")); + validatorComboBox->addItem(tr("Integer validator")); + validatorComboBox->addItem(tr("Double validator")); + + validatorLineEdit = new QLineEdit; + + QGroupBox *alignmentGroup = new QGroupBox(tr("Alignment")); + + QLabel *alignmentLabel = new QLabel(tr("Type:")); + QComboBox *alignmentComboBox = new QComboBox; + alignmentComboBox->addItem(tr("Left")); + alignmentComboBox->addItem(tr("Centered")); + alignmentComboBox->addItem(tr("Right")); + + alignmentLineEdit = new QLineEdit; + + QGroupBox *inputMaskGroup = new QGroupBox(tr("Input mask")); + + QLabel *inputMaskLabel = new QLabel(tr("Type:")); + QComboBox *inputMaskComboBox = new QComboBox; + inputMaskComboBox->addItem(tr("No mask")); + inputMaskComboBox->addItem(tr("Phone number")); + inputMaskComboBox->addItem(tr("ISO date")); + inputMaskComboBox->addItem(tr("License key")); + + inputMaskLineEdit = new QLineEdit; + + QGroupBox *accessGroup = new QGroupBox(tr("Access")); + + QLabel *accessLabel = new QLabel(tr("Read-only:")); + QComboBox *accessComboBox = new QComboBox; + accessComboBox->addItem(tr("False")); + accessComboBox->addItem(tr("True")); + + accessLineEdit = new QLineEdit; + + connect(echoComboBox, SIGNAL(activated(int)), + this, SLOT(echoChanged(int))); + connect(validatorComboBox, SIGNAL(activated(int)), + this, SLOT(validatorChanged(int))); + connect(alignmentComboBox, SIGNAL(activated(int)), + this, SLOT(alignmentChanged(int))); + connect(inputMaskComboBox, SIGNAL(activated(int)), + this, SLOT(inputMaskChanged(int))); + connect(accessComboBox, SIGNAL(activated(int)), + this, SLOT(accessChanged(int))); + + QGridLayout *echoLayout = new QGridLayout; + echoLayout->addWidget(echoLabel, 0, 0); + echoLayout->addWidget(echoComboBox, 0, 1); + echoLayout->addWidget(echoLineEdit, 1, 0, 1, 2); + echoGroup->setLayout(echoLayout); + + QGridLayout *validatorLayout = new QGridLayout; + validatorLayout->addWidget(validatorLabel, 0, 0); + validatorLayout->addWidget(validatorComboBox, 0, 1); + validatorLayout->addWidget(validatorLineEdit, 1, 0, 1, 2); + validatorGroup->setLayout(validatorLayout); + + QGridLayout *alignmentLayout = new QGridLayout; + alignmentLayout->addWidget(alignmentLabel, 0, 0); + alignmentLayout->addWidget(alignmentComboBox, 0, 1); + alignmentLayout->addWidget(alignmentLineEdit, 1, 0, 1, 2); + alignmentGroup-> setLayout(alignmentLayout); + + QGridLayout *inputMaskLayout = new QGridLayout; + inputMaskLayout->addWidget(inputMaskLabel, 0, 0); + inputMaskLayout->addWidget(inputMaskComboBox, 0, 1); + inputMaskLayout->addWidget(inputMaskLineEdit, 1, 0, 1, 2); + inputMaskGroup->setLayout(inputMaskLayout); + + QGridLayout *accessLayout = new QGridLayout; + accessLayout->addWidget(accessLabel, 0, 0); + accessLayout->addWidget(accessComboBox, 0, 1); + accessLayout->addWidget(accessLineEdit, 1, 0, 1, 2); + accessGroup->setLayout(accessLayout); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(echoGroup, 0, 0); + layout->addWidget(validatorGroup, 1, 0); + layout->addWidget(alignmentGroup, 2, 0); + layout->addWidget(inputMaskGroup, 0, 1); + layout->addWidget(accessGroup, 1, 1); + setLayout(layout); + + setWindowTitle(tr("Line Edits")); +} + +void Window::echoChanged(int index) +{ + switch (index) { + case 0: + echoLineEdit->setEchoMode(QLineEdit::Normal); + break; + case 1: + echoLineEdit->setEchoMode(QLineEdit::Password); + break; + case 2: + echoLineEdit->setEchoMode(QLineEdit::PasswordEchoOnEdit); + break; + case 3: + echoLineEdit->setEchoMode(QLineEdit::NoEcho); + } +} + +void Window::validatorChanged(int index) +{ + switch (index) { + case 0: + validatorLineEdit->setValidator(0); + break; + case 1: + validatorLineEdit->setValidator(new QIntValidator( + validatorLineEdit)); + break; + case 2: + validatorLineEdit->setValidator(new QDoubleValidator(-999.0, + 999.0, 2, validatorLineEdit)); + } + + validatorLineEdit->clear(); +} + +void Window::alignmentChanged(int index) +{ + switch (index) { + case 0: + alignmentLineEdit->setAlignment(Qt::AlignLeft); + break; + case 1: + alignmentLineEdit->setAlignment(Qt::AlignCenter); + break; + case 2: + alignmentLineEdit->setAlignment(Qt::AlignRight); + } +} + +void Window::inputMaskChanged(int index) +{ + switch (index) { + case 0: + inputMaskLineEdit->setInputMask(""); + break; + case 1: + inputMaskLineEdit->setInputMask("+99 99 99 99 99;_"); + break; + case 2: + inputMaskLineEdit->setInputMask("0000-00-00"); + inputMaskLineEdit->setText("00000000"); + inputMaskLineEdit->setCursorPosition(0); + break; + case 3: + inputMaskLineEdit->setInputMask(">AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#"); + } +} + +void Window::accessChanged(int index) +{ + switch (index) { + case 0: + accessLineEdit->setReadOnly(false); + break; + case 1: + accessLineEdit->setReadOnly(true); + } +} diff --git a/tests/manual/xembed-widgets/window.h b/tests/manual/xembed-widgets/window.h new file mode 100644 index 0000000000..fbb9b82300 --- /dev/null +++ b/tests/manual/xembed-widgets/window.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include <QWidget> + +QT_BEGIN_NAMESPACE +class QComboBox; +class QLineEdit; +QT_END_NAMESPACE + +class Window : public QWidget +{ + Q_OBJECT + +public: + Window(); + +public slots: + void echoChanged(int); + void validatorChanged(int); + void alignmentChanged(int); + void inputMaskChanged(int); + void accessChanged(int); + +private: + QLineEdit *echoLineEdit; + QLineEdit *validatorLineEdit; + QLineEdit *alignmentLineEdit; + QLineEdit *inputMaskLineEdit; + QLineEdit *accessLineEdit; +}; + +#endif diff --git a/tests/manual/xembed-widgets/xembed-widgets.pro b/tests/manual/xembed-widgets/xembed-widgets.pro new file mode 100644 index 0000000000..e406ee47fd --- /dev/null +++ b/tests/manual/xembed-widgets/xembed-widgets.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET= lineedits +QT += widgets + +SOURCES += \ + main.cpp \ + window.cpp +HEADERS += \ + window.h |