summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-17 14:15:53 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-17 14:43:26 +0100
commite5ac4afbf954a3e1616ce8543d46ddc668d0374f (patch)
treebe6d97001edebd5cb74c64aaf0010f3cc76a7293 /tests/manual
parente3ed95dd44b95b6e9361b562807e711d7ce5a58b (diff)
parent03c1a6ac717e3c5693653a5e294214056bda970e (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: mkspecs/features/mac/default_post.prf mkspecs/features/uikit/default_post.prf Change-Id: I2a6f783451f2ac9eb4c1a050f605435d2dacf218
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/cocoa/menurama/mainwindow.cpp8
-rw-r--r--tests/manual/cocoa/menurama/mainwindow.ui98
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.cpp16
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.h1
-rw-r--r--tests/manual/dialogs/main.cpp3
-rw-r--r--tests/manual/qcursor/childwidget/childwidget.pro6
-rw-r--r--tests/manual/qcursor/childwidget/main.cpp92
-rw-r--r--tests/manual/qcursor/childwindow/childwindow.pro5
-rw-r--r--tests/manual/qcursor/childwindow/main.cpp91
-rw-r--r--tests/manual/qcursor/childwindowcontainer/childwindowcontainer.pro6
-rw-r--r--tests/manual/qcursor/childwindowcontainer/main.cpp138
-rw-r--r--tests/manual/qcursor/qcursor.pro2
12 files changed, 414 insertions, 52 deletions
diff --git a/tests/manual/cocoa/menurama/mainwindow.cpp b/tests/manual/cocoa/menurama/mainwindow.cpp
index db8fdafc21..f7762f57f5 100644
--- a/tests/manual/cocoa/menurama/mainwindow.cpp
+++ b/tests/manual/cocoa/menurama/mainwindow.cpp
@@ -56,7 +56,13 @@ MainWindow::MainWindow(QWidget *parent) :
});
connect(ui->menuDynamic_Stuff, &QMenu::aboutToShow, [=] {
- menuApp->addDynMenu(QLatin1String("Added After aboutToShow()"), ui->menuDynamic_Stuff);
+ menuApp->addDynMenu(QLatin1String("Menu Added After aboutToShow()"), ui->menuDynamic_Stuff);
+
+ const QLatin1String itemTitle = QLatin1String("Disabled Item Added After aboutToShow()");
+ if (QAction *a = menuApp->findAction(itemTitle, ui->menuDynamic_Stuff))
+ ui->menuDynamic_Stuff->removeAction(a);
+ QAction *a = ui->menuDynamic_Stuff->addAction(itemTitle);
+ a->setEnabled(false);
});
connect(ui->pushButton, &QPushButton::clicked, [=] {
diff --git a/tests/manual/cocoa/menurama/mainwindow.ui b/tests/manual/cocoa/menurama/mainwindow.ui
index f73b41b861..d3caa6c608 100644
--- a/tests/manual/cocoa/menurama/mainwindow.ui
+++ b/tests/manual/cocoa/menurama/mainwindow.ui
@@ -6,63 +6,71 @@
<rect>
<x>0</x>
<y>0</y>
- <width>566</width>
- <height>300</height>
+ <width>429</width>
+ <height>251</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
- <widget class="QCheckBox" name="checkBox">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>40</y>
- <width>151</width>
- <height>20</height>
- </rect>
- </property>
- <property name="text">
- <string>Enable &quot;Stuff&quot; Menu</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- <widget class="QLabel" name="label">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>10</y>
- <width>321</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>The &quot;Help&quot; menu should NOT be visible.</string>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButton">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>80</y>
- <width>211</width>
- <height>32</height>
- </rect>
- </property>
- <property name="text">
- <string>Populate Dynamic Submenu</string>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>24</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>The &quot;Help&quot; menu should NOT be visible.
+
+Click on &quot;Dynamic Stuff&quot; then move left and right to other menus. Disabled items should remain that way.</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox">
+ <property name="text">
+ <string>Enable &quot;Stuff&quot; Menu</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Populate Dynamic Submenu</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>566</width>
+ <width>429</width>
<height>22</height>
</rect>
</property>
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp
index 534d5fa371..13e457d7dd 100644
--- a/tests/manual/cocoa/menurama/menuramaapplication.cpp
+++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp
@@ -69,13 +69,19 @@ void MenuramaApplication::populateMenu(QMenu *menu, bool clear)
void MenuramaApplication::addDynMenu(QLatin1String title, QMenu *parentMenu)
{
- foreach (QAction *a, parentMenu->actions())
- if (a->text() == title) {
- parentMenu->removeAction(a);
- break;
- }
+ if (QAction *a = findAction(title, parentMenu))
+ parentMenu->removeAction(a);
QMenu *subMenu = new QMenu(title, parentMenu);
populateMenu(subMenu, false /*clear*/);
parentMenu->addMenu(subMenu);
}
+
+QAction *MenuramaApplication::findAction(QLatin1String title, QMenu *parentMenu)
+{
+ foreach (QAction *a, parentMenu->actions())
+ if (a->text() == title)
+ return a;
+
+ return Q_NULLPTR;
+}
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.h b/tests/manual/cocoa/menurama/menuramaapplication.h
index 07c8da27a1..b0670cc53b 100644
--- a/tests/manual/cocoa/menurama/menuramaapplication.h
+++ b/tests/manual/cocoa/menurama/menuramaapplication.h
@@ -50,6 +50,7 @@ class MenuramaApplication : public QApplication
public:
MenuramaApplication(int argc, char **argv);
void addDynMenu(QLatin1String title, QMenu *parentMenu);
+ QAction *findAction(QLatin1String title, QMenu *parentMenu);
public slots:
void populateMenu(QMenu *menu, bool clear);
diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp
index f0f4e437e9..3f7b33ee7a 100644
--- a/tests/manual/dialogs/main.cpp
+++ b/tests/manual/dialogs/main.cpp
@@ -80,12 +80,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
int main(int argc, char *argv[])
{
+#if QT_VERSION >= 0x050700
for (int a = 1; a < argc; ++a) {
if (!qstrcmp(argv[a], "-n")) {
qDebug("AA_DontUseNativeDialogs");
QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
}
}
+#endif // Qt 5
+
QApplication a(argc, argv);
MainWindow w;
w.move(500, 200);
diff --git a/tests/manual/qcursor/childwidget/childwidget.pro b/tests/manual/qcursor/childwidget/childwidget.pro
new file mode 100644
index 0000000000..9ca41c5b4f
--- /dev/null
+++ b/tests/manual/qcursor/childwidget/childwidget.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = childwidget
+INCLUDEPATH += .
+QT += widgets
+
+SOURCES += main.cpp
diff --git a/tests/manual/qcursor/childwidget/main.cpp b/tests/manual/qcursor/childwidget/main.cpp
new file mode 100644
index 0000000000..4447c87210
--- /dev/null
+++ b/tests/manual/qcursor/childwidget/main.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite 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 <QtWidgets>
+
+class CursorWidget : public QWidget
+{
+public:
+ CursorWidget(QCursor cursor, QColor color)
+ :m_cursor(cursor)
+ ,m_color(color)
+ {
+ if (cursor.shape() == Qt::ArrowCursor)
+ unsetCursor();
+ else
+ setCursor(cursor);
+ }
+
+ void paintEvent(QPaintEvent *e)
+ {
+ QPainter p(this);
+ p.fillRect(e->rect(), m_color);
+ }
+
+ void mousePressEvent(QMouseEvent *)
+ {
+ // Toggle cursor
+ QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor;
+ if (newCursor.shape() == Qt::ArrowCursor)
+ unsetCursor();
+ else
+ setCursor(newCursor);
+ }
+
+private:
+ QCursor m_cursor;
+ QColor m_color;
+};
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ // Test child widgets (one of which is native) with set cursors.
+ // Click window to toggle cursor.
+
+ CursorWidget w1((QCursor(Qt::SizeVerCursor)), QColor(Qt::blue).darker());
+ w1.resize(200, 200);
+ w1.show();
+
+ CursorWidget w2((QCursor(Qt::OpenHandCursor)), QColor(Qt::red).darker());
+ w2.setParent(&w1);
+ w2.setGeometry(0, 0, 100, 100);
+ w2.show();
+
+ CursorWidget w3((QCursor(Qt::IBeamCursor)), QColor(Qt::green).darker());
+ w3.winId();
+ w3.setParent(&w1);
+ w3.setGeometry(100, 100, 100, 100);
+ w3.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/qcursor/childwindow/childwindow.pro b/tests/manual/qcursor/childwindow/childwindow.pro
new file mode 100644
index 0000000000..194536a91a
--- /dev/null
+++ b/tests/manual/qcursor/childwindow/childwindow.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+TARGET = childwindow
+INCLUDEPATH += .
+
+SOURCES += main.cpp
diff --git a/tests/manual/qcursor/childwindow/main.cpp b/tests/manual/qcursor/childwindow/main.cpp
new file mode 100644
index 0000000000..5fc293dfcf
--- /dev/null
+++ b/tests/manual/qcursor/childwindow/main.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite 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 <QtGui>
+
+class CursorWindow : public QRasterWindow
+{
+public:
+ CursorWindow(QCursor cursor, QColor color)
+ :m_cursor(cursor)
+ ,m_color(color)
+ {
+ if (cursor.shape() == Qt::ArrowCursor)
+ unsetCursor();
+ else
+ setCursor(cursor);
+ }
+
+ void paintEvent(QPaintEvent *e)
+ {
+ QPainter p(this);
+ p.fillRect(e->rect(), m_color);
+ }
+
+ void mousePressEvent(QMouseEvent *)
+ {
+ // Toggle cursor
+ QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor;
+ if (newCursor.shape() == Qt::ArrowCursor)
+ unsetCursor();
+ else
+ setCursor(newCursor);
+ }
+
+private:
+ QCursor m_cursor;
+ QColor m_color;
+};
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ // Test child windows with set cursors. Create parent window and
+ // two child windows. Click window to toggle cursor.
+
+ CursorWindow w1((QCursor(Qt::SizeVerCursor)), QColor(Qt::blue).darker());
+ w1.resize(200, 200);
+ w1.show();
+
+ CursorWindow w2((QCursor(Qt::OpenHandCursor)), QColor(Qt::red).darker());
+ w2.setParent(&w1);
+ w2.setGeometry(0, 0, 100, 100);
+ w2.show();
+
+ CursorWindow w3((QCursor(Qt::IBeamCursor)), QColor(Qt::green).darker());
+ w3.setParent(&w1);
+ w3.setGeometry(100, 100, 100, 100);
+ w3.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/qcursor/childwindowcontainer/childwindowcontainer.pro b/tests/manual/qcursor/childwindowcontainer/childwindowcontainer.pro
new file mode 100644
index 0000000000..2233ce4a63
--- /dev/null
+++ b/tests/manual/qcursor/childwindowcontainer/childwindowcontainer.pro
@@ -0,0 +1,6 @@
+TEMPLATE = app
+TARGET = childwindowcontainer
+INCLUDEPATH += .
+QT += widgets
+
+SOURCES += main.cpp
diff --git a/tests/manual/qcursor/childwindowcontainer/main.cpp b/tests/manual/qcursor/childwindowcontainer/main.cpp
new file mode 100644
index 0000000000..d440133a42
--- /dev/null
+++ b/tests/manual/qcursor/childwindowcontainer/main.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite 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 <QtWidgets>
+
+class CursorWindow : public QRasterWindow
+{
+public:
+ CursorWindow(QCursor cursor, QColor color)
+ :m_cursor(cursor)
+ ,m_color(color)
+ {
+ if (cursor.shape() == Qt::ArrowCursor)
+ unsetCursor();
+ else
+ setCursor(cursor);
+ }
+
+ void paintEvent(QPaintEvent *e)
+ {
+ QPainter p(this);
+ p.fillRect(e->rect(), m_color);
+ }
+
+ void mousePressEvent(QMouseEvent *)
+ {
+ // Toggle cursor
+ QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor;
+ if (newCursor.shape() == Qt::ArrowCursor)
+ unsetCursor();
+ else
+ setCursor(newCursor);
+ }
+
+private:
+ QCursor m_cursor;
+ QColor m_color;
+};
+
+class CursorWidget : public QWidget
+{
+public:
+ CursorWidget(QCursor cursor, QColor color)
+ :m_cursor(cursor)
+ ,m_color(color)
+ {
+ if (cursor.shape() == Qt::ArrowCursor)
+ unsetCursor();
+ else
+ setCursor(cursor);
+ }
+
+ void paintEvent(QPaintEvent *e)
+ {
+ QPainter p(this);
+ p.fillRect(e->rect(), m_color);
+ }
+
+ void mousePressEvent(QMouseEvent *)
+ {
+ // Toggle cursor
+ QCursor newCursor = (cursor().shape() == m_cursor.shape()) ? QCursor() : m_cursor;
+ if (newCursor.shape() == Qt::ArrowCursor)
+ unsetCursor();
+ else
+ setCursor(newCursor);
+ }
+
+private:
+ QCursor m_cursor;
+ QColor m_color;
+};
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ {
+ // Create top-level windowContainer with window. Setting the cursor
+ // for the container should set the cursor for the window as well.
+ // Setting the cursor for the window overrides the cursor for the
+ // container. The example starts out with a window cursor; click
+ // to fall back to the container cursor.
+ CursorWindow *w1 = new CursorWindow(QCursor(Qt::OpenHandCursor), QColor(Qt::red).darker());
+ QWidget* container = QWidget::createWindowContainer(w1);
+ container->resize(200, 200);
+ container->setCursor(Qt::PointingHandCursor);
+ container->show();
+ }
+
+ {
+ // Similar to above, but with a top-level QWiget
+ CursorWidget *w1 = new CursorWidget(QCursor(Qt::IBeamCursor), QColor(Qt::green).darker());
+ w1->resize(200, 200);
+
+ CursorWindow *w2 = new CursorWindow(QCursor(Qt::OpenHandCursor), QColor(Qt::red).darker());
+ QWidget* container = QWidget::createWindowContainer(w2);
+ container->winId(); // must make the container native, otherwise setCursor
+ // sets the cursor on a QWindowContainerClassWindow which
+ // is outside the QWindow hierarchy (macOS).
+ container->setParent(w1);
+ container->setCursor(Qt::PointingHandCursor);
+ container->setGeometry(0, 0, 100, 100);
+
+ w1->show();
+ }
+
+ return app.exec();
+}
diff --git a/tests/manual/qcursor/qcursor.pro b/tests/manual/qcursor/qcursor.pro
index 0b5c2b1945..c6617b8e89 100644
--- a/tests/manual/qcursor/qcursor.pro
+++ b/tests/manual/qcursor/qcursor.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
-SUBDIRS = allcursors grab_override qcursorhighdpi
+SUBDIRS = allcursors childwidget childwindow childwindowcontainer grab_override qcursorhighdpi