2016-08-11 00:24:04 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2017-02-21 09:48:17 +00:00
|
|
|
** 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.
|
2016-08-11 00:24:04 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef MENURAMAAPPLICATION_H
|
|
|
|
#define MENURAMAAPPLICATION_H
|
|
|
|
|
|
|
|
#include <QtWidgets>
|
|
|
|
|
|
|
|
#define menuApp (static_cast<MenuramaApplication *>(QCoreApplication::instance()))
|
|
|
|
|
|
|
|
class MenuramaApplication : public QApplication
|
|
|
|
{
|
|
|
|
public:
|
2017-11-14 16:23:49 +00:00
|
|
|
MenuramaApplication(int &argc, char **argv);
|
2016-08-11 00:24:04 +00:00
|
|
|
void addDynMenu(QLatin1String title, QMenu *parentMenu);
|
QCocoaMenu: Force NSMenuValidation when syncing items
When a menu item's enabled state changes after
-[QCocoaMenuDelegate menuWillOpen:] is invoked, i.e.,
during or after QMenu::aboutToShow() is emitted, that
state change may not be taken into account. This is
because the automatic menu validation, upon which Qt
relies, is not made aware of any such change.
By calling -[NSMenu update] when syncing the QPA menu
item, we induce Cocoa to invoke -[QCocoaMenuDelegate
validateMenuItem:] and ensure that previously synced
items, whose state may have changed, will be properly
updated. This, however, has a small side effect, namely
that menu-holding items will also go through the automatic
menu enabling path and may appear disabled since, until
now, they were not properly configured. In order to solve
this, we set the action on those items as well, and make
sure that both of QCocoaMenuDelegate's relevant methods,
validateMenuItem: and itemFired:, properly process
menu-holding items.
Menurama manual test updated accordingly.
Change-Id: I62f955538b8be09b8494ea0ce87fca7910148d38
Task-number: QTBUG-56850
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2016-11-03 00:37:43 +00:00
|
|
|
QAction *findAction(QLatin1String title, QMenu *parentMenu);
|
2016-08-11 00:24:04 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void populateMenu(QMenu *menu, bool clear);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MENURAMAAPPLICATION_H
|