mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Make QMenuBar on Linux work without private API
This commit is contained in:
parent
088cca7452
commit
4410aeb3eb
1 changed files with 5 additions and 27 deletions
|
@ -45,9 +45,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
#include <QtWidgets/QMenuBar>
|
#include <QtWidgets/QMenuBar>
|
||||||
|
|
||||||
#include <private/qguiapplication_p.h>
|
|
||||||
#include <private/qaction_p.h>
|
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <giomm.h>
|
#include <giomm.h>
|
||||||
|
@ -157,17 +154,14 @@ void SkipTaskbar(QWindow *window, bool skip) {
|
||||||
void SendKeySequence(
|
void SendKeySequence(
|
||||||
Qt::Key key,
|
Qt::Key key,
|
||||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
|
Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
|
||||||
const auto focused = QApplication::focusWidget();
|
const auto focused = static_cast<QObject*>(QApplication::focusWidget());
|
||||||
if (qobject_cast<QLineEdit*>(focused)
|
if (qobject_cast<QLineEdit*>(focused)
|
||||||
|| qobject_cast<QTextEdit*>(focused)
|
|| qobject_cast<QTextEdit*>(focused)
|
||||||
|| dynamic_cast<HistoryInner*>(focused)) {
|
|| dynamic_cast<HistoryInner*>(focused)) {
|
||||||
QApplication::postEvent(
|
QKeyEvent pressEvent(QEvent::KeyPress, key, modifiers);
|
||||||
focused,
|
focused->event(&pressEvent);
|
||||||
new QKeyEvent(QEvent::KeyPress, key, modifiers));
|
QKeyEvent releaseEvent(QEvent::KeyRelease, key, modifiers);
|
||||||
|
focused->event(&releaseEvent);
|
||||||
QApplication::postEvent(
|
|
||||||
focused,
|
|
||||||
new QKeyEvent(QEvent::KeyRelease, key, modifiers));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,11 +170,6 @@ void ForceDisabled(QAction *action, bool disabled) {
|
||||||
if (disabled) action->setDisabled(true);
|
if (disabled) action->setDisabled(true);
|
||||||
} else if (!disabled) {
|
} else if (!disabled) {
|
||||||
action->setDisabled(false);
|
action->setDisabled(false);
|
||||||
|
|
||||||
const auto privateAction = QActionPrivate::get(action);
|
|
||||||
privateAction->setShortcutEnabled(
|
|
||||||
false,
|
|
||||||
QGuiApplicationPrivate::instance()->shortcutMap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,17 +495,6 @@ void MainWindow::createGlobalMenu() {
|
||||||
|
|
||||||
about->setMenuRole(QAction::AboutQtRole);
|
about->setMenuRole(QAction::AboutQtRole);
|
||||||
|
|
||||||
// avoid shadowing actual shortcuts by the menubar
|
|
||||||
for (const auto &child : psMainMenu->children()) {
|
|
||||||
const auto action = qobject_cast<QAction*>(child);
|
|
||||||
if (action) {
|
|
||||||
const auto privateAction = QActionPrivate::get(action);
|
|
||||||
privateAction->setShortcutEnabled(
|
|
||||||
false,
|
|
||||||
QGuiApplicationPrivate::instance()->shortcutMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateGlobalMenu();
|
updateGlobalMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue