Add Ctrl+Q to quit

This commit is contained in:
Colin Kinloch 2024-02-03 18:30:36 +00:00 committed by tildearrow
parent 83b934862a
commit b2d61b1d3a
5 changed files with 19 additions and 15 deletions

View file

@ -83,6 +83,11 @@ void FurnaceGUI::doAction(int what) {
doRedo(); doRedo();
} }
break; break;
case GUI_ACTION_QUIT:
{
requestQuit();
}
break;
case GUI_ACTION_PLAY_TOGGLE: case GUI_ACTION_PLAY_TOGGLE:
if (e->isPlaying() && !e->isStepping()) { if (e->isPlaying() && !e->isStepping()) {
stop(); stop();

View file

@ -3672,12 +3672,8 @@ bool FurnaceGUI::loop() {
// used for MIDI wake up // used for MIDI wake up
break; break;
case SDL_QUIT: case SDL_QUIT:
if (modified) { if (requestQuit())
showWarning("Unsaved changes! Save changes before quitting?",GUI_WARN_QUIT);
} else {
quit=true;
return true; return true;
}
break; break;
} }
} }
@ -4327,12 +4323,8 @@ bool FurnaceGUI::loop() {
doAction(GUI_ACTION_OPEN_BACKUP); doAction(GUI_ACTION_OPEN_BACKUP);
} }
ImGui::Separator(); ImGui::Separator();
if (ImGui::MenuItem("exit")) { if (ImGui::MenuItem("exit...",BIND_FOR(GUI_ACTION_QUIT))) {
if (modified) { requestQuit();
showWarning("Unsaved changes! Save before quitting?",GUI_WARN_QUIT);
} else {
quit=true;
}
} }
ImGui::EndDisabled(); ImGui::EndDisabled();
ImGui::EndMenu(); ImGui::EndMenu();
@ -7253,8 +7245,13 @@ bool FurnaceGUI::finish() {
return true; return true;
} }
void FurnaceGUI::requestQuit() { bool FurnaceGUI::requestQuit() {
quit=true; if (modified) {
showWarning("Unsaved changes! Save changes before quitting?",GUI_WARN_QUIT);
} else {
quit=true;
}
return quit;
} }
FurnaceGUI::FurnaceGUI(): FurnaceGUI::FurnaceGUI():

View file

@ -582,6 +582,7 @@ enum FurnaceGUIActions {
GUI_ACTION_EXPORT, GUI_ACTION_EXPORT,
GUI_ACTION_UNDO, GUI_ACTION_UNDO,
GUI_ACTION_REDO, GUI_ACTION_REDO,
GUI_ACTION_QUIT,
GUI_ACTION_PLAY_TOGGLE, GUI_ACTION_PLAY_TOGGLE,
GUI_ACTION_PLAY, GUI_ACTION_PLAY,
GUI_ACTION_STOP, GUI_ACTION_STOP,
@ -2659,7 +2660,7 @@ class FurnaceGUI {
bool loop(); bool loop();
bool finish(); bool finish();
bool init(); bool init();
void requestQuit(); bool requestQuit();
FurnaceGUI(); FurnaceGUI();
}; };

View file

@ -548,6 +548,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
#else #else
D("REDO", "Redo", FURKMOD_CMD|SDLK_y), D("REDO", "Redo", FURKMOD_CMD|SDLK_y),
#endif #endif
D("QUIT", "Exit", FURKMOD_CMD|SDLK_q),
D("PLAY_TOGGLE", "Play/Stop (toggle)", SDLK_RETURN), D("PLAY_TOGGLE", "Play/Stop (toggle)", SDLK_RETURN),
D("PLAY", "Play", 0), D("PLAY", "Play", 0),
D("STOP", "Stop", 0), D("STOP", "Stop", 0),

View file

@ -39,7 +39,7 @@ typedef HRESULT (WINAPI *SPDA)(PROCESS_DPI_AWARENESS);
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
struct sigaction termsa; struct sigaction termsa = {0};
#endif #endif
#include "cli/cli.h" #include "cli/cli.h"