summaryrefslogtreecommitdiffstats
path: root/tests/manual/widgets/widgets/multiscreen-menus
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/widgets/widgets/multiscreen-menus')
-rw-r--r--tests/manual/widgets/widgets/multiscreen-menus/main.cpp41
-rw-r--r--tests/manual/widgets/widgets/multiscreen-menus/mainwindow.cpp64
-rw-r--r--tests/manual/widgets/widgets/multiscreen-menus/mainwindow.h52
-rw-r--r--tests/manual/widgets/widgets/multiscreen-menus/mainwindow.ui86
-rw-r--r--tests/manual/widgets/widgets/multiscreen-menus/multiscreen-menus.pro9
5 files changed, 252 insertions, 0 deletions
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