From f10dccb1b8d6fa462ca0891b0247ff133a00c8b0 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 18 Dec 2013 17:28:21 -0800 Subject: [PATCH] Fix for menu shortcuts; just include widget library rather than using awkward workaround. --- assignment-client/CMakeLists.txt | 3 ++- interface/src/Menu.cpp | 8 ++++---- interface/src/Menu.h | 4 ++-- libraries/shared/CMakeLists.txt | 3 ++- libraries/shared/src/AbstractMenuInterface.h | 14 +++++--------- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 464728f7e0..c7b8ab5732 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,11 +9,12 @@ set(MACRO_DIR ${ROOT_DIR}/cmake/macros) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") find_package(Qt5Network REQUIRED) +find_package(Qt5Widgets REQUIRED) include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -qt5_use_modules(${TARGET_NAME} Network) +qt5_use_modules(${TARGET_NAME} Network Widgets) # include glm include(${MACRO_DIR}/IncludeGLM.cmake) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 38f4ae3bae..98b807fea2 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -690,10 +690,10 @@ void Menu::addDisabledActionAndSeparator(QMenu* destinationMenu, const QString& QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, const QString actionName, - const QKEYSEQUENCE& shortcut, + const QKeySequence& shortcut, const QObject* receiver, const char* member, - QACTION_MENUROLE role) { + QAction::MenuRole role) { QAction* action; if (receiver && member) { @@ -702,7 +702,7 @@ QAction* Menu::addActionToQMenuAndActionHash(QMenu* destinationMenu, action = destinationMenu->addAction(actionName); action->setShortcut(shortcut); } - action->setMenuRole((QAction::MenuRole)role); + action->setMenuRole(role); _actionHash.insert(actionName, action); @@ -715,7 +715,7 @@ QAction* Menu::addCheckableActionToQMenuAndActionHash(QMenu* destinationMenu, const bool checked, const QObject* receiver, const char* member) { - QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, (QKEYSEQUENCE&)shortcut, receiver, member); + QAction* action = addActionToQMenuAndActionHash(destinationMenu, actionName, shortcut, receiver, member); action->setCheckable(true); action->setChecked(checked); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index c5742cc570..73bb0472b4 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -76,10 +76,10 @@ public: virtual QMenu* getActiveScriptsMenu() { return _activeScriptsMenu;} virtual QAction* addActionToQMenuAndActionHash(QMenu* destinationMenu, const QString actionName, - const QKEYSEQUENCE& shortcut = 0, + const QKeySequence& shortcut = 0, const QObject* receiver = NULL, const char* member = NULL, - QACTION_MENUROLE role = NO_ROLE); + QAction::MenuRole role = QAction::NoRole); virtual void removeAction(QMenu* menu, const QString& actionName); public slots: diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 8c05b1ff8f..1923d906bb 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -7,11 +7,12 @@ set(TARGET_NAME shared) project(${TARGET_NAME}) find_package(Qt5Network REQUIRED) +find_package(Qt5Widgets REQUIRED) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -qt5_use_modules(${TARGET_NAME} Network) +qt5_use_modules(${TARGET_NAME} Network Widgets) # include GLM include(${MACRO_DIR}/IncludeGLM.cmake) diff --git a/libraries/shared/src/AbstractMenuInterface.h b/libraries/shared/src/AbstractMenuInterface.h index 39c378f40b..66083e4ed4 100644 --- a/libraries/shared/src/AbstractMenuInterface.h +++ b/libraries/shared/src/AbstractMenuInterface.h @@ -10,27 +10,23 @@ #ifndef __hifi__AbstractMenuInterface__ #define __hifi__AbstractMenuInterface__ +#include + class QMenu; class QString; class QObject; class QKeySequence; -class QAction; - -// these are actually class scoped enums, but we don't want to depend on the class for this abstract interface -const int NO_ROLE = 0; -typedef int QACTION_MENUROLE; -typedef int QKEYSEQUENCE; class AbstractMenuInterface { public: virtual QMenu* getActiveScriptsMenu() = 0; virtual QAction* addActionToQMenuAndActionHash(QMenu* destinationMenu, const QString actionName, - const QKEYSEQUENCE& shortcut = 0, + const QKeySequence& shortcut = 0, const QObject* receiver = NULL, const char* member = NULL, - QACTION_MENUROLE role = NO_ROLE) = 0; + QAction::MenuRole role = QAction::NoRole) = 0; virtual void removeAction(QMenu* menu, const QString& actionName) = 0; }; -#endif /* defined(__hifi__AbstractMenuInterface__) */ \ No newline at end of file +#endif /* defined(__hifi__AbstractMenuInterface__) */