From bfb9bb84e36c78a119cb3fe79363c9c82819ae35 Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Fri, 29 Mar 2024 19:50:20 +0100 Subject: [PATCH 1/9] created methods for adding a profile to make doImportProfile method less heavy. Added Todos --- .../ProfileRegionController.ahk | 105 ++++++++++-------- .../Main/util/DomainSpecificGui.ahk | 1 + 2 files changed, 62 insertions(+), 44 deletions(-) diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk index 2edc037..92460bd 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk @@ -124,64 +124,81 @@ class ProfileRegionController{ } doAddProfile(profileToAdd, profileName){ + ; Guard condition + msgbox(profileToAdd) + msgbox(profileName) if (this.ExistingProfilesManager.hasFolder(profileName)){ msgbox("Failed to add profile. A profile with the given name already exists") + return } - else{ - try{ - profilePath := this.PresetProfilesManager.getFolderPathByName(profileToAdd) - this.ExistingProfilesManager.CopyFolderToNewLocation(profilePath, FilePaths.GetPathToProfiles() . "/" . profileName, profileName) - this.view.UpdateProfilesDropDownMenu() - this.addprofileView.Destroy() - msgbox("Successfully added profile " . profileName) - } - catch{ - msgbox("Failed to add profile, perhaps a profile with the given name already exists") - } + try{ + profilePath := this.PresetProfilesManager.getFolderPathByName(profileToAdd) + this.ExistingProfilesManager.CopyFolderToNewLocation(profilePath, FilePaths.GetPathToProfiles() . "/" . profileName, profileName) + this.view.UpdateProfilesDropDownMenu() + this.addprofileView.Destroy() + msgbox("Successfully added profile " . profileName) + } + catch{ + msgbox("Failed to add profile, perhaps a profile with the given name already exists") } } + ; TODO this methods is way too long.. doImportProfile(){ - - ; TODO check if the profile already exists - ; TODO check if the profile has a keyboards.json and ClassObjects.ini file. + test := DirSelect() selectedFilePath := FileSelect("D", , "Choose a location to save profile",) + ; Guard condition if selectedFilePath = ""{ ; Canceled + return } - else{ - try{ - filesFoundWhichShouldBeFound := 0 - amountOfFilesToFind := 2 - Loop Files (selectedFilePath . "\*"){ - subFolderName := A_LoopFileName - if (subFolderName = "keyboards.json" || subFolderName = "ClassObjects.ini"){ - filesFoundWhichShouldBeFound++ - } - amountOfFilesToFind -= 1 - if (amountOfFilesToFind = 0){ - break - } - } - if (filesFoundWhichShouldBeFound := 2){ - parts := StrSplit(selectedFilePath, "\") - folderName := parts[parts.length] - if (this.ExistingProfilesManager.CopyFolderToNewLocation(selectedFilePath, FilePaths.GetPathToProfiles() . "/" . folderName, folderName)){ - msgbox("Successfully imported profile " . folderName) - this.view.UpdateProfilesDropDownMenu() - } - else{ - msgbox("Failed to import profile, perhaps a profile with the given name already exists") - } - } - else{ - msgbox("The folder you selected is not a valid profile.") - } + if (!this.profileIsValid(selectedFilePath)){ + msgbox("The folder you selected is not a valid profile.") + return + } + try{ + folderName := this.getEndOfPath(selectedFilePath) + if (this.ExistingProfilesManager.CopyFolderToNewLocation(selectedFilePath, FilePaths.GetPathToProfiles() . "/" . folderName, folderName)){ + msgbox("Successfully imported profile " . folderName) + this.view.UpdateProfilesDropDownMenu() } - catch Error as e{ - MsgBox("Failed to import rofile") + else{ + msgbox("Failed to import profile, perhaps a profile with the given name already exists") + } + } + catch Error as e{ + MsgBox("Failed to import profile") + } + } + + ; TODO create a helper class for this + getEndOfPath(path){ + parts := StrSplit(path, "\") + return parts[parts.length] + } + + ; TODO create a helper class for this + profileIsValid(profilePath){ + validProfile := false + filesToBeFound := 2 + amountOfFilesToLookFor := 2 + Loop Files (profilePath . "\*"){ + subFolderName := A_LoopFileName + if (subFolderName = "Keyboards.json" || subFolderName = "ClassObjects.ini"){ + filesToBeFound-- + } + amountOfFilesToLookFor -= 1 + if (amountOfFilesToLookFor = 0){ + break } } + if (filesToBeFound = 0){ + validProfile := true + } + else{ + validProfile := false + } + return validProfile } doExportProfile(){ diff --git a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk index ca3e854..42bf701 100644 --- a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk +++ b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk @@ -3,6 +3,7 @@ #Include +; TODO on focus, change color of text and control, so that tab navigation is easiers... class DomainSpecificGui extends Gui{ __New(options := "", title := "", eventObj := ""){ From 335dd90aeeff668e2b3eeb943110bc32ffaae45a Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Fri, 29 Mar 2024 19:54:00 +0100 Subject: [PATCH 2/9] fixed issue with Tab3 text not having correct color --- .../Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk | 2 +- .../KeyboardEditing/HotKeyConfigurationView.ahk | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk index 4be7d89..f05b44e 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk @@ -40,7 +40,7 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ } CreateTabs(){ - Tab := this.AddTab3("yp+40 xm", ["Keyboards","Change Action Settings","Documentation"]) + Tab := this.Add("Tab3", "yp+40 xm", ["Keyboards","Change Action Settings","Documentation"]) Tab.UseTab(1) this.CreateKeyboardsTab() diff --git a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationView.ahk b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationView.ahk index 65a5813..db5f9bf 100644 --- a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationView.ahk +++ b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationView.ahk @@ -42,19 +42,19 @@ class HotKeyConfigurationView extends DomainSpecificGui{ } createChangeButtons(){ - buttonToChangeOriginalHotkey := this.AddButton("Default w100 xm", "Change Hotkey") + buttonToChangeOriginalHotkey := this.Add("Button", "Default w100 xm", "Change Hotkey") buttonToChangeOriginalHotkey.onEvent("Click", (*) => this.controller.changeHotkey("Hotkey")) - buttonToChangeOriginalAction := this.AddButton("Default w100", "Change Action") + buttonToChangeOriginalAction := this.Add("Button", "Default w100", "Change Action") buttonToChangeOriginalAction.onEvent("Click", (*) => this.controller.changeHotkey("Action")) } createFinalizationButtons(){ - saveButton := this.AddButton("Default w100", "Save+Done") + saveButton := this.Add("Button", "Default w100", "Save+Done") saveButton.onEvent("Click", (*) => this.controller.NotifyListenersSave()) - cancelButton := this.AddButton("Default w100", "Cancel+Done") + cancelButton := this.Add("Button", "Default w100", "Cancel+Done") cancelButton.onEvent("Click", (*) => this.Destroy()) - deleteButton := this.AddButton("Default w100", "Delete+Done") + deleteButton := this.Add("Button", "Default w100", "Delete+Done") deleteButton.onEvent("Click", (*) => this.controller.NotifyListenersDelete()) } From 45252352f35e67905e962b75591fdd380766136b Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Fri, 29 Mar 2024 20:20:37 +0100 Subject: [PATCH 3/9] added alt navigation to some buttons of main gui. Refactoring --- .../UserInterface/ExtraKeyboardsAppGuiView.ahk | 2 +- .../ProfileEditing/ProfileRegionController.ahk | 1 - .../Main/ProfileEditing/ProfileRegionView.ahk | 9 ++++----- .../UserInterface/Main/util/DomainSpecificGui.ahk | 15 +++++++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk index f05b44e..d54eb2d 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk @@ -40,7 +40,7 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ } CreateTabs(){ - Tab := this.Add("Tab3", "yp+40 xm", ["Keyboards","Change Action Settings","Documentation"]) + Tab := this.Add("Tab3", "yp+40 xm", ["&Keyboards","&Change Action Settings","Documentation"]) Tab.UseTab(1) this.CreateKeyboardsTab() diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk index 92460bd..af60281 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk @@ -145,7 +145,6 @@ class ProfileRegionController{ ; TODO this methods is way too long.. doImportProfile(){ - test := DirSelect() selectedFilePath := FileSelect("D", , "Choose a location to save profile",) ; Guard condition if selectedFilePath = ""{ diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk index 7da5462..966fd2e 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk @@ -24,11 +24,10 @@ class ProfileRegionView{ this.profilesDropDownMenu.OnEvent("Change", (*) => this.NotifyListenersProfileChanged(this.profilesDropDownMenu.Text)) - - editProfilesButton := guiObject.Add("Button", "Default w80 ym+1", "Edit profiles") - addProfileButton := guiObject.Add("Button", "Default w80 ym+1", "Add profile") - importProfileButton := guiObject.Add("Button", "Default w80 ym+1", "Import profile") - exportProfileButton := guiObject.Add("Button", "Default w80 ym+1", "Export profile") + editProfilesButton := guiObject.Add("Button", "Default w80 ym+1", "&Edit profiles") + addProfileButton := guiObject.Add("Button", "Default w80 ym+1", "&Add profile") + importProfileButton := guiObject.Add("Button", "Default w80 ym+1", "&Import profile") + exportProfileButton := guiObject.Add("Button", "Default w80 ym+1", "E&xport profile") editProfilesButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doOpenEditProfileView")()) diff --git a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk index 42bf701..ebf7918 100644 --- a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk +++ b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk @@ -21,16 +21,19 @@ class DomainSpecificGui extends Gui{ GuiColorsChanger.DwmSetCaptionColor(this, 0x7800ff) ; color is in RGB format GuiColorsChanger.DwmSetTextColor(this, 0x27eaf1) } - - Add(ControlType , Options := "", Text := ""){ - GuiCtrl := super.Add(ControlType, Options, Text) + SetControlColor(control){ controlColor := "14132b" fontColor := "27eaf1" - GuiColorsChanger.setControlColor(GuiCtrl, controlColor) - GuiColorsChanger.setControlTextColor(GuiCtrl, fontColor) + GuiColorsChanger.setControlColor(control, controlColor) + GuiColorsChanger.setControlTextColor(control, fontColor) + } + + Add(ControlType , Options := "", Text := ""){ + guiControl := super.Add(ControlType, Options, Text) - return GuiCtrl + this.SetControlColor(guiControl) + return guiControl } ; OnEvent(eventType, param1?, param2?, param3?) { From 31cfb2ec0c2e999a453444b5a52f37c62a3f504a Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Fri, 29 Mar 2024 20:34:15 +0100 Subject: [PATCH 4/9] dropdownlist for changing profiles can no longer be focused to avoid accidentally changing profiles --- .../Main/ProfileEditing/ProfileRegionController.ahk | 4 ---- .../Main/ProfileEditing/ProfileRegionView.ahk | 13 +++++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk index af60281..613c2cc 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk @@ -9,17 +9,13 @@ class ProfileRegionController{ view := "" - editView := "" - - addprofileView := "" ; Used to manage the preset user profiles, the user is only allowed to add a preset profile as a new profile PresetProfilesManager := "" ; Used to manage the existing user profiles, the user is allowed to edit, delete, and add new profiles ExistingProfilesManager := "" - __New(view){ this.view := view diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk index 966fd2e..a44fdeb 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk @@ -12,6 +12,8 @@ class ProfileRegionView{ guiHwnd := "" + editProfilesButton := "" + CreateView(guiObject, controller){ this.controller := controller @@ -24,13 +26,13 @@ class ProfileRegionView{ this.profilesDropDownMenu.OnEvent("Change", (*) => this.NotifyListenersProfileChanged(this.profilesDropDownMenu.Text)) - editProfilesButton := guiObject.Add("Button", "Default w80 ym+1", "&Edit profiles") + this.editProfilesButton := guiObject.Add("Button", "Default w80 ym+1", "&Edit profiles") addProfileButton := guiObject.Add("Button", "Default w80 ym+1", "&Add profile") importProfileButton := guiObject.Add("Button", "Default w80 ym+1", "&Import profile") exportProfileButton := guiObject.Add("Button", "Default w80 ym+1", "E&xport profile") - editProfilesButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doOpenEditProfileView")()) + this.editProfilesButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doOpenEditProfileView")()) addProfileButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doOpenAddProfileDialog")()) importProfileButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doImportProfile")()) exportProfileButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doExportProfile")()) @@ -77,9 +79,16 @@ class ProfileRegionView{ profilesDropDownMenu := guiObject.Add("DropDownList", "ym+1 Choose" . profileIndex, profiles) } + profilesDropDownMenu.OnEvent("Focus", (*) => this.unFocusDropDownMenu(profilesDropDownMenu)) + return profilesDropDownMenu } + unFocusDropDownMenu(dropDownMenu){ + ; This avoid focusing the dropdown, which is really irritating + this.editProfilesButton.Focus() + } + GetHwnd(){ return this.guiHwnd } From 2915e027fda7a218a135f562f79ac5a1cfb8242d Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Fri, 29 Mar 2024 21:05:50 +0100 Subject: [PATCH 5/9] created classes for themes, making it easy to switch color themes (though not yet implemented for user to change) --- .../Main/ProfileEditing/ProfileRegionView.ahk | 1 - .../Main/util/DomainSpecificGui.ahk | 49 +++++++++++-------- .../Lib/UserInterface/Main/util/GuiTheme.ahk | 32 ++++++++++++ .../Lib/UserInterface/Main/util/Themes.ahk | 15 +++++- 4 files changed, 74 insertions(+), 23 deletions(-) create mode 100644 src/Main/Lib/UserInterface/Main/util/GuiTheme.ahk diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk index a44fdeb..4b80677 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk @@ -38,7 +38,6 @@ class ProfileRegionView{ exportProfileButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doExportProfile")()) this.guiHwnd := guiObject.GetHwnd() - guiObject.Show() } diff --git a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk index ebf7918..6f47bef 100644 --- a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk +++ b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk @@ -1,41 +1,58 @@ #Requires AutoHotkey v2.0 #Include +#Include ; TODO on focus, change color of text and control, so that tab navigation is easiers... class DomainSpecificGui extends Gui{ + theme := "" + + ; TODO fetch color profile from meta file. __New(options := "", title := "", eventObj := ""){ super.__New(options, title, this) + + this.theme := Themes.BlueIsh() + this.OnEvent('Escape', (*) => this.Destroy()) + this.BackColor := this.theme.BackgroundColor() this.SetColors() - this.SetFont("c27eaf1 Bold") + this.SetFont("c" . this.theme.TextColor() . " Bold") + } + + SetColorProfile(){ + } SetColors(){ - this.BackColor := "35326b" - ; Top bar or whatever it is called - - GuiColorsChanger.DwmSetCaptionColor(this, 0x7800ff) ; color is in RGB format - GuiColorsChanger.DwmSetTextColor(this, 0x27eaf1) + GuiColorsChanger.DwmSetCaptionColor(this, "0x" this.theme.CaptionColor()) ; color is in RGB format + GuiColorsChanger.DwmSetTextColor(this, "0x" . this.theme.TextColor()) } SetControlColor(control){ - controlColor := "14132b" - fontColor := "27eaf1" - GuiColorsChanger.setControlColor(control, controlColor) - GuiColorsChanger.setControlTextColor(control, fontColor) + GuiColorsChanger.setControlColor(control, this.theme.ControlColor()) + GuiColorsChanger.setControlTextColor(control, this.theme.TextColor()) } Add(ControlType , Options := "", Text := ""){ guiControl := super.Add(ControlType, Options, Text) - this.SetControlColor(guiControl) return guiControl } + GetHwnd(){ + return this.Hwnd + } + + SetOwner(ownerHwnd := ""){ + if (ownerHwnd != ""){ + this.opt("+Owner" . ownerHwnd) + } + } + + ; OnEvent(eventType, param1?, param2?, param3?) { ; ; Check if a control is being added ; msgbox(eventType) @@ -58,14 +75,4 @@ class DomainSpecificGui extends Gui{ ; } ; super.OnEvent(eventType, parameters*) ; } - - GetHwnd(){ - return this.Hwnd - } - - SetOwner(ownerHwnd := ""){ - if (ownerHwnd != ""){ - this.opt("+Owner" . ownerHwnd) - } - } } diff --git a/src/Main/Lib/UserInterface/Main/util/GuiTheme.ahk b/src/Main/Lib/UserInterface/Main/util/GuiTheme.ahk new file mode 100644 index 0000000..d1166db --- /dev/null +++ b/src/Main/Lib/UserInterface/Main/util/GuiTheme.ahk @@ -0,0 +1,32 @@ +#Requires AutoHotkey v2.0 + +class GuiTheme{ + + CaptionColor_ := "" + BackgroundColor_ := "" + TextColor_ := "" + ControlColor_ := "" + + __New(BackgroundColor_, TextColor_, ControlColor_, CaptionColor_ := "ffffff"){ + this.BackgroundColor_ := BackgroundColor_ + this.TextColor_ := TextColor_ + this.ControlColor_ := ControlColor_ + this.CaptionColor_ := CaptionColor_ + } + + BackgroundColor(){ + return this.BackgroundColor_ + } + + TextColor(){ + return this.TextColor_ + } + + ControlColor(){ + return this.ControlColor_ + } + + CaptionColor(){ + return this.CaptionColor_ + } +} \ No newline at end of file diff --git a/src/Main/Lib/UserInterface/Main/util/Themes.ahk b/src/Main/Lib/UserInterface/Main/util/Themes.ahk index fa10dac..3842aab 100644 --- a/src/Main/Lib/UserInterface/Main/util/Themes.ahk +++ b/src/Main/Lib/UserInterface/Main/util/Themes.ahk @@ -1,3 +1,16 @@ #Requires AutoHotkey v2.0 -; TODO create \ No newline at end of file +; TODO create + +#Include + +class Themes{ + + static Blueish(){ + return GuiTheme("35326b", "27eaf1", "14132b", "7800ff") + } + + static RedIsh(){ + return GuiTheme("6b3535", "f12727", "2b1414") + } +} \ No newline at end of file From 53b28527e59a9897ff9b6258884f8f7d0f480287 Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Sat, 30 Mar 2024 09:00:25 +0100 Subject: [PATCH 6/9] added (non functional) buttons for adding/editing/deleting hotkeys (without double cliking the hotkeys area --- .../ExtraKeyboardsAppGuiController.ahk | 8 +++++- .../ExtraKeyboardsAppGuiView.ahk | 27 +++++++++++++++++-- .../Main/util/DomainSpecificGui.ahk | 3 ++- .../Lib/UserInterface/Main/util/Themes.ahk | 2 +- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk index bc9e2da..08b7bf1 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk @@ -29,6 +29,12 @@ Class ExtraKeyboardsAppGuiController{ this.view.Destroy() } + DoLayerSelected(currentLayer){ + this.ShowHotkeysForLayer(currentLayer) + this.View.UpdateButtonForAddingInfo() + + } + ShowHotkeysForLayer(currentLayer){ this.model.SetCurrentLayer(currentLayer) @@ -37,7 +43,7 @@ Class ExtraKeyboardsAppGuiController{ ; TODO make sure user cant create multiple popups? ; TODO change name for this... - EditHotkey(listView, indexOfKeyToEdit){ + AddOrEditHotkey(listView, indexOfKeyToEdit){ layerInformation := this.GetCurrentLayerInfo() diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk index d54eb2d..c097116 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk @@ -60,8 +60,31 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ this.hotkeysListView := ListViewMaker() this.hotkeysListView.CreateListView(this, "r20 w600 x+10 -multi" , ["KeyCombo","Action"]) - keyboardLayoutChanger.AddEventAction("ItemSelect", (*) => this.controller.ShowHotkeysForLayer(keyboardLayoutChanger.GetSelectionText())) - this.hotkeysListView.AddEventAction("DoubleClick", ObjBindMethod(this.controller, "EditHotkey")) + keyboardLayoutChanger.AddEventAction("ItemSelect", (*) => this.controller.DoLayerSelected(keyboardLayoutChanger.GetSelectionText())) + this.hotkeysListView.AddEventAction("DoubleClick", ObjBindMethod(this.controller, "AddOrEditHotkey")) + + this.ButtonForAddingInfo := this.Add("Button", "", "Add") + this.ButtonForAddingInfo.Opt("Hidden1") + + this.ButtonForEditingInfo := this.Add("Button", "Yp", "Edit") + this.ButtonForEditingInfo.Opt("Hidden1") + + this.ButtonForDeletingInfo := this.Add("Button", "Yp", "Delete") + this.ButtonForDeletingInfo.Opt("Hidden1") + } + + UpdateButtonForAddingInfo(){ + if (this.controller.GetCurrentLayer() == ""){ + this.ButtonForAddingInfo.Opt("Hidden1") + this.ButtonForEditingInfo.Opt("Hidden1") + this.ButtonForDeletingInfo.Opt("Hidden1") + } + else { + this.ButtonForAddingInfo.Opt("Hidden0") + this.ButtonForEditingInfo.Opt("Hidden0") + this.ButtonForDeletingInfo.Opt("Hidden0") + } + } UpdateHotkeys(){ diff --git a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk index 6f47bef..cee5655 100644 --- a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk +++ b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk @@ -13,7 +13,7 @@ class DomainSpecificGui extends Gui{ __New(options := "", title := "", eventObj := ""){ super.__New(options, title, this) - this.theme := Themes.BlueIsh() + this.theme := Themes.blueIsh() this.OnEvent('Escape', (*) => this.Destroy()) this.BackColor := this.theme.BackgroundColor() @@ -28,6 +28,7 @@ class DomainSpecificGui extends Gui{ SetColors(){ ; Top bar or whatever it is called GuiColorsChanger.DwmSetCaptionColor(this, "0x" this.theme.CaptionColor()) ; color is in RGB format + ; TODO add color for this too GuiColorsChanger.DwmSetTextColor(this, "0x" . this.theme.TextColor()) } diff --git a/src/Main/Lib/UserInterface/Main/util/Themes.ahk b/src/Main/Lib/UserInterface/Main/util/Themes.ahk index 3842aab..77b6c03 100644 --- a/src/Main/Lib/UserInterface/Main/util/Themes.ahk +++ b/src/Main/Lib/UserInterface/Main/util/Themes.ahk @@ -11,6 +11,6 @@ class Themes{ } static RedIsh(){ - return GuiTheme("6b3535", "f12727", "2b1414") + return GuiTheme("6b3535", "f12727", "2b1414", "7a0707") } } \ No newline at end of file From 22fd6f0c7d1aade97be89b01a2aad547f4115bc6 Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Sat, 30 Mar 2024 09:51:18 +0100 Subject: [PATCH 7/9] refactoring. Fixed bug with chaning hotkeys not working --- config/meta.ini | 2 +- .../ExtraKeyboardsAppGuiController.ahk | 6 +++--- .../ExtraKeyboardsAppGuiView.ahk | 20 ++++++++++++++++--- .../Main/ProfileEditing/ProfileRegionView.ahk | 2 +- .../UserInterface/Main/util/ListViewMaker.ahk | 17 ++++++++++++++-- .../Hotkeys/logic/HotkeysRegistry.ahk | 2 -- 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/config/meta.ini b/config/meta.ini index 88c9dff..e65f9b1 100644 --- a/config/meta.ini +++ b/config/meta.ini @@ -1,2 +1,2 @@ [General] -activeUserProfile=main +activeUserProfile=test diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk index 08b7bf1..0fbc2c4 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk @@ -31,7 +31,7 @@ Class ExtraKeyboardsAppGuiController{ DoLayerSelected(currentLayer){ this.ShowHotkeysForLayer(currentLayer) - this.View.UpdateButtonForAddingInfo() + this.View.UpdateConfigurationButtons() } @@ -43,7 +43,7 @@ Class ExtraKeyboardsAppGuiController{ ; TODO make sure user cant create multiple popups? ; TODO change name for this... - AddOrEditHotkey(listView, indexOfKeyToEdit){ + DoAddOrEditHotkey(listView, indexOfKeyToEdit){ layerInformation := this.GetCurrentLayerInfo() @@ -51,7 +51,7 @@ Class ExtraKeyboardsAppGuiController{ hotkeyInformation := HotkeyInfo() if (indexOfKeyToEdit = 0){ - ; this.CreatePopupForHotkeys(hotkeyInformation) + } else{ hotkeyBuild := listView.GetText(indexOfKeyToEdit, 1) diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk index c097116..1dfa946 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk @@ -61,7 +61,9 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ this.hotkeysListView.CreateListView(this, "r20 w600 x+10 -multi" , ["KeyCombo","Action"]) keyboardLayoutChanger.AddEventAction("ItemSelect", (*) => this.controller.DoLayerSelected(keyboardLayoutChanger.GetSelectionText())) - this.hotkeysListView.AddEventAction("DoubleClick", ObjBindMethod(this.controller, "AddOrEditHotkey")) + this.hotkeysListView.AddEventAction("ItemSelect", (*) => this.EnableConfigurationButtons()) + this.hotkeysListView.AddEventAction("DoubleClick", ObjBindMethod(this.controller, "DoAddOrEditHotkey")) + this.ButtonForAddingInfo := this.Add("Button", "", "Add") this.ButtonForAddingInfo.Opt("Hidden1") @@ -71,9 +73,12 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ this.ButtonForDeletingInfo := this.Add("Button", "Yp", "Delete") this.ButtonForDeletingInfo.Opt("Hidden1") + } - UpdateButtonForAddingInfo(){ + UpdateConfigurationButtons(){ + this.DisableConfigurationButtons() + if (this.controller.GetCurrentLayer() == ""){ this.ButtonForAddingInfo.Opt("Hidden1") this.ButtonForEditingInfo.Opt("Hidden1") @@ -84,7 +89,16 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ this.ButtonForEditingInfo.Opt("Hidden0") this.ButtonForDeletingInfo.Opt("Hidden0") } - + } + + EnableConfigurationButtons(){ + this.ButtonForEditingInfo.Enabled := true + this.ButtonForDeletingInfo.Enabled := true + } + + DisableConfigurationButtons(){ + this.ButtonForEditingInfo.Enabled := false + this.ButtonForDeletingInfo.Enabled := false } UpdateHotkeys(){ diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk index 4b80677..bc5c3e2 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk @@ -78,7 +78,7 @@ class ProfileRegionView{ profilesDropDownMenu := guiObject.Add("DropDownList", "ym+1 Choose" . profileIndex, profiles) } - profilesDropDownMenu.OnEvent("Focus", (*) => this.unFocusDropDownMenu(profilesDropDownMenu)) + ; profilesDropDownMenu.OnEvent("Focus", (*) => this.unFocusDropDownMenu(profilesDropDownMenu)) return profilesDropDownMenu } diff --git a/src/Main/Lib/UserInterface/Main/util/ListViewMaker.ahk b/src/Main/Lib/UserInterface/Main/util/ListViewMaker.ahk index e9f427e..b1e2836 100644 --- a/src/Main/Lib/UserInterface/Main/util/ListViewMaker.ahk +++ b/src/Main/Lib/UserInterface/Main/util/ListViewMaker.ahk @@ -30,13 +30,26 @@ class ListViewMaker{ ; Takes a two dimensional array, items, and adds each item to the listView SetNewListViewItems(items){ - this.listView.Delete() + ; TODO dont delete all items, just add new ones or modify existing ones. + ; this.listView.Delete() minWidths := this.GetMinWidthsForItems(items) + listViewLength := this.listView.GetCount() + + if (listViewLength > items.Length){ + Loop listViewLength - items.Length{ + this.listView.Delete(listViewLength-A_Index+1) + } + } Loop items.Length{ - this.listView.Add("Icon3", items[A_index]*) + if (A_index > listViewLength){ + this.listView.Add("Icon3", items[A_index]*) + } + else{ + this.listView.Modify(A_index, "Icon3",items[A_index]*) + } } Sleep(20) this.SetColumnWidths(minWidths) diff --git a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardsInfo/Hotkeys/logic/HotkeysRegistry.ahk b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardsInfo/Hotkeys/logic/HotkeysRegistry.ahk index 9352176..efc9483 100644 --- a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardsInfo/Hotkeys/logic/HotkeysRegistry.ahk +++ b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardsInfo/Hotkeys/logic/HotkeysRegistry.ahk @@ -41,9 +41,7 @@ class HotkeysRegistry{ this.hotkeys[hotkeyName].changeHotkey(newHotkey) this.hotkeys[newHotKey] := this.hotkeys[hotkeyName] } - ; If the new hotkey is empty, the original hotkey is just deleted instead of being replaced this.hotkeys.Delete(hotkeyName) - Hotkey(hotkeyName, "Off") } } From 8f9bbcd4095000d74d7132553e49ec32e6d2c2f9 Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Sat, 30 Mar 2024 15:57:17 +0100 Subject: [PATCH 8/9] refactoring of EKAG --- .../ExtraKeyboardsAppGuiController.ahk | 7 +++---- .../ExtraKeyboardsAppGuiView.ahk | 20 +++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk index 0fbc2c4..1b9871d 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk @@ -32,7 +32,6 @@ Class ExtraKeyboardsAppGuiController{ DoLayerSelected(currentLayer){ this.ShowHotkeysForLayer(currentLayer) this.View.UpdateConfigurationButtons() - } ShowHotkeysForLayer(currentLayer){ @@ -43,18 +42,18 @@ Class ExtraKeyboardsAppGuiController{ ; TODO make sure user cant create multiple popups? ; TODO change name for this... - DoAddOrEditHotkey(listView, indexOfKeyToEdit){ + DoAddOrEditHotkey(hotkeyBuild := ""){ layerInformation := this.GetCurrentLayerInfo() if (Type(layerInformation) == "HotkeysRegistry"){ hotkeyInformation := HotkeyInfo() - if (indexOfKeyToEdit = 0){ + ; TODO find a better way than this... + if (hotkeyBuild = "KeyCombo" || hotkeyBuild = ""){ } else{ - hotkeyBuild := listView.GetText(indexOfKeyToEdit, 1) hotkeyInformation := this.model.GetHotkeyInfoForCurrentLayer(hotkeyBuild) } this.CreatePopupForHotkeys(hotkeyInformation) diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk index 1dfa946..96494a9 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk @@ -60,12 +60,10 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ this.hotkeysListView := ListViewMaker() this.hotkeysListView.CreateListView(this, "r20 w600 x+10 -multi" , ["KeyCombo","Action"]) - keyboardLayoutChanger.AddEventAction("ItemSelect", (*) => this.controller.DoLayerSelected(keyboardLayoutChanger.GetSelectionText())) - this.hotkeysListView.AddEventAction("ItemSelect", (*) => this.EnableConfigurationButtons()) - this.hotkeysListView.AddEventAction("DoubleClick", ObjBindMethod(this.controller, "DoAddOrEditHotkey")) - this.ButtonForAddingInfo := this.Add("Button", "", "Add") + this.ButtonForAddingInfo.OnEvent("Click", (*) => this.controller.DoAddOrEditHotkey()) + this.ButtonForAddingInfo.Opt("Hidden1") this.ButtonForEditingInfo := this.Add("Button", "Yp", "Edit") @@ -74,6 +72,11 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ this.ButtonForDeletingInfo := this.Add("Button", "Yp", "Delete") this.ButtonForDeletingInfo.Opt("Hidden1") + + this.hotkeysListView.AddEventAction("ItemSelect", (listView, rowSelected, ColumnSelected) => this.ChangeConfigurationButtonsStatus(rowSelected)) + keyboardLayoutChanger.AddEventAction("ItemSelect", (*) => this.controller.DoLayerSelected(keyboardLayoutChanger.GetSelectionText())) + this.hotkeysListView.AddEventAction("DoubleClick", (listView, rowClicked) => this.controller.DoAddOrEditHotkey(listView.GetText(rowClicked, 1))) + } UpdateConfigurationButtons(){ @@ -91,6 +94,15 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ } } + ChangeConfigurationButtonsStatus(rowFocused){ + if (rowFocused = 0){ + this.DisableConfigurationButtons() + } + else{ + this.EnableConfigurationButtons() + } + } + EnableConfigurationButtons(){ this.ButtonForEditingInfo.Enabled := true this.ButtonForDeletingInfo.Enabled := true From f67cb9cea028e5ca572551e48122273ab965ca90 Mon Sep 17 00:00:00 2001 From: OSTERITE Date: Sun, 31 Mar 2024 12:58:22 +0200 Subject: [PATCH 9/9] improved check for valid profile --- .../Main/ProfileEditing/ProfileRegionController.ahk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk index 613c2cc..a5b66fb 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk @@ -121,8 +121,6 @@ class ProfileRegionController{ doAddProfile(profileToAdd, profileName){ ; Guard condition - msgbox(profileToAdd) - msgbox(profileName) if (this.ExistingProfilesManager.hasFolder(profileName)){ msgbox("Failed to add profile. A profile with the given name already exists") return @@ -183,11 +181,11 @@ class ProfileRegionController{ filesToBeFound-- } amountOfFilesToLookFor -= 1 - if (amountOfFilesToLookFor = 0){ + if (amountOfFilesToLookFor = -1){ break } } - if (filesToBeFound = 0){ + if (filesToBeFound = 0 && amountOfFilesToLookFor != -1){ validProfile := true } else{