diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2023-04-03 09:45:20 +0200 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2023-04-06 10:36:17 +0200 |
commit | 73f52eb39f80ce2ba9602c3faf8939b752aa9098 (patch) | |
tree | b1889fb77079412bdb9b3c002a346fea5e94083a /tests | |
parent | 4fa7ebcf6390ed415ffd8d6bdc4987b789dad309 (diff) | |
download | qtactiveqt-73f52eb39f80ce2ba9602c3faf8939b752aa9098.tar.gz |
examples: Remove menus example
Showing the usage of QMenuBar and QStatusBar in a QMainWindow can be
merged into another if needed.
In order to keep the use case's code in source, the example was moved to
tests/manual.
Pick-to: 6.5
Change-Id: I76ec12e9c83a42028f2de95ab17ca07544b53425
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/manual/menus/CMakeLists.txt | 25 | ||||
-rw-r--r-- | tests/manual/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc | 9 | ||||
-rw-r--r-- | tests/manual/menus/doc/src/menus.qdoc | 36 | ||||
-rw-r--r-- | tests/manual/menus/fileopen.xpm | 22 | ||||
-rw-r--r-- | tests/manual/menus/filesave.xpm | 22 | ||||
-rw-r--r-- | tests/manual/menus/main.cpp | 26 | ||||
-rw-r--r-- | tests/manual/menus/menus.cpp | 140 | ||||
-rw-r--r-- | tests/manual/menus/menus.def | 6 | ||||
-rw-r--r-- | tests/manual/menus/menus.h | 41 | ||||
-rw-r--r-- | tests/manual/menus/menus.ico | bin | 0 -> 766 bytes | |||
-rw-r--r-- | tests/manual/menus/menus.inf | 9 | ||||
-rw-r--r-- | tests/manual/menus/menus.pro | 16 | ||||
-rw-r--r-- | tests/manual/menus/menus.rc | 2 |
14 files changed, 356 insertions, 0 deletions
diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index 4db4d20..30a59d3 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -5,4 +5,6 @@ add_subdirectory(axviewer) add_subdirectory(dumpcpp) add_subdirectory(hierarchy) add_subdirectory(mediaplayer) +add_subdirectory(menus) +add_subdirectory(opengl) add_subdirectory(testcontrol) diff --git a/tests/manual/menus/CMakeLists.txt b/tests/manual/menus/CMakeLists.txt new file mode 100644 index 0000000..a8b3899 --- /dev/null +++ b/tests/manual/menus/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## menus Executable: +##################################################################### + +set(CMAKE_AUTOMOC ON) + +qt_internal_add_manual_test(tst_menus + GUI + SOURCES + main.cpp + menus.cpp menus.h + menus.def + menus.rc + LIBRARIES + Qt::AxServer + Qt::Core + Qt::Gui + Qt::Widgets +) + +qt_disable_warnings(tst_menus) +qt6_target_idl(tst_menus) diff --git a/tests/manual/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc b/tests/manual/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc new file mode 100644 index 0000000..a889f0f --- /dev/null +++ b/tests/manual/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc @@ -0,0 +1,9 @@ +// Copyright (C) 2015 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//! [0] +<object ID="QMenus" CLASSID="CLSID:4dc3f340-a6f7-44e4-a79b-3e9217695fbd" +CODEBASE="http://www.qt-project.org/demos/menusax.cab"> +[Object not available! Did you forget to build and register the server?] +</object> +//! [0] diff --git a/tests/manual/menus/doc/src/menus.qdoc b/tests/manual/menus/doc/src/menus.qdoc new file mode 100644 index 0000000..fdbe4ce --- /dev/null +++ b/tests/manual/menus/doc/src/menus.qdoc @@ -0,0 +1,36 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \page qaxserver-demo-menus.html + \preliminary + + \title Menubar Merging + + This example is not fully functional at the moment. + + \raw HTML + <object ID="QMenus" CLASSID="CLSID:4dc3f340-a6f7-44e4-a79b-3e9217695fbd" + CODEBASE="http://www.qt-project.org/demos/menusax.cab"> + [Object not available! Did you forget to build and register the server?] + </object> + \endraw +*/ + +/*! + \example activeqt/menus + \title Menus Example (ActiveQt) + + \brief The Menus example demonstrates the use of QMenuBar and QStatusBar + in a QMainWindow to implement an in-place active control. + + To build the example you must first build the QAxServer library. + Then run \c qmake and your make tool in \c + examples/activeqt/menus. + + The \l{qaxserver-demo-menus.html}{demonstration} requires your + WebBrowser to support ActiveX controls, and scripting to be + enabled. + + \snippet activeqt/menus/doc/snippets/doc_src_examples_activeqt_menus.qdoc 0 +*/ diff --git a/tests/manual/menus/fileopen.xpm b/tests/manual/menus/fileopen.xpm new file mode 100644 index 0000000..880417e --- /dev/null +++ b/tests/manual/menus/fileopen.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char *fileopen[] = { +" 16 13 5 1", +". c #040404", +"# c #808304", +"a c None", +"b c #f3f704", +"c c #f3f7f3", +"aaaaaaaaa...aaaa", +"aaaaaaaa.aaa.a.a", +"aaaaaaaaaaaaa..a", +"a...aaaaaaaa...a", +".bcb.......aaaaa", +".cbcbcbcbc.aaaaa", +".bcbcbcbcb.aaaaa", +".cbcb...........", +".bcb.#########.a", +".cb.#########.aa", +".b.#########.aaa", +"..#########.aaaa", +"...........aaaaa" +}; diff --git a/tests/manual/menus/filesave.xpm b/tests/manual/menus/filesave.xpm new file mode 100644 index 0000000..bd6870f --- /dev/null +++ b/tests/manual/menus/filesave.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char *filesave[] = { +" 14 14 4 1", +". c #040404", +"# c #808304", +"a c #bfc2bf", +"b c None", +"..............", +".#.aaaaaaaa.a.", +".#.aaaaaaaa...", +".#.aaaaaaaa.#.", +".#.aaaaaaaa.#.", +".#.aaaaaaaa.#.", +".#.aaaaaaaa.#.", +".##........##.", +".############.", +".##.........#.", +".##......aa.#.", +".##......aa.#.", +".##......aa.#.", +"b............." +}; diff --git a/tests/manual/menus/main.cpp b/tests/manual/menus/main.cpp new file mode 100644 index 0000000..70e84eb --- /dev/null +++ b/tests/manual/menus/main.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2015 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "menus.h" +#include <QApplication> +#include <QAxFactory> +#include <QScopedPointer> + +QAXFACTORY_BEGIN( + "{ce947ee3-0403-4fdc-895a-4fe779394b46}", // type library ID + "{8de435ce-8d2a-46ac-b3b3-cb800d0847c7}") // application ID + QAXCLASS(QMenus) +QAXFACTORY_END() + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QScopedPointer<QWidget> window; + + if (!QAxFactory::isServer()) { + window.reset(new QMenus()); + window->show(); + } + + return a.exec(); +} diff --git a/tests/manual/menus/menus.cpp b/tests/manual/menus/menus.cpp new file mode 100644 index 0000000..3093862 --- /dev/null +++ b/tests/manual/menus/menus.cpp @@ -0,0 +1,140 @@ +// Copyright (C) 2015 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "menus.h" +#include <QAction> +#include <QAxFactory> +#include <QMenuBar> +#include <QMessageBox> +#include <QTextEdit> +#include <QPixmap> + +#include "fileopen.xpm" +#include "filesave.xpm" + +QMenus::QMenus(QWidget *parent) + : QMainWindow(parent, {}) // QMainWindow's default flag is WType_TopLevel +{ + QAction *action; + + QMenu *file = new QMenu(this); + + action = new QAction(QPixmap((const char**)fileopen), tr("&Open"), this); + action->setShortcut(tr("CTRL+O")); + connect(action, &QAction::triggered, this, &QMenus::fileOpen); + file->addAction(action); + + action = new QAction(QPixmap((const char**)filesave), tr("&Save"), this); + action->setShortcut(tr("CTRL+S")); + connect(action, &QAction::triggered, this, &QMenus::fileSave); + file->addAction(action); + + QMenu *edit = new QMenu(this); + + action = new QAction(tr("&Normal"), this); + action->setShortcut(tr("CTRL+N")); + action->setToolTip(tr("Normal")); + action->setStatusTip(tr("Toggles Normal")); + action->setCheckable(true); + connect(action, &QAction::triggered, this, &QMenus::editNormal); + edit->addAction(action); + + action = new QAction(tr("&Bold"), this); + action->setShortcut(tr("CTRL+B")); + action->setCheckable(true); + connect(action, &QAction::triggered, this, &QMenus::editBold); + edit->addAction(action); + + action = new QAction(tr("&Underline"), this); + action->setShortcut(tr("CTRL+U")); + action->setCheckable(true); + connect(action, &QAction::triggered, this, &QMenus::editUnderline); + edit->addAction(action); + + QMenu *advanced = new QMenu(this); + action = new QAction(tr("&Font..."), this); + connect(action, &QAction::triggered, this, &QMenus::editAdvancedFont); + advanced->addAction(action); + + action = new QAction(tr("&Style..."), this); + connect(action, &QAction::triggered, this, &QMenus::editAdvancedStyle); + advanced->addAction(action); + + edit->addMenu(advanced)->setText(tr("&Advanced")); + + edit->addSeparator(); + + action = new QAction(tr("Una&vailable"), this); + action->setShortcut(tr("CTRL+V")); + action->setCheckable(true); + action->setEnabled(false); + connect(action, &QAction::triggered, this, &QMenus::editUnderline); + edit->addAction(action); + + QMenu *help = new QMenu(this); + + action = new QAction(tr("&About..."), this); + action->setShortcut(tr("F1")); + connect(action, &QAction::triggered, this, &QMenus::helpAbout); + help->addAction(action); + + action = new QAction(tr("&About Qt..."), this); + connect(action, &QAction::triggered, this, &QMenus::helpAboutQt); + help->addAction(action); + + if (!QAxFactory::isServer()) + menuBar()->addMenu(file)->setText(tr("&File")); + menuBar()->addMenu(edit)->setText(tr("&Edit")); + menuBar()->addMenu(help)->setText(tr("&Help")); + + m_editor = new QTextEdit(this); + setCentralWidget(m_editor); + + statusBar(); +} + +void QMenus::fileOpen() +{ + m_editor->append(tr("File Open selected.")); +} + +void QMenus::fileSave() +{ + m_editor->append(tr("File Save selected.")); +} + +void QMenus::editNormal() +{ + m_editor->append(tr("Edit Normal selected.")); +} + +void QMenus::editBold() +{ + m_editor->append(tr("Edit Bold selected.")); +} + +void QMenus::editUnderline() +{ + m_editor->append(tr("Edit Underline selected.")); +} + +void QMenus::editAdvancedFont() +{ + m_editor->append(tr("Edit Advanced Font selected.")); +} + +void QMenus::editAdvancedStyle() +{ + m_editor->append(tr("Edit Advanced Style selected.")); +} + +void QMenus::helpAbout() +{ + QMessageBox::about(this, tr("About QMenus"), + tr("This example implements an in-place ActiveX control with menus and status messages.")); +} + +void QMenus::helpAboutQt() +{ + QMessageBox::aboutQt(this); +} diff --git a/tests/manual/menus/menus.def b/tests/manual/menus/menus.def new file mode 100644 index 0000000..bc82a03 --- /dev/null +++ b/tests/manual/menus/menus.def @@ -0,0 +1,6 @@ +EXPORTS + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE + DumpIDL PRIVATE diff --git a/tests/manual/menus/menus.h b/tests/manual/menus/menus.h new file mode 100644 index 0000000..b21a9c3 --- /dev/null +++ b/tests/manual/menus/menus.h @@ -0,0 +1,41 @@ +// Copyright (C) 2015 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef MENUS_H +#define MENUS_H + +#include <QMainWindow> + +QT_BEGIN_NAMESPACE +class QTextEdit; +QT_END_NAMESPACE + +class QMenus : public QMainWindow +{ + Q_OBJECT + Q_CLASSINFO("ClassID", "{4dc3f340-a6f7-44e4-a79b-3e9217695fbd}") + Q_CLASSINFO("InterfaceID", "{9ee49617-7d5c-441a-b833-4b068d40d751}") + Q_CLASSINFO("EventsID", "{13eca64b-ee2a-4f3c-aa04-5d9d975979a7}") + +public: + explicit QMenus(QWidget *parent = nullptr); + +public slots: + void fileOpen(); + void fileSave(); + + void editNormal(); + void editBold(); + void editUnderline(); + + void editAdvancedFont(); + void editAdvancedStyle(); + + void helpAbout(); + void helpAboutQt(); + +private: + QTextEdit *m_editor; +}; + +#endif // MENUS_H diff --git a/tests/manual/menus/menus.ico b/tests/manual/menus/menus.ico Binary files differnew file mode 100644 index 0000000..c80d36a --- /dev/null +++ b/tests/manual/menus/menus.ico diff --git a/tests/manual/menus/menus.inf b/tests/manual/menus/menus.inf new file mode 100644 index 0000000..f97efe8 --- /dev/null +++ b/tests/manual/menus/menus.inf @@ -0,0 +1,9 @@ +[version] + signature="$CHICAGO$" + AdvancedINF=2.0 + [Add.Code] + menusax.exe=menusax.exe + [menusax.exe] + file-win32-x86=thiscab + clsid={4dc3f340-a6f7-44e4-a79b-3e9217695fbd} + RegisterServer=yes diff --git a/tests/manual/menus/menus.pro b/tests/manual/menus/menus.pro new file mode 100644 index 0000000..f5a7890 --- /dev/null +++ b/tests/manual/menus/menus.pro @@ -0,0 +1,16 @@ +include(../shared.pri) + +TEMPLATE = app +TARGET = menusax + +CONFIG += warn_off +QT += widgets axserver + +SOURCES = main.cpp menus.cpp +HEADERS = menus.h +RC_FILE = menus.rc +DEF_FILE = menus.def + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/menus +INSTALLS += target diff --git a/tests/manual/menus/menus.rc b/tests/manual/menus/menus.rc new file mode 100644 index 0000000..d466b35 --- /dev/null +++ b/tests/manual/menus/menus.rc @@ -0,0 +1,2 @@ +1 TYPELIB "menus.rc" +1 ICON "menus.ico" |