mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
* Force context menu to show shortcuts fix. Closes #1154 * Mocking problem fixed
This commit is contained in:
parent
85a57f9e17
commit
8c82449423
@ -3,6 +3,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
@ -122,6 +123,11 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
|
|||||||
mainWindow = new MainWindow();
|
mainWindow = new MainWindow();
|
||||||
installEventFilter(mainWindow);
|
installEventFilter(mainWindow);
|
||||||
|
|
||||||
|
// set up context menu shortcut display fix
|
||||||
|
#if QT_VERSION_CHECK(5, 10, 0) < QT_VERSION
|
||||||
|
setStyle(new CutterProxyStyle());
|
||||||
|
#endif // QT_VERSION_CHECK(5, 10, 0) < QT_VERSION
|
||||||
|
|
||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
if (analLevelSpecified) {
|
if (analLevelSpecified) {
|
||||||
printf("%s\n",
|
printf("%s\n",
|
||||||
@ -285,3 +291,21 @@ bool CutterApplication::loadTranslations()
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CutterProxyStyle::polish(QWidget *widget)
|
||||||
|
{
|
||||||
|
QProxyStyle::polish(widget);
|
||||||
|
#if QT_VERSION_CHECK(5, 10, 0) < QT_VERSION
|
||||||
|
// HACK: This is the only way I've found to force Qt (5.10 and newer) to
|
||||||
|
// display shortcuts in context menus on all platforms. It's ugly,
|
||||||
|
// but it gets the job done.
|
||||||
|
if (auto menu = qobject_cast<QMenu*>(widget)) {
|
||||||
|
const auto &actions = menu->actions();
|
||||||
|
for (auto action : actions) {
|
||||||
|
action->setShortcutVisibleInContextMenu(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // QT_VERSION_CHECK(5, 10, 0) < QT_VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QProxyStyle>
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
@ -38,4 +39,18 @@ private:
|
|||||||
MainWindow *mainWindow;
|
MainWindow *mainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief CutterProxyStyle is used to force shortcuts displaying in context menu
|
||||||
|
*/
|
||||||
|
class CutterProxyStyle : public QProxyStyle
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* \brief it is enough to get notification about QMenu polishing to force shortcut displaying
|
||||||
|
*/
|
||||||
|
void polish(QWidget *widget) override;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // CUTTERAPPLICATION_H
|
#endif // CUTTERAPPLICATION_H
|
||||||
|
Loading…
Reference in New Issue
Block a user