Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RealGUI] Fixes #183 : Use the qt menu instead of the native one in Mac OS #366

Merged
merged 1 commit into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions SofaGui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ if(NOT SOFA_NO_OPENGL)
set(SOFA_HAVE_QWT 1) # cmakedefine
endif()

## Qt native menu
set(DEFAULT_SOFAGUI_ENABLE_NATIVE_MENU ON)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(DEFAULT_SOFAGUI_ENABLE_NATIVE_MENU OFF)
endif()

option(SOFAGUI_ENABLE_NATIVE_MENU "Enable Qt to use the operating system's native menu for the Qt GUI" ${DEFAULT_SOFAGUI_ENABLE_NATIVE_MENU})
if(SOFAGUI_ENABLE_NATIVE_MENU)
set(SOFA_GUI_NATIVE_MENU 1)
endif()

set(SOFA_GUI_QT 1) # cmakedefine
list(APPEND SOFAGUI_TARGETS SofaGuiQt)
Expand Down
1 change: 1 addition & 0 deletions SofaGui/SofaGuiConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(SOFA_GUI_QT @SOFA_GUI_QT@)
set(SOFA_GUI_INTERACTION @SOFA_GUI_INTERACTION@)
set(SOFA_GUI_QTVIEWER @SOFA_GUI_QTVIEWER@)
set(SOFA_GUI_QGLVIEWER @SOFA_GUI_QGLVIEWER@)
set(SOFA_GUI_NATIVE_MENU @SOFA_GUI_NATIVE_MENU@)
set(SOFA_QT5 @SOFA_QT5@)

if(SOFA_HAVE_QT)
Expand Down
1 change: 1 addition & 0 deletions SofaGui/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#cmakedefine SOFA_GUI_QGLVIEWER
#cmakedefine SOFA_GUI_QTVIEWER
#cmakedefine SOFA_GUI_INTERACTION
#cmakedefine SOFA_GUI_NATIVE_MENU
#cmakedefine SOFA_HAVE_QWT

#endif
8 changes: 8 additions & 0 deletions applications/sofa/gui/qt/RealGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ void RealGUI::InitApplication( RealGUI* _gui)
QString pathIcon=(sofa::helper::system::DataRepository.getFirstPath() + std::string( "/icons/SOFA.png" )).c_str();
application->setWindowIcon(QIcon(pathIcon));

#ifdef SOFA_GUI_NATIVE_MENU
// Use the OS'native menu instead of the Qt one
_gui->menubar->setNativeMenuBar(true);
#else
// Use the qt menu instead of the native one in order to standardize the way the menu is showed on every OS
_gui->menubar->setNativeMenuBar(false);
#endif

// show the gui
_gui->show(); // adding extra line in the console?
}
Expand Down