Skip to content

Instantly share code, notes, and snippets.

@punesemu
Created November 17, 2023 23:21
Show Gist options
  • Save punesemu/4ec7e08cfaa638ffd365a7c2182aaaeb to your computer and use it in GitHub Desktop.
Save punesemu/4ec7e08cfaa638ffd365a7c2182aaaeb to your computer and use it in GitHub Desktop.
Subject: [PATCH] Open menubar with mouse.
---
Index: src/gui/mainWindow.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp
--- a/src/gui/mainWindow.cpp (revision 3f64b8d390a8b272db4808499e5f5981ae7b0f9f)
+++ b/src/gui/mainWindow.cpp (date 1700262731114)
@@ -90,6 +90,7 @@
fullscreen_resize = false;
visibility.menubar = true;
visibility.toolbars = true;
+ tmm = (BYTE)TOGGLE_MENUBAR_NONE;
{
QHBoxLayout *layout = new QHBoxLayout(central_widget);
@@ -189,6 +190,7 @@
connect(this, SIGNAL(et_gg_reset()), this, SLOT(s_et_gg_reset()));
connect(this, SIGNAL(et_vs_reset()), this, SLOT(s_et_vs_reset()));
connect(this, SIGNAL(et_external_control_windows_show()), this, SLOT(s_et_external_control_windows_show()));
+ connect(this, SIGNAL(et_toggle_menubar_from_mouse()), this, SLOT(s_et_toggle_menubar_from_mouse()));
egds = new timerEgds(this);
@@ -1244,6 +1246,18 @@
return (-1);
}
+void mainWindow::toggle_menubar(BYTE mode) {
+ if ((cfg->fullscreen != FULLSCR) || (gfx.type_of_fscreen_in_use != FULLSCR)) {
+ return;
+ }
+
+ emu_thread_pause();
+
+ menubar->setVisible(!menubar->isVisible());
+ tmm = menubar->isVisible() ? mode : (BYTE)TOGGLE_MENUBAR_NONE;
+
+ emu_thread_continue();
+}
void mainWindow::s_set_fullscreen(void) {
BYTE delay = FALSE;
@@ -2404,15 +2418,7 @@
toolbar->rewind->toolButton_Pause->click();
}
void mainWindow::s_shcut_toggle_menubar(void) {
- if ((cfg->fullscreen != FULLSCR) || (gfx.type_of_fscreen_in_use != FULLSCR)) {
- return;
- }
-
- emu_thread_pause();
-
- menubar->setVisible(!menubar->isVisible());
-
- emu_thread_continue();
+ toggle_menubar(TOGGLE_MENUBAR_FROM_SHORTCUT);
}
void mainWindow::s_shcut_toggle_capture_input(void) const {
if (nes_keyboard.enabled) {
@@ -2448,6 +2454,9 @@
void mainWindow::s_et_external_control_windows_show(void) {
gui_external_control_windows_show();
}
+void mainWindow::s_et_toggle_menubar_from_mouse(void) {
+ toggle_menubar(TOGGLE_MENUBAR_FROM_MOUSEMOVE);
+}
// ----------------------------------------------------------------------------------------------
Index: src/gui/wdgScreen.cpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/gui/wdgScreen.cpp b/src/gui/wdgScreen.cpp
--- a/src/gui/wdgScreen.cpp (revision 3f64b8d390a8b272db4808499e5f5981ae7b0f9f)
+++ b/src/gui/wdgScreen.cpp (date 1700262797708)
@@ -141,6 +141,25 @@
}
}
+ // gestione della menu bar durante il fullscreen
+ if ((cfg->fullscreen == FULLSCR) && (gfx.type_of_fscreen_in_use == FULLSCR)) {
+ if (event->type() == QEvent::MouseMove) {
+ if (mapFromGlobal(QCursor::pos()).y() <= mainwin->menuBar()->height()) {
+ if (mainwin->menuBar()->isHidden()) {
+ emit mainwin->et_toggle_menubar_from_mouse();
+ }
+ } else {
+ if (mainwin->menuBar()->isVisible() && (mainwin->tmm != (BYTE)mainwin->TOGGLE_MENUBAR_FROM_SHORTCUT)) {
+ emit mainwin->et_toggle_menubar_from_mouse();
+ }
+ }
+ } else if (event->type() == QEvent::Enter) {
+ if (mainwin->menuBar()->isVisible() && (mainwin->tmm != (BYTE)mainwin->TOGGLE_MENUBAR_FROM_SHORTCUT)) {
+ emit mainwin->et_toggle_menubar_from_mouse();
+ }
+ }
+ }
+
return (QObject::eventFilter(obj, event));
}
void wdgScreen::dragEnterEvent(QDragEnterEvent *event) {
Index: src/gui/mainWindow.hpp
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/gui/mainWindow.hpp b/src/gui/mainWindow.hpp
--- a/src/gui/mainWindow.hpp (revision 3f64b8d390a8b272db4808499e5f5981ae7b0f9f)
+++ b/src/gui/mainWindow.hpp (date 1700261702725)
@@ -123,6 +123,13 @@
class mainWindow : public QMainWindow, public Ui::mainWindow {
Q_OBJECT
+ public:
+ enum _toggle_menubar_mode {
+ TOGGLE_MENUBAR_NONE,
+ TOGGLE_MENUBAR_FROM_SHORTCUT,
+ TOGGLE_MENUBAR_FROM_MOUSEMOVE
+ };
+
public:
struct _qaction_shcut_extern {
QAction *mode_auto;
@@ -165,6 +172,7 @@
wdgStatusBar *statusbar;
wdgToolBar *toolbar;
QShortcut *shortcut[SET_MAX_NUM_SC];
+ BYTE tmm;
private:
struct _shcjoy {
@@ -196,6 +204,7 @@
void et_gg_reset(void);
void et_vs_reset(void);
void et_external_control_windows_show(void);
+ void et_toggle_menubar_from_mouse(void);
protected:
#if defined (_WIN32)
@@ -255,6 +264,7 @@
void geom_to_cfg(const QRect &geom, _last_geometry *lg);
void set_dialog_geom(QRect &geom);
int is_shortcut(const QKeyEvent *event);
+ void toggle_menubar(BYTE mode);
public slots:
void s_set_fullscreen(void);
@@ -331,6 +341,7 @@
void s_et_gg_reset(void);
void s_et_vs_reset(void);
void s_et_external_control_windows_show(void);
+ void s_et_toggle_menubar_from_mouse(void);
};
#endif /* MAINWINDOW_HPP_ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment