summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/manual.pro1
-rw-r--r--tests/manual/qcursor/qcursorhighdpi/main.cpp69
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.cpp8
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.h1
-rw-r--r--tests/manual/qtbug-52641/main.cpp87
-rw-r--r--tests/manual/qtbug-52641/qtbug-52641.pro5
-rw-r--r--tests/manual/textrendering/glyphshaping/glyphshaping.pro1
-rw-r--r--tests/manual/touch/main.cpp3
-rw-r--r--tests/manual/widgets/styles/main.cpp232
-rw-r--r--tests/manual/widgets/styles/styles.pro7
-rw-r--r--tests/manual/widgets/widgets.pro2
11 files changed, 410 insertions, 6 deletions
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index 05988c2160..fd42411a1d 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -31,6 +31,7 @@ qsysinfo \
qtabletevent \
qtexteditlist \
qtbug-8933 \
+qtbug-52641 \
qtouchevent \
touch \
qwidget_zorder \
diff --git a/tests/manual/qcursor/qcursorhighdpi/main.cpp b/tests/manual/qcursor/qcursorhighdpi/main.cpp
index 13c414fbbb..4a7646c39d 100644
--- a/tests/manual/qcursor/qcursorhighdpi/main.cpp
+++ b/tests/manual/qcursor/qcursorhighdpi/main.cpp
@@ -39,10 +39,12 @@
#include <QBitmap>
#include <QCursor>
+#include <QDrag>
#include <QPainter>
#include <QPixmap>
#include <QDebug>
+#include <QMimeData>
#include <QStringList>
#include <QTextStream>
@@ -63,6 +65,14 @@
#include <algorithm>
#include <iterator>
+#if QT_VERSION < 0x050000
+QDebug operator<<(QDebug d, const QPixmap &p)
+{
+ d.nospace() << "QPixmap(" << p.size() << ')';
+ return d;
+}
+#endif // Qt 4
+
// High DPI cursor test for testing cursor sizes in multi-screen setups.
// It creates one widget per screen with a grid of standard cursors,
// pixmap / bitmap cursors and pixmap / bitmap cursors with device pixel ratio 2.
@@ -154,6 +164,49 @@ static QCursor bitmapCursorDevicePixelRatio(int size, int dpr)
}
#endif // Qt 5
+// A label from which a pixmap can be dragged for testing drag with pixmaps/DPR.
+class DraggableLabel : public QLabel {
+public:
+ explicit DraggableLabel(const QPixmap &p, const QString &text, QWidget *parent = Q_NULLPTR)
+ : QLabel(text, parent), m_pixmap(p)
+ {
+ setToolTip(QLatin1String("Click to drag away the pixmap. Press Shift to set a circular mask."));
+ }
+
+protected:
+ void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+
+private:
+ const QPixmap m_pixmap;
+};
+
+void DraggableLabel::mousePressEvent(QMouseEvent *)
+{
+ QMimeData *mimeData = new QMimeData;
+ mimeData->setImageData(qVariantFromValue(m_pixmap));
+ QDrag *drag = new QDrag(this);
+ QPixmap pixmap = m_pixmap;
+ if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
+ QBitmap mask(pixmap.width(), pixmap.height());
+ mask.clear();
+ QPainter painter(&mask);
+ painter.setBrush(Qt::color1);
+ const int hx = pixmap.width() / 2;
+ const int hy = pixmap.width() / 2;
+ painter.drawEllipse(QPoint(hx, hy), hx, hy);
+ pixmap.setMask(mask);
+ }
+ drag->setMimeData(mimeData);
+ drag->setPixmap(pixmap);
+ QPoint sizeP = QPoint(m_pixmap.width(), m_pixmap.height());
+#if QT_VERSION > 0x050000
+ sizeP /= int(m_pixmap.devicePixelRatio());
+#endif // Qt 5
+ drag->setHotSpot(sizeP / 2);
+ qDebug() << "Dragging:" << m_pixmap;
+ drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
+}
+
// Vertical ruler widget with 10 px marks
class VerticalRuler : public QWidget {
public:
@@ -205,8 +258,15 @@ static QLabel *createCursorLabel(const QCursor &cursor, const QString &additiona
#endif // Qt 5
if (!additionalText.isEmpty())
labelText += ' ' + additionalText;
- QLabel *result = new QLabel(labelText);
- result->setFrameShape(QFrame::Box);
+ const QPixmap cursorPixmap = cursor.pixmap();
+ QLabel *result = Q_NULLPTR;
+ if (cursorPixmap.size().isEmpty()) {
+ result = new QLabel(labelText);
+ result->setFrameShape(QFrame::Box);
+ } else {
+ result = new DraggableLabel(cursor.pixmap(), labelText);
+ result->setFrameShape(QFrame::StyledPanel);
+ }
result->setCursor(cursor);
return result;
}
@@ -299,7 +359,10 @@ int main(int argc, char *argv[])
QDesktopWidget *desktopWidget = app.desktop();
- for (int s = desktopWidget->screenCount() - 1; s >= 0; --s) {
+ const int lastScreen = arguments.contains("-p")
+ ? 0 // Primary screen only
+ : desktopWidget->screenCount() - 1; // All screens
+ for (int s = lastScreen; s >= 0; --s) {
MainWindowPtr window(new MainWindow(desktopWidget->screen(s)));
const QPoint pos = desktopWidget->screenGeometry(s).center() - QPoint(200, 100);
window->move(pos);
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
index a30e32b6d9..b4273bde8e 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
@@ -33,7 +33,7 @@
#include <QMetaObject>
#include <QMetaEnum>
-TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo)
+TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCount(0)
{
QPalette newPalette = palette();
newPalette.setColor(QPalette::Window, Qt::white);
@@ -82,6 +82,10 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev)
mGPos = event->globalPos();
mTimestamp = event->timestamp();
}
+ break;
+ case QEvent::Wheel:
+ ++mWheelEventCount;
+ break;
default:
break;
}
@@ -176,6 +180,8 @@ void TabletWidget::paintEvent(QPaintEvent *)
eventInfo << QString("z: %1").arg(QString::number(mZ));
eventInfo << QString("Unique Id: %1").arg(QString::number(mUnique));
+
+ eventInfo << QString("Total wheel events: %1").arg(QString::number(mWheelEventCount));
}
QString text = eventInfo.join("\n");
diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h
index 4e6520e4cc..2b014a213a 100644
--- a/tests/manual/qtabletevent/device_information/tabletwidget.h
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.h
@@ -61,6 +61,7 @@ private:
qint64 mUnique;
bool mMouseToo;
ulong mTimestamp;
+ int mWheelEventCount;
};
#endif // TABLETWIDGET_H
diff --git a/tests/manual/qtbug-52641/main.cpp b/tests/manual/qtbug-52641/main.cpp
new file mode 100644
index 0000000000..33ebd8584c
--- /dev/null
+++ b/tests/manual/qtbug-52641/main.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Kai Pastor
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of 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 <QFileDialog>
+#include <QPainter>
+#include <QPdfWriter>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ QString filepath = QFileDialog::getSaveFileName(nullptr, "Save File", "",
+ "PDF files (*.pdf)");
+ if (filepath.isEmpty())
+ return 1;
+ QPdfWriter writer(filepath);
+ writer.setPageSize(QPageSize(QPageSize::A4));
+ writer.setResolution(300);
+
+ QPainterPath path;
+ path.moveTo(0,0);
+ path.lineTo(1000,0);
+ path.lineTo(1000,1000);
+ path.lineTo(0,800);
+ path.lineTo(500,100);
+ path.lineTo(800,900);
+ path.lineTo(300,600);
+
+ QPen pen;
+ pen.setWidth(30);
+ pen.setJoinStyle(Qt::MiterJoin);
+
+ // The black path on the first page must always be visible in the PDF viewer.
+ QPainter p(&writer);
+ pen.setMiterLimit(6.0);
+ p.setPen(pen);
+ p.drawPath(path);
+
+ // If a miter limit below 1.0 is written to the PDF,
+ // broken PDF viewers may not show the red path on the second page.
+ writer.newPage();
+ pen.setMiterLimit(0.6);
+ pen.setColor(Qt::red);
+ p.setPen(pen);
+ p.drawPath(path);
+
+ p.end();
+ return 0;
+}
diff --git a/tests/manual/qtbug-52641/qtbug-52641.pro b/tests/manual/qtbug-52641/qtbug-52641.pro
new file mode 100644
index 0000000000..5a9ff6df52
--- /dev/null
+++ b/tests/manual/qtbug-52641/qtbug-52641.pro
@@ -0,0 +1,5 @@
+TARGET = qtbug-52641
+TEMPLATE = app
+QT = core gui widgets
+SOURCES = main.cpp
+
diff --git a/tests/manual/textrendering/glyphshaping/glyphshaping.pro b/tests/manual/textrendering/glyphshaping/glyphshaping.pro
index 6500814423..f4e0b45734 100644
--- a/tests/manual/textrendering/glyphshaping/glyphshaping.pro
+++ b/tests/manual/textrendering/glyphshaping/glyphshaping.pro
@@ -1,6 +1,5 @@
QT += widgets
SOURCES = main.cpp
-OTHER_FILES = glyphshaping_data.xml
glyphshaping_data.path = .
glyphshaping_data.files = $$PWD/glyphshaping_data.xml
DEPLOYMENT += glyphshaping_data
diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp
index fb0c8559f9..66ad02f78b 100644
--- a/tests/manual/touch/main.cpp
+++ b/tests/manual/touch/main.cpp
@@ -256,6 +256,9 @@ QColor Point::color() const
case Qt::MouseEventSynthesizedByQt:
globalColor = Qt::blue;
break;
+ case Qt::MouseEventSynthesizedByApplication:
+ globalColor = Qt::green;
+ break;
case Qt::MouseEventNotSynthesized:
break;
}
diff --git a/tests/manual/widgets/styles/main.cpp b/tests/manual/widgets/styles/main.cpp
new file mode 100644
index 0000000000..add9afd5b2
--- /dev/null
+++ b/tests/manual/widgets/styles/main.cpp
@@ -0,0 +1,232 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QAction>
+#include <QApplication>
+#include <QDebug>
+#include <QGridLayout>
+#include <QLabel>
+#include <QMainWindow>
+#include <QMenu>
+#include <QMenuBar>
+#include <QPalette>
+#include <QPixmap>
+#include <QPlainTextEdit>
+#include <QStyle>
+#include <QTabWidget>
+#include <QTextStream>
+#include <QVBoxLayout>
+#include <QWindow>
+#include <QScreen>
+
+// Format enumeration value and strip off the class name
+// added by QDebug: "QStyle::StandardPixmap(SP_Icon)" -> "SP_Icon".
+template <typename Enum>
+static inline QString formatEnumValue(Enum value)
+{
+ QString result;
+ QDebug(&result) << value;
+ int index = result.indexOf(QLatin1Char('('));
+ if (index > 0) { // "QStyle::StandardPixmap(..)".
+ result.remove(0, index + 1);
+ index = result.lastIndexOf(QLatin1Char(')'));
+ if (index > 0)
+ result.truncate(index);
+ }
+ return result;
+}
+
+static QString pixmapDescription(QStyle::StandardPixmap sp, const QPixmap &pixmap)
+{
+ QString description = formatEnumValue(sp);
+ QTextStream str(&description);
+ str << '(' << int(sp) << ") ";
+ if (pixmap.isNull()) {
+ str << "(null)";
+ } else {
+ const qreal dpr = pixmap.devicePixelRatioF();
+ str << ' ' << pixmap.width() << 'x' << pixmap.height();
+ if (!qFuzzyCompare(dpr, qreal(1)))
+ str << " DPR=" << dpr;
+ }
+ return description;
+}
+
+// Display pixmaps returned by QStyle::standardPixmap() in a grid.
+static QWidget *createStandardPixmapPage(QWidget *parent)
+{
+ QWidget *result = new QWidget(parent);
+ QGridLayout *grid = new QGridLayout(result);
+ int row = 0;
+ int column = 0;
+ const int maxColumns = 6;
+ for (int i = 0; i <= int(QStyle::SP_LineEditClearButton); ++i) {
+ const QStyle::StandardPixmap sp = static_cast<QStyle::StandardPixmap>(i);
+ QPixmap pixmap = result->style()->standardPixmap(sp, Q_NULLPTR, result);
+ QLabel *descriptionLabel = new QLabel(pixmapDescription(sp, pixmap));
+ grid->addWidget(descriptionLabel, row, column++);
+ QLabel *displayLabel = new QLabel;
+ displayLabel->setPixmap(pixmap);
+ displayLabel->setFrameShape(QFrame::Box);
+ grid->addWidget(displayLabel, row, column++);
+ if (column >= maxColumns) {
+ ++row;
+ column = 0;
+ }
+ }
+ return result;
+}
+
+// Display values returned by QStyle::pixelMetric().
+static QWidget *createMetricsPage(QWidget *parent)
+{
+ QPlainTextEdit *result = new QPlainTextEdit(parent);
+ QString text;
+ QTextStream str(&text);
+ for (int i = 0; i <= int(QStyle::PM_HeaderDefaultSectionSizeVertical); ++i) {
+ const QStyle::PixelMetric m = static_cast<QStyle::PixelMetric>(i);
+ str << formatEnumValue(m) << '(' << int(m) << ")="
+ << result->style()->pixelMetric(m, Q_NULLPTR, result) << '\n';
+ }
+ result->setPlainText(text);
+ return result;
+}
+
+// Display values returned by QStyle::styleHint()
+static QWidget *createHintsPage(QWidget *parent)
+{
+ QPlainTextEdit *result = new QPlainTextEdit(parent);
+ QString text;
+ QTextStream str(&text);
+ for (int i = 0; i <= int(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave); ++i) {
+ const QStyle::StyleHint h = static_cast<QStyle::StyleHint>(i);
+ str << formatEnumValue(h) << '(' << int(h) << ")="
+ << result->style()->styleHint(h, Q_NULLPTR, result) << '\n';
+ }
+ result->setPlainText(text);
+ return result;
+}
+
+// Display palette colors
+static QWidget *createColorsPage(QWidget *parent)
+{
+ QWidget *result = new QWidget(parent);
+ QGridLayout *grid = new QGridLayout;
+ const QPalette palette = QGuiApplication::palette();
+ int row = 0;
+ for (int r = 0; r < int(QPalette::NColorRoles); ++r) {
+ const QPalette::ColorRole role = static_cast<QPalette::ColorRole>(r);
+ const QColor color = palette.color(QPalette::Active, role);
+ if (color.isValid()) {
+ const QString description =
+ formatEnumValue(role) + QLatin1Char('(') + QString::number(r)
+ + QLatin1String(") ") + color.name(QColor::HexArgb);
+ grid->addWidget(new QLabel(description), row, 0);
+ QLabel *displayLabel = new QLabel;
+ QPixmap pixmap(20, 20);
+ pixmap.fill(color);
+ displayLabel->setPixmap(pixmap);
+ displayLabel->setFrameShape(QFrame::Box);
+ grid->addWidget(displayLabel, row, 1);
+ ++row;
+ }
+ }
+ QHBoxLayout *hBox = new QHBoxLayout;
+ hBox->addLayout(grid);
+ hBox->addStretch();
+ QVBoxLayout *vBox = new QVBoxLayout(result);
+ vBox->addLayout(hBox);
+ vBox->addStretch();
+ return result;
+}
+
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ MainWindow();
+
+public slots:
+ void updateDescription();
+
+private:
+ QTabWidget *m_tabWidget;
+ QLabel *m_descriptionLabel;
+};
+
+MainWindow::MainWindow()
+ : m_tabWidget(new QTabWidget)
+ , m_descriptionLabel(new QLabel)
+{
+ QMenu *fileMenu = menuBar()->addMenu("&File");
+ QAction *a = fileMenu->addAction("Quit", this, &QWidget::close);
+ a->setShortcut(Qt::CTRL + Qt::Key_Q);
+
+ QWidget *central = new QWidget;
+ QVBoxLayout *mainLayout = new QVBoxLayout(central);
+ mainLayout->addWidget(m_descriptionLabel);
+ mainLayout->addWidget(m_tabWidget);
+ m_tabWidget->addTab(createStandardPixmapPage(m_tabWidget), "Standard Pixmaps");
+ m_tabWidget->addTab(createHintsPage(m_tabWidget), "Hints");
+ m_tabWidget->addTab(createMetricsPage(m_tabWidget), "Pixel Metrics");
+ m_tabWidget->addTab(createColorsPage(m_tabWidget), "Colors");
+ setCentralWidget(central);
+
+ setWindowTitle(QLatin1String("Style Tester (Qt") + QLatin1String(QT_VERSION_STR)
+ + QLatin1String(", ") + style()->objectName() + QLatin1Char(')'));
+}
+
+void MainWindow::updateDescription()
+{
+ QString text;
+ QTextStream str(&text);
+ str << "Qt " << QT_VERSION_STR << ", platform: " << QGuiApplication::platformName()
+ << ", Style: \"" << style()->objectName() << "\", DPR=" << devicePixelRatioF()
+ << ' ' << logicalDpiX() << ',' << logicalDpiY() << "DPI";
+ if (const QWindow *w = windowHandle())
+ str << ", Screen: \"" << w->screen()->name() << '"';
+ m_descriptionLabel->setText(text);
+}
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+ QApplication app(argc, argv);
+ MainWindow mw;
+ mw.show();
+ mw.updateDescription();
+ QObject::connect(mw.windowHandle(), &QWindow::screenChanged,
+ &mw, &MainWindow::updateDescription);
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/widgets/styles/styles.pro b/tests/manual/widgets/styles/styles.pro
new file mode 100644
index 0000000000..ef8217a9a3
--- /dev/null
+++ b/tests/manual/widgets/styles/styles.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+QT = widgets
+CONFIG += console
+CONFIG -= app_bundle
+CONFIG += c++11
+
+SOURCES += main.cpp
diff --git a/tests/manual/widgets/widgets.pro b/tests/manual/widgets/widgets.pro
index e9dcdf39e7..3a128581cf 100644
--- a/tests/manual/widgets/widgets.pro
+++ b/tests/manual/widgets/widgets.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = itemviews qgraphicsview kernel
-
+greaterThan(QT_MAJOR_VERSION, 4): SUBDIRS += styles