Merge remote-tracking branch 'origin/5.15' into dev

Change-Id: I784e23d7913294225686879c9bd77dafe3580bac
This commit is contained in:
Qt Forward Merge Bot 2020-01-10 01:01:15 +01:00
commit 0dc5562fa4
32 changed files with 1531 additions and 162 deletions

View File

@ -57,7 +57,6 @@
#include <QJsonValue> #include <QJsonValue>
static JsonConverter jsonConverter; static JsonConverter jsonConverter;
static BinaryJsonConverter BinaryJsonConverter;
static const char optionHelp[] = static const char optionHelp[] =
"compact=no|yes Use compact JSON form.\n"; "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)); 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());
}

View File

@ -69,17 +69,4 @@ public:
void saveFile(QIODevice *f, const QVariant &contents, const QStringList &options) override; 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 #endif // JSONCONVERTER_H

View File

@ -37,8 +37,8 @@
game generally involves serializing each game object's member variables 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. 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 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 \l {https://tools.ietf.org/html/rfc7049} {CBOR} format, which is great if you
readable, or if you need to keep the file size down. 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 In this example, we'll demonstrate how to save and load a simple game to
and from JSON and binary formats. 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 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, 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. file couldn't be opened.
Since QJsonDocument's \l{QJsonDocument::fromJson()}{fromJson()} and Since QJsonDocument's \l{QJsonDocument::fromJson()}{fromJson()} and
@ -172,7 +172,7 @@
\snippet serialization/savegame/main.cpp 1 \snippet serialization/savegame/main.cpp 1
When the player has finished, we save their game. For demonstration 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 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 the example, making sure to also specify the "load" option), although the
binary save file will contain some garbage characters (which is normal). binary save file will contain some garbage characters (which is normal).

View File

@ -50,6 +50,8 @@
#include "game.h" #include "game.h"
#include <QCborMap>
#include <QCborValue>
#include <QFile> #include <QFile>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
@ -122,14 +124,14 @@ bool Game::loadGame(Game::SaveFormat saveFormat)
QJsonDocument loadDoc(saveFormat == Json QJsonDocument loadDoc(saveFormat == Json
? QJsonDocument::fromJson(saveData) ? QJsonDocument::fromJson(saveData)
: QJsonDocument::fromBinaryData(saveData)); : QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject()));
read(loadDoc.object()); read(loadDoc.object());
QTextStream(stdout) << "Loaded save for " QTextStream(stdout) << "Loaded save for "
<< loadDoc["player"]["name"].toString() << loadDoc["player"]["name"].toString()
<< " using " << " using "
<< (saveFormat != Json ? "binary " : "") << "JSON...\n"; << (saveFormat != Json ? "CBOR" : "JSON") << "...\n";
return true; return true;
} }
//! [3] //! [3]
@ -148,10 +150,9 @@ bool Game::saveGame(Game::SaveFormat saveFormat) const
QJsonObject gameObject; QJsonObject gameObject;
write(gameObject); write(gameObject);
QJsonDocument saveDoc(gameObject);
saveFile.write(saveFormat == Json saveFile.write(saveFormat == Json
? saveDoc.toJson() ? QJsonDocument(gameObject).toJson()
: saveDoc.toBinaryData()); : QCborValue::fromJsonValue(gameObject).toCbor());
return true; return true;
} }

View File

@ -27,7 +27,6 @@
/*! /*!
\example widgets/styles \example widgets/styles
\meta {tag} {gallery}
\title Styles Example \title Styles Example
\ingroup examples-widgets \ingroup examples-widgets
\brief The Styles example illustrates how to create custom widget \brief The Styles example illustrates how to create custom widget

View File

@ -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

View File

@ -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();
}

View File

@ -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;
}
}
}

View File

@ -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

View File

@ -9,6 +9,7 @@ SUBDIRS = \
dialogs \ dialogs \
draganddrop \ draganddrop \
effects \ effects \
gallery \
gestures \ gestures \
graphicsview \ graphicsview \
itemviews \ itemviews \

View File

@ -1857,10 +1857,13 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom
const QString &tmp_out, const QString &tmp_out,
bool dep_lines, bool dep_lines,
QStringList *deps, QStringList *deps,
bool existingDepsOnly) bool existingDepsOnly,
bool checkCommandAvailability)
{ {
char buff[256]; char buff[256];
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell); 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); dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) { if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
QByteArray depData; QByteArray depData;

View File

@ -87,7 +87,8 @@ protected:
void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd, void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd,
const QString &tmp_dep_cmd, const QString &inpf, const QString &tmp_dep_cmd, const QString &inpf,
const QString &tmp_out, bool dep_lines, QStringList *deps, const QString &tmp_out, bool dep_lines, QStringList *deps,
bool existingDepsOnly); bool existingDepsOnly,
bool checkCommandAvailability = false);
void writeExtraCompilerTargets(QTextStream &t); void writeExtraCompilerTargets(QTextStream &t);
void writeExtraCompilerVariables(QTextStream &t); void writeExtraCompilerVariables(QTextStream &t);
bool writeDummyMakefile(QTextStream &t); bool writeDummyMakefile(QTextStream &t);

View File

@ -2351,33 +2351,15 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
if (!tmp_dep.isEmpty()) if (!tmp_dep.isEmpty())
deps = tmp_dep; deps = tmp_dep;
if (!tmp_dep_cmd.isEmpty()) { if (!tmp_dep_cmd.isEmpty()) {
// Execute dependency command, and add every line as a dep const QString dep_cd_cmd = QLatin1String("cd ")
char buff[256]; + IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
QString dep_cmd = Project->replaceExtraCompilerVariables( + QLatin1String(" && ");
tmp_dep_cmd, inFile, out, MakefileGenerator::LocalShell); Project->callExtraCompilerDependCommand(extraCompilerName, dep_cd_cmd, tmp_dep_cmd,
if(Project->canExecute(dep_cmd)) { inFile, out,
dep_cmd.prepend(QLatin1String("cd ") true, // dep_lines
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false)) &deps,
+ QLatin1String(" && ")); configs.contains("dep_existing_only"),
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) { true /* checkCommandAvailability */);
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);
}
}
}
}
} }
for (int i = 0; i < deps.count(); ++i) for (int i = 0; i < deps.count(); ++i)
deps[i] = Option::fixPathToTargetOS( deps[i] = Option::fixPathToTargetOS(

View File

@ -69,6 +69,8 @@ public:
bool pchIsCFile = false; bool pchIsCFile = false;
VCProjectWriter *projectWriter; VCProjectWriter *projectWriter;
using Win32MakefileGenerator::callExtraCompilerDependCommand;
protected: protected:
virtual VCProjectWriter *createProjectWriter(); virtual VCProjectWriter *createProjectWriter();
bool doDepends() const override { return false; } // Never necessary bool doDepends() const override { return false; } // Never necessary

View File

@ -237,7 +237,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other)
the application. 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 Creates a QJsonDocument that uses the first \a size bytes from
\a data. It assumes \a data contains a binary encoded JSON document. \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 QByteArray QJsonDocument::toBinaryData() const
{ {
int size = 0; int size = 0;
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
const char *raw = rawData(&size); const char *raw = rawData(&size);
QT_WARNING_POP
return QByteArray(raw, size); 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. Creates a QJsonDocument from the QVariant \a variant.

View File

@ -111,13 +111,19 @@ public:
BypassValidation 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); static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate);
QT_DEPRECATED_X("Use CBOR format instead")
const char *rawData(int *size) const; const char *rawData(int *size) const;
QT_DEPRECATED_X("Use CBOR format instead")
static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate); static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate);
QT_DEPRECATED_X("Use CBOR format instead")
QByteArray toBinaryData() const; QByteArray toBinaryData() const;
#endif // QT_CONFIG(binaryjson) #endif // QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15)
static QJsonDocument fromVariant(const QVariant &variant); static QJsonDocument fromVariant(const QVariant &variant);
QVariant toVariant() const; QVariant toVariant() const;

View File

@ -227,7 +227,10 @@ inline bool QPixmap::loadFromData(const QByteArray &buf, const char *format,
#if QT_DEPRECATED_SINCE(5, 0) #if QT_DEPRECATED_SINCE(5, 0)
inline QPixmap QPixmap::alphaChannel() const inline QPixmap QPixmap::alphaChannel() const
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
return QPixmap::fromImage(toImage().alphaChannel()); return QPixmap::fromImage(toImage().alphaChannel());
QT_WARNING_POP
} }
inline void QPixmap::setAlphaChannel(const QPixmap &p) inline void QPixmap::setAlphaChannel(const QPixmap &p)

View File

@ -153,7 +153,7 @@ Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorR
// that behavior by disabling rounding by default. // that behavior by disabling rounding by default.
Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; Qt::HighDpiScaleFactorRoundingPolicy::PassThrough;
#else #else
Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor; Qt::HighDpiScaleFactorRoundingPolicy::Round;
#endif #endif
bool QGuiApplicationPrivate::highDpiScalingUpdated = false; bool QGuiApplicationPrivate::highDpiScalingUpdated = false;
@ -3554,8 +3554,8 @@ Qt::ApplicationState QGuiApplication::applicationState()
environment variable. The QGuiApplication::highDpiScaleFactorRoundingPolicy() environment variable. The QGuiApplication::highDpiScaleFactorRoundingPolicy()
accessor will reflect the environment, if set. accessor will reflect the environment, if set.
The default value is Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor. The default value is Qt::HighDpiScaleFactorRoundingPolicy::Round.
On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThough, On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThrough,
which preserves historical behavior from earlier Qt versions. which preserves historical behavior from earlier Qt versions.
*/ */
void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy) void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy)

View File

@ -342,8 +342,11 @@ bool QShaderDescription::isValid() const
*/ */
QByteArray QShaderDescription::toBinaryJson() 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(); return d->makeDoc().toBinaryData();
QT_WARNING_POP
#else #else
qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature"); qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature");
return QByteArray(); return QByteArray();
@ -382,8 +385,11 @@ QByteArray QShaderDescription::toJson() const
QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data)
{ {
QShaderDescription desc; 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)); QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data));
QT_WARNING_POP
#else #else
Q_UNUSED(data); Q_UNUSED(data);
qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature");

View File

@ -93,6 +93,10 @@
"libs": "-llibssl -llibcrypto -lUser32 -lWs2_32 -lAdvapi32 -lCrypt32", "libs": "-llibssl -llibcrypto -lUser32 -lWs2_32 -lAdvapi32 -lCrypt32",
"condition": "config.msvc" "condition": "config.msvc"
}, },
{
"libs": "-lssl_arm64-v8a -lcrypto_arm64-v8a",
"condition": "config.android"
},
{ {
"libs": "-lssl -lcrypto", "libs": "-lssl -lcrypto",
"condition": "!config.msvc" "condition": "!config.msvc"
@ -432,7 +436,7 @@
"report": [ "report": [
{ {
"type": "note", "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 == ''", && input.openssl.prefix == '' && input.openssl.libs == '' && input.openssl.libs.debug == ''",
"message": "When linking against OpenSSL, you can override the default "message": "When linking against OpenSSL, you can override the default
library names through OPENSSL_LIBS. library names through OPENSSL_LIBS.

View File

@ -115,9 +115,11 @@ qtConfig(ssl) {
# - libs in <OPENSSL_DIR>\lib\VC\static # - 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" # - 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): \ qtConfig(openssl-linked): {
QMAKE_USE_FOR_PRIVATE += openssl android {
else: \ build_pass: LIBS_PRIVATE += -lssl_$${QT_ARCH} -lcrypto_$${QT_ARCH}
} else: QMAKE_USE_FOR_PRIVATE += openssl
} else: \
QMAKE_USE_FOR_PRIVATE += openssl/nolink QMAKE_USE_FOR_PRIVATE += openssl/nolink
win32 { win32 {
LIBS_PRIVATE += -lcrypt32 LIBS_PRIVATE += -lcrypt32

View File

@ -544,7 +544,7 @@ void resizeWindow(QWindow *window, QWasmWindow::ResizeMode mode,
void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent) void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent)
{ {
auto timestamp = mouseEvent->timestamp; auto timestamp = emscripten_date_now();
QPoint targetPoint(mouseEvent->targetX, mouseEvent->targetY); QPoint targetPoint(mouseEvent->targetX, mouseEvent->targetY);
QPoint globalPoint = screen()->geometry().topLeft() + targetPoint; QPoint globalPoint = screen()->geometry().topLeft() + targetPoint;
@ -670,7 +670,7 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh
QWasmEventTranslator *translator = (QWasmEventTranslator*)userData; QWasmEventTranslator *translator = (QWasmEventTranslator*)userData;
Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent); Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent);
auto timestamp = mouseEvent.timestamp; auto timestamp = emscripten_date_now();
QPoint targetPoint(mouseEvent.targetX, mouseEvent.targetY); QPoint targetPoint(mouseEvent.targetX, mouseEvent.targetY);
QPoint globalPoint = eventTranslator->screen()->geometry().topLeft() + targetPoint; QPoint globalPoint = eventTranslator->screen()->geometry().topLeft() + targetPoint;

View File

@ -1394,6 +1394,8 @@ void QXcbWindow::propagateSizeHints()
} }
xcb_icccm_set_wm_normal_hints(xcb_connection(), m_window, &hints); xcb_icccm_set_wm_normal_hints(xcb_connection(), m_window, &hints);
m_sizeHintsScaleFactor = QHighDpiScaling::scaleAndOrigin(screen()).factor;
} }
void QXcbWindow::requestActivateWindow() void QXcbWindow::requestActivateWindow()
@ -1785,6 +1787,9 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
// will make the comparison later. // will make the comparison later.
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); 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, // 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. // because the "XCB_GRAVITY_NORTH_WEST" flag doesn't send it automatically.
if (!m_oldWindowSize.isEmpty() if (!m_oldWindowSize.isEmpty()

View File

@ -278,6 +278,8 @@ protected:
QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr; QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr;
int m_swapInterval = -1; int m_swapInterval = -1;
qreal m_sizeHintsScaleFactor = 1.0;
}; };
class QXcbForeignWindow : public QXcbWindow class QXcbForeignWindow : public QXcbWindow

View File

@ -28,7 +28,7 @@ qhp.QtTestLib.subprojects.classes.sortPages = true
tagfile = ../../../doc/qttestlib/qttestlib.tags tagfile = ../../../doc/qttestlib/qttestlib.tags
depends += qtcore qtdoc qtwidgets qtgui qmake qtqmltest depends += qtcore qtdoc qtwidgets qtgui qmake qtqmltest qtcmake
headerdirs += .. headerdirs += ..

View File

@ -85,7 +85,7 @@
You can use a Qt Creator wizard to create a project that contains Qt tests 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 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 \section1 Creating a Test
@ -146,7 +146,7 @@
\section2 Building with CMake and CTest \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 \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 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 matched against the test name. You can further apply the \c LABELS property

View File

@ -1868,7 +1868,7 @@ bool QApplication::event(QEvent *e)
closeAllWindows(); closeAllWindows();
for (auto *w : topLevelWidgets()) { for (auto *w : topLevelWidgets()) {
if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) && 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(); e->ignore();
return true; return true;
} }

View File

@ -42,6 +42,7 @@
#include <QtGui/qpa/qplatformsystemtrayicon.h> #include <QtGui/qpa/qplatformsystemtrayicon.h>
#include <qpa/qplatformtheme.h> #include <qpa/qplatformtheme.h>
#include <private/qguiapplication_p.h> #include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
#include <QApplication> #include <QApplication>
#include <QStyle> #include <QStyle>
@ -75,10 +76,14 @@ void QSystemTrayIconPrivate::remove_sys()
QRect QSystemTrayIconPrivate::geometry_sys() const QRect QSystemTrayIconPrivate::geometry_sys() const
{ {
if (qpa_sys) if (!qpa_sys)
return qpa_sys->geometry();
else
return QRect(); 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() void QSystemTrayIconPrivate::updateIcon_sys()

View File

@ -221,6 +221,8 @@ private Q_SLOTS:
void comparison(); void comparison();
void overloadResolution();
private: private:
template <typename String> template <typename String>
void conversion_tests(String arg) const; void conversion_tests(String arg) const;
@ -678,5 +680,61 @@ void tst_QStringView::comparison()
QVERIFY(bb.compare(aa) > 0); 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) QTEST_APPLESS_MAIN(tst_QStringView)
#include "tst_qstringview.moc" #include "tst_qstringview.moc"

View File

@ -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

View File

@ -45,11 +45,23 @@ static const char diffToStderrEnvVar[] = "UIC_STDERR_DIFF";
struct TestEntry 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; QByteArray name;
QString baselineBaseName; QString uiFileName;
QString baseLineFileName;
QString generatedFileName; QString generatedFileName;
Flags flags;
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(TestEntry::Flags)
class tst_uic : public QObject class tst_uic : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -73,8 +85,8 @@ private Q_SLOTS:
void compare(); void compare();
void compare_data() const; void compare_data() const;
void python(); void pythonCompile();
void python_data() const; void pythonCompile_data() const;
void runCompare(); void runCompare();
@ -89,9 +101,12 @@ private:
QString m_python; 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() tst_uic::tst_uic()
: m_command(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/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()); m_testEntries.reserve(baselineFiles.size());
for (const QFileInfo &baselineFile : baselineFiles) { for (const QFileInfo &baselineFile : baselineFiles) {
const QString baseName = baselineFile.baseName(); const QString baseName = baselineFile.baseName();
const QString baselineBaseName = baseLinePrefix + baseName; TestEntry entry;
const QString generatedFile = generatedPrefix + baselineFile.fileName() // qprintsettingsoutput: variable named 'from' clashes with Python
+ QLatin1String(".h"); if (baseName == QLatin1String("qprintsettingsoutput"))
m_testEntries.append(TestEntry{baseName.toLocal8Bit(), baselineBaseName, generatedFile}); 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) { for (const TestEntry &te : m_testEntries) {
QStringList options; QStringList options;
if (te.name == QByteArrayLiteral("qttrid")) if (te.flags.testFlag(TestEntry::IdBasedTranslation))
options << QStringList(QLatin1String("-idbased")); options.append(QLatin1String("-idbased"));
QTest::newRow(te.name.constData()) << (te.baselineBaseName + QLatin1String(".ui")) if (te.flags.testFlag(TestEntry::Python))
options << QLatin1String("-g") << QLatin1String("python");
QTest::newRow(te.name.constData()) << te.uiFileName
<< te.generatedFileName << options; << te.generatedFileName << options;
} }
} }
@ -319,7 +353,7 @@ void tst_uic::compare_data() const
QTest::addColumn<QString>("generatedFile"); QTest::addColumn<QString>("generatedFile");
for (const TestEntry &te : m_testEntries) { 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; << te.generatedFileName;
} }
} }
@ -396,7 +430,8 @@ static inline QByteArray msgCompilePythonFailed(const QByteArray &error)
return lines.join('\n'); 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>("originalFile");
QTest::addColumn<QString>("generatedFile"); QTest::addColumn<QString>("generatedFile");
@ -405,19 +440,15 @@ void tst_uic::python_data() const
? qMin(1, m_testEntries.size()) : m_testEntries.size(); ? qMin(1, m_testEntries.size()) : m_testEntries.size();
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
const TestEntry &te = m_testEntries.at(i); const TestEntry &te = m_testEntries.at(i);
// qprintsettingsoutput: variable named 'from' clashes with Python if (!te.flags.testFlag(TestEntry::DontTestPythonCompile)) {
if (!te.baselineBaseName.endsWith(QLatin1String("/qprintsettingsoutput"))) {
QString generatedFile = te.generatedFileName;
generatedFile.chop(1); // foo.h -> foo.py
generatedFile.append(QLatin1String("py"));
QTest::newRow(te.name.constData()) QTest::newRow(te.name.constData())
<< (te.baselineBaseName + QLatin1String(".ui")) << te.uiFileName
<< generatedFile; << te.generatedFileName;
} }
} }
} }
void tst_uic::python() void tst_uic::pythonCompile()
{ {
QFETCH(QString, originalFile); QFETCH(QString, originalFile);
QFETCH(QString, generatedFile); QFETCH(QString, generatedFile);

View File

@ -505,26 +505,27 @@ void tst_QSpinBox::valueChangedHelper(int value)
actualValues << value; actualValues << value;
} }
class MySpinBox: public QSpinBox class ReadOnlyChangeTracker: public QSpinBox
{ {
public: public:
MySpinBox(QWidget *parent = 0) : QSpinBox(parent) {} ReadOnlyChangeTracker(QWidget *parent = 0) : QSpinBox(parent) {}
void changeEvent(QEvent *ev) { 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() void tst_QSpinBox::setReadOnly()
{ {
MySpinBox spin(0); ReadOnlyChangeTracker spin(0);
spin.show(); spin.show();
QTest::keyClick(&spin, Qt::Key_Up); QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1); QCOMPARE(spin.value(), 1);
spin.setReadOnly(true); spin.setReadOnly(true);
#ifndef Q_OS_WINRT // QTBUG-68297 #ifndef Q_OS_WINRT // QTBUG-68297
QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange); QCOMPARE(spin.readOnlyChangeEventCount, 1);
#endif #endif
QTest::keyClick(&spin, Qt::Key_Up); QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1); QCOMPARE(spin.value(), 1);
@ -532,7 +533,7 @@ void tst_QSpinBox::setReadOnly()
QCOMPARE(spin.value(), 2); QCOMPARE(spin.value(), 2);
spin.setReadOnly(false); spin.setReadOnly(false);
#ifndef Q_OS_WINRT // QTBUG-68297 #ifndef Q_OS_WINRT // QTBUG-68297
QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange << QEvent::ReadOnlyChange); QCOMPARE(spin.readOnlyChangeEventCount, 2);
#endif #endif
QTest::keyClick(&spin, Qt::Key_Up); QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 3); QCOMPARE(spin.value(), 3);