diff --git a/tests/manual/widgets/widgets.pro b/tests/manual/widgets/widgets.pro index 3a128581cfe..e3942a49e9c 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 00000000000..f63d644320f --- /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 + +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 00000000000..a53eda37fab --- /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 + +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 00000000000..7689062221c --- /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 + +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 00000000000..dbc5c437b48 --- /dev/null +++ b/tests/manual/widgets/widgets/multiscreen-menus/mainwindow.ui @@ -0,0 +1,86 @@ + + + MainWindow + + + + 0 + 0 + 427 + 228 + + + + MainWindow + + + + + + + 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. + + + true + + + + + + + + + + 0 + 0 + + + + Menu Button + + + + + + + + 18 + + + + Right-click for context menu + + + false + + + Qt::AlignHCenter|Qt::AlignTop + + + true + + + + + + + + + + + 0 + 0 + 427 + 22 + + + + + + + + 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 00000000000..a723b3f7627 --- /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