diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 76a9cc8bd..c1a32d9f1 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -92,6 +92,9 @@ add_library(ui STATIC qt_soundgain.cpp qt_soundgain.ui + qt_styleoverride.cpp + qt_styleoverride.hpp + ../qt_resources.qrc ) if (APPLE) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 630fa1bac..698800fd3 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -27,7 +27,7 @@ Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin) #include "qt_mainwindow.hpp" #include "cocoa_mouse.hpp" - +#include "qt_styleoverride.hpp" // Void Cast #define VC(x) const_cast(x) @@ -89,6 +89,7 @@ main_thread_fn() int main(int argc, char* argv[]) { QApplication app(argc, argv); + app.setStyle(new StyleOverride()); #ifdef __APPLE__ CocoaEventFilter cocoafilter; app.installNativeEventFilter(&cocoafilter); diff --git a/src/qt/qt_styleoverride.cpp b/src/qt/qt_styleoverride.cpp new file mode 100644 index 000000000..85727b9ac --- /dev/null +++ b/src/qt/qt_styleoverride.cpp @@ -0,0 +1,14 @@ +#include "qt_styleoverride.hpp" + +int StyleOverride::styleHint( + StyleHint hint, + const QStyleOption *option, + const QWidget *widget, + QStyleHintReturn *returnData) const +{ + /* Disable using menu with alt key */ + if (hint == QStyle::SH_MenuBar_AltKeyNavigation) + return 0; + + return QProxyStyle::styleHint(hint, option, widget, returnData); +} \ No newline at end of file diff --git a/src/qt/qt_styleoverride.hpp b/src/qt/qt_styleoverride.hpp new file mode 100644 index 000000000..46a73fa4e --- /dev/null +++ b/src/qt/qt_styleoverride.hpp @@ -0,0 +1,16 @@ +#ifndef QT_STYLEOVERRIDE_HPP +#define QT_STYLEOVERRIDE_HPP + +#include + +class StyleOverride : public QProxyStyle +{ +public: + int styleHint( + StyleHint hint, + const QStyleOption *option = nullptr, + const QWidget *widget = nullptr, + QStyleHintReturn *returnData = nullptr) const override; +}; + +#endif \ No newline at end of file