From a30c746ea41046462cfd02ba2978c040f6b87aa7 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 1 May 2017 14:01:46 +0700 Subject: Introducing multiscreen-menus manual test We have been noticing several menu popup sizing issues in the presence of multiple, heterogenous displays. Most remarkably, we'd often pick the primary display's geometry when computing the menu's size hint. This results in usability issues if the primary display is smaller than the display onto which the menu popup is being displayed. This manual test covers menu bar, context and push button menus. Torn-off menus are also enabled. We turn off the use of native menu bars to cover a few more cases. Change-Id: I29658ebdc56e41aa1bf99d06d96aed6bfb5461b3 Reviewed-by: Friedemann Kleint --- tests/manual/widgets/widgets.pro | 2 +- .../widgets/widgets/multiscreen-menus/main.cpp | 41 +++++++++++ .../widgets/multiscreen-menus/mainwindow.cpp | 64 ++++++++++++++++ .../widgets/widgets/multiscreen-menus/mainwindow.h | 52 +++++++++++++ .../widgets/multiscreen-menus/mainwindow.ui | 86 ++++++++++++++++++++++ .../multiscreen-menus/multiscreen-menus.pro | 9 +++ 6 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 tests/manual/widgets/widgets/multiscreen-menus/main.cpp create mode 100644 tests/manual/widgets/widgets/multiscreen-menus/mainwindow.cpp create mode 100644 tests/manual/widgets/widgets/multiscreen-menus/mainwindow.h create mode 100644 tests/manual/widgets/widgets/multiscreen-menus/mainwindow.ui create mode 100644 tests/manual/widgets/widgets/multiscreen-menus/multiscreen-menus.pro (limited to 'tests/manual') 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 + +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 + +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 + +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 @@ + + + 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 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 -- cgit v1.2.3