mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
Working hotkey reset.
This commit is contained in:
parent
f1c39e2038
commit
e36fa357b9
@ -70,6 +70,10 @@ static void confirmResetHotkeys() {
|
||||
static void checkConflictAndSave(Hotkeys::Id id, const std::string& key) {
|
||||
const std::string existing = Hotkeys::Existing(key);
|
||||
|
||||
if (existing == Hotkeys::Name(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (existing.size()) {
|
||||
std::shared_ptr<DialogOverlay> dialog(new DialogOverlay());
|
||||
|
||||
@ -99,7 +103,7 @@ static void checkConflictAndSave(Hotkeys::Id id, const std::string& key) {
|
||||
HotkeysLayout::HotkeysLayout() {
|
||||
auto adapter = std::make_shared<HotkeysAdapter>();
|
||||
|
||||
adapter->SetItemDecorator([&adapter, this](ScrollableWindow*, size_t index, size_t, Entry) -> int64_t {
|
||||
adapter->SetItemDecorator([this](ScrollableWindow*, size_t index, size_t, Entry) -> int64_t {
|
||||
if (this->listWindow->GetSelectedIndex() == index) {
|
||||
return COLOR_PAIR(CURSESPP_HIGHLIGHTED_LIST_ITEM);
|
||||
}
|
||||
@ -142,6 +146,7 @@ void HotkeysLayout::SetShortcutsWindow(ShortcutsWindow* shortcuts) {
|
||||
bool HotkeysLayout::KeyPress(const std::string& kn) {
|
||||
if (kn == "M-r") {
|
||||
confirmResetHotkeys();
|
||||
this->listWindow->OnAdapterChanged();
|
||||
return true;
|
||||
}
|
||||
else if (Hotkeys::Is(Hotkeys::NavigateSettings, kn)) {
|
||||
|
@ -125,6 +125,7 @@ void ReassignHotkeyOverlay::InitViews() {
|
||||
this->hotkeyInput->SetRawKeyBlacklist({ "KEY_ENTER", "^[" });
|
||||
this->hotkeyInput->SetFocusOrder(0);
|
||||
this->hotkeyInput->SetFocusedFrameColor(CURSESPP_OVERLAY_INPUT_FRAME);
|
||||
this->hotkeyInput->SetText(Hotkeys::Get(this->id));
|
||||
this->hotkeyInput->SetFocusedContentColor(CURSESPP_OVERLAY_CONTENT);
|
||||
|
||||
this->shortcuts = std::make_shared<ShortcutsWindow>();
|
||||
|
@ -204,7 +204,7 @@ static std::unordered_map<Id, std::string, EnumHasher> customIdToKey;
|
||||
static std::shared_ptr<Preferences> prefs;
|
||||
|
||||
static void savePreferences() {
|
||||
for (const std::pair<std::string, Id>& pair : NAME_TO_ID) {
|
||||
for (const auto& pair : NAME_TO_ID) {
|
||||
prefs->SetString(
|
||||
pair.first.c_str(),
|
||||
Hotkeys::Get(pair.second).c_str());
|
||||
@ -302,7 +302,9 @@ void Hotkeys::Set(Id id, const std::string& kn) {
|
||||
}
|
||||
|
||||
void Hotkeys::Reset() {
|
||||
/* CAL TODO */
|
||||
customIdToKey.clear();
|
||||
savePreferences();
|
||||
loadPreferences();
|
||||
}
|
||||
|
||||
std::string Hotkeys::Existing(const std::string& kn) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user