diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-01-10 01:01:15 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-01-10 01:01:15 +0100 |
commit | 0dc5562fa4f01140e98e55ceaa743b0f4fc276c7 (patch) | |
tree | 85fe2bfd06469a8d92a1d4ab233bc14d1b57aff4 | |
parent | 6074ebf728668288e082cf7dca15de215cc0f653 (diff) | |
parent | 5507d0f1b04ea6b1d91be9ade30bc31d1830c220 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I784e23d7913294225686879c9bd77dafe3580bac
32 files changed, 1531 insertions, 162 deletions
diff --git a/examples/corelib/serialization/convert/jsonconverter.cpp b/examples/corelib/serialization/convert/jsonconverter.cpp index 80d1cc6827..ec24af703d 100644 --- a/examples/corelib/serialization/convert/jsonconverter.cpp +++ b/examples/corelib/serialization/convert/jsonconverter.cpp @@ -57,7 +57,6 @@ #include <QJsonValue> static JsonConverter jsonConverter; -static BinaryJsonConverter BinaryJsonConverter; static const char optionHelp[] = "compact=no|yes Use compact JSON form.\n"; @@ -151,62 +150,3 @@ void JsonConverter::saveFile(QIODevice *f, const QVariant &contents, const QStri f->write(convertFromVariant(contents).toJson(format)); } - -QString BinaryJsonConverter::name() -{ - return "binary-json"; -} - -Converter::Direction BinaryJsonConverter::directions() -{ - return InOut; -} - -Converter::Options BinaryJsonConverter::outputOptions() -{ - return {}; -} - -const char *BinaryJsonConverter::optionsHelp() -{ - return nullptr; -} - -bool BinaryJsonConverter::probeFile(QIODevice *f) -{ - return f->isReadable() && f->peek(4) == "qbjs"; -} - -QVariant BinaryJsonConverter::loadFile(QIODevice *f, Converter *&outputConverter) -{ - if (!outputConverter) - outputConverter = &jsonConverter; - - QJsonDocument doc; - if (auto file = qobject_cast<QFile *>(f)) { - uchar *ptr = file->map(0, file->size()); - if (ptr) - doc = QJsonDocument::fromRawData(reinterpret_cast<char *>(ptr), file->size()); - } - - if (doc.isNull()) - doc = QJsonDocument::fromBinaryData(f->readAll()); - - if (!doc.isObject() && !doc.isArray()) { - fprintf(stderr, "Failed to load Binary JSON.\n"); - exit(EXIT_FAILURE); - } - if (outputConverter == null) - return QVariant(); - return doc.toVariant(); -} - -void BinaryJsonConverter::saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) -{ - if (!options.isEmpty()) { - fprintf(stderr, "Unknown option '%s' to JSON output. This format has no options.\n", qPrintable(options.first())); - exit(EXIT_FAILURE); - } - - f->write(convertFromVariant(contents).toBinaryData()); -} diff --git a/examples/corelib/serialization/convert/jsonconverter.h b/examples/corelib/serialization/convert/jsonconverter.h index 17170603c7..445a0e6695 100644 --- a/examples/corelib/serialization/convert/jsonconverter.h +++ b/examples/corelib/serialization/convert/jsonconverter.h @@ -69,17 +69,4 @@ public: void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override; }; -class BinaryJsonConverter : public Converter -{ - // Converter interface -public: - QString name() override; - Direction directions() override; - Options outputOptions() override; - const char *optionsHelp() override; - bool probeFile(QIODevice *f) override; - QVariant loadFile(QIODevice *f, Converter *&outputConverter) override; - void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override; -}; - #endif // JSONCONVERTER_H diff --git a/examples/corelib/serialization/savegame/doc/src/savegame.qdoc b/examples/corelib/serialization/savegame/doc/src/savegame.qdoc index a35f763430..e20cb6bc6c 100644 --- a/examples/corelib/serialization/savegame/doc/src/savegame.qdoc +++ b/examples/corelib/serialization/savegame/doc/src/savegame.qdoc @@ -37,8 +37,8 @@ game generally involves serializing each game object's member variables to a file. Many formats can be used for this purpose, one of which is JSON. With QJsonDocument, you also have the ability to serialize a document in a - binary format, which is great if you don't want the save file to be - readable, or if you need to keep the file size down. + \l {https://tools.ietf.org/html/rfc7049} {CBOR} format, which is great if you + don't want the save file to be readable, or if you need to keep the file size down. In this example, we'll demonstrate how to save and load a simple game to and from JSON and binary formats. @@ -133,7 +133,7 @@ When loading a saved game in loadGame(), the first thing we do is open the save file based on which format it was saved to; \c "save.json" for JSON, - and \c "save.dat" for binary. We print a warning and return \c false if the + and \c "save.dat" for CBOR. We print a warning and return \c false if the file couldn't be opened. Since QJsonDocument's \l{QJsonDocument::fromJson()}{fromJson()} and @@ -172,7 +172,7 @@ \snippet serialization/savegame/main.cpp 1 When the player has finished, we save their game. For demonstration - purposes, we can serialize to either JSON or binary. You can examine the + purposes, we can serialize to either JSON or CBOR. You can examine the contents of the files in the same directory as the executable (or re-run the example, making sure to also specify the "load" option), although the binary save file will contain some garbage characters (which is normal). diff --git a/examples/corelib/serialization/savegame/game.cpp b/examples/corelib/serialization/savegame/game.cpp index c39362bc68..58fc087b1f 100644 --- a/examples/corelib/serialization/savegame/game.cpp +++ b/examples/corelib/serialization/savegame/game.cpp @@ -50,6 +50,8 @@ #include "game.h" +#include <QCborMap> +#include <QCborValue> #include <QFile> #include <QJsonArray> #include <QJsonDocument> @@ -122,14 +124,14 @@ bool Game::loadGame(Game::SaveFormat saveFormat) QJsonDocument loadDoc(saveFormat == Json ? QJsonDocument::fromJson(saveData) - : QJsonDocument::fromBinaryData(saveData)); + : QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject())); read(loadDoc.object()); QTextStream(stdout) << "Loaded save for " << loadDoc["player"]["name"].toString() << " using " - << (saveFormat != Json ? "binary " : "") << "JSON...\n"; + << (saveFormat != Json ? "CBOR" : "JSON") << "...\n"; return true; } //! [3] @@ -148,10 +150,9 @@ bool Game::saveGame(Game::SaveFormat saveFormat) const QJsonObject gameObject; write(gameObject); - QJsonDocument saveDoc(gameObject); saveFile.write(saveFormat == Json - ? saveDoc.toJson() - : saveDoc.toBinaryData()); + ? QJsonDocument(gameObject).toJson() + : QCborValue::fromJsonValue(gameObject).toCbor()); return true; } diff --git a/examples/widgets/doc/src/styles.qdoc b/examples/widgets/doc/src/styles.qdoc index 7a7ae20e91..014541a330 100644 --- a/examples/widgets/doc/src/styles.qdoc +++ b/examples/widgets/doc/src/styles.qdoc @@ -27,7 +27,6 @@ /*! \example widgets/styles - \meta {tag} {gallery} \title Styles Example \ingroup examples-widgets \brief The Styles example illustrates how to create custom widget diff --git a/examples/widgets/gallery/gallery.pro b/examples/widgets/gallery/gallery.pro new file mode 100644 index 0000000000..38bf8d6d8e --- /dev/null +++ b/examples/widgets/gallery/gallery.pro @@ -0,0 +1,10 @@ +QT += widgets +requires(qtConfig(combobox)) + +HEADERS = widgetgallery.h +SOURCES = main.cpp \ + widgetgallery.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/widgets/gallery +INSTALLS += target diff --git a/examples/widgets/gallery/main.cpp b/examples/widgets/gallery/main.cpp new file mode 100644 index 0000000000..7f1782c84e --- /dev/null +++ b/examples/widgets/gallery/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 "widgetgallery.h" + +int main(int argc, char *argv[]) +{ + bool useHighDpiScaling = true; + + for (int i = 1; i < argc; ++i) { + if (qstrcmp(argv[i], "--no-scaling") == 0) + useHighDpiScaling = false; + } + + if (useHighDpiScaling) { + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + } else { + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); + } + + QApplication app(argc, argv); + WidgetGallery gallery; + gallery.show(); + return QCoreApplication::exec(); +} diff --git a/examples/widgets/gallery/widgetgallery.cpp b/examples/widgets/gallery/widgetgallery.cpp new file mode 100644 index 0000000000..3bbe8943d1 --- /dev/null +++ b/examples/widgets/gallery/widgetgallery.cpp @@ -0,0 +1,474 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 "widgetgallery.h" + +#include <QApplication> +#include <QCheckBox> +#include <QComboBox> +#include <QCommandLinkButton> +#include <QDateTimeEdit> +#include <QDial> +#include <QDialogButtonBox> +#include <QFileSystemModel> +#include <QGridLayout> +#include <QGroupBox> +#include <QMenu> +#include <QLabel> +#include <QLineEdit> +#include <QListWidget> +#include <QPlainTextEdit> +#include <QProgressBar> +#include <QPushButton> +#include <QRadioButton> +#include <QScrollBar> +#include <QShortcut> +#include <QSpinBox> +#include <QStandardItemModel> +#include <QStyle> +#include <QStyleFactory> +#include <QTextBrowser> +#include <QTreeView> +#include <QTableWidget> +#include <QTextEdit> +#include <QToolBox> +#include <QToolButton> + +#include <QIcon> +#include <QDesktopServices> +#include <QScreen> +#include <QWindow> + +#include <QDebug> +#include <QLibraryInfo> +#include <QSysInfo> +#include <QTextStream> +#include <QTimer> + +static inline QString className(const QObject *o) +{ + return QString::fromUtf8(o->metaObject()->className()); +} + +static inline void setClassNameToolTip(QWidget *w) +{ + w->setToolTip(className(w)); +} + +static QString helpUrl(const QString &page) +{ + QString result; + QTextStream(&result) << "https://doc.qt.io/qt-" << QT_VERSION_MAJOR + << '/' << page << ".html"; + return result; +} + +static inline QString helpUrl(const QWidget *w) +{ + return helpUrl(className(w).toLower()); +} + +static void launchHelp(const QWidget *w) +{ + QDesktopServices::openUrl(helpUrl(w)); +} + +static void launchModuleHelp() +{ + QDesktopServices::openUrl(helpUrl(QLatin1String("qtwidgets-index"))); +} + +template <class Widget> +Widget *createWidget(const char *name, QWidget *parent = nullptr) +{ + auto result = new Widget(parent); + result->setObjectName(QLatin1String(name)); + setClassNameToolTip(result); + return result; +} + +template <class Widget, class Parameter> +Widget *createWidget1(const Parameter &p1, const char *name, QWidget *parent = nullptr) +{ + auto result = new Widget(p1, parent); + result->setObjectName(QLatin1String(name)); + setClassNameToolTip(result); + return result; +} + +QTextStream &operator<<(QTextStream &str, const QRect &r) +{ + str << r.width() << 'x' << r.height() << Qt::forcesign << r.x() << r.y() + << Qt::noforcesign; + return str; +} + +static QString highDpiScaleFactorRoundingPolicy() +{ + QString result; + QDebug(&result) << QGuiApplication::highDpiScaleFactorRoundingPolicy(); + if (result.endsWith(QLatin1Char(')'))) + result.chop(1); + const int lastSep = result.lastIndexOf(QLatin1String("::")); + if (lastSep != -1) + result.remove(0, lastSep + 2); + return result; +} + +WidgetGallery::WidgetGallery(QWidget *parent) + : QDialog(parent) + , progressBar(createProgressBar()) +{ + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + auto styleComboBox = createWidget<QComboBox>("styleComboBox"); + const QString defaultStyleName = QApplication::style()->objectName(); + QStringList styleNames = QStyleFactory::keys(); + for (int i = 1, size = styleNames.size(); i < size; ++i) { + if (defaultStyleName.compare(styleNames.at(i), Qt::CaseInsensitive) == 0) { + styleNames.swapItemsAt(0, i); + break; + } + } + styleComboBox->addItems(styleNames); + + auto styleLabel = createWidget1<QLabel>(tr("&Style:"), "styleLabel"); + styleLabel->setBuddy(styleComboBox); + + auto helpLabel = createWidget1<QLabel>(tr("Press F1 over a widget to see Documentation"), "helpLabel"); + + auto disableWidgetsCheckBox = createWidget1<QCheckBox>(tr("&Disable widgets"), "disableWidgetsCheckBox"); + + auto buttonsGroupBox = createButtonsGroupBox(); + auto itemViewTabWidget = createItemViewTabWidget(); + auto simpleInputWidgetsGroupBox = createSimpleInputWidgetsGroupBox(); + auto textToolBox = createTextToolBox(); + + connect(styleComboBox, &QComboBox::textActivated, + this, &WidgetGallery::changeStyle); + connect(disableWidgetsCheckBox, &QCheckBox::toggled, + buttonsGroupBox, &QWidget::setDisabled); + connect(disableWidgetsCheckBox, &QCheckBox::toggled, + textToolBox, &QWidget::setDisabled); + connect(disableWidgetsCheckBox, &QCheckBox::toggled, + itemViewTabWidget, &QWidget::setDisabled); + connect(disableWidgetsCheckBox, &QCheckBox::toggled, + simpleInputWidgetsGroupBox, &QWidget::setDisabled); + + auto topLayout = new QHBoxLayout; + topLayout->addWidget(styleLabel); + topLayout->addWidget(styleComboBox); + topLayout->addStretch(1); + topLayout->addWidget(helpLabel); + topLayout->addStretch(1); + topLayout->addWidget(disableWidgetsCheckBox); + + auto dialogButtonBox = createWidget1<QDialogButtonBox>(QDialogButtonBox::Help | QDialogButtonBox::Close, + "dialogButtonBox"); + connect(dialogButtonBox, &QDialogButtonBox::helpRequested, this, launchModuleHelp); + connect(dialogButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + auto mainLayout = new QGridLayout(this); + mainLayout->addLayout(topLayout, 0, 0, 1, 2); + mainLayout->addWidget(buttonsGroupBox, 1, 0); + mainLayout->addWidget(simpleInputWidgetsGroupBox, 1, 1); + mainLayout->addWidget(itemViewTabWidget, 2, 0); + mainLayout->addWidget(textToolBox, 2, 1); + mainLayout->addWidget(progressBar, 3, 0, 1, 2); + mainLayout->addWidget(dialogButtonBox, 4, 0, 1, 2); + + setWindowTitle(tr("Widget Gallery Qt %1").arg(QT_VERSION_STR)); + + new QShortcut(QKeySequence::HelpContents, this, this, &WidgetGallery::helpOnCurrentWidget); +} + +void WidgetGallery::setVisible(bool visible) +{ + QDialog::setVisible(visible); + if (visible) { + connect(windowHandle(), &QWindow::screenChanged, this, &WidgetGallery::updateSystemInfo); + updateSystemInfo(); + } +} + +void WidgetGallery::changeStyle(const QString &styleName) +{ + QApplication::setStyle(QStyleFactory::create(styleName)); +} + +void WidgetGallery::advanceProgressBar() +{ + int curVal = progressBar->value(); + int maxVal = progressBar->maximum(); + progressBar->setValue(curVal + (maxVal - curVal) / 100); +} + +QGroupBox *WidgetGallery::createButtonsGroupBox() +{ + auto result = createWidget1<QGroupBox>(tr("Buttons"), "buttonsGroupBox"); + + auto defaultPushButton = createWidget1<QPushButton>(tr("Default Push Button"), "defaultPushButton"); + defaultPushButton->setDefault(true); + + auto togglePushButton = createWidget1<QPushButton>(tr("Toggle Push Button"), "togglePushButton"); + togglePushButton->setCheckable(true); + togglePushButton->setChecked(true); + + auto flatPushButton = createWidget1<QPushButton>(tr("Flat Push Button"), "flatPushButton"); + flatPushButton->setFlat(true); + + auto toolButton = createWidget<QToolButton>("toolButton"); + toolButton->setText(tr("Tool Button")); + + auto menuToolButton = createWidget<QToolButton>("menuButton"); + menuToolButton->setText(tr("Menu Button")); + auto toolMenu = new QMenu(menuToolButton); + menuToolButton->setPopupMode(QToolButton::InstantPopup); + toolMenu->addAction("Option"); + toolMenu->addSeparator(); + auto action = toolMenu->addAction("Checkable Option"); + action->setCheckable(true); + menuToolButton->setMenu(toolMenu); + auto toolLayout = new QHBoxLayout; + toolLayout->addWidget(toolButton); + toolLayout->addWidget(menuToolButton); + + auto commandLinkButton = createWidget1<QCommandLinkButton>(tr("Command Link Button"), "commandLinkButton"); + commandLinkButton->setDescription(tr("Description")); + + auto buttonLayout = new QVBoxLayout; + buttonLayout->addWidget(defaultPushButton); + buttonLayout->addWidget(togglePushButton); + buttonLayout->addWidget(flatPushButton); + buttonLayout->addLayout(toolLayout); + buttonLayout->addWidget(commandLinkButton); + buttonLayout->addStretch(1); + + auto radioButton1 = createWidget1<QRadioButton>(tr("Radio button 1"), "radioButton1"); + auto radioButton2 = createWidget1<QRadioButton>(tr("Radio button 2"), "radioButton2"); + auto radioButton3 = createWidget1<QRadioButton>(tr("Radio button 3"), "radioButton3"); + radioButton1->setChecked(true); + + auto checkBox = createWidget1<QCheckBox>(tr("Tri-state check box"), "checkBox"); + checkBox->setTristate(true); + checkBox->setCheckState(Qt::PartiallyChecked); + + auto checkableLayout = new QVBoxLayout; + checkableLayout->addWidget(radioButton1); + checkableLayout->addWidget(radioButton2); + checkableLayout->addWidget(radioButton3); + checkableLayout->addWidget(checkBox); + checkableLayout->addStretch(1); + + auto mainLayout = new QHBoxLayout(result); + mainLayout->addLayout(buttonLayout); + mainLayout->addLayout(checkableLayout); + mainLayout->addStretch(); + return result; +} + +static QWidget *embedIntoHBoxLayout(QWidget *w, int margin = 5) +{ + auto result = new QWidget; + auto layout = new QHBoxLayout(result); + layout->setContentsMargins(margin, margin, margin, margin); + layout->addWidget(w); + return result; +} + +QToolBox *WidgetGallery::createTextToolBox() +{ + auto result = createWidget<QToolBox>("toolBox"); + + const QString plainText = tr("Twinkle, twinkle, little star,\n" + "How I wonder what you are.\n" + "Up above the world so high,\n" + "Like a diamond in the sky.\n" + "Twinkle, twinkle, little star,\n" + "How I wonder what you are!\n"); + // Create centered/italic HTML rich text + QString richText = QLatin1String("<html><head/><body><i>"); + for (const auto &line : plainText.splitRef(QLatin1Char('\n'))) + richText += QLatin1String("<center>") + line + QLatin1String("</center>"); + richText += QLatin1String("</i></body></html>"); + + auto textEdit = createWidget1<QTextEdit>(richText, "textEdit"); + auto plainTextEdit = createWidget1<QPlainTextEdit>(plainText, "plainTextEdit"); + + systemInfoTextBrowser = createWidget<QTextBrowser>("systemInfoTextBrowser"); + + result->addItem(embedIntoHBoxLayout(textEdit), tr("Text Edit")); + result->addItem(embedIntoHBoxLayout(plainTextEdit), tr("Plain Text Edit")); + result->addItem(embedIntoHBoxLayout(systemInfoTextBrowser), tr("Text Browser")); + return result; +} + +QTabWidget *WidgetGallery::createItemViewTabWidget() +{ + auto result = createWidget<QTabWidget>("bottomLeftTabWidget"); + result->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored); + + auto treeView = createWidget<QTreeView>("treeView"); + auto fileSystemModel = new QFileSystemModel(treeView); + fileSystemModel->setRootPath(QDir::rootPath()); + treeView->setModel(fileSystemModel); + + auto tableWidget = createWidget<QTableWidget>("tableWidget"); + tableWidget->setRowCount(10); + tableWidget->setColumnCount(10); + + auto listModel = new QStandardItemModel(0, 1, result); + listModel->appendRow(new QStandardItem(QIcon(QLatin1String(":/qt-project.org/styles/commonstyle/images/diropen-128.png")), + tr("Directory"))); + listModel->appendRow(new QStandardItem(QIcon(QLatin1String(":/qt-project.org/styles/commonstyle/images/computer-32.png")), + tr("Computer"))); + + auto listView = createWidget<QListView>("listView"); + listView->setModel(listModel); + + auto iconModeListView = createWidget<QListView>("iconModeListView"); + iconModeListView->setViewMode(QListView::IconMode); + iconModeListView->setModel(listModel); + + result->addTab(embedIntoHBoxLayout(treeView), tr("&Tree View")); + result->addTab(embedIntoHBoxLayout(tableWidget), tr("T&able")); + result->addTab(embedIntoHBoxLayout(listView), tr("&List")); + result->addTab(embedIntoHBoxLayout(iconModeListView), tr("&Icon Mode List")); + return result; +} + +QGroupBox *WidgetGallery::createSimpleInputWidgetsGroupBox() +{ + auto result = createWidget1<QGroupBox>(tr("Simple Input Widgets"), "bottomRightGroupBox"); + result->setCheckable(true); + result->setChecked(true); + + auto lineEdit = createWidget1<QLineEdit>("s3cRe7", "lineEdit"); + lineEdit->setClearButtonEnabled(true); + lineEdit->setEchoMode(QLineEdit::Password); + + auto spinBox = createWidget<QSpinBox>("spinBox", result); + spinBox->setValue(50); + + auto dateTimeEdit = createWidget<QDateTimeEdit>("dateTimeEdit", result); + dateTimeEdit->setDateTime(QDateTime::currentDateTime()); + + auto slider = createWidget<QSlider>("slider", result); + slider->setOrientation(Qt::Horizontal); + slider->setValue(40); + + auto scrollBar = createWidget<QScrollBar>("scrollBar", result); + scrollBar->setOrientation(Qt::Horizontal); + setClassNameToolTip(scrollBar); + scrollBar->setValue(60); + + auto dial = createWidget<QDial>("dial", result); + dial->setValue(30); + dial->setNotchesVisible(true); + + auto layout = new QGridLayout(result); + layout->addWidget(lineEdit, 0, 0, 1, 2); + layout->addWidget(spinBox, 1, 0, 1, 2); + layout->addWidget(dateTimeEdit, 2, 0, 1, 2); + layout->addWidget(slider, 3, 0); + layout->addWidget(scrollBar, 4, 0); + layout->addWidget(dial, 3, 1, 2, 1); + layout->setRowStretch(5, 1); + return result; +} + +QProgressBar *WidgetGallery::createProgressBar() +{ + auto result = createWidget<QProgressBar>("progressBar"); + result->setRange(0, 10000); + result->setValue(0); + + auto timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, &WidgetGallery::advanceProgressBar); + timer->start(1000); + return result; +} + +void WidgetGallery::updateSystemInfo() +{ + QString systemInfo; + QTextStream str(&systemInfo); + str << "<html><head/><body><h3>Build</h3><p>" << QLibraryInfo::build() << "</p>" + << "<h3>Operating System</h3><p>" << QSysInfo::prettyProductName() << "</p>" + << "<h3>Screens</h3><p>High DPI scale factor rounding policy: " + << highDpiScaleFactorRoundingPolicy() << "</p><ol>"; + const auto screens = QGuiApplication::screens(); + for (auto screen : screens) { + const bool current = screen == this->screen(); + str << "<li>"; + if (current) + str << "<i>"; + str << '"' << screen->name() << "\" " << screen->geometry() << ", " + << screen->logicalDotsPerInchX() << "DPI, DPR=" + << screen->devicePixelRatio(); + if (current) + str << "</i>"; + str << "</li>"; + } + str << "</ol></body></html>"; + systemInfoTextBrowser->setHtml(systemInfo); +} + +void WidgetGallery::helpOnCurrentWidget() +{ + // Skip over internal widgets + for (auto w = QApplication::widgetAt(QCursor::pos(screen())); w; w = w->parentWidget()) { + const QString name = w->objectName(); + if (!name.isEmpty() && !name.startsWith(QLatin1String("qt_"))) { + launchHelp(w); + break; + } + } +} diff --git a/examples/widgets/gallery/widgetgallery.h b/examples/widgets/gallery/widgetgallery.h new file mode 100644 index 0000000000..419c925190 --- /dev/null +++ b/examples/widgets/gallery/widgetgallery.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 The Qt Company Ltd 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 WIDGETGALLERY_H +#define WIDGETGALLERY_H + +#include <QDialog> + +QT_BEGIN_NAMESPACE +class QGroupBox; +class QProgressBar; +class QTabWidget; +class QTextBrowser; +class QToolBox; +QT_END_NAMESPACE + +class WidgetGallery : public QDialog +{ + Q_OBJECT + +public: + explicit WidgetGallery(QWidget *parent = nullptr); + + void setVisible(bool visible) override; + +private slots: + void changeStyle(const QString &styleName); + void advanceProgressBar(); + void helpOnCurrentWidget(); + void updateSystemInfo(); + +private: + static QGroupBox *createButtonsGroupBox(); + static QTabWidget *createItemViewTabWidget(); + static QGroupBox *createSimpleInputWidgetsGroupBox(); + QToolBox *createTextToolBox(); + QProgressBar *createProgressBar(); + + QProgressBar *progressBar; + QTextBrowser *systemInfoTextBrowser; +}; + +#endif // WIDGETGALLERY_H diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro index d975ea8307..99e1c71594 100644 --- a/examples/widgets/widgets.pro +++ b/examples/widgets/widgets.pro @@ -9,6 +9,7 @@ SUBDIRS = \ dialogs \ draganddrop \ effects \ + gallery \ gestures \ graphicsview \ itemviews \ diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index ed7d057a88..dcb44239a0 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1857,10 +1857,13 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom const QString &tmp_out, bool dep_lines, QStringList *deps, - bool existingDepsOnly) + bool existingDepsOnly, + bool checkCommandAvailability) { char buff[256]; QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell); + if (checkCommandAvailability && !canExecute(dep_cmd)) + return; dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd); if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) { QByteArray depData; diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h index 47e4c7531c..ab970c966f 100644 --- a/qmake/generators/makefile.h +++ b/qmake/generators/makefile.h @@ -87,7 +87,8 @@ protected: void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd, const QString &tmp_dep_cmd, const QString &inpf, const QString &tmp_out, bool dep_lines, QStringList *deps, - bool existingDepsOnly); + bool existingDepsOnly, + bool checkCommandAvailability = false); void writeExtraCompilerTargets(QTextStream &t); void writeExtraCompilerVariables(QTextStream &t); bool writeDummyMakefile(QTextStream &t); diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 5396eba72e..2b39a4baaa 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2351,33 +2351,15 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) if (!tmp_dep.isEmpty()) deps = tmp_dep; if (!tmp_dep_cmd.isEmpty()) { - // Execute dependency command, and add every line as a dep - char buff[256]; - QString dep_cmd = Project->replaceExtraCompilerVariables( - tmp_dep_cmd, inFile, out, MakefileGenerator::LocalShell); - if(Project->canExecute(dep_cmd)) { - dep_cmd.prepend(QLatin1String("cd ") - + IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false)) - + QLatin1String(" && ")); - if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) { - QString indeps; - while(!feof(proc)) { - int read_in = (int)fread(buff, 1, 255, proc); - if(!read_in) - break; - indeps += QByteArray(buff, read_in); - } - QT_PCLOSE(proc); - if(!indeps.isEmpty()) { - QStringList extradeps = indeps.split(QLatin1Char('\n')); - for (int i = 0; i < extradeps.count(); ++i) { - QString dd = extradeps.at(i).simplified(); - if (!dd.isEmpty()) - deps += Project->fileFixify(dd, MakefileGenerator::FileFixifyFromOutdir); - } - } - } - } + const QString dep_cd_cmd = QLatin1String("cd ") + + IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false)) + + QLatin1String(" && "); + Project->callExtraCompilerDependCommand(extraCompilerName, dep_cd_cmd, tmp_dep_cmd, + inFile, out, + true, // dep_lines + &deps, + configs.contains("dep_existing_only"), + true /* checkCommandAvailability */); } for (int i = 0; i < deps.count(); ++i) deps[i] = Option::fixPathToTargetOS( diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index 8f38252274..c565b709d2 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -69,6 +69,8 @@ public: bool pchIsCFile = false; VCProjectWriter *projectWriter; + using Win32MakefileGenerator::callExtraCompilerDependCommand; + protected: virtual VCProjectWriter *createProjectWriter(); bool doDepends() const override { return false; } // Never necessary diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index b9b1902f34..fe0500bdef 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -237,7 +237,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other) the application. */ -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! Creates a QJsonDocument that uses the first \a size bytes from \a data. It assumes \a data contains a binary encoded JSON document. @@ -385,10 +385,13 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati QByteArray QJsonDocument::toBinaryData() const { int size = 0; +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED const char *raw = rawData(&size); +QT_WARNING_POP return QByteArray(raw, size); } -#endif // QT_CONFIG(binaryjson) +#endif // QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! Creates a QJsonDocument from the QVariant \a variant. diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h index 325e47b531..758bbfd9dd 100644 --- a/src/corelib/serialization/qjsondocument.h +++ b/src/corelib/serialization/qjsondocument.h @@ -111,13 +111,19 @@ public: BypassValidation }; -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use CBOR format instead") static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate); + + QT_DEPRECATED_X("Use CBOR format instead") const char *rawData(int *size) const; + QT_DEPRECATED_X("Use CBOR format instead") static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate); + + QT_DEPRECATED_X("Use CBOR format instead") QByteArray toBinaryData() const; -#endif // QT_CONFIG(binaryjson) +#endif // QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) static QJsonDocument fromVariant(const QVariant &variant); QVariant toVariant() const; diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 8c1395857e..8a06ebe603 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -227,7 +227,10 @@ inline bool QPixmap::loadFromData(const QByteArray &buf, const char *format, #if QT_DEPRECATED_SINCE(5, 0) inline QPixmap QPixmap::alphaChannel() const { + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED return QPixmap::fromImage(toImage().alphaChannel()); + QT_WARNING_POP } inline void QPixmap::setAlphaChannel(const QPixmap &p) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 2291241ef6..03ea937ab3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -153,7 +153,7 @@ Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorR // that behavior by disabling rounding by default. Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; #else - Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor; + Qt::HighDpiScaleFactorRoundingPolicy::Round; #endif bool QGuiApplicationPrivate::highDpiScalingUpdated = false; @@ -3554,8 +3554,8 @@ Qt::ApplicationState QGuiApplication::applicationState() environment variable. The QGuiApplication::highDpiScaleFactorRoundingPolicy() accessor will reflect the environment, if set. - The default value is Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor. - On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThough, + The default value is Qt::HighDpiScaleFactorRoundingPolicy::Round. + On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThrough, which preserves historical behavior from earlier Qt versions. */ void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy) diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index d0f73f6aa7..7e9b7d7b8e 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -342,8 +342,11 @@ bool QShaderDescription::isValid() const */ QByteArray QShaderDescription::toBinaryJson() const { -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED return d->makeDoc().toBinaryData(); +QT_WARNING_POP #else qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature"); return QByteArray(); @@ -382,8 +385,11 @@ QByteArray QShaderDescription::toJson() const QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) { QShaderDescription desc; -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data)); +QT_WARNING_POP #else Q_UNUSED(data); qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); diff --git a/src/network/configure.json b/src/network/configure.json index 6bc71469dc..496401749f 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -94,6 +94,10 @@ "condition": "config.msvc" }, { + "libs": "-lssl_arm64-v8a -lcrypto_arm64-v8a", + "condition": "config.android" + }, + { "libs": "-lssl -lcrypto", "condition": "!config.msvc" } @@ -432,7 +436,7 @@ "report": [ { "type": "note", - "condition": "features.openssl-linked && libs.openssl.source != 0 + "condition": "!config.android && features.openssl-linked && libs.openssl.source != 0 && input.openssl.prefix == '' && input.openssl.libs == '' && input.openssl.libs.debug == ''", "message": "When linking against OpenSSL, you can override the default library names through OPENSSL_LIBS. diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri index 0c8b9ccd40..dfbf539303 100644 --- a/src/network/ssl/ssl.pri +++ b/src/network/ssl/ssl.pri @@ -115,9 +115,11 @@ qtConfig(ssl) { # - libs in <OPENSSL_DIR>\lib\VC\static # - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD" - qtConfig(openssl-linked): \ - QMAKE_USE_FOR_PRIVATE += openssl - else: \ + qtConfig(openssl-linked): { + android { + build_pass: LIBS_PRIVATE += -lssl_$${QT_ARCH} -lcrypto_$${QT_ARCH} + } else: QMAKE_USE_FOR_PRIVATE += openssl + } else: \ QMAKE_USE_FOR_PRIVATE += openssl/nolink win32 { LIBS_PRIVATE += -lcrypt32 diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index ad94ba9c77..a4ec78f27b 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -544,7 +544,7 @@ void resizeWindow(QWindow *window, QWasmWindow::ResizeMode mode, void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent) { - auto timestamp = mouseEvent->timestamp; + auto timestamp = emscripten_date_now(); QPoint targetPoint(mouseEvent->targetX, mouseEvent->targetY); QPoint globalPoint = screen()->geometry().topLeft() + targetPoint; @@ -670,7 +670,7 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh QWasmEventTranslator *translator = (QWasmEventTranslator*)userData; Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent); - auto timestamp = mouseEvent.timestamp; + auto timestamp = emscripten_date_now(); QPoint targetPoint(mouseEvent.targetX, mouseEvent.targetY); QPoint globalPoint = eventTranslator->screen()->geometry().topLeft() + targetPoint; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 23ed80ab5a..adca902c69 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1394,6 +1394,8 @@ void QXcbWindow::propagateSizeHints() } xcb_icccm_set_wm_normal_hints(xcb_connection(), m_window, &hints); + + m_sizeHintsScaleFactor = QHighDpiScaling::scaleAndOrigin(screen()).factor; } void QXcbWindow::requestActivateWindow() @@ -1785,6 +1787,9 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * // will make the comparison later. QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); + if (!qFuzzyCompare(QHighDpiScaling::scaleAndOrigin(newScreen).factor, m_sizeHintsScaleFactor)) + propagateSizeHints(); + // Send the synthetic expose event on resize only when the window is shrinked, // because the "XCB_GRAVITY_NORTH_WEST" flag doesn't send it automatically. if (!m_oldWindowSize.isEmpty() diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 13b37db028..976a442b11 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -278,6 +278,8 @@ protected: QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr; int m_swapInterval = -1; + + qreal m_sizeHintsScaleFactor = 1.0; }; class QXcbForeignWindow : public QXcbWindow diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf index 73310221cf..52e1480295 100644 --- a/src/testlib/doc/qttestlib.qdocconf +++ b/src/testlib/doc/qttestlib.qdocconf @@ -28,7 +28,7 @@ qhp.QtTestLib.subprojects.classes.sortPages = true tagfile = ../../../doc/qttestlib/qttestlib.tags -depends += qtcore qtdoc qtwidgets qtgui qmake qtqmltest +depends += qtcore qtdoc qtwidgets qtgui qmake qtqmltest qtcmake headerdirs += .. diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index 688cc2f2f6..89edabf3f3 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -85,7 +85,7 @@ You can use a Qt Creator wizard to create a project that contains Qt tests and build and run them directly from Qt Creator. For more information, see - \l {Running Autotests}. + \l {Qt Creator: Running Autotests}{Running Autotests}. \section1 Creating a Test @@ -146,7 +146,7 @@ \section2 Building with CMake and CTest - You can use \l {CMake and CTest} to create a test. + You can use \l {Building with CMake and CTest} to create a test. \l{https://cmake.org/cmake/help/latest/manual/ctest.1.html}{CTest} enables you to include or exclude tests based on a regular expression that is matched against the test name. You can further apply the \c LABELS property diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 85542a75f8..9568e35639 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1868,7 +1868,7 @@ bool QApplication::event(QEvent *e) closeAllWindows(); for (auto *w : topLevelWidgets()) { if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) && - (!(w->windowType() == Qt::Dialog) || !w->parentWidget())) { + (!(w->windowType() == Qt::Dialog) || !w->parentWidget()) && !w->testAttribute(Qt::WA_DontShowOnScreen)) { e->ignore(); return true; } diff --git a/src/widgets/util/qsystemtrayicon_qpa.cpp b/src/widgets/util/qsystemtrayicon_qpa.cpp index c0bf058681..f2b0819132 100644 --- a/src/widgets/util/qsystemtrayicon_qpa.cpp +++ b/src/widgets/util/qsystemtrayicon_qpa.cpp @@ -42,6 +42,7 @@ #include <QtGui/qpa/qplatformsystemtrayicon.h> #include <qpa/qplatformtheme.h> #include <private/qguiapplication_p.h> +#include <private/qhighdpiscaling_p.h> #include <QApplication> #include <QStyle> @@ -75,10 +76,14 @@ void QSystemTrayIconPrivate::remove_sys() QRect QSystemTrayIconPrivate::geometry_sys() const { - if (qpa_sys) - return qpa_sys->geometry(); - else + if (!qpa_sys) return QRect(); + auto screen = QGuiApplication::primaryScreen(); +#if QT_CONFIG(menu) + if (menu) + screen = menu->screen(); +#endif + return QHighDpi::fromNativePixels(qpa_sys->geometry(), screen); } void QSystemTrayIconPrivate::updateIcon_sys() diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp index 47ce9a6f63..631bcce508 100644 --- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp @@ -221,6 +221,8 @@ private Q_SLOTS: void comparison(); + void overloadResolution(); + private: template <typename String> void conversion_tests(String arg) const; @@ -678,5 +680,61 @@ void tst_QStringView::comparison() QVERIFY(bb.compare(aa) > 0); } +namespace QStringViewOverloadResolution { +static void test(QString) = delete; +static void test(QStringView) {} +} + +// Compile-time only test: overload resolution prefers QStringView over QString +void tst_QStringView::overloadResolution() +{ + { + QChar qcharArray[42] = {}; + QStringViewOverloadResolution::test(qcharArray); + QChar *qcharPointer = qcharArray; + QStringViewOverloadResolution::test(qcharPointer); + } + + { + ushort ushortArray[42] = {}; + QStringViewOverloadResolution::test(ushortArray); + ushort *ushortPointer = ushortArray; + QStringViewOverloadResolution::test(ushortPointer); + } + + { + QStringRef stringRef; + QStringViewOverloadResolution::test(stringRef); + QStringViewOverloadResolution::test(qAsConst(stringRef)); + QStringViewOverloadResolution::test(std::move(stringRef)); + } + +#if defined(Q_OS_WIN) + { + wchar_t wchartArray[42] = {}; + QStringViewOverloadResolution::test(wchartArray); + QStringViewOverloadResolution::test(L"test"); + } +#endif + +#if defined(Q_COMPILER_UNICODE_STRINGS) + { + char16_t char16Array[] = u"test"; + QStringViewOverloadResolution::test(char16Array); + char16_t *char16Pointer = char16Array; + QStringViewOverloadResolution::test(char16Pointer); + } +#endif + +#if defined(Q_STDLIB_UNICODE_STRINGS) + { + std::u16string string; + QStringViewOverloadResolution::test(string); + QStringViewOverloadResolution::test(qAsConst(string)); + QStringViewOverloadResolution::test(std::move(string)); + } +#endif +} + QTEST_APPLESS_MAIN(tst_QStringView) #include "tst_qstringview.moc" diff --git a/tests/auto/tools/uic/baseline/config.ui.py b/tests/auto/tools/uic/baseline/config.ui.py new file mode 100644 index 0000000000..f7e1ffc773 --- /dev/null +++ b/tests/auto/tools/uic/baseline/config.ui.py @@ -0,0 +1,678 @@ +# -*- coding: utf-8 -*- + +##################################################################### +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the autotests of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## 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 The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +##################################################################### + +################################################################################ +## Form generated from reading UI file 'config.ui' +## +## Created by: Qt User Interface Compiler version 5.14.1 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint, + QRect, QSize, QUrl, Qt) +from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont, + QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap, + QRadialGradient) +from PySide2.QtWidgets import * + +import GammaView + + +class Ui_Config(object): + def setupUi(self, Config): + if Config.objectName(): + Config.setObjectName(u"Config") + Config.resize(600, 650) + Config.setSizeGripEnabled(True) + self.vboxLayout = QVBoxLayout(Config) + self.vboxLayout.setSpacing(6) + self.vboxLayout.setContentsMargins(11, 11, 11, 11) + self.vboxLayout.setObjectName(u"vboxLayout") + self.vboxLayout.setContentsMargins(8, 8, 8, 8) + self.hboxLayout = QHBoxLayout() + self.hboxLayout.setSpacing(6) + self.hboxLayout.setObjectName(u"hboxLayout") + self.hboxLayout.setContentsMargins(0, 0, 0, 0) + self.ButtonGroup1 = QGroupBox(Config) + self.ButtonGroup1.setObjectName(u"ButtonGroup1") + sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.ButtonGroup1.sizePolicy().hasHeightForWidth()) + self.ButtonGroup1.setSizePolicy(sizePolicy) + self.vboxLayout1 = QVBoxLayout(self.ButtonGroup1) + self.vboxLayout1.setSpacing(6) + self.vboxLayout1.setContentsMargins(11, 11, 11, 11) + self.vboxLayout1.setObjectName(u"vboxLayout1") + self.vboxLayout1.setContentsMargins(11, 11, 11, 11) + self.size_176_220 = QRadioButton(self.ButtonGroup1) + self.size_176_220.setObjectName(u"size_176_220") + + self.vboxLayout1.addWidget(self.size_176_220) + + self.size_240_320 = QRadioButton(self.ButtonGroup1) + self.size_240_320.setObjectName(u"size_240_320") + + self.vboxLayout1.addWidget(self.size_240_320) + + self.size_320_240 = QRadioButton(self.ButtonGroup1) + self.size_320_240.setObjectName(u"size_320_240") + + self.vboxLayout1.addWidget(self.size_320_240) + + self.size_640_480 = QRadioButton(self.ButtonGroup1) + self.size_640_480.setObjectName(u"size_640_480") + + self.vboxLayout1.addWidget(self.size_640_480) + + self.size_800_600 = QRadioButton(self.ButtonGroup1) + self.size_800_600.setObjectName(u"size_800_600") + + self.vboxLayout1.addWidget(self.size_800_600) + + self.size_1024_768 = QRadioButton(self.ButtonGroup1) + self.size_1024_768.setObjectName(u"size_1024_768") + + self.vboxLayout1.addWidget(self.size_1024_768) + + self.hboxLayout1 = QHBoxLayout() + self.hboxLayout1.setSpacing(6) + self.hboxLayout1.setObjectName(u"hboxLayout1") + self.hboxLayout1.setContentsMargins(0, 0, 0, 0) + self.size_custom = QRadioButton(self.ButtonGroup1) + self.size_custom.setObjectName(u"size_custom") + sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + sizePolicy1.setHorizontalStretch(0) + sizePolicy1.setVerticalStretch(0) + sizePolicy1.setHeightForWidth(self.size_custom.sizePolicy().hasHeightForWidth()) + self.size_custom.setSizePolicy(sizePolicy1) + + self.hboxLayout1.addWidget(self.size_custom) + + self.size_width = QSpinBox(self.ButtonGroup1) + self.size_width.setObjectName(u"size_width") + self.size_width.setMinimum(1) + self.size_width.setMaximum(1280) + self.size_width.setSingleStep(16) + self.size_width.setValue(400) + + self.hboxLayout1.addWidget(self.size_width) + + self.size_height = QSpinBox(self.ButtonGroup1) + self.size_height.setObjectName(u"size_height") + self.size_height.setMinimum(1) + self.size_height.setMaximum(1024) + self.size_height.setSingleStep(16) + self.size_height.setValue(300) + + self.hboxLayout1.addWidget(self.size_height) + + + self.vboxLayout1.addLayout(self.hboxLayout1) + + + self.hboxLayout.addWidget(self.ButtonGroup1) + + self.ButtonGroup2 = QGroupBox(Config) + self.ButtonGroup2.setObjectName(u"ButtonGroup2") + self.vboxLayout2 = QVBoxLayout(self.ButtonGroup2) + self.vboxLayout2.setSpacing(6) + self.vboxLayout2.setContentsMargins(11, 11, 11, 11) + self.vboxLayout2.setObjectName(u"vboxLayout2") + self.vboxLayout2.setContentsMargins(11, 11, 11, 11) + self.depth_1 = QRadioButton(self.ButtonGroup2) + self.depth_1.setObjectName(u"depth_1") + + self.vboxLayout2.addWidget(self.depth_1) + + self.depth_4gray = QRadioButton(self.ButtonGroup2) + self.depth_4gray.setObjectName(u"depth_4gray") + + self.vboxLayout2.addWidget(self.depth_4gray) + + self.depth_8 = QRadioButton(self.ButtonGroup2) + self.depth_8.setObjectName(u"depth_8") + + self.vboxLayout2.addWidget(self.depth_8) + + self.depth_12 = QRadioButton(self.ButtonGroup2) + self.depth_12.setObjectName(u"depth_12") + + self.vboxLayout2.addWidget(self.depth_12) + + self.depth_15 = QRadioButton(self.ButtonGroup2) + self.depth_15.setObjectName(u"depth_15") + + self.vboxLayout2.addWidget(self.depth_15) + + self.depth_16 = QRadioButton(self.ButtonGroup2) + self.depth_16.setObjectName(u"depth_16") + + self.vboxLayout2.addWidget(self.depth_16) + + self.depth_18 = QRadioButton(self.ButtonGroup2) + self.depth_18.setObjectName(u"depth_18") + + self.vboxLayout2.addWidget(self.depth_18) + + self.depth_24 = QRadioButton(self.ButtonGroup2) + self.depth_24.setObjectName(u"depth_24") + + self.vboxLayout2.addWidget(self.depth_24) + + self.depth_32 = QRadioButton(self.ButtonGroup2) + self.depth_32.setObjectName(u"depth_32") + + self.vboxLayout2.addWidget(self.depth_32) + + self.depth_32_argb = QRadioButton(self.ButtonGroup2) + self.depth_32_argb.setObjectName(u"depth_32_argb") + + self.vboxLayout2.addWidget(self.depth_32_argb) + + + self.hboxLayout.addWidget(self.ButtonGroup2) + + + self.vboxLayout.addLayout(self.hboxLayout) + + self.hboxLayout2 = QHBoxLayout() + self.hboxLayout2.setSpacing(6) + self.hboxLayout2.setObjectName(u"hboxLayout2") + self.hboxLayout2.setContentsMargins(0, 0, 0, 0) + self.TextLabel1_3 = QLabel(Config) + self.TextLabel1_3.setObjectName(u"TextLabel1_3") + + self.hboxLayout2.addWidget(self.TextLabel1_3) + + self.skin = QComboBox(Config) + self.skin.addItem("") + self.skin.setObjectName(u"skin") + sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) + sizePolicy2.setHorizontalStretch(0) + sizePolicy2.setVerticalStretch(0) + sizePolicy2.setHeightForWidth(self.skin.sizePolicy().hasHeightForWidth()) + self.skin.setSizePolicy(sizePolicy2) + + self.hboxLayout2.addWidget(self.skin) + + + self.vboxLayout.addLayout(self.hboxLayout2) + + self.touchScreen = QCheckBox(Config) + self.touchScreen.setObjectName(u"touchScreen") + + self.vboxLayout.addWidget(self.touchScreen) + + self.lcdScreen = QCheckBox(Config) + self.lcdScreen.setObjectName(u"lcdScreen") + + self.vboxLayout.addWidget(self.lcdScreen) + + self.spacerItem = QSpacerItem(20, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) + + self.vboxLayout.addItem(self.spacerItem) + + self.TextLabel1 = QLabel(Config) + self.TextLabel1.setObjectName(u"TextLabel1") + sizePolicy.setHeightForWidth(self.TextLabel1.sizePolicy().hasHeightForWidth()) + self.TextLabel1.setSizePolicy(sizePolicy) + self.TextLabel1.setWordWrap(True) + + self.vboxLayout.addWidget(self.TextLabel1) + + self.GroupBox1 = QGroupBox(Config) + self.GroupBox1.setObjectName(u"GroupBox1") + self.gridLayout = QGridLayout(self.GroupBox1) + self.gridLayout.setSpacing(6) + self.gridLayout.setContentsMargins(11, 11, 11, 11) + self.gridLayout.setObjectName(u"gridLayout") + self.gridLayout.setHorizontalSpacing(6) + self.gridLayout.setVerticalSpacing(6) + self.gridLayout.setContentsMargins(11, 11, 11, 11) + self.TextLabel3 = QLabel(self.GroupBox1) + self.TextLabel3.setObjectName(u"TextLabel3") + + self.gridLayout.addWidget(self.TextLabel3, 6, 0, 1, 1) + + self.bslider = QSlider(self.GroupBox1) + self.bslider.setObjectName(u"bslider") + palette = QPalette() + brush = QBrush(QColor(128, 128, 128, 255)) + brush.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.WindowText, brush) + brush1 = QBrush(QColor(0, 0, 255, 255)) + brush1.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.Button, brush1) + brush2 = QBrush(QColor(127, 127, 255, 255)) + brush2.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.Light, brush2) + brush3 = QBrush(QColor(38, 38, 255, 255)) + brush3.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.Midlight, brush3) + brush4 = QBrush(QColor(0, 0, 127, 255)) + brush4.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.Dark, brush4) + brush5 = QBrush(QColor(0, 0, 170, 255)) + brush5.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.Mid, brush5) + brush6 = QBrush(QColor(0, 0, 0, 255)) + brush6.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.Text, brush6) + brush7 = QBrush(QColor(255, 255, 255, 255)) + brush7.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.BrightText, brush7) + palette.setBrush(QPalette.Active, QPalette.ButtonText, brush) + palette.setBrush(QPalette.Active, QPalette.Base, brush7) + brush8 = QBrush(QColor(220, 220, 220, 255)) + brush8.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.Window, brush8) + palette.setBrush(QPalette.Active, QPalette.Shadow, brush6) + brush9 = QBrush(QColor(10, 95, 137, 255)) + brush9.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.Highlight, brush9) + palette.setBrush(QPalette.Active, QPalette.HighlightedText, brush7) + palette.setBrush(QPalette.Active, QPalette.Link, brush6) + palette.setBrush(QPalette.Active, QPalette.LinkVisited, brush6) + brush10 = QBrush(QColor(232, 232, 232, 255)) + brush10.setStyle(Qt.SolidPattern) + palette.setBrush(QPalette.Active, QPalette.AlternateBase, brush10) + palette.setBrush(QPalette.Inactive, QPalette.WindowText, brush) + palette.setBrush(QPalette.Inactive, QPalette.Button, brush1) + palette.setBrush(QPalette.Inactive, QPalette.Light, brush2) + palette.setBrush(QPalette.Inactive, QPalette.Midlight, brush3) + palette.setBrush(QPalette.Inactive, QPalette.Dark, brush4) + palette.setBrush(QPalette.Inactive, QPalette.Mid, brush5) + palette.setBrush(QPalette.Inactive, QPalette.Text, brush6) + palette.setBrush(QPalette.Inactive, QPalette.BrightText, brush7) + palette.setBrush(QPalette.Inactive, QPalette.ButtonText, brush) + palette.setBrush(QPalette.Inactive, QPalette.Base, brush7) + palette.setBrush(QPalette.Inactive, QPalette.Window, brush8) + palette.setBrush(QPalette.Inactive, QPalette.Shadow, brush6) + palette.setBrush(QPalette.Inactive, QPalette.Highlight, brush9) + palette.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush7) + palette.setBrush(QPalette.Inactive, QPalette.Link, brush6) + palette.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush6) + palette.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10) + palette.setBrush(QPalette.Disabled, QPalette.WindowText, brush) + palette.setBrush(QPalette.Disabled, QPalette.Button, brush1) + palette.setBrush(QPalette.Disabled, QPalette.Light, brush2) + palette.setBrush(QPalette.Disabled, QPalette.Midlight, brush3) + palette.setBrush(QPalette.Disabled, QPalette.Dark, brush4) + palette.setBrush(QPalette.Disabled, QPalette.Mid, brush5) + palette.setBrush(QPalette.Disabled, QPalette.Text, brush6) + palette.setBrush(QPalette.Disabled, QPalette.BrightText, brush7) + palette.setBrush(QPalette.Disabled, QPalette.ButtonText, brush) + palette.setBrush(QPalette.Disabled, QPalette.Base, brush7) + palette.setBrush(QPalette.Disabled, QPalette.Window, brush8) + palette.setBrush(QPalette.Disabled, QPalette.Shadow, brush6) + palette.setBrush(QPalette.Disabled, QPalette.Highlight, brush9) + palette.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush7) + palette.setBrush(QPalette.Disabled, QPalette.Link, brush6) + palette.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush6) + palette.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10) + self.bslider.setPalette(palette) + self.bslider.setMaximum(400) + self.bslider.setValue(100) + self.bslider.setOrientation(Qt.Horizontal) + + self.gridLayout.addWidget(self.bslider, 6, 1, 1, 1) + + self.blabel = QLabel(self.GroupBox1) + self.blabel.setObjectName(u"blabel") + + self.gridLayout.addWidget(self.blabel, 6, 2, 1, 1) + + self.TextLabel2 = QLabel(self.GroupBox1) + self.TextLabel2.setObjectName(u"TextLabel2") + + self.gridLayout.addWidget(self.TextLabel2, 4, 0, 1, 1) + + self.gslider = QSlider(self.GroupBox1) + self.gslider.setObjectName(u"gslider") + palette1 = QPalette() + palette1.setBrush(QPalette.Active, QPalette.WindowText, brush) + brush11 = QBrush(QColor(0, 255, 0, 255)) + brush11.setStyle(Qt.SolidPattern) + palette1.setBrush(QPalette.Active, QPalette.Button, brush11) + brush12 = QBrush(QColor(127, 255, 127, 255)) + brush12.setStyle(Qt.SolidPattern) + palette1.setBrush(QPalette.Active, QPalette.Light, brush12) + brush13 = QBrush(QColor(38, 255, 38, 255)) + brush13.setStyle(Qt.SolidPattern) + palette1.setBrush(QPalette.Active, QPalette.Midlight, brush13) + brush14 = QBrush(QColor(0, 127, 0, 255)) + brush14.setStyle(Qt.SolidPattern) + palette1.setBrush(QPalette.Active, QPalette.Dark, brush14) + brush15 = QBrush(QColor(0, 170, 0, 255)) + brush15.setStyle(Qt.SolidPattern) + palette1.setBrush(QPalette.Active, QPalette.Mid, brush15) + palette1.setBrush(QPalette.Active, QPalette.Text, brush6) + palette1.setBrush(QPalette.Active, QPalette.BrightText, brush7) + palette1.setBrush(QPalette.Active, QPalette.ButtonText, brush) + palette1.setBrush(QPalette.Active, QPalette.Base, brush7) + palette1.setBrush(QPalette.Active, QPalette.Window, brush8) + palette1.setBrush(QPalette.Active, QPalette.Shadow, brush6) + palette1.setBrush(QPalette.Active, QPalette.Highlight, brush9) + palette1.setBrush(QPalette.Active, QPalette.HighlightedText, brush7) + palette1.setBrush(QPalette.Active, QPalette.Link, brush6) + palette1.setBrush(QPalette.Active, QPalette.LinkVisited, brush6) + palette1.setBrush(QPalette.Active, QPalette.AlternateBase, brush10) + palette1.setBrush(QPalette.Inactive, QPalette.WindowText, brush) + palette1.setBrush(QPalette.Inactive, QPalette.Button, brush11) + palette1.setBrush(QPalette.Inactive, QPalette.Light, brush12) + palette1.setBrush(QPalette.Inactive, QPalette.Midlight, brush13) + palette1.setBrush(QPalette.Inactive, QPalette.Dark, brush14) + palette1.setBrush(QPalette.Inactive, QPalette.Mid, brush15) + palette1.setBrush(QPalette.Inactive, QPalette.Text, brush6) + palette1.setBrush(QPalette.Inactive, QPalette.BrightText, brush7) + palette1.setBrush(QPalette.Inactive, QPalette.ButtonText, brush) + palette1.setBrush(QPalette.Inactive, QPalette.Base, brush7) + palette1.setBrush(QPalette.Inactive, QPalette.Window, brush8) + palette1.setBrush(QPalette.Inactive, QPalette.Shadow, brush6) + palette1.setBrush(QPalette.Inactive, QPalette.Highlight, brush9) + palette1.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush7) + palette1.setBrush(QPalette.Inactive, QPalette.Link, brush6) + palette1.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush6) + palette1.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10) + palette1.setBrush(QPalette.Disabled, QPalette.WindowText, brush) + palette1.setBrush(QPalette.Disabled, QPalette.Button, brush11) + palette1.setBrush(QPalette.Disabled, QPalette.Light, brush12) + palette1.setBrush(QPalette.Disabled, QPalette.Midlight, brush13) + palette1.setBrush(QPalette.Disabled, QPalette.Dark, brush14) + palette1.setBrush(QPalette.Disabled, QPalette.Mid, brush15) + palette1.setBrush(QPalette.Disabled, QPalette.Text, brush6) + palette1.setBrush(QPalette.Disabled, QPalette.BrightText, brush7) + palette1.setBrush(QPalette.Disabled, QPalette.ButtonText, brush) + palette1.setBrush(QPalette.Disabled, QPalette.Base, brush7) + palette1.setBrush(QPalette.Disabled, QPalette.Window, brush8) + palette1.setBrush(QPalette.Disabled, QPalette.Shadow, brush6) + palette1.setBrush(QPalette.Disabled, QPalette.Highlight, brush9) + palette1.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush7) + palette1.setBrush(QPalette.Disabled, QPalette.Link, brush6) + palette1.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush6) + palette1.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10) + self.gslider.setPalette(palette1) + self.gslider.setMaximum(400) + self.gslider.setValue(100) + self.gslider.setOrientation(Qt.Horizontal) + + self.gridLayout.addWidget(self.gslider, 4, 1, 1, 1) + + self.glabel = QLabel(self.GroupBox1) + self.glabel.setObjectName(u"glabel") + + self.gridLayout.addWidget(self.glabel, 4, 2, 1, 1) + + self.TextLabel7 = QLabel(self.GroupBox1) + self.TextLabel7.setObjectName(u"TextLabel7") + + self.gridLayout.addWidget(self.TextLabel7, 0, 0, 1, 1) + + self.TextLabel8 = QLabel(self.GroupBox1) + self.TextLabel8.setObjectName(u"TextLabel8") + + self.gridLayout.addWidget(self.TextLabel8, 0, 2, 1, 1) + + self.gammaslider = QSlider(self.GroupBox1) + self.gammaslider.setObjectName(u"gammaslider") + palette2 = QPalette() + palette2.setBrush(QPalette.Active, QPalette.WindowText, brush) + palette2.setBrush(QPalette.Active, QPalette.Button, brush7) + palette2.setBrush(QPalette.Active, QPalette.Light, brush7) + palette2.setBrush(QPalette.Active, QPalette.Midlight, brush7) + brush16 = QBrush(QColor(127, 127, 127, 255)) + brush16.setStyle(Qt.SolidPattern) + palette2.setBrush(QPalette.Active, QPalette.Dark, brush16) + brush17 = QBrush(QColor(170, 170, 170, 255)) + brush17.setStyle(Qt.SolidPattern) + palette2.setBrush(QPalette.Active, QPalette.Mid, brush17) + palette2.setBrush(QPalette.Active, QPalette.Text, brush6) + palette2.setBrush(QPalette.Active, QPalette.BrightText, brush7) + palette2.setBrush(QPalette.Active, QPalette.ButtonText, brush) + palette2.setBrush(QPalette.Active, QPalette.Base, brush7) + palette2.setBrush(QPalette.Active, QPalette.Window, brush8) + palette2.setBrush(QPalette.Active, QPalette.Shadow, brush6) + palette2.setBrush(QPalette.Active, QPalette.Highlight, brush9) + palette2.setBrush(QPalette.Active, QPalette.HighlightedText, brush7) + palette2.setBrush(QPalette.Active, QPalette.Link, brush6) + palette2.setBrush(QPalette.Active, QPalette.LinkVisited, brush6) + palette2.setBrush(QPalette.Active, QPalette.AlternateBase, brush10) + palette2.setBrush(QPalette.Inactive, QPalette.WindowText, brush) + palette2.setBrush(QPalette.Inactive, QPalette.Button, brush7) + palette2.setBrush(QPalette.Inactive, QPalette.Light, brush7) + palette2.setBrush(QPalette.Inactive, QPalette.Midlight, brush7) + palette2.setBrush(QPalette.Inactive, QPalette.Dark, brush16) + palette2.setBrush(QPalette.Inactive, QPalette.Mid, brush17) + palette2.setBrush(QPalette.Inactive, QPalette.Text, brush6) + palette2.setBrush(QPalette.Inactive, QPalette.BrightText, brush7) + palette2.setBrush(QPalette.Inactive, QPalette.ButtonText, brush) + palette2.setBrush(QPalette.Inactive, QPalette.Base, brush7) + palette2.setBrush(QPalette.Inactive, QPalette.Window, brush8) + palette2.setBrush(QPalette.Inactive, QPalette.Shadow, brush6) + palette2.setBrush(QPalette.Inactive, QPalette.Highlight, brush9) + palette2.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush7) + palette2.setBrush(QPalette.Inactive, QPalette.Link, brush6) + palette2.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush6) + palette2.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10) + palette2.setBrush(QPalette.Disabled, QPalette.WindowText, brush) + palette2.setBrush(QPalette.Disabled, QPalette.Button, brush7) + palette2.setBrush(QPalette.Disabled, QPalette.Light, brush7) + palette2.setBrush(QPalette.Disabled, QPalette.Midlight, brush7) + palette2.setBrush(QPalette.Disabled, QPalette.Dark, brush16) + palette2.setBrush(QPalette.Disabled, QPalette.Mid, brush17) + palette2.setBrush(QPalette.Disabled, QPalette.Text, brush6) + palette2.setBrush(QPalette.Disabled, QPalette.BrightText, brush7) + palette2.setBrush(QPalette.Disabled, QPalette.ButtonText, brush) + palette2.setBrush(QPalette.Disabled, QPalette.Base, brush7) + palette2.setBrush(QPalette.Disabled, QPalette.Window, brush8) + palette2.setBrush(QPalette.Disabled, QPalette.Shadow, brush6) + palette2.setBrush(QPalette.Disabled, QPalette.Highlight, brush9) + palette2.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush7) + palette2.setBrush(QPalette.Disabled, QPalette.Link, brush6) + palette2.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush6) + palette2.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10) + self.gammaslider.setPalette(palette2) + self.gammaslider.setMaximum(400) + self.gammaslider.setValue(100) + self.gammaslider.setOrientation(Qt.Horizontal) + + self.gridLayout.addWidget(self.gammaslider, 0, 1, 1, 1) + + self.TextLabel1_2 = QLabel(self.GroupBox1) + self.TextLabel1_2.setObjectName(u"TextLabel1_2") + + self.gridLayout.addWidget(self.TextLabel1_2, 2, 0, 1, 1) + + self.rlabel = QLabel(self.GroupBox1) + self.rlabel.setObjectName(u"rlabel") + + self.gridLayout.addWidget(self.rlabel, 2, 2, 1, 1) + + self.rslider = QSlider(self.GroupBox1) + self.rslider.setObjectName(u"rslider") + palette3 = QPalette() + palette3.setBrush(QPalette.Active, QPalette.WindowText, brush) + brush18 = QBrush(QColor(255, 0, 0, 255)) + brush18.setStyle(Qt.SolidPattern) + palette3.setBrush(QPalette.Active, QPalette.Button, brush18) + brush19 = QBrush(QColor(255, 127, 127, 255)) + brush19.setStyle(Qt.SolidPattern) + palette3.setBrush(QPalette.Active, QPalette.Light, brush19) + brush20 = QBrush(QColor(255, 38, 38, 255)) + brush20.setStyle(Qt.SolidPattern) + palette3.setBrush(QPalette.Active, QPalette.Midlight, brush20) + brush21 = QBrush(QColor(127, 0, 0, 255)) + brush21.setStyle(Qt.SolidPattern) + palette3.setBrush(QPalette.Active, QPalette.Dark, brush21) + brush22 = QBrush(QColor(170, 0, 0, 255)) + brush22.setStyle(Qt.SolidPattern) + palette3.setBrush(QPalette.Active, QPalette.Mid, brush22) + palette3.setBrush(QPalette.Active, QPalette.Text, brush6) + palette3.setBrush(QPalette.Active, QPalette.BrightText, brush7) + palette3.setBrush(QPalette.Active, QPalette.ButtonText, brush) + palette3.setBrush(QPalette.Active, QPalette.Base, brush7) + palette3.setBrush(QPalette.Active, QPalette.Window, brush8) + palette3.setBrush(QPalette.Active, QPalette.Shadow, brush6) + palette3.setBrush(QPalette.Active, QPalette.Highlight, brush9) + palette3.setBrush(QPalette.Active, QPalette.HighlightedText, brush7) + palette3.setBrush(QPalette.Active, QPalette.Link, brush6) + palette3.setBrush(QPalette.Active, QPalette.LinkVisited, brush6) + palette3.setBrush(QPalette.Active, QPalette.AlternateBase, brush10) + palette3.setBrush(QPalette.Inactive, QPalette.WindowText, brush) + palette3.setBrush(QPalette.Inactive, QPalette.Button, brush18) + palette3.setBrush(QPalette.Inactive, QPalette.Light, brush19) + palette3.setBrush(QPalette.Inactive, QPalette.Midlight, brush20) + palette3.setBrush(QPalette.Inactive, QPalette.Dark, brush21) + palette3.setBrush(QPalette.Inactive, QPalette.Mid, brush22) + palette3.setBrush(QPalette.Inactive, QPalette.Text, brush6) + palette3.setBrush(QPalette.Inactive, QPalette.BrightText, brush7) + palette3.setBrush(QPalette.Inactive, QPalette.ButtonText, brush) + palette3.setBrush(QPalette.Inactive, QPalette.Base, brush7) + palette3.setBrush(QPalette.Inactive, QPalette.Window, brush8) + palette3.setBrush(QPalette.Inactive, QPalette.Shadow, brush6) + palette3.setBrush(QPalette.Inactive, QPalette.Highlight, brush9) + palette3.setBrush(QPalette.Inactive, QPalette.HighlightedText, brush7) + palette3.setBrush(QPalette.Inactive, QPalette.Link, brush6) + palette3.setBrush(QPalette.Inactive, QPalette.LinkVisited, brush6) + palette3.setBrush(QPalette.Inactive, QPalette.AlternateBase, brush10) + palette3.setBrush(QPalette.Disabled, QPalette.WindowText, brush) + palette3.setBrush(QPalette.Disabled, QPalette.Button, brush18) + palette3.setBrush(QPalette.Disabled, QPalette.Light, brush19) + palette3.setBrush(QPalette.Disabled, QPalette.Midlight, brush20) + palette3.setBrush(QPalette.Disabled, QPalette.Dark, brush21) + palette3.setBrush(QPalette.Disabled, QPalette.Mid, brush22) + palette3.setBrush(QPalette.Disabled, QPalette.Text, brush6) + palette3.setBrush(QPalette.Disabled, QPalette.BrightText, brush7) + palette3.setBrush(QPalette.Disabled, QPalette.ButtonText, brush) + palette3.setBrush(QPalette.Disabled, QPalette.Base, brush7) + palette3.setBrush(QPalette.Disabled, QPalette.Window, brush8) + palette3.setBrush(QPalette.Disabled, QPalette.Shadow, brush6) + palette3.setBrush(QPalette.Disabled, QPalette.Highlight, brush9) + palette3.setBrush(QPalette.Disabled, QPalette.HighlightedText, brush7) + palette3.setBrush(QPalette.Disabled, QPalette.Link, brush6) + palette3.setBrush(QPalette.Disabled, QPalette.LinkVisited, brush6) + palette3.setBrush(QPalette.Disabled, QPalette.AlternateBase, brush10) + self.rslider.setPalette(palette3) + self.rslider.setMaximum(400) + self.rslider.setValue(100) + self.rslider.setOrientation(Qt.Horizontal) + + self.gridLayout.addWidget(self.rslider, 2, 1, 1, 1) + + self.PushButton3 = QPushButton(self.GroupBox1) + self.PushButton3.setObjectName(u"PushButton3") + + self.gridLayout.addWidget(self.PushButton3, 8, 0, 1, 3) + + self.MyCustomWidget1 = GammaView(self.GroupBox1) + self.MyCustomWidget1.setObjectName(u"MyCustomWidget1") + + self.gridLayout.addWidget(self.MyCustomWidget1, 0, 3, 9, 1) + + + self.vboxLayout.addWidget(self.GroupBox1) + + self.hboxLayout3 = QHBoxLayout() + self.hboxLayout3.setSpacing(6) + self.hboxLayout3.setObjectName(u"hboxLayout3") + self.hboxLayout3.setContentsMargins(0, 0, 0, 0) + self.spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) + + self.hboxLayout3.addItem(self.spacerItem1) + + self.buttonOk = QPushButton(Config) + self.buttonOk.setObjectName(u"buttonOk") + self.buttonOk.setAutoDefault(True) + + self.hboxLayout3.addWidget(self.buttonOk) + + self.buttonCancel = QPushButton(Config) + self.buttonCancel.setObjectName(u"buttonCancel") + self.buttonCancel.setAutoDefault(True) + + self.hboxLayout3.addWidget(self.buttonCancel) + + + self.vboxLayout.addLayout(self.hboxLayout3) + + + self.retranslateUi(Config) + self.size_width.valueChanged.connect(self.size_custom.click) + self.size_height.valueChanged.connect(self.size_custom.click) + + self.buttonOk.setDefault(True) + + + QMetaObject.connectSlotsByName(Config) + # setupUi + + def retranslateUi(self, Config): + Config.setWindowTitle(QCoreApplication.translate("Config", u"Configure", None)) + self.ButtonGroup1.setTitle(QCoreApplication.translate("Config", u"Size", None)) + self.size_176_220.setText(QCoreApplication.translate("Config", u"176x220 \"SmartPhone\"", None)) + self.size_240_320.setText(QCoreApplication.translate("Config", u"240x320 \"PDA\"", None)) + self.size_320_240.setText(QCoreApplication.translate("Config", u"320x240 \"TV\" / \"QVGA\"", None)) + self.size_640_480.setText(QCoreApplication.translate("Config", u"640x480 \"VGA\"", None)) + self.size_800_600.setText(QCoreApplication.translate("Config", u"800x600", None)) + self.size_1024_768.setText(QCoreApplication.translate("Config", u"1024x768", None)) + self.size_custom.setText(QCoreApplication.translate("Config", u"Custom", None)) + self.ButtonGroup2.setTitle(QCoreApplication.translate("Config", u"Depth", None)) + self.depth_1.setText(QCoreApplication.translate("Config", u"1 bit monochrome", None)) + self.depth_4gray.setText(QCoreApplication.translate("Config", u"4 bit grayscale", None)) + self.depth_8.setText(QCoreApplication.translate("Config", u"8 bit", None)) + self.depth_12.setText(QCoreApplication.translate("Config", u"12 (16) bit", None)) + self.depth_15.setText(QCoreApplication.translate("Config", u"15 bit", None)) + self.depth_16.setText(QCoreApplication.translate("Config", u"16 bit", None)) + self.depth_18.setText(QCoreApplication.translate("Config", u"18 bit", None)) + self.depth_24.setText(QCoreApplication.translate("Config", u"24 bit", None)) + self.depth_32.setText(QCoreApplication.translate("Config", u"32 bit", None)) + self.depth_32_argb.setText(QCoreApplication.translate("Config", u"32 bit ARGB", None)) + self.TextLabel1_3.setText(QCoreApplication.translate("Config", u"Skin", None)) + self.skin.setItemText(0, QCoreApplication.translate("Config", u"None", None)) + + self.touchScreen.setText(QCoreApplication.translate("Config", u"Emulate touch screen (no mouse move)", None)) + self.lcdScreen.setText(QCoreApplication.translate("Config", u"Emulate LCD screen (Only with fixed zoom of 3.0 times magnification)", None)) + self.TextLabel1.setText(QCoreApplication.translate("Config", u"<p>Note that any applications using the virtual framebuffer will be terminated if you change the Size or Depth <i>above</i>. You may freely modify the Gamma <i>below</i>.", None)) + self.GroupBox1.setTitle(QCoreApplication.translate("Config", u"Gamma", None)) + self.TextLabel3.setText(QCoreApplication.translate("Config", u"Blue", None)) + self.blabel.setText(QCoreApplication.translate("Config", u"1.0", None)) + self.TextLabel2.setText(QCoreApplication.translate("Config", u"Green", None)) + self.glabel.setText(QCoreApplication.translate("Config", u"1.0", None)) + self.TextLabel7.setText(QCoreApplication.translate("Config", u"All", None)) + self.TextLabel8.setText(QCoreApplication.translate("Config", u"1.0", None)) + self.TextLabel1_2.setText(QCoreApplication.translate("Config", u"Red", None)) + self.rlabel.setText(QCoreApplication.translate("Config", u"1.0", None)) + self.PushButton3.setText(QCoreApplication.translate("Config", u"Set all to 1.0", None)) + self.buttonOk.setText(QCoreApplication.translate("Config", u"&OK", None)) + self.buttonCancel.setText(QCoreApplication.translate("Config", u"&Cancel", None)) + # retranslateUi + diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp index 5b2f1f008b..4c0a4bbe26 100644 --- a/tests/auto/tools/uic/tst_uic.cpp +++ b/tests/auto/tools/uic/tst_uic.cpp @@ -45,11 +45,23 @@ static const char diffToStderrEnvVar[] = "UIC_STDERR_DIFF"; struct TestEntry { + enum Flag + { + IdBasedTranslation = 0x1, + Python = 0x2, // Python baseline is present + DontTestPythonCompile = 0x4 // Do not test Python compilation + }; + Q_DECLARE_FLAGS(Flags, Flag) + QByteArray name; - QString baselineBaseName; + QString uiFileName; + QString baseLineFileName; QString generatedFileName; + Flags flags; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(TestEntry::Flags) + class tst_uic : public QObject { Q_OBJECT @@ -73,8 +85,8 @@ private Q_SLOTS: void compare(); void compare_data() const; - void python(); - void python_data() const; + void pythonCompile(); + void pythonCompile_data() const; void runCompare(); @@ -89,9 +101,12 @@ private: QString m_python; }; +static const char versionRegexp[] = + R"([*#][*#] Created by: Qt User Interface Compiler version \d{1,2}\.\d{1,2}\.\d{1,2})"; + tst_uic::tst_uic() : m_command(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/uic")) - , m_versionRegexp(QLatin1String(R"(\*\* Created by: Qt User Interface Compiler version \d{1,2}\.\d{1,2}\.\d{1,2})")) + , m_versionRegexp(QLatin1String(versionRegexp)) { } @@ -165,10 +180,27 @@ void tst_uic::populateTestEntries() m_testEntries.reserve(baselineFiles.size()); for (const QFileInfo &baselineFile : baselineFiles) { const QString baseName = baselineFile.baseName(); - const QString baselineBaseName = baseLinePrefix + baseName; - const QString generatedFile = generatedPrefix + baselineFile.fileName() - + QLatin1String(".h"); - m_testEntries.append(TestEntry{baseName.toLocal8Bit(), baselineBaseName, generatedFile}); + TestEntry entry; + // qprintsettingsoutput: variable named 'from' clashes with Python + if (baseName == QLatin1String("qprintsettingsoutput")) + entry.flags.setFlag(TestEntry::DontTestPythonCompile); + else if (baseName == QLatin1String("qttrid")) + entry.flags.setFlag(TestEntry::IdBasedTranslation); + entry.name = baseName.toLocal8Bit(); + entry.uiFileName = baselineFile.absoluteFilePath(); + entry.baseLineFileName = entry.uiFileName + QLatin1String(".h"); + const QString generatedFilePrefix = generatedPrefix + baselineFile.fileName(); + entry.generatedFileName = generatedFilePrefix + QLatin1String(".h"); + m_testEntries.append(entry); + // Check for a Python baseline + entry.baseLineFileName = entry.uiFileName + QLatin1String(".py"); + if (QFileInfo::exists(entry.baseLineFileName)) { + entry.name.append(QByteArrayLiteral("-python")); + entry.flags.setFlag(TestEntry::DontTestPythonCompile); + entry.flags.setFlag(TestEntry::Python); + entry.generatedFileName = generatedFilePrefix + QLatin1String(".py"); + m_testEntries.append(entry); + } } } @@ -237,9 +269,11 @@ void tst_uic::run_data() const for (const TestEntry &te : m_testEntries) { QStringList options; - if (te.name == QByteArrayLiteral("qttrid")) - options << QStringList(QLatin1String("-idbased")); - QTest::newRow(te.name.constData()) << (te.baselineBaseName + QLatin1String(".ui")) + if (te.flags.testFlag(TestEntry::IdBasedTranslation)) + options.append(QLatin1String("-idbased")); + if (te.flags.testFlag(TestEntry::Python)) + options << QLatin1String("-g") << QLatin1String("python"); + QTest::newRow(te.name.constData()) << te.uiFileName << te.generatedFileName << options; } } @@ -319,7 +353,7 @@ void tst_uic::compare_data() const QTest::addColumn<QString>("generatedFile"); for (const TestEntry &te : m_testEntries) { - QTest::newRow(te.name.constData()) << (te.baselineBaseName + QLatin1String(".ui.h")) + QTest::newRow(te.name.constData()) << te.baseLineFileName << te.generatedFileName; } } @@ -396,7 +430,8 @@ static inline QByteArray msgCompilePythonFailed(const QByteArray &error) return lines.join('\n'); } -void tst_uic::python_data() const +// Test Python code generation by compiling the file +void tst_uic::pythonCompile_data() const { QTest::addColumn<QString>("originalFile"); QTest::addColumn<QString>("generatedFile"); @@ -405,19 +440,15 @@ void tst_uic::python_data() const ? qMin(1, m_testEntries.size()) : m_testEntries.size(); for (int i = 0; i < size; ++i) { const TestEntry &te = m_testEntries.at(i); - // qprintsettingsoutput: variable named 'from' clashes with Python - if (!te.baselineBaseName.endsWith(QLatin1String("/qprintsettingsoutput"))) { - QString generatedFile = te.generatedFileName; - generatedFile.chop(1); // foo.h -> foo.py - generatedFile.append(QLatin1String("py")); + if (!te.flags.testFlag(TestEntry::DontTestPythonCompile)) { QTest::newRow(te.name.constData()) - << (te.baselineBaseName + QLatin1String(".ui")) - << generatedFile; + << te.uiFileName + << te.generatedFileName; } } } -void tst_uic::python() +void tst_uic::pythonCompile() { QFETCH(QString, originalFile); QFETCH(QString, generatedFile); diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index b5d2e68118..5b49e3484c 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -505,26 +505,27 @@ void tst_QSpinBox::valueChangedHelper(int value) actualValues << value; } -class MySpinBox: public QSpinBox +class ReadOnlyChangeTracker: public QSpinBox { public: - MySpinBox(QWidget *parent = 0) : QSpinBox(parent) {} + ReadOnlyChangeTracker(QWidget *parent = 0) : QSpinBox(parent) {} void changeEvent(QEvent *ev) { - eventsReceived.append(ev->type()); + if (ev->type() == QEvent::ReadOnlyChange) + ++readOnlyChangeEventCount; } - QList<QEvent::Type> eventsReceived; + int readOnlyChangeEventCount = 0; }; void tst_QSpinBox::setReadOnly() { - MySpinBox spin(0); + ReadOnlyChangeTracker spin(0); spin.show(); QTest::keyClick(&spin, Qt::Key_Up); QCOMPARE(spin.value(), 1); spin.setReadOnly(true); #ifndef Q_OS_WINRT // QTBUG-68297 - QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange); + QCOMPARE(spin.readOnlyChangeEventCount, 1); #endif QTest::keyClick(&spin, Qt::Key_Up); QCOMPARE(spin.value(), 1); @@ -532,7 +533,7 @@ void tst_QSpinBox::setReadOnly() QCOMPARE(spin.value(), 2); spin.setReadOnly(false); #ifndef Q_OS_WINRT // QTBUG-68297 - QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange << QEvent::ReadOnlyChange); + QCOMPARE(spin.readOnlyChangeEventCount, 2); #endif QTest::keyClick(&spin, Qt::Key_Up); QCOMPARE(spin.value(), 3); |