| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2017 The Qt Company Ltd. |
| 4 |
** Contact: https://www.qt.io/licensing/ |
| 5 |
** |
| 6 |
** This file is part of the test suite of the Qt Toolkit. |
| 7 |
** |
| 8 |
** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 |
** Commercial License Usage |
| 10 |
** Licensees holding valid commercial Qt licenses may use this file in |
| 11 |
** accordance with the commercial license agreement provided with the |
| 12 |
** Software or, alternatively, in accordance with the terms contained in |
| 13 |
** a written agreement between you and The Qt Company. For licensing terms |
| 14 |
** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 |
** information use the contact form at https://www.qt.io/contact-us. |
| 16 |
** |
| 17 |
** GNU General Public License Usage |
| 18 |
** Alternatively, this file may be used under the terms of the GNU |
| 19 |
** General Public License version 3 as published by the Free Software |
| 20 |
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 |
** included in the packaging of this file. Please review the following |
| 22 |
** information to ensure the GNU General Public License requirements will |
| 23 |
** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 |
** |
| 25 |
** $QT_END_LICENSE$ |
| 26 |
** |
| 27 |
****************************************************************************/ |
| 28 |
|
| 29 |
#include "mainwindow.h" |
| 30 |
#include "menuramaapplication.h" |
| 31 |
|
| 32 |
#include <QtWidgets/QAction> |
| 33 |
#include <QtWidgets/QMenu> |
| 34 |
|
| 35 |
int main(int argc, char *argv[]) |
| 36 |
{ |
| 37 |
MenuramaApplication a(argc, argv); |
| 38 |
a.setQuitOnLastWindowClosed(false); |
| 39 |
|
| 40 |
auto *dockMenu = new QMenu(); |
| 41 |
dockMenu->setAsDockMenu(); |
| 42 |
dockMenu->addAction(QLatin1String("New Window"), [=] { |
| 43 |
auto *w = new MainWindow; |
| 44 |
w->setAttribute(Qt::WA_DeleteOnClose, true); |
| 45 |
w->show(); |
| 46 |
}); |
| 47 |
auto *disabledAction = dockMenu->addAction(QLatin1String("Disabled Item"), [=] { |
| 48 |
qDebug() << "Should not happen!"; |
| 49 |
Q_UNREACHABLE(); |
| 50 |
}); |
| 51 |
disabledAction->setEnabled(false); |
| 52 |
dockMenu->addAction(QLatin1String("Last Item Before Separator"), [=] { |
| 53 |
qDebug() << "Last Item triggered"; |
| 54 |
}); |
| 55 |
auto *hiddenAction = dockMenu->addAction(QLatin1String("Invisible Item (FIXME rdar:39615815)"), [=] { |
| 56 |
qDebug() << "Should not happen!"; |
| 57 |
Q_UNREACHABLE(); |
| 58 |
}); |
| 59 |
hiddenAction->setVisible(false); |
| 60 |
dockMenu->addSeparator(); |
| 61 |
auto *toolsMenu = dockMenu->addMenu(QLatin1String("Menurama Tools")); |
| 62 |
toolsMenu->addAction(QLatin1String("Hammer"), [=] { |
| 63 |
qDebug() << "Bang! Bang!"; |
| 64 |
}); |
| 65 |
toolsMenu->addAction(QLatin1String("Wrench"), [=] { |
| 66 |
qDebug() << "Clang! Clang!"; |
| 67 |
}); |
| 68 |
toolsMenu->addAction(QLatin1String("Screwdriver"), [=] { |
| 69 |
qDebug() << "Squeak! Squeak!"; |
| 70 |
}); |
| 71 |
|
| 72 |
MainWindow w; |
| 73 |
w.show(); |
| 74 |
|
| 75 |
return a.exec(); |
| 76 |
} |