mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-25 17:20:47 +02:00
Make global quit shortcut optional
Some people prefer to use the window manager to close windows.
This commit is contained in:
@@ -444,6 +444,7 @@ int Main(int argc, char *argv[])
|
||||
engine.ShowAvatars = showAvatars;
|
||||
engine.Begin();
|
||||
engine.SetFastQuit(prefs.Get("FastQuit", true));
|
||||
engine.SetGlobalQuit(prefs.Get("GlobalQuit", true));
|
||||
engine.TouchUI = prefs.Get("TouchUI", DEFAULT_TOUCH_UI);
|
||||
engine.windowFrameOps = windowFrameOps;
|
||||
|
||||
|
@@ -68,6 +68,7 @@ int main(int argc, char * argv[])
|
||||
|
||||
engine.Begin();
|
||||
engine.SetFastQuit(true);
|
||||
engine.SetGlobalQuit(true);
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
|
@@ -291,7 +291,7 @@ static void EventProcess(const SDL_Event &event)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (ALLOW_QUIT && !event.key.repeat && event.key.keysym.sym == 'q' && (event.key.keysym.mod&KMOD_CTRL) && !(event.key.keysym.mod&KMOD_ALT))
|
||||
if (engine.GetGlobalQuit() && ALLOW_QUIT && !event.key.repeat && event.key.keysym.sym == 'q' && (event.key.keysym.mod&KMOD_CTRL) && !(event.key.keysym.mod&KMOD_ALT))
|
||||
engine.ConfirmExit();
|
||||
else
|
||||
engine.onKeyPress(event.key.keysym.sym, event.key.keysym.scancode, event.key.repeat, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
|
||||
|
@@ -16,6 +16,7 @@ Engine::Engine():
|
||||
state_(NULL),
|
||||
windowTargetPosition(0, 0),
|
||||
FastQuit(1),
|
||||
GlobalQuit(true),
|
||||
lastTick(0),
|
||||
mouseb_(0),
|
||||
mousex_(0),
|
||||
|
@@ -51,6 +51,8 @@ namespace ui
|
||||
inline int GetDrawingFrequencyLimit() {return drawingFrequencyLimit;}
|
||||
void SetFastQuit(bool fastquit) { FastQuit = fastquit; }
|
||||
inline bool GetFastQuit() {return FastQuit; }
|
||||
void SetGlobalQuit(bool newGlobalQuit) { GlobalQuit = newGlobalQuit; }
|
||||
inline bool GetGlobalQuit() {return GlobalQuit; }
|
||||
|
||||
void Tick();
|
||||
void Draw();
|
||||
@@ -110,6 +112,7 @@ namespace ui
|
||||
|
||||
bool running_;
|
||||
bool FastQuit;
|
||||
bool GlobalQuit;
|
||||
|
||||
long unsigned int lastTick;
|
||||
int mouseb_;
|
||||
|
@@ -127,6 +127,11 @@ void OptionsController::SetFastQuit(bool fastquit)
|
||||
model->SetFastQuit(fastquit);
|
||||
}
|
||||
|
||||
void OptionsController::SetGlobalQuit(bool newGlobalQuit)
|
||||
{
|
||||
model->SetGlobalQuit(newGlobalQuit);
|
||||
}
|
||||
|
||||
void OptionsController::SetDecoSpace(int decoSpace)
|
||||
{
|
||||
model->SetDecoSpace(decoSpace);
|
||||
|
@@ -34,6 +34,7 @@ public:
|
||||
void SetNativeClipoard(bool nativeClipoard);
|
||||
void SetResizable(bool resizable);
|
||||
void SetFastQuit(bool fastquit);
|
||||
void SetGlobalQuit(bool newGlobalQuit);
|
||||
void SetDecoSpace(int decoSpace);
|
||||
void SetShowAvatars(bool showAvatars);
|
||||
void SetMouseClickrequired(bool mouseClickRequired);
|
||||
|
@@ -256,6 +256,17 @@ void OptionsModel::SetFastQuit(bool fastquit)
|
||||
notifySettingsChanged();
|
||||
}
|
||||
|
||||
bool OptionsModel::GetGlobalQuit()
|
||||
{
|
||||
return ui::Engine::Ref().GetGlobalQuit();
|
||||
}
|
||||
void OptionsModel::SetGlobalQuit(bool newGlobalQuit)
|
||||
{
|
||||
ui::Engine::Ref().SetGlobalQuit(newGlobalQuit);
|
||||
GlobalPrefs::Ref().Set("GlobalQuit", newGlobalQuit);
|
||||
notifySettingsChanged();
|
||||
}
|
||||
|
||||
int OptionsModel::GetDecoSpace()
|
||||
{
|
||||
return gModel->GetDecoSpace();
|
||||
|
@@ -57,6 +57,8 @@ public:
|
||||
void SetBlurryScaling(bool newBlurryScaling);
|
||||
bool GetFastQuit();
|
||||
void SetFastQuit(bool fastquit);
|
||||
bool GetGlobalQuit();
|
||||
void SetGlobalQuit(bool newGlobalQuit);
|
||||
int GetDecoSpace();
|
||||
void SetDecoSpace(int decoSpace);
|
||||
bool GetMouseClickRequired();
|
||||
|
@@ -286,6 +286,9 @@ OptionsView::OptionsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340))
|
||||
fastquit = addCheckbox(0, "Fast quit", "Always exit completely when hitting close", [this] {
|
||||
c->SetFastQuit(fastquit->GetChecked());
|
||||
});
|
||||
globalQuit = addCheckbox(0, "Global quit shortcut", "Ctrl+q works everywhere", [this] {
|
||||
c->SetGlobalQuit(globalQuit->GetChecked());
|
||||
});
|
||||
}
|
||||
showAvatars = addCheckbox(0, "Show avatars", "Disable if you have a slow connection", [this] {
|
||||
c->SetShowAvatars(showAvatars->GetChecked());
|
||||
@@ -487,6 +490,10 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
|
||||
{
|
||||
fastquit->SetChecked(sender->GetFastQuit());
|
||||
}
|
||||
if (globalQuit)
|
||||
{
|
||||
globalQuit->SetChecked(sender->GetGlobalQuit());
|
||||
}
|
||||
if (nativeClipoard)
|
||||
{
|
||||
nativeClipoard->SetChecked(sender->GetNativeClipoard());
|
||||
|
@@ -33,6 +33,7 @@ class OptionsView: public ui::Window
|
||||
ui::Checkbox *forceIntegerScaling{};
|
||||
ui::Checkbox *blurryScaling{};
|
||||
ui::Checkbox *fastquit{};
|
||||
ui::Checkbox *globalQuit{};
|
||||
ui::DropDown *decoSpace{};
|
||||
ui::Checkbox *showAvatars{};
|
||||
ui::Checkbox *momentumScroll{};
|
||||
|
Reference in New Issue
Block a user