mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-26 01:23:37 +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.ShowAvatars = showAvatars;
|
||||||
engine.Begin();
|
engine.Begin();
|
||||||
engine.SetFastQuit(prefs.Get("FastQuit", true));
|
engine.SetFastQuit(prefs.Get("FastQuit", true));
|
||||||
|
engine.SetGlobalQuit(prefs.Get("GlobalQuit", true));
|
||||||
engine.TouchUI = prefs.Get("TouchUI", DEFAULT_TOUCH_UI);
|
engine.TouchUI = prefs.Get("TouchUI", DEFAULT_TOUCH_UI);
|
||||||
engine.windowFrameOps = windowFrameOps;
|
engine.windowFrameOps = windowFrameOps;
|
||||||
|
|
||||||
|
@@ -68,6 +68,7 @@ int main(int argc, char * argv[])
|
|||||||
|
|
||||||
engine.Begin();
|
engine.Begin();
|
||||||
engine.SetFastQuit(true);
|
engine.SetFastQuit(true);
|
||||||
|
engine.SetGlobalQuit(true);
|
||||||
|
|
||||||
if (argc >= 2)
|
if (argc >= 2)
|
||||||
{
|
{
|
||||||
|
@@ -291,7 +291,7 @@ static void EventProcess(const SDL_Event &event)
|
|||||||
{
|
{
|
||||||
break;
|
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();
|
engine.ConfirmExit();
|
||||||
else
|
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);
|
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),
|
state_(NULL),
|
||||||
windowTargetPosition(0, 0),
|
windowTargetPosition(0, 0),
|
||||||
FastQuit(1),
|
FastQuit(1),
|
||||||
|
GlobalQuit(true),
|
||||||
lastTick(0),
|
lastTick(0),
|
||||||
mouseb_(0),
|
mouseb_(0),
|
||||||
mousex_(0),
|
mousex_(0),
|
||||||
|
@@ -51,6 +51,8 @@ namespace ui
|
|||||||
inline int GetDrawingFrequencyLimit() {return drawingFrequencyLimit;}
|
inline int GetDrawingFrequencyLimit() {return drawingFrequencyLimit;}
|
||||||
void SetFastQuit(bool fastquit) { FastQuit = fastquit; }
|
void SetFastQuit(bool fastquit) { FastQuit = fastquit; }
|
||||||
inline bool GetFastQuit() {return FastQuit; }
|
inline bool GetFastQuit() {return FastQuit; }
|
||||||
|
void SetGlobalQuit(bool newGlobalQuit) { GlobalQuit = newGlobalQuit; }
|
||||||
|
inline bool GetGlobalQuit() {return GlobalQuit; }
|
||||||
|
|
||||||
void Tick();
|
void Tick();
|
||||||
void Draw();
|
void Draw();
|
||||||
@@ -110,6 +112,7 @@ namespace ui
|
|||||||
|
|
||||||
bool running_;
|
bool running_;
|
||||||
bool FastQuit;
|
bool FastQuit;
|
||||||
|
bool GlobalQuit;
|
||||||
|
|
||||||
long unsigned int lastTick;
|
long unsigned int lastTick;
|
||||||
int mouseb_;
|
int mouseb_;
|
||||||
|
@@ -127,6 +127,11 @@ void OptionsController::SetFastQuit(bool fastquit)
|
|||||||
model->SetFastQuit(fastquit);
|
model->SetFastQuit(fastquit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsController::SetGlobalQuit(bool newGlobalQuit)
|
||||||
|
{
|
||||||
|
model->SetGlobalQuit(newGlobalQuit);
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsController::SetDecoSpace(int decoSpace)
|
void OptionsController::SetDecoSpace(int decoSpace)
|
||||||
{
|
{
|
||||||
model->SetDecoSpace(decoSpace);
|
model->SetDecoSpace(decoSpace);
|
||||||
|
@@ -34,6 +34,7 @@ public:
|
|||||||
void SetNativeClipoard(bool nativeClipoard);
|
void SetNativeClipoard(bool nativeClipoard);
|
||||||
void SetResizable(bool resizable);
|
void SetResizable(bool resizable);
|
||||||
void SetFastQuit(bool fastquit);
|
void SetFastQuit(bool fastquit);
|
||||||
|
void SetGlobalQuit(bool newGlobalQuit);
|
||||||
void SetDecoSpace(int decoSpace);
|
void SetDecoSpace(int decoSpace);
|
||||||
void SetShowAvatars(bool showAvatars);
|
void SetShowAvatars(bool showAvatars);
|
||||||
void SetMouseClickrequired(bool mouseClickRequired);
|
void SetMouseClickrequired(bool mouseClickRequired);
|
||||||
|
@@ -256,6 +256,17 @@ void OptionsModel::SetFastQuit(bool fastquit)
|
|||||||
notifySettingsChanged();
|
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()
|
int OptionsModel::GetDecoSpace()
|
||||||
{
|
{
|
||||||
return gModel->GetDecoSpace();
|
return gModel->GetDecoSpace();
|
||||||
|
@@ -57,6 +57,8 @@ public:
|
|||||||
void SetBlurryScaling(bool newBlurryScaling);
|
void SetBlurryScaling(bool newBlurryScaling);
|
||||||
bool GetFastQuit();
|
bool GetFastQuit();
|
||||||
void SetFastQuit(bool fastquit);
|
void SetFastQuit(bool fastquit);
|
||||||
|
bool GetGlobalQuit();
|
||||||
|
void SetGlobalQuit(bool newGlobalQuit);
|
||||||
int GetDecoSpace();
|
int GetDecoSpace();
|
||||||
void SetDecoSpace(int decoSpace);
|
void SetDecoSpace(int decoSpace);
|
||||||
bool GetMouseClickRequired();
|
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] {
|
fastquit = addCheckbox(0, "Fast quit", "Always exit completely when hitting close", [this] {
|
||||||
c->SetFastQuit(fastquit->GetChecked());
|
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] {
|
showAvatars = addCheckbox(0, "Show avatars", "Disable if you have a slow connection", [this] {
|
||||||
c->SetShowAvatars(showAvatars->GetChecked());
|
c->SetShowAvatars(showAvatars->GetChecked());
|
||||||
@@ -487,6 +490,10 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
|
|||||||
{
|
{
|
||||||
fastquit->SetChecked(sender->GetFastQuit());
|
fastquit->SetChecked(sender->GetFastQuit());
|
||||||
}
|
}
|
||||||
|
if (globalQuit)
|
||||||
|
{
|
||||||
|
globalQuit->SetChecked(sender->GetGlobalQuit());
|
||||||
|
}
|
||||||
if (nativeClipoard)
|
if (nativeClipoard)
|
||||||
{
|
{
|
||||||
nativeClipoard->SetChecked(sender->GetNativeClipoard());
|
nativeClipoard->SetChecked(sender->GetNativeClipoard());
|
||||||
|
@@ -33,6 +33,7 @@ class OptionsView: public ui::Window
|
|||||||
ui::Checkbox *forceIntegerScaling{};
|
ui::Checkbox *forceIntegerScaling{};
|
||||||
ui::Checkbox *blurryScaling{};
|
ui::Checkbox *blurryScaling{};
|
||||||
ui::Checkbox *fastquit{};
|
ui::Checkbox *fastquit{};
|
||||||
|
ui::Checkbox *globalQuit{};
|
||||||
ui::DropDown *decoSpace{};
|
ui::DropDown *decoSpace{};
|
||||||
ui::Checkbox *showAvatars{};
|
ui::Checkbox *showAvatars{};
|
||||||
ui::Checkbox *momentumScroll{};
|
ui::Checkbox *momentumScroll{};
|
||||||
|
Reference in New Issue
Block a user