diff options
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | cmake/modules/FindMACOS_FRAMEWORKS.cmake | 1 | ||||
-rw-r--r-- | ui/macosx/cocoa_bridge.h | 39 | ||||
-rw-r--r-- | ui/macosx/cocoa_bridge.mm | 47 | ||||
-rw-r--r-- | wireshark-qt.cpp | 10 |
5 files changed, 103 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 743ec612fe..f7f86a7d6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1248,6 +1248,7 @@ if(APPLE) # set(HAVE_MACOS_FRAMEWORKS 1) FIND_LIBRARY (APPLE_APPLICATION_SERVICES_LIBRARY ApplicationServices) + FIND_LIBRARY (APPLE_APPKIT_LIBRARY AppKit) FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation) FIND_LIBRARY (APPLE_SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration) endif() @@ -1545,6 +1546,10 @@ if(WIN32) set(PLATFORM_UI_RC_FILES image/file_dlg_win32.rc ) +elseif(APPLE) + set(PLATFORM_UI_SRC + ui/macosx/cocoa_bridge.mm + ) endif() # sources common for wireshark, tshark, rawshark and sharkd @@ -2177,6 +2182,7 @@ if(BUILD_wireshark AND QT_FOUND) wscodecs ${LIBEPAN_LIBS} ${APPLE_APPLICATION_SERVICES_LIBRARY} + ${APPLE_APPKIT_LIBRARY} ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} ${NL_LIBRARIES} diff --git a/cmake/modules/FindMACOS_FRAMEWORKS.cmake b/cmake/modules/FindMACOS_FRAMEWORKS.cmake index 119fa84f36..df9cf5a157 100644 --- a/cmake/modules/FindMACOS_FRAMEWORKS.cmake +++ b/cmake/modules/FindMACOS_FRAMEWORKS.cmake @@ -16,6 +16,7 @@ if(APPLE) set(HAVE_MACOS_FRAMEWORKS 1) set(MACOS_FRAMEWORKS_FOUND TRUE) FIND_LIBRARY (APPLE_APPLICATION_SERVICES_LIBRARY ApplicationServices) + FIND_LIBRARY (APPLE_APPKIT_LIBRARY AppKit) FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation) FIND_LIBRARY (APPLE_SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration) endif() diff --git a/ui/macosx/cocoa_bridge.h b/ui/macosx/cocoa_bridge.h new file mode 100644 index 0000000000..e164922c60 --- /dev/null +++ b/ui/macosx/cocoa_bridge.h @@ -0,0 +1,39 @@ +/* cocoa_bridge.h + * + * This code was taken directly from: + * https://forum.qt.io/topic/82609/remove-native-mac-menu-items-such-as-show-tab-bar + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef COCOABRIDGE_H +#define COCOABRIDGE_H + +class CocoaBridge +{ + + CocoaBridge() {} + +public: + static void cleanOSGeneratedMenuItems(); + +}; + +#endif // COCOABRIDGE_H + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/macosx/cocoa_bridge.mm b/ui/macosx/cocoa_bridge.mm new file mode 100644 index 0000000000..93116b0e22 --- /dev/null +++ b/ui/macosx/cocoa_bridge.mm @@ -0,0 +1,47 @@ +/* cocoa_bridge.mm + * + * This code was taken directly from: + * https://forum.qt.io/topic/82609/remove-native-mac-menu-items-such-as-show-tab-bar + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include <ui/macosx/cocoa_bridge.h> + +#import <Cocoa/Cocoa.h> + +void CocoaBridge::cleanOSGeneratedMenuItems() +{ +#ifdef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER + // Remove (don't allow) the "Show Tab Bar" menu item from the "View" menu, if + // supported + + if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)]) + NSWindow.allowsAutomaticWindowTabbing = NO; +#endif + + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"]; + + // Remove (disable) the "Start Dictation..." and "Emoji & Symbols" menu items + // from the "Edit" menu + + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledDictationMenuItem"]; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledCharacterPaletteMenuItem"]; +} + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/wireshark-qt.cpp b/wireshark-qt.cpp index b56c4bbdb7..2972dcf50d 100644 --- a/wireshark-qt.cpp +++ b/wireshark-qt.cpp @@ -110,6 +110,11 @@ #include "epan/crypt/dot11decrypt_ws.h" +/* Handle the addition of View menu items without request */ +#if defined(Q_OS_MAC) +#include <ui/macosx/cocoa_bridge.h> +#endif + #include <ui/qt/utils/qt_ui_utils.h> #define INVALID_OPTION 1 @@ -397,6 +402,11 @@ int main(int argc, char *qt_argv[]) #endif /* DEBUG_STARTUP_TIME */ cmdarg_err_init(wireshark_cmdarg_err, wireshark_cmdarg_err_cont); +#if defined(Q_OS_MAC) + /* Disable automatic addition of tab menu entries in view menu */ + CocoaBridge::cleanOSGeneratedMenuItems(); +#endif + /* Set the C-language locale to the native environment. */ setlocale(LC_ALL, ""); |