mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-06 03:39:50 +00:00
Allow for customizing the quit key via settings.json
using the AppQuitKey
property.
Right now there's no UI for it, and it may stay this way because it's an uncommon use case and I have some concerns about users accidentally binding it to an important key and making the app difficult to start/navigate.
This commit is contained in:
parent
2872627190
commit
c06c774bd7
@ -151,6 +151,9 @@ int main(int argc, char* argv[]) {
|
||||
app.SetIcon(IDI_ICON1);
|
||||
app.SetSingleInstanceId("musikcube");
|
||||
#endif
|
||||
|
||||
app.SetQuitKey(prefs->GetString(keys::AppQuitKey, "^D"));
|
||||
|
||||
/* fire up the indexer if configured to run on startup */
|
||||
if (prefs->GetBool(musik::core::prefs::keys::SyncOnStartup, true)) {
|
||||
library->Indexer()->Schedule(IIndexer::SyncType::All);
|
||||
|
@ -120,7 +120,7 @@ void ConsoleLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
|
||||
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateConsole), _TSTR("shortcuts_console"));
|
||||
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLibrary), _TSTR("shortcuts_library"));
|
||||
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateSettings), _TSTR("shortcuts_settings"));
|
||||
shortcuts->AddShortcut("^D", _TSTR("shortcuts_quit"));
|
||||
shortcuts->AddShortcut(App::Instance().GetQuitKey(), _TSTR("shortcuts_quit"));
|
||||
|
||||
shortcuts->SetChangedCallback([this](std::string key) {
|
||||
if (Hotkeys::Is(Hotkeys::NavigateSettings, key)) {
|
||||
@ -129,7 +129,7 @@ void ConsoleLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
|
||||
if (Hotkeys::Is(Hotkeys::NavigateLibrary, key)) {
|
||||
this->Broadcast(message::JumpToLibrary);
|
||||
}
|
||||
else if (key == "^D") {
|
||||
else if (key == App::Instance().GetQuitKey()) {
|
||||
App::Instance().Quit();
|
||||
}
|
||||
else {
|
||||
|
@ -228,7 +228,7 @@ void HotkeysLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
|
||||
Hotkeys::Get(Hotkeys::NavigateSettings),
|
||||
_TSTR("shortcuts_settings"));
|
||||
|
||||
shortcuts->AddShortcut("^D", _TSTR("shortcuts_quit"));
|
||||
shortcuts->AddShortcut(App::Instance().GetQuitKey(), _TSTR("shortcuts_quit"));
|
||||
|
||||
shortcuts->SetChangedCallback([this](std::string key) {
|
||||
this->KeyPress(key);
|
||||
|
@ -247,13 +247,13 @@ void LibraryLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
|
||||
this->shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLibraryTracks), _TSTR("shortcuts_tracks"));
|
||||
this->shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLibraryPlayQueue), _TSTR("shortcuts_play_queue"));
|
||||
this->shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateSettings), _TSTR("shortcuts_settings"));
|
||||
this->shortcuts->AddShortcut("^D", _TSTR("shortcuts_quit"));
|
||||
this->shortcuts->AddShortcut(App::Instance().GetQuitKey(), _TSTR("shortcuts_quit"));
|
||||
|
||||
this->shortcuts->SetChangedCallback([this](std::string key) {
|
||||
if (Hotkeys::Is(Hotkeys::NavigateSettings, key)) {
|
||||
this->Broadcast(message::JumpToSettings);
|
||||
}
|
||||
else if (key == "^D") {
|
||||
else if (key == App::Instance().GetQuitKey()) {
|
||||
App::Instance().Quit();
|
||||
}
|
||||
else {
|
||||
|
@ -512,7 +512,7 @@ void SettingsLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
|
||||
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateSettings), _TSTR("shortcuts_settings"));
|
||||
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateLibrary), _TSTR("shortcuts_library"));
|
||||
shortcuts->AddShortcut(Hotkeys::Get(Hotkeys::NavigateConsole), _TSTR("shortcuts_console"));
|
||||
shortcuts->AddShortcut("^D", _TSTR("shortcuts_quit"));
|
||||
shortcuts->AddShortcut(App::Instance().GetQuitKey(), _TSTR("shortcuts_quit"));
|
||||
|
||||
shortcuts->SetChangedCallback([this](std::string key) {
|
||||
if (Hotkeys::Is(Hotkeys::NavigateConsole, key)) {
|
||||
@ -521,7 +521,7 @@ void SettingsLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
|
||||
if (Hotkeys::Is(Hotkeys::NavigateLibrary, key)) {
|
||||
this->Broadcast(message::JumpToLibrary);
|
||||
}
|
||||
else if (key == "^D") {
|
||||
else if (key == App::Instance().GetQuitKey()) {
|
||||
app.Quit();
|
||||
}
|
||||
this->KeyPress(key);
|
||||
|
@ -52,6 +52,7 @@ namespace musik { namespace cube { namespace prefs {
|
||||
const std::string keys::LastBrowseDirectoryRoot = "LastBrowseDirectoryRoot";
|
||||
const std::string keys::LastCategoryFilter = "LastCategoryFilter";
|
||||
const std::string keys::LastTrackFilter = "LastTrackFilter";
|
||||
const std::string keys::AppQuitKey = "AppQuitKey";
|
||||
|
||||
} } }
|
||||
|
||||
|
@ -54,6 +54,7 @@ namespace musik { namespace cube { namespace prefs {
|
||||
extern const std::string LastBrowseDirectoryRoot;
|
||||
extern const std::string LastCategoryFilter;
|
||||
extern const std::string LastTrackFilter;
|
||||
extern const std::string AppQuitKey;
|
||||
}
|
||||
|
||||
} } }
|
||||
|
@ -234,6 +234,14 @@ void App::OnResized() {
|
||||
}
|
||||
}
|
||||
|
||||
void App::SetQuitKey(const std::string& kn) {
|
||||
this->quitKey = kn;
|
||||
}
|
||||
|
||||
std::string App::GetQuitKey() {
|
||||
return this->quitKey;
|
||||
}
|
||||
|
||||
void App::InjectKeyPress(const std::string& key) {
|
||||
this->injectedKeys.push(key);
|
||||
}
|
||||
@ -325,7 +333,7 @@ process:
|
||||
else if (kn == "KEY_BTAB") { /* shift-tab */
|
||||
this->FocusPrevInLayout();
|
||||
}
|
||||
else if (kn == "^D") { /* ctrl+d quits */
|
||||
else if (kn == this->quitKey) { /* ctrl+d quits */
|
||||
this->quit = true;
|
||||
}
|
||||
else if (kn == "KEY_RESIZE") {
|
||||
|
@ -55,8 +55,7 @@ Checkbox::Checkbox()
|
||||
|
||||
Checkbox::Checkbox(const std::string& value)
|
||||
: TextLabel(decorate(value, false))
|
||||
, originalText(value)
|
||||
, checked(checked) {
|
||||
, originalText(value) {
|
||||
}
|
||||
|
||||
Checkbox::Checkbox(const std::string& value, const text::TextAlign alignment)
|
||||
|
@ -63,6 +63,8 @@ namespace cursespp {
|
||||
void SetMouseEnabled(bool enabled);
|
||||
bool IsOverlayVisible() { return this->state.overlay != nullptr; }
|
||||
void SetMinimizeToTray(bool minimizeToTray);
|
||||
std::string GetQuitKey();
|
||||
void SetQuitKey(const std::string& kn);
|
||||
void Minimize();
|
||||
void Restore();
|
||||
|
||||
@ -117,6 +119,7 @@ namespace cursespp {
|
||||
Colors::Mode colorMode { Colors::Palette };
|
||||
Colors::BgType bgType { Colors::Theme };
|
||||
std::string colorTheme;
|
||||
std::string quitKey{"^D"};
|
||||
int minWidth, minHeight;
|
||||
bool mouseEnabled;
|
||||
bool quit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user