qt: Disable alt key menu navigation with style override
This commit is contained in:
@@ -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)
|
||||
|
@@ -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<wchar_t*>(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);
|
||||
|
14
src/qt/qt_styleoverride.cpp
Normal file
14
src/qt/qt_styleoverride.cpp
Normal file
@@ -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);
|
||||
}
|
16
src/qt/qt_styleoverride.hpp
Normal file
16
src/qt/qt_styleoverride.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef QT_STYLEOVERRIDE_HPP
|
||||
#define QT_STYLEOVERRIDE_HPP
|
||||
|
||||
#include <QProxyStyle>
|
||||
|
||||
class StyleOverride : public QProxyStyle
|
||||
{
|
||||
public:
|
||||
int styleHint(
|
||||
StyleHint hint,
|
||||
const QStyleOption *option = nullptr,
|
||||
const QWidget *widget = nullptr,
|
||||
QStyleHintReturn *returnData = nullptr) const override;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user