summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/cocoa/menurama/mainwindow.h2
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.cpp2
-rw-r--r--tests/manual/diaglib/eventfilter.cpp29
-rw-r--r--tests/manual/diaglib/logwidget.cpp2
-rw-r--r--tests/manual/diaglib/nativewindowdump.cpp17
-rw-r--r--tests/manual/foreignwindows/main.cpp6
-rw-r--r--tests/manual/highdpi/dragwidget.h18
-rw-r--r--tests/manual/qlayout/gridwidget.cpp4
-rw-r--r--tests/manual/qlayout/hbwidget.cpp4
-rw-r--r--tests/manual/qlayout/vbwidget.cpp4
-rw-r--r--tests/manual/qscreen/main.cpp8
-rw-r--r--tests/manual/qscreen/propertywatcher.cpp2
-rw-r--r--tests/manual/qscreen/propertywatcher.h2
-rw-r--r--tests/manual/qsysinfo/main.cpp4
-rw-r--r--tests/manual/qtabletevent/regular_widgets/main.cpp37
-rw-r--r--tests/manual/touch/main.cpp12
-rw-r--r--tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp4
-rw-r--r--tests/manual/widgets/styles/main.cpp127
18 files changed, 222 insertions, 62 deletions
diff --git a/tests/manual/cocoa/menurama/mainwindow.h b/tests/manual/cocoa/menurama/mainwindow.h
index a7afa770be..3ca90dad8f 100644
--- a/tests/manual/cocoa/menurama/mainwindow.h
+++ b/tests/manual/cocoa/menurama/mainwindow.h
@@ -44,7 +44,7 @@ public:
~MainWindow();
protected:
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *) override;
public slots:
void enableStuffMenu(bool enable);
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp
index 4cd741000e..1506fe7d19 100644
--- a/tests/manual/cocoa/menurama/menuramaapplication.cpp
+++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp
@@ -71,5 +71,5 @@ QAction *MenuramaApplication::findAction(QLatin1String title, QMenu *parentMenu)
if (a->text() == title)
return a;
- return Q_NULLPTR;
+ return nullptr;
}
diff --git a/tests/manual/diaglib/eventfilter.cpp b/tests/manual/diaglib/eventfilter.cpp
index 3874adbdeb..0646964b4a 100644
--- a/tests/manual/diaglib/eventfilter.cpp
+++ b/tests/manual/diaglib/eventfilter.cpp
@@ -195,6 +195,19 @@ static void formatApplicationState(QDebug debug)
#endif // HAVE_GUI_APPLICATION
}
+#ifdef HAVE_APPLICATION
+static void formatMouseState(QObject *o, QDebug debug)
+{
+ if (o->isWidgetType()) {
+ const QWidget *w = static_cast<const QWidget *>(o);
+ if (QWidget::mouseGrabber() == w)
+ debug << " [grabbed]";
+ if (w->hasMouseTracking())
+ debug << " [tracking]";
+ }
+}
+#endif // HAVE_APPLICATION
+
bool EventFilter::eventFilter(QObject *o, QEvent *e)
{
static int n = 0;
@@ -210,6 +223,22 @@ bool EventFilter::eventFilter(QObject *o, QEvent *e)
case QEvent::FocusIn:
formatApplicationState(debug);
break;
+#ifdef HAVE_APPLICATION
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ case QEvent::NonClientAreaMouseButtonDblClick:
+ case QEvent::NonClientAreaMouseButtonPress:
+ case QEvent::NonClientAreaMouseButtonRelease:
+ case QEvent::NonClientAreaMouseMove:
+# if QT_VERSION >= 0x050000
+ case QEvent::Enter:
+# endif
+ case QEvent::Leave:
+ formatMouseState(o, debug);
+ break;
+#endif // HAVE_APPLICATION
default:
break;
}
diff --git a/tests/manual/diaglib/logwidget.cpp b/tests/manual/diaglib/logwidget.cpp
index 8e4844fab2..35fabd6e2e 100644
--- a/tests/manual/diaglib/logwidget.cpp
+++ b/tests/manual/diaglib/logwidget.cpp
@@ -133,7 +133,7 @@ void LogWidget::install()
qInfo("%s", qPrintable(LogWidget::startupMessage()));
}
-void LogWidget::uninstall() { qInstallMessageHandler(Q_NULLPTR); }
+void LogWidget::uninstall() { qInstallMessageHandler(nullptr); }
#else // Qt 5
diff --git a/tests/manual/diaglib/nativewindowdump.cpp b/tests/manual/diaglib/nativewindowdump.cpp
index 83edf878b3..a854e8a790 100644
--- a/tests/manual/diaglib/nativewindowdump.cpp
+++ b/tests/manual/diaglib/nativewindowdump.cpp
@@ -28,10 +28,25 @@
#include "nativewindowdump.h"
+#if QT_VERSION >= 0x050000
+# include <QtGui/QGuiApplication>
+# include <qpa/qplatformnativeinterface.h>
+#endif
+
+#include <QtCore/QDebug>
+
namespace QtDiag {
-void dumpNativeWindows(WId)
+void dumpNativeWindows(WId wid)
{
+#if QT_VERSION >= 0x050000
+ QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface();
+ QString result;
+ QMetaObject::invokeMethod(ni, "dumpNativeWindows", Qt::DirectConnection,
+ Q_RETURN_ARG(QString, result),
+ Q_ARG(WId, wid));
+ qDebug().noquote() << result;
+#endif // Qt 5
}
void dumpNativeQtTopLevels()
diff --git a/tests/manual/foreignwindows/main.cpp b/tests/manual/foreignwindows/main.cpp
index cda7e7207e..74c6d8c376 100644
--- a/tests/manual/foreignwindows/main.cpp
+++ b/tests/manual/foreignwindows/main.cpp
@@ -110,7 +110,7 @@ EmbeddingWindow::EmbeddingWindow(QWindow *window) : m_window(window)
+ QLatin1String(" 0x") + QString::number(window->winId(), 16);
setWindowTitle(title);
setObjectName("MainWindow");
- QWidget *container = QWidget::createWindowContainer(window, Q_NULLPTR, Qt::Widget);
+ QWidget *container = QWidget::createWindowContainer(window, nullptr, Qt::Widget);
container->setObjectName("Container");
setCentralWidget(container);
@@ -149,8 +149,8 @@ EmbeddingWindow::EmbeddingWindow(QWindow *window) : m_window(window)
void EmbeddingWindow::releaseForeignWindow()
{
if (m_window) {
- m_window->setParent(Q_NULLPTR);
- m_window = Q_NULLPTR;
+ m_window->setParent(nullptr);
+ m_window = nullptr;
m_releaseAction->setEnabled(false);
}
}
diff --git a/tests/manual/highdpi/dragwidget.h b/tests/manual/highdpi/dragwidget.h
index 2cb821d509..8b67b20410 100644
--- a/tests/manual/highdpi/dragwidget.h
+++ b/tests/manual/highdpi/dragwidget.h
@@ -43,15 +43,15 @@ public:
DragWidget(QString text = QString(), QWidget *parent = 0);
protected:
- void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE;
- void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void dragMoveEvent(QDragMoveEvent * event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
- void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QDragEnterEvent *event) override;
+ void dragLeaveEvent(QDragLeaveEvent *event) override;
+ void dropEvent(QDropEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void dragMoveEvent(QDragMoveEvent * event) override;
+ void paintEvent(QPaintEvent *) override;
+ void timerEvent(QTimerEvent *event) override;
+ void showEvent(QShowEvent *event) override;
+ void hideEvent(QHideEvent *event) override;
private:
QPoint dragPos;
QPoint dropPos;
diff --git a/tests/manual/qlayout/gridwidget.cpp b/tests/manual/qlayout/gridwidget.cpp
index ede13a22c3..f19b3eac6f 100644
--- a/tests/manual/qlayout/gridwidget.cpp
+++ b/tests/manual/qlayout/gridwidget.cpp
@@ -62,8 +62,8 @@ GridWidget::GridWidget(QWidget *parent) :
qDebug("There should be four warnings, but no crash or freeze:");
hb->addWidget(this, 6, 6); ///< This command should print a warning, but should not add "this"
- hb->addWidget(Q_NULLPTR, 6, 7); ///< This command should print a warning, but should not add "NULL"
+ hb->addWidget(nullptr, 6, 7); ///< This command should print a warning, but should not add "NULL"
hb->addLayout(hb, 7, 6); ///< This command should print a warning, but should not add "hb"
- hb->addLayout(Q_NULLPTR, 7, 7); ///< This command should print a warning, but should not add "NULL"
+ hb->addLayout(nullptr, 7, 7); ///< This command should print a warning, but should not add "NULL"
qDebug("Neither crashed nor frozen");
}
diff --git a/tests/manual/qlayout/hbwidget.cpp b/tests/manual/qlayout/hbwidget.cpp
index d1f6c94d5b..80219d01fd 100644
--- a/tests/manual/qlayout/hbwidget.cpp
+++ b/tests/manual/qlayout/hbwidget.cpp
@@ -58,8 +58,8 @@ HbWidget::HbWidget(QWidget *parent) :
qDebug("There should be four warnings, but no crash or freeze:");
hb->addWidget(this); ///< This command should print a warning, but should not add "this"
- hb->addWidget(Q_NULLPTR); ///< This command should print a warning, but should not add "NULL"
+ hb->addWidget(nullptr); ///< This command should print a warning, but should not add "NULL"
hb->addLayout(hb); ///< This command should print a warning, but should not add "hb"
- hb->addLayout(Q_NULLPTR); ///< This command should print a warning, but should not add "NULL"
+ hb->addLayout(nullptr); ///< This command should print a warning, but should not add "NULL"
qDebug("Neither crashed nor frozen");
}
diff --git a/tests/manual/qlayout/vbwidget.cpp b/tests/manual/qlayout/vbwidget.cpp
index d3898422fb..97f240f9a0 100644
--- a/tests/manual/qlayout/vbwidget.cpp
+++ b/tests/manual/qlayout/vbwidget.cpp
@@ -58,8 +58,8 @@ VbWidget::VbWidget(QWidget *parent) :
qDebug("There should be four warnings, but no crash or freeze:");
hb->addWidget(this); ///< This command should print a warning, but should not add "this"
- hb->addWidget(Q_NULLPTR); ///< This command should print a warning, but should not add "NULL"
+ hb->addWidget(nullptr); ///< This command should print a warning, but should not add "NULL"
hb->addLayout(hb); ///< This command should print a warning, but should not add "hb"
- hb->addLayout(Q_NULLPTR); ///< This command should print a warning, but should not add "NULL"
+ hb->addLayout(nullptr); ///< This command should print a warning, but should not add "NULL"
qDebug("Neither crashed nor frozen");
}
diff --git a/tests/manual/qscreen/main.cpp b/tests/manual/qscreen/main.cpp
index 445af82e09..6fba872b12 100644
--- a/tests/manual/qscreen/main.cpp
+++ b/tests/manual/qscreen/main.cpp
@@ -73,12 +73,12 @@ public:
}
protected:
- void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE {
+ void mouseMoveEvent(QMouseEvent *ev) override {
m_cursorPos = ev->screenPos().toPoint();
updateText();
}
- void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE {
+ void mousePressEvent(QMouseEvent *ev) override {
m_cursorPos = ev->screenPos().toPoint();
qDebug() << "top level @" << m_cursorPos << ":" << QGuiApplication::topLevelAt(m_cursorPos);
updateText();
@@ -100,7 +100,7 @@ class ScreenPropertyWatcher : public PropertyWatcher
{
Q_OBJECT
public:
- ScreenPropertyWatcher(QWidget *wp = Q_NULLPTR) : PropertyWatcher(Q_NULLPTR, QString(), wp)
+ ScreenPropertyWatcher(QWidget *wp = nullptr) : PropertyWatcher(nullptr, QString(), wp)
{
// workaround for the fact that virtualSiblings is not a property,
// thus there is no change notification:
@@ -150,7 +150,7 @@ public:
QScreen *screenSubject() const { return m_watcher->screenSubject(); }
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
void startMouseMonitor();
private:
diff --git a/tests/manual/qscreen/propertywatcher.cpp b/tests/manual/qscreen/propertywatcher.cpp
index 0fb322a480..d2a552f108 100644
--- a/tests/manual/qscreen/propertywatcher.cpp
+++ b/tests/manual/qscreen/propertywatcher.cpp
@@ -34,7 +34,7 @@
#include "propertyfield.h"
PropertyWatcher::PropertyWatcher(QObject *subject, QString annotation, QWidget *parent)
- : QWidget(parent), m_subject(Q_NULLPTR), m_formLayout(new QFormLayout(this))
+ : QWidget(parent), m_subject(nullptr), m_formLayout(new QFormLayout(this))
{
setMinimumSize(450, 300);
m_formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
diff --git a/tests/manual/qscreen/propertywatcher.h b/tests/manual/qscreen/propertywatcher.h
index f371a3b9b6..d988d96c91 100644
--- a/tests/manual/qscreen/propertywatcher.h
+++ b/tests/manual/qscreen/propertywatcher.h
@@ -39,7 +39,7 @@ class PropertyWatcher : public QWidget
Q_OBJECT
public:
- explicit PropertyWatcher(QObject* subject = Q_NULLPTR, QString annotation = QString(), QWidget *parent = Q_NULLPTR);
+ explicit PropertyWatcher(QObject* subject = nullptr, QString annotation = QString(), QWidget *parent = nullptr);
QFormLayout *formLayout() { return m_formLayout; }
diff --git a/tests/manual/qsysinfo/main.cpp b/tests/manual/qsysinfo/main.cpp
index 5b391e5dfd..62d0c51416 100644
--- a/tests/manual/qsysinfo/main.cpp
+++ b/tests/manual/qsysinfo/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 Intel Corporation.
+** Copyright (C) 2017 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -133,6 +133,8 @@ int main(int argc, char *argv[])
printf("QSysInfo::productVersion() = %s\n", qPrintable(QSysInfo::productVersion()));
printf("QSysInfo::prettyProductName() = %s\n", qPrintable(QSysInfo::prettyProductName()));
printf("QSysInfo::machineHostName() = %s\n", qPrintable(QSysInfo::machineHostName()));
+ printf("QSysInfo::machineUniqueId() = %s\n", QSysInfo::machineUniqueId().constData());
+ printf("QSysInfo::bootUniqueId() = %s\n", qPrintable(QSysInfo::bootUniqueId()));
const auto osv = QOperatingSystemVersion::current();
printf("QOperatingSystemVersion::current() = %s %d.%d.%d\n",
diff --git a/tests/manual/qtabletevent/regular_widgets/main.cpp b/tests/manual/qtabletevent/regular_widgets/main.cpp
index 339d1d3633..caf8c70c6f 100644
--- a/tests/manual/qtabletevent/regular_widgets/main.cpp
+++ b/tests/manual/qtabletevent/regular_widgets/main.cpp
@@ -82,7 +82,7 @@ class EventReportWidget : public QWidget
{
Q_OBJECT
public:
- EventReportWidget() { startTimer(1000); }
+ EventReportWidget();
public slots:
void clearPoints() { m_points.clear(); update(); }
@@ -98,6 +98,8 @@ protected:
void tabletEvent(QTabletEvent *) override;
+ bool event(QEvent *event) override;
+
void paintEvent(QPaintEvent *) override;
void timerEvent(QTimerEvent *) override;
@@ -108,10 +110,17 @@ private:
bool m_lastIsTabletMove = false;
Qt::MouseButton m_lastButton = Qt::NoButton;
QVector<TabletPoint> m_points;
+ QVector<QPointF> m_touchPoints;
int m_tabletMoveCount = 0;
int m_paintEventCount = 0;
};
+EventReportWidget::EventReportWidget()
+{
+ setAttribute(Qt::WA_AcceptTouchEvents);
+ startTimer(1000);
+}
+
void EventReportWidget::paintEvent(QPaintEvent *)
{
QPainter p(this);
@@ -160,6 +169,11 @@ void EventReportWidget::paintEvent(QPaintEvent *)
}
}
}
+ p.setPen(Qt::blue);
+ for (QPointF t : m_touchPoints) {
+ p.drawLine(t.x() - 40, t.y(), t.x() + 40, t.y());
+ p.drawLine(t.x(), t.y() - 40, t.x(), t.y() + 40);
+ }
++m_paintEventCount;
}
@@ -198,6 +212,27 @@ void EventReportWidget::tabletEvent(QTabletEvent *event)
m_lastIsTabletMove = isMove;
}
+bool EventReportWidget::event(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ event->accept();
+ m_touchPoints.clear();
+ for (const QTouchEvent::TouchPoint &p : static_cast<const QTouchEvent *>(event)->touchPoints())
+ m_touchPoints.append(p.pos());
+ update();
+ break;
+ case QEvent::TouchEnd:
+ m_touchPoints.clear();
+ update();
+ break;
+ default:
+ return QWidget::event(event);
+ }
+ return true;
+}
+
void EventReportWidget::outputMouseEvent(QMouseEvent *event)
{
if (event->type() == QEvent::MouseMove) {
diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp
index 1d00ea5db5..d3c6079c7d 100644
--- a/tests/manual/touch/main.cpp
+++ b/tests/manual/touch/main.cpp
@@ -118,7 +118,7 @@ public:
explicit PanGesture(const QWidget *w, const QPanGesture *source) : Gesture(w, source)
, m_offset(source->offset()) {}
- void draw(const QRectF &rect, QPainter &painter) const Q_DECL_OVERRIDE
+ void draw(const QRectF &rect, QPainter &painter) const override
{
const QPointF hotSpot = drawHotSpot(rect, painter);
painter.drawLine(hotSpot, hotSpot + m_offset);
@@ -134,7 +134,7 @@ public:
, m_horizontal(source->horizontalDirection()), m_vertical(source->verticalDirection())
, m_angle(source->swipeAngle()) {}
- void draw(const QRectF &rect, QPainter &painter) const Q_DECL_OVERRIDE;
+ void draw(const QRectF &rect, QPainter &painter) const override;
private:
QSwipeGesture::SwipeDirection m_horizontal;
@@ -169,7 +169,7 @@ void SwipeGesture::draw(const QRectF &rect, QPainter &painter) const
Gesture *Gesture::fromQGesture(const QWidget *w, const QGesture *source)
{
- Gesture *result = Q_NULLPTR;
+ Gesture *result = nullptr;
switch (source->gestureType()) {
case Qt::TapGesture:
case Qt::TapAndHoldGesture:
@@ -197,7 +197,7 @@ class EventFilter : public QObject {
public:
explicit EventFilter(const EventTypeVector &types, QObject *p) : QObject(p), m_types(types) {}
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *, QEvent *) override;
signals:
void eventReceived(const QString &);
@@ -292,8 +292,8 @@ signals:
void logMessage(const QString &);
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ void paintEvent(QPaintEvent *) override;
private:
void handleGestureEvent(QGestureEvent *gestureEvent);
diff --git a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
index e8844f87fd..f2c5494ebc 100644
--- a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
+++ b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
@@ -36,7 +36,7 @@ public:
setFlags(QGraphicsItem::ItemIsSelectable);
}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option*/, QWidget * /*widget*/) Q_DECL_OVERRIDE
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option*/, QWidget * /*widget*/) override
{
if (isSelected())
painter->fillRect(rect(), QColor(255, 0, 0));
@@ -55,7 +55,7 @@ public:
connect(this, SIGNAL(rubberBandChanged(QRect, QPointF, QPointF)), this, SLOT(updateRubberbandInfo(QRect, QPointF, QPointF)));
}
protected:
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE
+ void mouseMoveEvent(QMouseEvent *event) override
{
QGraphicsView::mouseMoveEvent(event);
diff --git a/tests/manual/widgets/styles/main.cpp b/tests/manual/widgets/styles/main.cpp
index 7c840dc9ae..43580ce781 100644
--- a/tests/manual/widgets/styles/main.cpp
+++ b/tests/manual/widgets/styles/main.cpp
@@ -30,6 +30,7 @@
#include <QApplication>
#include <QDebug>
#include <QGridLayout>
+#include <QGroupBox>
#include <QLabel>
#include <QMainWindow>
#include <QMenu>
@@ -41,6 +42,7 @@
#include <QTabWidget>
#include <QTextStream>
#include <QVBoxLayout>
+#include <QVector>
#include <QWindow>
#include <QScreen>
@@ -61,22 +63,67 @@ static inline QString formatEnumValue(Enum value)
return result;
}
-static QString pixmapDescription(QStyle::StandardPixmap sp, const QPixmap &pixmap)
+static QTextStream &operator<<(QTextStream &str, const QSize &s)
{
- 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;
+ str << s.width();
+ if (s.width() != s.height())
+ str << 'x' << s.height();
+ return str;
+}
+
+struct StyleIconEntry
+{
+ QString name;
+ QStyle::StandardPixmap pixmap;
+};
+
+static bool operator<(const StyleIconEntry &e1, const StyleIconEntry &e2)
+{
+ return e1.name < e2.name;
+}
+
+static QVector<StyleIconEntry> styleIconEntries()
+{
+ QVector<StyleIconEntry> result;
+ const int count = int(QStyle::SP_LineEditClearButton) + 1;
+ result.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ QStyle::StandardPixmap px = static_cast<QStyle::StandardPixmap>(i);
+ result.append({formatEnumValue(px), px});
}
- return description;
+ std::sort(result.begin(), result.end());
+ return result;
}
+class IconDisplayWidget : public QGroupBox
+{
+public:
+ explicit IconDisplayWidget(const QString &title, const QString &text,
+ const QPixmap &pixmap, QWidget *p = nullptr);
+};
+
+IconDisplayWidget::IconDisplayWidget(const QString &title, const QString &text,
+ const QPixmap &pixmap, QWidget *p)
+ : QGroupBox(title, p)
+{
+ QHBoxLayout *hLayout = new QHBoxLayout(this);
+ hLayout->addWidget(new QLabel(text, this));
+ QLabel *iconLabel = new QLabel(this);
+ iconLabel->setPixmap(pixmap);
+ hLayout->addWidget(iconLabel);
+}
+
+static IconDisplayWidget *createStandardPixmapDisplay(const StyleIconEntry &e, QWidget *parent)
+{
+ QPixmap pixmap = parent->style()->standardPixmap(e.pixmap, nullptr, parent);
+ QString description;
+ QTextStream str(&description);
+ str << pixmap.size();
+ return new IconDisplayWidget(e.name, description, pixmap, parent);
+}
+
+enum : int { maxColumns = 6 };
+
// Display pixmaps returned by QStyle::standardPixmap() in a grid.
static QWidget *createStandardPixmapPage(QWidget *parent)
{
@@ -84,16 +131,47 @@ static QWidget *createStandardPixmapPage(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++);
+ QVector<StyleIconEntry> entries = styleIconEntries();
+ for (int i = 0, size = entries.size(); i < size; ++i) {
+ grid->addWidget(createStandardPixmapDisplay(entries.at(i), parent), row, column++);
+ if (column >= maxColumns) {
+ ++row;
+ column = 0;
+ }
+ }
+ return result;
+}
+
+// Display icons returned by QStyle::standardIcon() in a grid.
+static IconDisplayWidget *createStandardIconDisplay(const StyleIconEntry &e,
+ const QSize &displaySize,
+ QWidget *parent)
+{
+ QIcon icon = parent->style()->standardIcon(e.pixmap, nullptr, parent);
+ QString description;
+ QTextStream str(&description);
+ auto availableSizes = icon.availableSizes();
+ std::sort(availableSizes.begin(), availableSizes.end(),
+ [](QSize s1, QSize s2) { return s1.width() < s2.width(); });
+ for (int i =0; i < availableSizes.size(); ++i) {
+ if (i)
+ str << ',';
+ str << availableSizes.at(i);
+ }
+ return new IconDisplayWidget(e.name, description, icon.pixmap(displaySize), parent);
+}
+
+static QWidget *createStandardIconPage(QWidget *parent)
+{
+ QWidget *result = new QWidget(parent);
+ QGridLayout *grid = new QGridLayout(result);
+ int row = 0;
+ int column = 0;
+ const int largeIconSize = parent->style()->pixelMetric(QStyle::PM_LargeIconSize);
+ const QSize displaySize(largeIconSize, largeIconSize);
+ QVector<StyleIconEntry> entries = styleIconEntries();
+ for (int i = 0, size = entries.size(); i < size; ++i) {
+ grid->addWidget(createStandardIconDisplay(entries.at(i), displaySize, parent), row, column++);
if (column >= maxColumns) {
++row;
column = 0;
@@ -111,7 +189,7 @@ static QWidget *createMetricsPage(QWidget *parent)
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->style()->pixelMetric(m, nullptr, result) << '\n';
}
result->setPlainText(text);
return result;
@@ -126,7 +204,7 @@ static QWidget *createHintsPage(QWidget *parent)
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->style()->styleHint(h, nullptr, result) << '\n';
}
result->setPlainText(text);
return result;
@@ -190,6 +268,7 @@ MainWindow::MainWindow()
QVBoxLayout *mainLayout = new QVBoxLayout(central);
mainLayout->addWidget(m_descriptionLabel);
mainLayout->addWidget(m_tabWidget);
+ m_tabWidget->addTab(createStandardIconPage(m_tabWidget), "Standard Icon");
m_tabWidget->addTab(createStandardPixmapPage(m_tabWidget), "Standard Pixmaps");
m_tabWidget->addTab(createHintsPage(m_tabWidget), "Hints");
m_tabWidget->addTab(createMetricsPage(m_tabWidget), "Pixel Metrics");