mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix events in fullscreen
This commit is contained in:
parent
9f3c68cb6a
commit
fd7989e748
|
@ -30,8 +30,11 @@ void ActionMapper::clearMenu(const QString& name) {
|
|||
emit menuCleared(name);
|
||||
}
|
||||
|
||||
void ActionMapper::rebuildMenu(QMenuBar* menubar, const ShortcutController& shortcuts) {
|
||||
void ActionMapper::rebuildMenu(QMenuBar* menubar, QWidget* context, const ShortcutController& shortcuts) {
|
||||
menubar->clear();
|
||||
for (QAction* action : context->actions()) {
|
||||
context->removeAction(action);
|
||||
}
|
||||
for (const QString& m : m_menus[{}]) {
|
||||
if (m_hiddenActions.contains(m)) {
|
||||
continue;
|
||||
|
@ -39,11 +42,11 @@ void ActionMapper::rebuildMenu(QMenuBar* menubar, const ShortcutController& shor
|
|||
QString menu = m.mid(1);
|
||||
QMenu* qmenu = menubar->addMenu(m_menuNames[menu]);
|
||||
|
||||
rebuildMenu(menu, qmenu, shortcuts);
|
||||
rebuildMenu(menu, qmenu, context, shortcuts);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionMapper::rebuildMenu(const QString& menu, QMenu* qmenu, const ShortcutController& shortcuts) {
|
||||
void ActionMapper::rebuildMenu(const QString& menu, QMenu* qmenu, QWidget* context, const ShortcutController& shortcuts) {
|
||||
for (const QString& actionName : m_menus[menu]) {
|
||||
if (actionName.isNull()) {
|
||||
qmenu->addSeparator();
|
||||
|
@ -55,12 +58,13 @@ void ActionMapper::rebuildMenu(const QString& menu, QMenu* qmenu, const Shortcut
|
|||
if (actionName[0] == '.') {
|
||||
QString name = actionName.mid(1);
|
||||
QMenu* newMenu = qmenu->addMenu(m_menuNames[name]);
|
||||
rebuildMenu(name, newMenu, shortcuts);
|
||||
rebuildMenu(name, newMenu, context, shortcuts);
|
||||
continue;
|
||||
}
|
||||
Action* action = &m_actions[actionName];
|
||||
QAction* qaction = qmenu->addAction(action->visibleName());
|
||||
qaction->setEnabled(action->isEnabled());
|
||||
qaction->setShortcutContext(Qt::WidgetShortcut);
|
||||
if (action->isExclusive() || action->booleanAction()) {
|
||||
qaction->setCheckable(true);
|
||||
}
|
||||
|
@ -88,6 +92,7 @@ void ActionMapper::rebuildMenu(const QString& menu, QMenu* qmenu, const Shortcut
|
|||
qaction->setShortcut(QKeySequence(shortcut));
|
||||
});
|
||||
}
|
||||
context->addAction(qaction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
void addMenu(const QString& visibleName, const QString& name, const QString& parent = {});
|
||||
void addHiddenMenu(const QString& visibleName, const QString& name, const QString& parent = {});
|
||||
void clearMenu(const QString& name);
|
||||
void rebuildMenu(QMenuBar*, const ShortcutController&);
|
||||
void rebuildMenu(QMenuBar*, QWidget* context, const ShortcutController&);
|
||||
|
||||
void addSeparator(const QString& menu);
|
||||
|
||||
|
@ -59,7 +59,7 @@ signals:
|
|||
void menuCleared(const QString& name);
|
||||
|
||||
private:
|
||||
void rebuildMenu(const QString& menu, QMenu* qmenu, const ShortcutController&);
|
||||
void rebuildMenu(const QString& menu, QMenu* qmenu, QWidget* context, const ShortcutController&);
|
||||
Action* addAction(const Action& act, const QString& name, const QString& menu, const QKeySequence& shortcut);
|
||||
|
||||
QHash<QString, Action> m_actions;
|
||||
|
|
|
@ -617,6 +617,7 @@ void Window::showEvent(QShowEvent* event) {
|
|||
m_fullscreenOnStart = false;
|
||||
}
|
||||
reloadDisplayDriver();
|
||||
setFocus();
|
||||
}
|
||||
|
||||
void Window::closeEvent(QCloseEvent* event) {
|
||||
|
@ -768,7 +769,7 @@ void Window::gameStarted() {
|
|||
action->setActive(true);
|
||||
}
|
||||
}
|
||||
m_actions.rebuildMenu(menuBar(), *m_shortcutController);
|
||||
m_actions.rebuildMenu(menuBar(), this, *m_shortcutController);
|
||||
|
||||
|
||||
#ifdef USE_DISCORD_RPC
|
||||
|
@ -1603,7 +1604,7 @@ void Window::setupMenu(QMenuBar* menubar) {
|
|||
}
|
||||
|
||||
m_shortcutController->rebuildItems();
|
||||
m_actions.rebuildMenu(menubar, *m_shortcutController);
|
||||
m_actions.rebuildMenu(menuBar(), this, *m_shortcutController);
|
||||
}
|
||||
|
||||
void Window::attachWidget(QWidget* widget) {
|
||||
|
@ -1640,7 +1641,7 @@ void Window::updateMRU() {
|
|||
}
|
||||
m_config->setMRU(m_mruFiles);
|
||||
m_config->write();
|
||||
m_actions.rebuildMenu(menuBar(), *m_shortcutController);
|
||||
m_actions.rebuildMenu(menuBar(), this, *m_shortcutController);
|
||||
}
|
||||
|
||||
Action* Window::addGameAction(const QString& visibleName, const QString& name, Action::Function function, const QString& menu, const QKeySequence& shortcut) {
|
||||
|
|
Loading…
Reference in New Issue