diff options
Diffstat (limited to 'tests')
13 files changed, 536 insertions, 13 deletions
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index d70b099fe3..7dd1a1be01 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -111,19 +111,19 @@ void tst_QFlags::constExpr() default: QVERIFY(false); } - QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::LeftButton>(Qt::LeftButton)); - QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::MiddleButton>(0)); - QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) | Qt::MiddleButton>(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton)); - QVERIFY(verifyConstExpr<~(Qt::LeftButton | Qt::RightButton)>(~(Qt::LeftButton | Qt::RightButton))); - QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::LeftButton) ^ Qt::RightButton>(Qt::LeftButton ^ Qt::RightButton)); - QVERIFY(verifyConstExpr<Qt::MouseButtons(0)>(0)); - QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::RightButton) & 0xff>(Qt::RightButton)); - QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::RightButton) | 0xff>(0xff)); + QVERIFY(verifyConstExpr<uint((Qt::LeftButton | Qt::RightButton) & Qt::LeftButton)>(Qt::LeftButton)); + QVERIFY(verifyConstExpr<uint((Qt::LeftButton | Qt::RightButton) & Qt::MiddleButton)>(0)); + QVERIFY(verifyConstExpr<uint((Qt::LeftButton | Qt::RightButton) | Qt::MiddleButton)>(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton)); + QVERIFY(verifyConstExpr<uint(~(Qt::LeftButton | Qt::RightButton))>(~(Qt::LeftButton | Qt::RightButton))); + QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(Qt::LeftButton) ^ Qt::RightButton)>(Qt::LeftButton ^ Qt::RightButton)); + QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(0))>(0)); + QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(Qt::RightButton) & 0xff)>(Qt::RightButton)); + QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(Qt::RightButton) | 0xff)>(0xff)); QVERIFY(!verifyConstExpr<Qt::RightButton>(!Qt::MouseButtons(Qt::LeftButton))); #if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304 - QVERIFY(verifyConstExpr<testRelaxedConstExpr()>(Qt::MiddleButton)); + QVERIFY(verifyConstExpr<uint(testRelaxedConstExpr())>(Qt::MiddleButton)); #endif #endif } diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp index 1598382959..a52b80170f 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp @@ -360,11 +360,16 @@ void tst_QSocketNotifier::asyncMultipleDatagram() QSignalSpy spy(m_asyncReceiver, &QIODevice::readyRead); connect(m_asyncReceiver, &QIODevice::readyRead, this, &tst_QSocketNotifier::async_readDatagramSlot); + + // activate socket notifiers + QTestEventLoop::instance().enterLoopMSecs(100); + m_asyncSender->writeDatagram("1", makeNonAny(m_asyncReceiver->localAddress()), port); m_asyncSender->writeDatagram("2", makeNonAny(m_asyncReceiver->localAddress()), port); // wait a little to ensure that the datagrams we've just sent // will be delivered on receiver side. QTest::qSleep(100); + QVERIFY(m_asyncReceiver->hasPendingDatagrams()); QTimer::singleShot(500, this, &tst_QSocketNotifier::async_writeDatagramSlot); diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index d628fad705..e031ffec71 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -594,6 +594,7 @@ void tst_QIcon::fromTheme() QIcon noIcon = QIcon::fromTheme("broken-icon"); QVERIFY(noIcon.isNull()); QVERIFY(!QIcon::hasThemeIcon("broken-icon")); + QCOMPARE(noIcon.actualSize(QSize(32, 32), QIcon::Normal, QIcon::On), QSize(0, 0)); // Test non existing icon with fallback noIcon = QIcon::fromTheme("broken-icon", abIcon); diff --git a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp index e3f8f0fbac..14ba9c5c84 100644 --- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp +++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp @@ -84,6 +84,7 @@ private slots: void task251909(); void qtbug3778(); + void qtbug60024(); }; Q_DECLARE_METATYPE(QPainterPath) @@ -1293,6 +1294,260 @@ void tst_QPathClipper::qtbug3778() QVERIFY(p12.contains(QPointF(100, 100))); } +void tst_QPathClipper::qtbug60024() +{ + QPolygonF poly1, poly2; + poly1 << QPointF(508.331,1010.23) ; + poly1 << QPointF(492.798,1023.11) ; + poly1 << QPointF(491.431,1024.23) ; + poly1 << QPointF(491.928,1022.94) ; + poly1 << QPointF(492.054,1022.15) ; + poly1 << QPointF(492.136,1020.91) ; + poly1 << QPointF(491.638,1019.2) ; + poly1 << QPointF(490.436,1017.12) ; + poly1 << QPointF(489.856,1016.46) ; + poly1 << QPointF(489.276,1016.08) ; + poly1 << QPointF(488.16,1015.54) ; + poly1 << QPointF(487.33,1014.91) ; + poly1 << QPointF(486.914,1014.16) ; + poly1 << QPointF(486.875,1013.54) ; + poly1 << QPointF(487.204,1012.38) ; + poly1 << QPointF(487.412,1011.34) ; + poly1 << QPointF(487.373,1009.92) ; + poly1 << QPointF(487.702,1007.34) ; + poly1 << QPointF(487.909,1006.3) ; + poly1 << QPointF(488.242,1005.55) ; + poly1 << QPointF(488.74,1004.14) ; + poly1 << QPointF(489.445,1003.14) ; + poly1 << QPointF(490.107,1001.56) ; + poly1 << QPointF(490.064,1000.98) ; + poly1 << QPointF(489.566,999.936) ; + poly1 << QPointF(488.489,998.194) ; + poly1 << QPointF(488.117,997.274) ; + poly1 << QPointF(487.909,995.946) ; + poly1 << QPointF(487.909,995.027) ; + poly1 << QPointF(488.117,993.16) ; + poly1 << QPointF(488.658,989.749) ; + poly1 << QPointF(488.861,987.002) ; + poly1 << QPointF(489.359,976.434) ; + poly1 << QPointF(489.484,974.476) ; + poly1 << QPointF(489.484,972.859) ; + poly1 << QPointF(489.359,971.775) ; + poly1 << QPointF(489.151,970.986) ; + poly1 << QPointF(488.948,969.323) ; + poly1 << QPointF(488.74,966.036) ; + poly1 << QPointF(488.74,964.118) ; + poly1 << QPointF(489.03,961.292) ; + poly1 << QPointF(489.237,960.667) ; + poly1 << QPointF(489.648,960.043) ; + poly1 << QPointF(490.452,959.229) ; + poly1 << QPointF(491.528,958.225) ; + poly1 << QPointF(491.731,957.515) ; + poly1 << QPointF(491.32,956.812) ; + poly1 << QPointF(490.45,955.852) ; + poly1 << QPointF(489.412,954.354) ; + poly1 << QPointF(488.68,952.934) ; + poly1 << QPointF(488.625,951.201) ; + poly1 << QPointF(488.954,950.072) ; + poly1 << QPointF(489.237,949.225) ; + poly1 << QPointF(489.256,948.668) ; + poly1 << QPointF(489.402,948.186) ; + poly1 << QPointF(489.566,947.437) ; + poly1 << QPointF(490.025,945.899) ; + poly1 << QPointF(490.687,944.026) ; + poly1 << QPointF(491.059,942.073) ; + poly1 << QPointF(491.31,941.159) ; + poly1 << QPointF(491.846,937.248) ; + poly1 << QPointF(492.054,936.374) ; + poly1 << QPointF(492.594,935.29) ; + poly1 << QPointF(492.594,935.086) ; + poly1 << QPointF(492.261,934.416) ; + poly1 << QPointF(492.054,933.377) ; + poly1 << QPointF(492.054,932.628) ; + poly1 << QPointF(492.798,929.217) ; + poly1 << QPointF(493.174,928.217) ; + poly1 << QPointF(493.005,927.514) ; + poly1 << QPointF(492.923,926.719) ; + poly1 << QPointF(493.295,921.44) ; + poly1 << QPointF(493.421,919.771) ; + poly1 << QPointF(493.628,914.492) ; + poly1 << QPointF(493.71,913.158) ; + poly1 << QPointF(493.961,910.831) ; + poly1 << QPointF(494.623,909.247) ; + poly1 << QPointF(495.41,906.085) ; + poly1 << QPointF(495.203,905.421) ; + poly1 << QPointF(494.788,904.632) ; + poly1 << QPointF(494.705,904.297) ; + poly1 << QPointF(494.788,903.797) ; + poly1 << QPointF(495.121,902.844) ; + poly1 << QPointF(495.493,902.055) ; + poly1 << QPointF(496.033,900.556) ; + poly1 << QPointF(496.28,900.096) ; + poly1 << QPointF(496.488,899.222) ; + poly1 << QPointF(496.28,898.723) ; + poly1 << QPointF(495.41,898.098) ; + poly1 << QPointF(494.326,898.084) ; + poly1 << QPointF(493.993,897.42) ; + poly1 << QPointF(493.829,896.67) ; + poly1 << QPointF(493.621,894.962) ; + poly1 << QPointF(493.565,893.93) ; + poly1 << QPointF(494.416,893.358) ; + poly1 << QPointF(501.666,887.435) ; + poly1 << QPointF(513.305,877.908) ; + poly1 << QPointF(523.795,869.356) ; + poly1 << QPointF(603.378,804.221) ; + poly1 << QPointF(618.764,791.762) ; + poly1 << QPointF(618.981,791.584) ; + poly1 << QPointF(634.696,778.743) ; + poly1 << QPointF(673.531,747.007) ; + poly1 << QPointF(726.115,704.031) ; + poly1 << QPointF(759.04,677.12) ; + poly1 << QPointF(759.672,676.62) ; + poly1 << QPointF(778.846,660.773) ; + poly1 << QPointF(789.919,651.709) ; + poly1 << QPointF(810.528,634.696) ; + poly1 << QPointF(810.804,634.468) ; + poly1 << QPointF(818.197,628.365) ; + poly1 << QPointF(826.44,621.505) ; + poly1 << QPointF(832.634,616.351) ; + poly1 << QPointF(835.337,614.05) ; + poly1 << QPointF(835.492,613.931) ; + poly1 << QPointF(852.079,600.176) ; + poly1 << QPointF(860.469,593.219) ; + poly1 << QPointF(869.883,585.411) ; + poly1 << QPointF(896.749,563.131) ; + poly1 << QPointF(922.094,542.111) ; + poly1 << QPointF(936.469,530.189) ; + poly1 << QPointF(990.034,485.759) ; + poly1 << QPointF(1001.65,476.123) ; + poly1 << QPointF(1010.87,468.472) ; + poly1 << QPointF(1028.6,453.769) ; + poly1 << QPointF(1095.89,397.341) ; + poly1 << QPointF(1130.52,368.297) ; + poly1 << QPointF(1135.05,364.497) ; + poly1 << QPointF(1123.55,337.582) ; + poly1 << QPointF(1103.42,290.476) ; + poly1 << QPointF(1095.21,271.259) ; + poly1 << QPointF(1068.04,207.66) ; + poly1 << QPointF(1051.62,169.118) ; + poly1 << QPointF(1038.65,138.708) ; + poly1 << QPointF(1027.81,113.269) ; + poly1 << QPointF(1020.97,97.2145) ; + poly1 << QPointF(1010.84,73.4644) ; + poly1 << QPointF(988.424,20.9198) ; + poly1 << QPointF(968.442,-25.9307) ; + poly1 << QPointF(964.63,-34.8693) ; + poly1 << QPointF(961.883,-41.3111) ; + poly1 << QPointF(953.157,-61.929) ; + poly1 << QPointF(949.712,-70.0717) ; + poly1 << QPointF(946.048,-78.7331) ; + poly1 << QPointF(945.789,-79.3443) ; + poly1 << QPointF(945.548,-79.9146) ; + poly1 << QPointF(941.671,-89.0782) ; + poly1 << QPointF(940.408,-92.0616) ; + poly1 << QPointF(940.095,-92.8021) ; + poly1 << QPointF(938.65,-97.1094) ; + poly1 << QPointF(934.565,-106.581) ; + poly1 << QPointF(928.429,-121.542) ; + poly1 << QPointF(928.24,-122.003) ; + poly1 << QPointF(920.902,-139.241) ; + poly1 << QPointF(910.85,-162.115) ; + poly1 << QPointF(910.744,-162.357) ; + poly1 << QPointF(900.875,-186.271) ; + poly1 << QPointF(889.416,-213.089) ; + poly1 << QPointF(883.705,-226.225) ; + poly1 << QPointF(882.788,-228.422) ; + poly1 << QPointF(881.399,-231.753) ; + poly1 << QPointF(880.373,-234.213) ; + poly1 << QPointF(875.788,-245.204) ; + poly1 << QPointF(872.772,-252.085) ; + poly1 << QPointF(869.686,-259.126) ; + poly1 << QPointF(865.607,-268.43) ; + poly1 << QPointF(868.74,-269.605) ; + poly1 << QPointF(869.315,-269.834) ; + poly1 << QPointF(879.443,-273.853) ; + poly1 << QPointF(880.259,-274.217) ; + poly1 << QPointF(888.958,-278.09) ; + poly1 << QPointF(894.204,-280.426) ; + poly1 << QPointF(902.866,-284.423) ; + poly1 << QPointF(913.804,-289.072) ; + poly1 << QPointF(917.975,-290.846) ; + poly1 << QPointF(921.854,-292.375) ; + poly1 << QPointF(930.52,-295.793) ; + poly1 << QPointF(939.972,-299.79) ; + poly1 << QPointF(940.899,-300.183) ; + poly1 << QPointF(943.262,-294.709) ; + poly1 << QPointF(946.922,-286.233) ; + poly1 << QPointF(952.358,-273.643) ; + poly1 << QPointF(959.976,-256) ; + poly1 << QPointF(975.219,-220.296) ; + poly1 << QPointF(988.991,-188.494) ; + poly1 << QPointF(990.089,-185.959) ; + poly1 << QPointF(1001.86,-158.88) ; + poly1 << QPointF(1003.8,-154.245) ; + poly1 << QPointF(1011.55,-135.749) ; + poly1 << QPointF(1012.2,-134.199) ; + poly1 << QPointF(1012.77,-132.837) ; + poly1 << QPointF(1015.9,-125.529) ; + poly1 << QPointF(1015.99,-125.305) ; + poly1 << QPointF(1016.42,-124.299) ; + poly1 << QPointF(1018.02,-120.569) ; + poly1 << QPointF(1018.47,-119.395) ; + poly1 << QPointF(1028.09,-97.0593) ; + poly1 << QPointF(1028.89,-95.1902) ; + poly1 << QPointF(1032.85,-85.957) ; + poly1 << QPointF(1044.48,-58.8103) ; + poly1 << QPointF(1047.23,-52.3933) ; + poly1 << QPointF(1076.35,15.5527) ; + poly1 << QPointF(1089.43,46.0648) ; + poly1 << QPointF(1105.35,83.1913) ; + poly1 << QPointF(1120.01,117.391) ; + poly1 << QPointF(1131.66,144.66) ; + poly1 << QPointF(1142.1,169.072) ; + poly1 << QPointF(1183.42,265.698) ; + poly1 << QPointF(1200.9,306.583) ; + poly1 << QPointF(1208.48,324.306) ; + poly1 << QPointF(1231.19,377.389) ; + poly1 << QPointF(1241.55,400.064) ; + poly1 << QPointF(1139.56,485.759) ; + poly1 << QPointF(1104.96,514.822) ; + poly1 << QPointF(1044.32,565.761) ; + poly1 << QPointF(1020.92,585.411) ; + poly1 << QPointF(1013.72,591.462) ; + poly1 << QPointF(1012.73,592.285) ; + poly1 << QPointF(926.449,663.776) ; + poly1 << QPointF(843.981,732.099) ; + poly1 << QPointF(826.923,746.23) ; + poly1 << QPointF(810.856,759.539) ; + poly1 << QPointF(736.788,820.887) ; + poly1 << QPointF(709.695,843.348) ; + poly1 << QPointF(693.265,856.967) ; + poly1 << QPointF(690.228,859.484) ; + poly1 << QPointF(673.813,873.091) ; + poly1 << QPointF(672.34,874.317) ; + poly1 << QPointF(618.453,919.164) ; + poly1 << QPointF(607.821,928.011) ; + poly1 << QPointF(596.057,937.538) ; + poly1 << QPointF(580.774,950.204) ; + poly1 << QPointF(573.229,956.457) ; + poly1 << QPointF(533.091,989.719) ; + poly1 << QPointF(513.657,1005.86) ; + poly1 << QPointF(508.331,1010.23) ; + + poly2 << QPointF(941.306,435.236) ; + poly2 << QPointF(983.306,435.236) ; + poly2 << QPointF(983.306,473.236) ; + poly2 << QPointF(941.306,473.236) ; + poly2 << QPointF(941.306,435.236) ; + + QPainterPath path1, path2; + path1.addPolygon(poly1); + path2.addPolygon(poly2); + + QVERIFY(!path1.intersects(path2)); + QVERIFY(path1.intersected(path2).isEmpty()); +} + QTEST_MAIN(tst_QPathClipper) diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index a74a056d91..60ee4eb471 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -625,6 +625,18 @@ void tst_QLocalSocket::readBufferOverflow() QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); // no more bytes available QCOMPARE(client.bytesAvailable(), 0); + +#ifdef Q_OS_WIN + // Test overflow caused by an asynchronous pipe operation. + client.setReadBufferSize(1); + serverSocket->write(buffer, 2); + + QVERIFY(client.waitForReadyRead()); + // socket disconnects, if there any error on pipe + QCOMPARE(client.state(), QLocalSocket::ConnectedState); + QCOMPARE(client.bytesAvailable(), qint64(2)); + QCOMPARE(client.read(buffer, 2), qint64(2)); +#endif } static qint64 writeCommand(const QVariant &command, QIODevice *device, int commandCounter) diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST index cfab0b7eb0..52c023b78f 100644 --- a/tests/auto/network/ssl/qsslsocket/BLACKLIST +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -5,5 +5,3 @@ windows rhel-7.2 [protocolServerSide:tls1.0-any] rhel-7.2 -[protocolServerSide] -osx-10.11 diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 1ff7a0c97b..d48ee03a22 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -676,7 +676,7 @@ void tst_QFileDialog2::completionOnLevelAfterRoot() } if (!invalid) { foreach (const QString &check, entryList) { - if (check.startsWith(entry.left(5)) && check != entry) { + if (check.startsWith(entry.left(5), Qt::CaseInsensitive) && check != entry) { invalid = true; break; } diff --git a/tests/manual/widgets/widgets.pro b/tests/manual/widgets/widgets.pro index 3a128581cf..e3942a49e9 100644 --- a/tests/manual/widgets/widgets.pro +++ b/tests/manual/widgets/widgets.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = itemviews qgraphicsview kernel +SUBDIRS = itemviews qgraphicsview kernel widgets greaterThan(QT_MAJOR_VERSION, 4): SUBDIRS += styles diff --git a/tests/manual/widgets/widgets/multiscreen-menus/main.cpp b/tests/manual/widgets/widgets/multiscreen-menus/main.cpp new file mode 100644 index 0000000000..f63d644320 --- /dev/null +++ b/tests/manual/widgets/widgets/multiscreen-menus/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include <QApplication> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + a.setAttribute(Qt::AA_DontUseNativeMenuBar); + + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.cpp b/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.cpp new file mode 100644 index 0000000000..a53eda37fa --- /dev/null +++ b/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include <QtGui/QtEvents> + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + setStyleSheet("QMenu { menu-scrollable: 0 }"); + + auto *mb = new QMenuBar(this); + setMenuBar(mb); + + auto *m = new QMenu(mb); + m->setTitle("&Menu"); + m->setTearOffEnabled(true); + + for (int i = 0; i < 80; ++i) + m->addAction("Menu Item #" + QString::number(i)); + + mb->addMenu(m); + + ui->menuButton->setMenu(m); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::contextMenuEvent(QContextMenuEvent *e) +{ + const auto *mb = menuBar(); + mb->actions().first()->menu()->popup(mb->mapToGlobal(e->pos())); +} diff --git a/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.h b/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.h new file mode 100644 index 0000000000..7689062221 --- /dev/null +++ b/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + + void contextMenuEvent(QContextMenuEvent *e) override; + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.ui b/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.ui new file mode 100644 index 0000000000..dbc5c437b4 --- /dev/null +++ b/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.ui @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>427</width> + <height>228</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralWidget"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Move this window to a secondary screen, ideally with a larger size than the primary screen. + +Open menu bar, button and context menus. The menu contents should be consistent with the screen it's being displayed on. + +Tear-off the menu and move around across screens. The torn-off menu should adapt to the screen size.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="menuButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Menu Button</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="font"> + <font> + <pointsize>18</pointsize> + </font> + </property> + <property name="text"> + <string>Right-click for context menu</string> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + <property name="alignment"> + <set>Qt::AlignHCenter|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menuBar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>427</width> + <height>22</height> + </rect> + </property> + </widget> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources/> + <connections/> +</ui> diff --git a/tests/manual/widgets/widgets/multiscreen-menus/multiscreen-menus.pro b/tests/manual/widgets/widgets/multiscreen-menus/multiscreen-menus.pro new file mode 100644 index 0000000000..a723b3f762 --- /dev/null +++ b/tests/manual/widgets/widgets/multiscreen-menus/multiscreen-menus.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +QT += core gui widgets + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui |