diff --git a/config/ObjectInfo.json b/config/ObjectInfo.json index d4c55fc..477e6ef 100644 --- a/config/ObjectInfo.json +++ b/config/ObjectInfo.json @@ -272,8 +272,8 @@ "Description": "Hides the active window", "Parameters": [] }, - "HideGui": { - "MethodName": "HideGui", + "Hide": { + "MethodName": "Hide", "FriendlyName": "Hide the screen hider itself (turn it off)", "Description": "Hides the screen hider itself", "Parameters": [] diff --git a/config/PresetProfiles/AllPurpose_en/Keyboards.json b/config/PresetProfiles/AllPurpose_en/Keyboards.json index a321730..67c31cc 100644 --- a/config/PresetProfiles/AllPurpose_en/Keyboards.json +++ b/config/PresetProfiles/AllPurpose_en/Keyboards.json @@ -330,7 +330,7 @@ "isObject":1 }, "f":{ - "MethodName":"HideGui", + "MethodName":"Hide", "ObjectName":"PrivacyController", "Parameters":[], "isObject":1 diff --git a/config/PresetProfiles/AllPurpose_no/Keyboards.json b/config/PresetProfiles/AllPurpose_no/Keyboards.json index 1883f72..2d13bc4 100644 --- a/config/PresetProfiles/AllPurpose_no/Keyboards.json +++ b/config/PresetProfiles/AllPurpose_no/Keyboards.json @@ -293,7 +293,7 @@ "isObject":1 }, "f":{ - "MethodName":"HideGui", + "MethodName":"Hide", "ObjectName":"PrivacyController", "Parameters":[], "isObject":1 diff --git a/config/PresetProfiles/SimpleOneLayerNavigation_en/ClassObjects.ini b/config/PresetProfiles/Simple_en/ClassObjects.ini similarity index 100% rename from config/PresetProfiles/SimpleOneLayerNavigation_en/ClassObjects.ini rename to config/PresetProfiles/Simple_en/ClassObjects.ini diff --git a/config/PresetProfiles/SimpleOneLayerNavigation_en/Keyboards.json b/config/PresetProfiles/Simple_en/Keyboards.json similarity index 100% rename from config/PresetProfiles/SimpleOneLayerNavigation_en/Keyboards.json rename to config/PresetProfiles/Simple_en/Keyboards.json diff --git a/config/PresetProfiles/SimpleOneLayerNavigation_no/ClassObjects.ini b/config/PresetProfiles/Simple_no/ClassObjects.ini similarity index 100% rename from config/PresetProfiles/SimpleOneLayerNavigation_no/ClassObjects.ini rename to config/PresetProfiles/Simple_no/ClassObjects.ini diff --git a/config/PresetProfiles/SimpleOneLayerNavigation_no/Keyboards.json b/config/PresetProfiles/Simple_no/Keyboards.json similarity index 100% rename from config/PresetProfiles/SimpleOneLayerNavigation_no/Keyboards.json rename to config/PresetProfiles/Simple_no/Keyboards.json diff --git a/config/UserProfiles/Default/Keyboards.json b/config/UserProfiles/Default/Keyboards.json index d0caeae..76a12bf 100644 --- a/config/UserProfiles/Default/Keyboards.json +++ b/config/UserProfiles/Default/Keyboards.json @@ -34,7 +34,7 @@ "key": "Esc", "modifiers": "" }, - "*å":{ + "*[":{ "isObject": false, "key": "Esc", "modifiers": "" @@ -104,7 +104,7 @@ "key": "Del", "modifiers": "" }, - "*ø": { + "*;": { "isObject": false, "key": "BackSpace", "modifiers": "" diff --git a/config/meta.ini b/config/meta.ini index a507921..88c9dff 100644 --- a/config/meta.ini +++ b/config/meta.ini @@ -1,2 +1,2 @@ [General] -activeUserProfile=Main +activeUserProfile=main diff --git a/src/Main/Lib/Actions/Action.ahk b/src/Main/Lib/Actions/Action.ahk new file mode 100644 index 0000000..324c8bd --- /dev/null +++ b/src/Main/Lib/Actions/Action.ahk @@ -0,0 +1,9 @@ +#Requires AutoHotkey v2.0 + +; A super class for all actions. +class Action{ + + Destroy(){ + + } +} \ No newline at end of file diff --git a/src/Main/Lib/Actions/BatteryAndPower/BatteryController.ahk b/src/Main/Lib/Actions/BatteryAndPower/BatteryController.ahk index ff98ea5..64c0fe1 100644 --- a/src/Main/Lib/Actions/BatteryAndPower/BatteryController.ahk +++ b/src/Main/Lib/Actions/BatteryAndPower/BatteryController.ahk @@ -1,6 +1,8 @@ #Requires AutoHotkey v2.0 -Class BatteryController{ +#Include + +Class BatteryController extends Action{ currentBatterySaverThreshold := 50 defaultBatterySaverThreshold := 50 diff --git a/src/Main/Lib/Actions/Clock/CountdownDisplay.ahk b/src/Main/Lib/Actions/Clock/CountdownDisplay.ahk index 1dca2e9..aeede32 100644 --- a/src/Main/Lib/Actions/Clock/CountdownDisplay.ahk +++ b/src/Main/Lib/Actions/Clock/CountdownDisplay.ahk @@ -3,7 +3,10 @@ ; TODO: could create a clock gui class, which can create a gui for countdown or clock -Class CountdownDisplay{ +#Include + + +Class CountdownDisplay extends Action{ countdownStopped := false CountDown := "" @@ -25,15 +28,17 @@ Class CountdownDisplay{ this.GUICountdown.Add("Text", "w200 Center vCountdown", this.CountDown.getTimeAsString()) } - DestroyGui(){ - this.GUICountdown.Destroy() + Destroy(){ + try{ + this.GUICountdown.Destroy() + } } - ShowGui(){ + Show(){ this.GUICountdown.Show() } - HideGui(){ + Hide(){ this.GUICountdown.Hide() } diff --git a/src/Main/Lib/Actions/CommandPromptOpener.ahk b/src/Main/Lib/Actions/CommandPromptOpener.ahk index 8850005..0433364 100644 --- a/src/Main/Lib/Actions/CommandPromptOpener.ahk +++ b/src/Main/Lib/Actions/CommandPromptOpener.ahk @@ -1,8 +1,9 @@ #Requires AutoHotkey v2.0 #Include +#Include -Class CommandPromptOpener{ +Class CommandPromptOpener extends Action{ defaultPath := "" diff --git a/src/Main/Lib/Actions/IODevices/ComputerInputController.ahk b/src/Main/Lib/Actions/IODevices/ComputerInputController.ahk index 8a620e9..6f6b942 100644 --- a/src/Main/Lib/Actions/IODevices/ComputerInputController.ahk +++ b/src/Main/Lib/Actions/IODevices/ComputerInputController.ahk @@ -2,8 +2,9 @@ #Include ".\Keyboard.ahk" #Include ".\Mouse.ahk" +#Include -Class ComputerInputController{ +Class ComputerInputController extends Action{ MouseInput := "" KeyboardInput := "" diff --git a/src/Main/Lib/Actions/IODevices/DeviceManager.ahk b/src/Main/Lib/Actions/IODevices/DeviceManager.ahk index 311f59b..5c81535 100644 --- a/src/Main/Lib/Actions/IODevices/DeviceManager.ahk +++ b/src/Main/Lib/Actions/IODevices/DeviceManager.ahk @@ -5,8 +5,10 @@ ; TODO ini file should probably contain paths to the scripts which control the devices ; TODO maybe possible to create a class which can run powershell scripts, which can be created by the user (perhaps uploaded by the user) and which they have to add the path to in the ini file or something (dont have to have path, only name i guesss.) +#Include -Class DeviceManager{ + +Class DeviceManager extends Action{ bluetoothActionToToggle := "" touchPadActionToToggle := "" diff --git a/src/Main/Lib/Actions/IODevices/Keyboard.ahk b/src/Main/Lib/Actions/IODevices/Keyboard.ahk index 3df61d6..f814901 100644 --- a/src/Main/Lib/Actions/IODevices/Keyboard.ahk +++ b/src/Main/Lib/Actions/IODevices/Keyboard.ahk @@ -1,6 +1,8 @@ #Requires AutoHotkey v2.0 -class Keyboard{ +#Include + +class Keyboard extends Action{ sendInputRepeatedly := false diff --git a/src/Main/Lib/Actions/IODevices/Monitor.ahk b/src/Main/Lib/Actions/IODevices/Monitor.ahk index 79cd126..5d282ff 100644 --- a/src/Main/Lib/Actions/IODevices/Monitor.ahk +++ b/src/Main/Lib/Actions/IODevices/Monitor.ahk @@ -1,6 +1,8 @@ #Requires Autohotkey v2.0 -Class Monitor{ +#Include + +Class Monitor extends Action{ ; red ; green diff --git a/src/Main/Lib/Actions/IODevices/Mouse.ahk b/src/Main/Lib/Actions/IODevices/Mouse.ahk index 3e149ce..76e086e 100644 --- a/src/Main/Lib/Actions/IODevices/Mouse.ahk +++ b/src/Main/Lib/Actions/IODevices/Mouse.ahk @@ -2,7 +2,9 @@ #Include -Class Mouse{ +#Include + +Class Mouse extends Action{ autoClickerCPS := 10 autoClickerEnabled := false diff --git a/src/Main/Lib/Actions/KeysPressedGui.ahk b/src/Main/Lib/Actions/KeysPressedGui.ahk index ab4d183..305050f 100644 --- a/src/Main/Lib/Actions/KeysPressedGui.ahk +++ b/src/Main/Lib/Actions/KeysPressedGui.ahk @@ -2,8 +2,10 @@ #Include +#Include + ; TODO use MVC design pattern. -Class KeysPressedGui{ +Class KeysPressedGui extends Action{ GuiShowKeysPressed := "" showKeysPressedControl := "" @@ -36,10 +38,10 @@ Class KeysPressedGui{ ShowKeysPressed(){ this.CreateInputReader() - this.ShowGui() + this.Show() } - ShowGui(){ + Show(){ this.guiHidden := false this.GuiShowKeysPressed.Show() } @@ -48,15 +50,15 @@ Class KeysPressedGui{ this.DestroyInputReader() this.storedKeys := "" GuiSizeChanger.SetTextAndResize(this.showKeysPressedControl, this.storedKeys) - this.HideGui() + this.Hide() } - HideGui(){ + Hide(){ this.guiHidden := true this.GuiShowKeysPressed.Hide() } - DestroyGui(){ + Destroy(){ this.GuiShowKeysPressed.Destroy() } diff --git a/src/Main/Lib/LayerControlling/LayerController.ahk b/src/Main/Lib/Actions/LayerControlling/LayerController.ahk similarity index 86% rename from src/Main/Lib/LayerControlling/LayerController.ahk rename to src/Main/Lib/Actions/LayerControlling/LayerController.ahk index 3404db8..9882eb1 100644 --- a/src/Main/Lib/LayerControlling/LayerController.ahk +++ b/src/Main/Lib/Actions/LayerControlling/LayerController.ahk @@ -5,7 +5,9 @@ ; TODO: perhaps it should be called registry? ; TODO; instead of multiple guis, it would be possible to just change the color and have the same gui no change... -Class LayerController{ +#Include + +Class LayerController extends Action{ layers := [] activeLayer := 0 @@ -16,14 +18,18 @@ Class LayerController{ this.layers.InsertAt(layer, layerIndicatorInstance) } + destroyLayerIndicator(layer){ + this.layers[layer].Destroy() + } + showLayerIndicator(layer){ this.activeLayer := layer - this.layers[layer].showGui() + this.layers[layer].Show() this.hideInactiveLayers() } hideLayerIndicator(layer){ - this.layers[layer].hideGui() + this.layers[layer].Hide() } hideInactiveLayers(){ @@ -78,4 +84,10 @@ Class LayerController{ setActiveLayer(activeLayer){ this.activeLayer := activeLayer } + + Destroy(){ + loop this.layers.Length{ + this.destroyLayerIndicator(A_Index) + } + } } \ No newline at end of file diff --git a/src/Main/Lib/LayerControlling/LayerIndicator.ahk b/src/Main/Lib/Actions/LayerControlling/LayerIndicator.ahk similarity index 90% rename from src/Main/Lib/LayerControlling/LayerIndicator.ahk rename to src/Main/Lib/Actions/LayerControlling/LayerIndicator.ahk index c271a5f..33e79a3 100644 --- a/src/Main/Lib/LayerControlling/LayerIndicator.ahk +++ b/src/Main/Lib/Actions/LayerControlling/LayerIndicator.ahk @@ -1,6 +1,8 @@ #Requires Autohotkey v2.0 -Class LayerIndicator{ +#Include + +Class LayerIndicator extends Action{ indicatorColor := "" layer := 0 @@ -18,17 +20,17 @@ Class LayerIndicator{ this.layerIndicatorGui.BackColor := this.indicatorColor } - destroyGui(){ + Destroy(){ this.layerIndicatorGui.destroy() } - showGui(){ + Show(){ guiHeight := A_ScreenHeight-142 WinSetAlwaysOnTop 1, this.layerIndicatorGui this.layerIndicatorGui.show("x0 y" . guiHeight . " w50 h142 NoActivate") } - hideGui(){ + Hide(){ this.layerIndicatorGui.hide() } diff --git a/src/Main/Lib/Actions/Navigation/FileNavigation/FileExplorerNavigator.ahk b/src/Main/Lib/Actions/Navigation/FileNavigation/FileExplorerNavigator.ahk index fa64a49..0fb007c 100644 --- a/src/Main/Lib/Actions/Navigation/FileNavigation/FileExplorerNavigator.ahk +++ b/src/Main/Lib/Actions/Navigation/FileNavigation/FileExplorerNavigator.ahk @@ -1,6 +1,8 @@ #Requires AutoHotkey v2.0 -Class FileExplorerNavigator{ +#Include + +Class FileExplorerNavigator extends Action{ ; navigates to the specified folder diff --git a/src/Main/Lib/Actions/Navigation/WebNavigation/WebNavigator.ahk b/src/Main/Lib/Actions/Navigation/WebNavigation/WebNavigator.ahk index f713fc7..39e5007 100644 --- a/src/Main/Lib/Actions/Navigation/WebNavigation/WebNavigator.ahk +++ b/src/Main/Lib/Actions/Navigation/WebNavigation/WebNavigator.ahk @@ -2,7 +2,9 @@ #Include ".\Translator.ahk" #Include "..\..\IODevices\ComputerInputController.ahk" -Class WebNavigator{ +#Include + +Class WebNavigator extends Action{ chatGptLoadTime := 3000 diff --git a/src/Main/Lib/Actions/Privacy/ScreenPrivacyController.ahk b/src/Main/Lib/Actions/Privacy/ScreenPrivacyController.ahk index e158ee9..4a8c661 100644 --- a/src/Main/Lib/Actions/Privacy/ScreenPrivacyController.ahk +++ b/src/Main/Lib/Actions/Privacy/ScreenPrivacyController.ahk @@ -1,7 +1,10 @@ #Requires Autohotkey v2.0 #Include "..\Clock\CountdownDisplay.ahk" -Class ScreenPrivacyController{ + +#Include + +Class ScreenPrivacyController extends Action{ ; TODO, perhaps this could be combined with monitor.ahk, or something similar with a different name? GUIPrivacyBox := "" @@ -15,18 +18,18 @@ Class ScreenPrivacyController{ this.GUIPrivacyBox.BackColor := "Black" } - DestroyGui(){ + Destroy(){ this.GUIPrivacyBox.Destroy() this.GUICountdown.StopCountdown() - this.GUICountdown.DestroyGui() + this.GUICountdown.Destroy() } - HideGui(){ + Hide(){ this.GUIPrivacyBox.Hide() try{ this.GUICountdown.StopCountdown() - this.GUICountdown.DestroyGui() + this.GUICountdown.Destroy() } } @@ -43,14 +46,14 @@ Class ScreenPrivacyController{ ; this.GUICountdown.SetCountdown(this.minutes, this.seconds) this.GUICountdown.CreateGui() - this.GUICountdown.ShowGui() + this.GUICountdown.Show() this.GUICountdown.StartCountdown() } ; Hides the active window HideWindow(){ try{ this.GUICountdown.StopCountdown() - this.GUICountdown.DestroyGui() + this.GUICountdown.Destroy() } WinGetPos(&X, &Y, &Width, &Height, "A") @@ -62,7 +65,7 @@ Class ScreenPrivacyController{ HideTabs(){ try{ this.GUICountdown.StopCountdown() - this.GUICountdown.DestroyGui() + this.GUICountdown.Destroy() } ; TODO make this work for more browsers Title := WinGetTitle("A") diff --git a/src/Main/Lib/Actions/ProcessManager.ahk b/src/Main/Lib/Actions/ProcessManager.ahk index 606803e..2cc79e9 100644 --- a/src/Main/Lib/Actions/ProcessManager.ahk +++ b/src/Main/Lib/Actions/ProcessManager.ahk @@ -1,6 +1,8 @@ #Requires AutoHotkey v2.0 -Class ProcessManager{ +#Include + +Class ProcessManager extends Action{ CloseFocusedProcess(){ Send("!{f4}") diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsApp.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsApp.ahk index 7b478e2..a0f956a 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsApp.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsApp.ahk @@ -27,8 +27,8 @@ Class ExtraKeyboardsApp{ UserInterface := "" - __New(activeObjectsRegistry, keyboardLayersInfoRegister, mainScript, keyNames){ - this.Model := ExtraKeyboardsAppGuiModel(activeObjectsRegistry, keyboardLayersInfoRegister, keyNames) + __New(activeObjectsRegistry, keyboardLayersInfoRegister, mainScript){ + this.Model := ExtraKeyboardsAppGuiModel(activeObjectsRegistry, keyboardLayersInfoRegister) this.UserInterface := ExtraKeyboardsAppGuiView() this.Controller := ExtraKeyboardsAppGuiController(this.Model, this.UserInterface, mainScript) } diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk index 6794198..bc9e2da 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiController.ahk @@ -7,6 +7,8 @@ #Include "Main\Functionality\KeyboardEditing\HotKeyConfigurationController.ahk" #Include "Main\Functionality\KeyboardEditing\HotKeyConfigurationModel.ahk" +#Include + ; #Include Class ExtraKeyboardsAppGuiController{ @@ -20,8 +22,9 @@ Class ExtraKeyboardsAppGuiController{ this.MainScript := MainScript } - HandleProfileChangedEvent(){ + HandleProfileChangedEvent(newProfileName){ ; TODO this should probably be changed? it is sort of heavy to basically restart the entire program when changing profiles. + FilePaths.SetCurrentProfile(newProfileName) this.mainScript.Start() this.view.Destroy() } @@ -33,6 +36,7 @@ Class ExtraKeyboardsAppGuiController{ } ; TODO make sure user cant create multiple popups? + ; TODO change name for this... EditHotkey(listView, indexOfKeyToEdit){ layerInformation := this.GetCurrentLayerInfo() @@ -40,7 +44,6 @@ Class ExtraKeyboardsAppGuiController{ if (Type(layerInformation) == "HotkeysRegistry"){ hotkeyInformation := HotkeyInfo() - ; hotkeyInformation if (indexOfKeyToEdit = 0){ ; this.CreatePopupForHotkeys(hotkeyInformation) } @@ -65,7 +68,7 @@ Class ExtraKeyboardsAppGuiController{ ; TODO move to view? CreatePopupForHotkeys(hotkeyInformation){ - popupForConfiguringHotkeyModel := HotKeyConfigurationModel(this.GetActiveObjectsRegistry(), this.GetKeyNames(), hotkeyInformation) + popupForConfiguringHotkeyModel := HotKeyConfigurationModel(this.GetActiveObjectsRegistry(), hotkeyInformation) popupForConfiguringHotkey := HotKeyConfigurationView("+Resize +MinSize300x280", this.GetHwnd()) popupForConfiguringHotkeyController := HotKeyConfigurationController(popupForConfiguringHotkeyModel, popupForConfiguringHotkey) popupForConfiguringHotkey.CreateMain(popupForConfiguringHotkeyController) @@ -73,7 +76,7 @@ Class ExtraKeyboardsAppGuiController{ popupForConfiguringHotkey.getHwnd() - popupForConfiguringHotkeyController.subscribeToSaveEvent(ObjBindMethod(this, "changeHotkeys")) + popupForConfiguringHotkeyController.subscribeToSaveEvent(ObjBindMethod(this, "AddOrChangeHotkey")) popupForConfiguringHotkeyController.subscribeToDeleteEvent(ObjBindMethod(this, "deleteHotkey")) } @@ -96,6 +99,8 @@ Class ExtraKeyboardsAppGuiController{ WinWaitClose("Settings Editor Dialog" , , 1000) + this.MainScript.RunLogicalStartup() + this.view.UpdateSettingsForActions() } } @@ -104,40 +109,45 @@ Class ExtraKeyboardsAppGuiController{ this.model.ChangeFunctionSetting(setting, currentFunctionSettings) } - ChangeHotkeys(hotkeyInformation, originalHotkeyKey){ + AddOrChangeHotkey(hotkeyInformation, originalHotkeyKey){ newHotkeyKey := hotkeyInformation.getHotkeyName() - ; If it does not exist, add it ; TODO this is bad, how the heck does EKAPGC know the default values is NONE? + ; Add if (originalHotkeyKey = ""){ - try{ - hotkeyInformation.changeHotkey(newHotkeyKey) - this.model.AddHotkey(hotkeyInformation) + if (hotkeyInformation.actionIsSet() AND hotkeyInformation.getHotkeyName() != ""){ + try{ + this.model.AddHotkey(hotkeyInformation) + } + catch Error as e{ + msgbox("Could not add hotkey. " . e.Message) + } } - catch Error as e{ - msgbox("Could not add hotkey. " . e.Message) + else { + msgbox("Please select a hotkey and an action") } - } + } ; Change else{ try{ this.model.ChangeHotkey(originalHotkeyKey, newHotkeyKey, hotkeyInformation) - msgbox("Changed hotkey") } catch Error as e{ msgbox("Could not modify hotkey. " . e.Message) } } - this.MainScript.RunLogicalStartup() } DeleteHotkey(hotkeyKey){ try{ + + this.MainScript.SetHotkeysForAllLayers(false) this.model.DeleteHotkey(hotkeyKey) msgbox("Deleted hotkey") } catch Error as e{ + this.MainScript.SetHotkeysForAllLayers(false) msgbox("Could not delete hotkey. " . e.Message) } this.MainScript.RunLogicalStartup() @@ -171,10 +181,6 @@ Class ExtraKeyboardsAppGuiController{ return this.model.GetActiveObjectsRegistry() } - GetKeyNames(){ - return this.model.GetKeyNames() - } - GetActionNames(){ return this.model.GetActionNames() } diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiModel.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiModel.ahk index 8217d66..653d6cf 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiModel.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiModel.ahk @@ -7,7 +7,6 @@ Class ExtraKeyboardsAppGuiModel{ - keyNames := "" currentLayer := "" currentFunction := "" activeObjectsRegistry := "" @@ -17,15 +16,13 @@ Class ExtraKeyboardsAppGuiModel{ actionSettings := "" - __New(activeObjectsRegistry, keyboardLayersInfoRegister, keyNames){ + __New(activeObjectsRegistry, keyboardLayersInfoRegister){ ReaderForActionSettings := ActionSettingsReader(FilePaths.GetPathToCurrentSettings()) this.actionSettings := ReaderForActionSettings.ReadSettings() - this.keyNames := keyNames this.activeObjectsRegistry := activeObjectsRegistry this.keyboardLayerIdentifiers := keyboardLayersInfoRegister.getLayerIdentifiers() this.keyboardLayersInfoRegister := keyboardLayersInfoRegister - } ChangeHotkey(originalHotkey, newHotkey, newAction){ @@ -36,14 +33,13 @@ Class ExtraKeyboardsAppGuiModel{ } AddHotkey(newAction){ - this.keyboardLayersInfoRegister.AddHotkey(this.GetCurrentLayer(), newAction) - ToJsonFileWriter.WriteKeyboardLayersInfoRegisterToJsonFile(this.keyboardLayersInfoRegister, this.GetPathToCurrentProfile() . "\Keyboards.json") } DeleteHotkey(hotkeyKey){ this.keyboardLayersInfoRegister.DeleteHotkey(this.GetCurrentLayer(), hotkeyKey) + ToJsonFileWriter.WriteKeyboardLayersInfoRegisterToJsonFile(this.keyboardLayersInfoRegister, this.GetPathToCurrentProfile() . "\Keyboards.json") } @@ -103,13 +99,8 @@ Class ExtraKeyboardsAppGuiModel{ return this.activeObjectsRegistry } - GetKeyNames(){ - return this.keyNames - } - ChangeFunctionSetting(setting, actionName){ this.actionSettings.ChangeActionSetting(actionName, this.GetPathToCurrentSettings(), setting) - } GetPathToCurrentSettings(){ @@ -121,7 +112,16 @@ Class ExtraKeyboardsAppGuiModel{ } GetHotkeyInfoForCurrentLayer(hotkeyKey){ - return this.keyboardLayersInfoRegister.GetHotkeyInfoForLayer(this.GetCurrentLayer(), hotkeyKey) + hotkeyInformation := this.keyboardLayersInfoRegister.GetHotkeyInfoForLayer(this.GetCurrentLayer(), hotkeyKey) + hotkeyToReturn := HotkeyInfo(hotkeyInformation.getHotkeyName()) + + if (hotkeyInformation.hotkeyIsObject()){ + hotkeyToReturn.setInfoForSpecialHotKey(hotkeyInformation.GetobjectName(), hotkeyInformation.GetMethodName(), hotkeyInformation.getparameters()) + } + else{ + hotkeyToReturn.setInfoForNormalHotKey(hotkeyInformation.getNewHotkeyName(), hotkeyInformation.getNewHotkeyModifiers()) + } + return hotkeyToReturn } ; GetFriendlyHotkeysForLayer(layerIdentifier){ diff --git a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk index b91aa8e..4be7d89 100644 --- a/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk +++ b/src/Main/Lib/UserInterface/ExtraKeyboardsAppGuiView.ahk @@ -1,6 +1,6 @@ #Requires AutoHotkey v2.0 -#Include + #Include #Include #Include @@ -33,11 +33,10 @@ Class ExtraKeyboardsAppGuiView extends DomainSpecificGui{ } CreateProfileEditor(){ - profileModel := ProfileRegionModel(this) profileView := ProfileRegionView() profileView.SubscribeToProfileChangedEvent(ObjBindMethod(this.controller, "HandleProfileChangedEvent")) - profileController := ProfileRegionController(profileModel, profileView) - profileController.CreateView() + profileController := ProfileRegionController(profileView) + profileController.CreateView(this) } CreateTabs(){ diff --git a/src/Main/Lib/UserInterface/Main/Functionality/ActionSettings/SettingsEditorDialog.ahk b/src/Main/Lib/UserInterface/Main/Functionality/ActionSettings/SettingsEditorDialog.ahk index 56a921f..fcc04be 100644 --- a/src/Main/Lib/UserInterface/Main/Functionality/ActionSettings/SettingsEditorDialog.ahk +++ b/src/Main/Lib/UserInterface/Main/Functionality/ActionSettings/SettingsEditorDialog.ahk @@ -12,11 +12,7 @@ class SettingsEditorDialog extends DomainSpecificGui{ __New(ownerHwnd := ""){ this.saveEventSubscribers := Array() Super.__New("+Resize", "Settings Editor Dialog") - - if (ownerHwnd != ""){ - this.SetOwner(ownerHwnd) - } - + this.SetOwner(ownerHwnd) } CreateControls(setting){ diff --git a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationController.ahk b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationController.ahk index 9dcbb28..5528621 100644 --- a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationController.ahk +++ b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationController.ahk @@ -12,6 +12,9 @@ class HotKeyConfigurationController{ model := "" view := "" + + + saveEventSubscribers := Array() deleteEventSubscribers := Array() @@ -20,13 +23,12 @@ class HotKeyConfigurationController{ __New(model, view){ this.model := model this.view := view - this.hotkeyCrafterController_ := HotkeyCrafterController(this.GetAvailableKeyNames(), this.GetActiveObjectsRegistry()) + this.hotkeyCrafterController_ := HotkeyCrafterController(this.GetActiveObjectsRegistry()) } changeHotkey(whatToChange){ this.view.hide() - availableKeyNames := this.model.GetAvailableKeyNames() hotkeyInfo := this.model.GetHotkeyInfo() if (hotkeyInfo != ""){ originalHotkey := hotkeyInfo.getFriendlyHotkeyName() @@ -39,11 +41,10 @@ class HotKeyConfigurationController{ whatToChange := StrLower(whatToChange) if (whatToChange == "hotkey"){ - this.changeOriginalHotkey(availableKeyNames, originalHotkey) + this.changeOriginalHotkey(originalHotkey) } else if (whatToChange == "action"){ - activeObjectsRegistry := this.model.GetActiveObjectsRegistry() - this.changeOriginalAction(activeObjectsRegistry, availableKeyNames, action) + this.changeOriginalAction(action) } WinWait("HotkeyCrafterGui") @@ -52,11 +53,10 @@ class HotKeyConfigurationController{ } - changeOriginalHotkey(availableKeyNames, originalHotkey){ - + changeOriginalHotkey(originalHotkey){ - hotkeyCrafterView_ := HotkeyCrafterView(this.hotkeyCrafterController_) + hotkeyCrafterView_.create(originalHotkey) hotkeyCrafterView_.CreateButtons() hotkeyCrafterView_.SetInformativeTopText("Original Hotkey: " . originalHotkey) @@ -65,7 +65,8 @@ class HotKeyConfigurationController{ hotkeyCrafterView_.Show() } - changeOriginalAction(activeObjectsRegistry, availableKeyNames, action){ + ; TODO remove first parameter + changeOriginalAction(action){ ActionCrafterView_ := ActionCrafterView(this.hotkeyCrafterController_) this.hotkeyCrafterController_.AddActionCrafterView(ActionCrafterView_) @@ -104,22 +105,23 @@ class HotKeyConfigurationController{ saveButtonClickedForHotkeyChangeEvent(newHotkey){ newHotkeyKey := newHotkey.getNewHotkeyModifiers() newHotkeyKey .= newHotkey.getNewHotkeyName() + + ; this.hotkeyCrafterController_.ChangeHotkey(this.model.GetHotkeyInfo(), newHotkey) this.model.SetHotkeyKey(newHotkeyKey) this.view.updateHotkeyText() this.view.Show() - } saveButtonClickedForActionChangeEvent(newAction){ - if (newAction.getMethodName() != ""){ - this.model.SetHotkeyAction(newAction) - this.view.updateActionText() - } - else{ - this.model.SetHotkeyAction(newAction) - this.view.updateActionText() - } + this.model.SetHotkeyAction(newAction) + this.view.updateActionText() + ; if (newAction.getMethodName() != ""){ + ; } + ; else{ + ; this.model.SetHotkeyAction(newAction) + ; this.view.updateActionText() + ; } this.view.Show() } @@ -128,10 +130,6 @@ class HotKeyConfigurationController{ return this.model } - GetAvailableKeyNames(){ - return this.model.GetAvailableKeyNames() - } - GetActiveObjectsRegistry(){ return this.model.GetActiveObjectsRegistry() } diff --git a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationModel.ahk b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationModel.ahk index bb105b1..6ff6c3a 100644 --- a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationModel.ahk +++ b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationModel.ahk @@ -8,15 +8,13 @@ class HotKeyConfigurationModel{ activeObjectsRegistry := "" - availableKeyNames := Array() hotkeyInformation := "" originalHotkeyKey := "" originalActionFriendly := "" - __New(activeObjectsRegistry, availableKeyNames, hotkeyInformation){ + __New(activeObjectsRegistry, hotkeyInformation){ this.activeObjectsRegistry := activeObjectsRegistry - this.availableKeyNames := availableKeyNames this.hotkeyInformation := hotkeyInformation this.originalHotkeyKey := this.hotkeyInformation.getHotkeyName() @@ -27,10 +25,8 @@ class HotKeyConfigurationModel{ return this.activeObjectsRegistry } - GetAvailableKeyNames(){ - return this.availableKeyNames - } + ; TODO dont do this here... do it after save+done is clicked...!! SetHotkeyKey(newHotkey){ this.hotkeyInformation.changeHotkey(newHotkey) } diff --git a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationView.ahk b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationView.ahk index dbe730d..65a5813 100644 --- a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationView.ahk +++ b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/HotKeyConfigurationView.ahk @@ -14,10 +14,7 @@ class HotKeyConfigurationView extends DomainSpecificGui{ __New(settings, ownerHwnd := ""){ super.__New(settings, "Hotkey Configuration") - - if (ownerHwnd != ""){ - this.setOwner(ownerHwnd) - } + this.setOwner(ownerHwnd) } CreateMain(controller){ diff --git a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/KeyChanging/HotkeyChanging/HotkeyCrafterView.ahk b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/KeyChanging/HotkeyChanging/HotkeyCrafterView.ahk index d1d4e19..dc983a0 100644 --- a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/KeyChanging/HotkeyChanging/HotkeyCrafterView.ahk +++ b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/KeyChanging/HotkeyChanging/HotkeyCrafterView.ahk @@ -31,7 +31,7 @@ class HotkeyCrafterView extends DomainSpecificGui{ this.SimpleHotkeyCrafter := SimpleHotkeyCraftingControl(this, "w300 h50", HotkeyFormatConverter.convertFromFriendlyName(originalHotkey, " + ")) this.SimpleHotkeyCrafter.SubscribeToHotkeySelectedEvent(ObjBindMethod(this, "updateSaveButtonStatus")) - this.advancedHotkeyCrafter := AdvancedHotkeyCraftingControl(this, "w370 h200 xp yp", this.controller.getAvailableKeyNames()) + this.advancedHotkeyCrafter := AdvancedHotkeyCraftingControl(this, "w370 h200 xp yp", this.controller.GetAvailableKeyNames()) this.advancedHotkeyCrafter.SubscribeToHotkeySelectedEvent(ObjBindMethod(this, "updateSaveButtonStatus")) this.advancedHotkeyCrafter.hide() diff --git a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/KeyChanging/HotkeyCrafterController.ahk b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/KeyChanging/HotkeyCrafterController.ahk index 475630b..e705b6d 100644 --- a/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/KeyChanging/HotkeyCrafterController.ahk +++ b/src/Main/Lib/UserInterface/Main/Functionality/KeyboardEditing/KeyChanging/HotkeyCrafterController.ahk @@ -1,10 +1,11 @@ #Requires AutoHotkey v2.0 +#Include #Include + class HotkeyCrafterController{ - availableKeyNames := "" activeObjectsRegistry := "" actionCrafterView := "" @@ -12,9 +13,8 @@ class HotkeyCrafterController{ currentAction := "" - __New(availableKeyNames, activeObjectsRegistry){ + __New(activeObjectsRegistry){ this.isCraftingSpecialAction_ := true - this.availableKeyNames := availableKeyNames this.activeObjectsRegistry := activeObjectsRegistry this.currentAction := "" } @@ -24,7 +24,10 @@ class HotkeyCrafterController{ } GetAvailableKeyNames(){ - return this.availableKeyNames + keyNamesFileObjReader := KeyNamesReader() + fileObjectOfKeyNames := FileOpen(FilePaths.GetPathToKeyNames(), "rw" , "UTF-8") + availableKeyNames := keyNamesFileObjReader.ReadKeyNamesFromTextFileObject(fileObjectOfKeyNames).GetKeyNames() + return availableKeyNames } GetActiveObjectsRegistry(){ diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/AddProfiles/AddProfileDialog.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/AddProfiles/AddProfileDialog.ahk new file mode 100644 index 0000000..3300f3b --- /dev/null +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/AddProfiles/AddProfileDialog.ahk @@ -0,0 +1,90 @@ +#Requires AutoHotkey v2.0 + +#Include + +class AddProfileDialog extends DomainSpecificGui{ + + addProfileButton := "" + profileAddedSubscribers := "" + + customProfilesDropDownMenu := "" + profileNameField := "" + + __New(ownerHwnd := ""){ + this.profileAddedSubscribers := Array() + Super.__New("+Resize", "Add Profile") + this.SetFont("s10") + this.SetOwner(ownerHwnd) + } + + CreateView(profiles){ + + this.Add("Text", "w150" , "Selected Profile: ") + + this.customProfilesDropDownMenu := this.Add("DropDownList", "xp yp+25 Choose1", profiles) + + this.Add("Text", "w150 ym", "Name of profile to add:") + this.profileNameField := this.Add("Edit", "r1 xp yp+25", "") + this.profileNameField.OnEvent("Change", (*) => this.HandleInputFieldChange(this.profileNameField.Text)) + + + this.addProfileButton := this.Add("Button", "Default w80 xp yp+50", "Add profile") + this.addProfileButton.OnEvent("Click", (*) => this.NotifyListenersProfileAdded()) + this.DisableAddProfileButton() + + cancelButton := this.Add("Button", "Default w80 yp ", "Cancel") + cancelButton.OnEvent("Click", (*) => this.Destroy()) + } + + SubscribeToProfileAddedEvent(event){ + this.profileAddedSubscribers.Push(event) + } + + NotifyListenersProfileAdded(){ + Loop this.profileAddedSubscribers.Length{ + this.profileAddedSubscribers[A_Index](this.customProfilesDropDownMenu.Text, this.profileNameField.Text) + } + this.Destroy() + } + + ; CreateView(controller, profiles){ + + ; this.Add("Text", "w150" , "Selected Profile: ") + + ; customProfilesDropDownMenu := this.Add("DropDownList", "yp Choose1", profiles) + + ; this.Add("Text", "w150 xm yp+50", "Name of profile to add:") + ; profileNameField := this.Add("Edit", "r1 yp", "") + ; profileNameField.OnEvent("Change", (*) => this.HandleInputFieldChange(profileNameField.Text)) + + + ; this.addProfileButton := this.Add("Button", "Default w80 xp yp+50", "Add profile") + ; this.addProfileButton.OnEvent("Click", (*) => controller.HandleAddProfileConfirmedEvent(customProfilesDropDownMenu.Text, profileNameField.Text)) + ; this.DisableAddProfileButton() + + ; cancelButton := this.Add("Button", "Default w80 yp ", "Cancel") + ; cancelButton.OnEvent("Click", (*) => this.Destroy()) + ; } + + CreateSelectedProfileRegion(){ + + } + + HandleInputFieldChange(profileNameFieldText){ + if (profileNameFieldText != ""){ + this.EnableAddProfileButton() + } else { + this.DisableAddProfileButton() + } + } + + DisableAddProfileButton(){ + this.addProfileButton.Opt("+Disabled") + } + + EnableAddProfileButton(){ + this.addProfileButton.Opt("-Disabled") + } + + +} \ No newline at end of file diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/AddProfiles/AddProfilesView.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/AddProfiles/AddProfilesView.ahk deleted file mode 100644 index 0961b67..0000000 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/AddProfiles/AddProfilesView.ahk +++ /dev/null @@ -1,34 +0,0 @@ -#Requires AutoHotkey v2.0 - -class AddProfilesView{ - - controller := "" - addProfileGui := "" - - CreateView(controller, model){ - - this.controller := controller - this.model := model - - this.addProfileGui := Gui("+Resize +MinSize320x240") - - this.addProfileGui.Add("Text", , "Selected Profile:") - customProfilesDropDownMenu := this.addProfileGui.Add("DropDownList", "ym+1 Choose1", this.model.getPresetProfiles()) - - - this.addProfileGui.Add("Text", "ym+1", "Name of profile to add:") - profileNameField := this.addProfileGui.Add("Edit", "r1 ym+1", "") - addProfileButton := this.addProfileGui.Add("Button", "Default w80 ym+1", "Add profile") - - addProfileButton.OnEvent("Click", (*) => this.controller.HandleAddProfileConfirmedEvent(customProfilesDropDownMenu.Text, profileNameField.Text)) - - cancelButton := this.addProfileGui.Add("Button", "Default w80 ym+1", "Cancel") - cancelButton.OnEvent("Click", (*) => this.addProfileGui.Destroy()) - - this.addProfileGui.Show() - } - - Destroy(){ - this.addProfileGui.Destroy() - } -} \ No newline at end of file diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/EditProfiles/EditorModel.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/EditProfiles/EditorModel.ahk deleted file mode 100644 index b281844..0000000 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/EditProfiles/EditorModel.ahk +++ /dev/null @@ -1,47 +0,0 @@ -#Requires AutoHotkey v2.0 - -; TODO inheritance with ProfileRegionModel perhaps -class EditorModel{ - currentProfile := "" - profiles := [] - - __New(profiles, currentProfile){ - this.profiles := profiles - this.currentProfile := currentProfile - } - - setProfiles(profiles){ - this.profiles := profiles - if (this.profiles.Length != 0){ - try{ - this.currentProfile := profiles[this.getCurrentProfileIndex()] - } - catch{ - this.currentProfile := profiles[1] - } - } - } - - getProfiles(){ - return this.profiles - } - - getCurrentProfile(){ - return this.currentProfile - } - - getCurrentProfileIndex(){ - currentProfileIndex := -1 - Loop this.profiles.Length{ - if (this.profiles[A_Index] = this.currentProfile){ - currentProfileIndex := A_Index - } - } - return currentProfileIndex - } - - SetCurrentProfile(profileName){ - this.currentProfile := profileName - - } -} \ No newline at end of file diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/EditProfiles/EditorView.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/EditProfiles/EditorView.ahk index 1a1e65c..1578a46 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/EditProfiles/EditorView.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/EditProfiles/EditorView.ahk @@ -1,52 +1,54 @@ #Requires AutoHotkey v2.0 -class EditorView{ +#Include - controller := "" - model := "" - editProfilesGui := "" +class EditorView extends DomainSpecificGui{ + + controller := "" profilesToEditDropDownMenu := "" - CreateView(controller, model){ + __New(ownerHwnd := ""){ + Super.__New("+Resize +MinSize320x240", "Profiles Editor") + this.SetOwner(ownerHwnd) + } + + CreateView(controller){ this.controller := controller - this.model := model - this.editProfilesGui := Gui("+Resize +MinSize320x240") - this.editProfilesGui.Add("Text", , "Selected Profile:") + this.Add("Text", , "Selected Profile:") - this.profilesToEditDropDownMenu := this.editProfilesGui.Add("DropDownList", "ym Choose" . model.GetCurrentProfileIndex(), model.GetProfiles()) - this.profilesToEditDropDownMenu.OnEvent("Change", (*) => ObjBindMethod(model, "SetCurrentProfile", this.profilesToEditDropDownMenu.Text)()) + this.profilesToEditDropDownMenu := this.Add("DropDownList", "ym Choose" . controller.GetCurrentProfileIndex(), controller.GetProfiles()) - renameProfileButton := this.editProfilesGui.Add("Button", "Default w80 xm+1", "Change profile name") - renameProfileButton.OnEvent("Click", (*) => ObjBindMethod(this.controller, "HandleRenameProfileButtonClickEvent")()) - - deleteProfileButton := this.editProfilesGui.Add("Button", "Default w80 xm+1", "Delete profile") - deleteProfileButton.OnEvent("Click", (*) => ObjBindMethod(this.controller, "HandleDeleteProfileButtonClickEvent")()) + renameProfileButton := this.Add("Button", "Default w80 xm+1", "Change profile name") + renameProfileButton.OnEvent("Click", (*) => this.CreateRenameProfileInputBox()) - this.editProfilesGui.Show() + deleteProfileButton := this.Add("Button", "Default w80 xm+1", "Delete profile") + deleteProfileButton.OnEvent("Click", (*) => this.CreateDeleteProfileInputBox()) + this.Show() } + ; TODO pretty identical to createdeleteprofielinputbox CreateRenameProfileInputBox(){ - inputPrompt := InputBox("Please write the new name for the profile! `n Original profile name: " . this.model.getCurrentProfile(), "Edit object value",, this.model.getCurrentProfile()) - this.controller.HandleRenameProfile(this.model.getCurrentProfile(), inputPrompt) + profileToRename := this.profilesToEditDropDownMenu.Text + inputPrompt := InputBox("Please write the new name for the profile! `n Original profile name: " . profileToRename, "Change name of profile",, profileToRename) + this.controller.HandleRenameProfile(profileToRename, inputPrompt) } CreateDeleteProfileInputBox(){ - inputPrompt := InputBox("Are you sure you want to delete the profile named '" . this.model.getCurrentProfile() . "'? Deleted profiles cannot be resuscitated. Type yes to confirm", "Edit object value",, this.model.getCurrentProfile()) - this.controller.HandleDeleteProfile(inputPrompt) + profileToDelete := this.profilesToEditDropDownMenu.Text + inputPrompt := InputBox("Are you sure you want to delete the profile named '" . profileToDelete . "'? Deleted profiles cannot be resuscitated. Type yes to confirm", "Delete profile",, profileToDelete) + this.controller.HandleDeleteProfile(profileToDelete, inputPrompt) } UpdateProfilesDropDownMenu(){ - profiles := this.model.getProfiles() - currentProfileIndex := this.model.getCurrentProfileIndex() + profiles := this.controller.getProfiles() + currentProfileIndex := this.controller.getCurrentProfileIndex() this.profilesToEditDropDownMenu.Delete() this.profilesToEditDropDownMenu.Add(profiles) try{ this.profilesToEditDropDownMenu.Value := currentProfileIndex } - } - } \ No newline at end of file diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk index 02c56a9..36df0ac 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionController.ahk @@ -1,109 +1,108 @@ #Requires AutoHotkey v2.0 #Include ".\EditProfiles\EditorView.ahk" -#Include ".\EditProfiles\EditorModel.ahk" -#Include ".\AddProfiles\AddProfilesView.ahk" +#Include ".\AddProfiles\AddProfileDialog.ahk" -class ProfileRegionController{ - - ; 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 := "" - ; A constant which is the path to the preset profiles - - currentProfile := "" - currentProfileIndex := "" +#Include +#Include - ; Gui part - profilesDropDownMenu := "" +class ProfileRegionController{ - model := "" view := "" - callback := "" - editView := "" - editModel := "" addprofileView := "" - addprofileModel := "" - __New(model, view){ - this.model := model + ; 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 - } - CreateView(){ - guiObject := this.model.getGuiObject() - this.view.CreateView(guiObject, this) - } + this.ExistingProfilesManager := FolderManager() + this.PresetProfilesManager := FolderManager() - GetProfiles(){ - return this.model.getProfiles() - } + this.PresetProfilesManager.addSubFoldersToRegistryFromFolder(FilePaths.GetPathToPresetProfiles()) + this.PresetProfilesManager.addFolderToRegistry("EmptyProfile", FilePaths.GetPathToEmptyProfile()) + this.ExistingProfilesManager.addSubFoldersToRegistryFromFolder(FilePaths.GetPathToProfiles()) - GetCurrentProfileIndex(){ - return this.model.getCurrentProfileIndex() } - GetCurrentProfile(){ - return this.model.getCurrentProfile() + CreateView(guiObject){ + this.view.CreateView(guiObject, this) } - HandleProfileChangedEvent(dropDownList, *){ - profileSelected := dropDownList.Text - - this.model.setCurrentProfile(profileSelected) + GetProfiles(){ + return this.ExistingProfilesManager.getFolderNames() + } + + getPresetProfiles(){ + return this.PresetProfilesManager.getFolderNames() } - HandleEditProfilesEvent(*){ - this.CreateEditorView() + getCurrentProfileIndex(){ + currentProfileIndex := -1 + profiles := this.getProfiles() + Loop profiles.Length{ + + if (profiles[A_Index] = FilePaths.GetCurrentProfile()){ + currentProfileIndex := A_Index + } + } + return currentProfileIndex } - CreateEditorView(){ - this.editModel := EditorModel(this.getProfiles(), this.getCurrentProfile()) - this.editView := EditorView() - this.editView.CreateView(this, this.editModel) + GetCurrentProfile(){ + return FilePaths.GetCurrentProfile() } - HandleRenameProfileButtonClickEvent(){ - this.editView.CreateRenameProfileInputBox() + doOpenEditProfileView(){ + this.editView := EditorView(this.GetHwnd()) + this.editView.CreateView(this) } HandleRenameProfile(profileToRename, inputPrompt){ - if inputPrompt.Result = "Cancel"{ + newProfileName := inputPrompt.Value + inputPromptResult := inputPrompt.Result + + if (inputPromptResult = "Cancel"){ msgbox("Cancelled renaming profile") ; Do nothing } - else if(inputPrompt.Value = ""){ + else if(newProfileName = ""){ msgbox("No new name for profile given, cancelling") ; Do Nothing } else{ - if(this.model.renameProfile(profileToRename, inputPrompt.Value)){ - this.editModel.SetProfiles(this.model.getProfiles()) + + if(this.ExistingProfilesManager.RenameFolder(profileToRename, newProfileName )){ + FilePaths.SetCurrentProfile(newProfileName) this.view.UpdateProfilesDropDownMenu() this.editView.UpdateProfilesDropDownMenu() - msgbox("Successfully renamed profile to " . inputPrompt.Value) + msgbox("Successfully renamed profile to " . newProfileName) + } + else{ + msgbox("failed to change profile name, perhaps name already exists or illegal characters were used.") } } } - HandleDeleteProfileButtonClickEvent(){ - this.editView.CreateDeleteProfileInputBox() - } + HandleDeleteProfile(profileToDelete, inputPrompt){ + inputPromptResult := inputPrompt.Result + - HandleDeleteProfile(inputPrompt){ - if inputPrompt.Result = "Cancel"{ + if (inputPromptResult = "Cancel"){ msgbox("Cancelled deleting profile") ; Do nothing } else if (StrLower(inputPrompt.Value) = "yes"){ - profileToDelete := this.editModel.getCurrentProfile() - if (this.model.deleteProfile(profileToDelete)){ - this.editModel.SetProfiles(this.model.getProfiles()) + + if (this.ExistingProfilesManager.DeleteFolder(profileToDelete)){ this.view.UpdateProfilesDropDownMenu() this.editView.UpdateProfilesDropDownMenu() msgbox("Successfully deleted profile " . profileToDelete) @@ -117,19 +116,198 @@ class ProfileRegionController{ } } - HandleAddProfileEvent(){ - this.addprofileView := AddProfilesView() - this.addprofileView.CreateView(this, this.model) + doOpenAddProfileDialog(){ + this.addprofileView := AddProfileDialog(this.GetHwnd()) + this.addprofileView.CreateView(this.GetPresetProfiles()) + this.addProfileView.SubscribeToProfileAddedEvent(ObjBindMethod(this, "HandleAddProfileConfirmedEvent")) + this.addprofileView.Show() } HandleAddProfileConfirmedEvent(profileToAdd, profileName){ - if (this.model.addProfile(profileToAdd, profileName)){ - this.view.UpdateProfilesDropDownMenu() - this.addprofileView.Destroy() - msgbox("Successfully added profile " . profileName) + if (this.ExistingProfilesManager.hasFolder(profileName)){ + msgbox("Failed to add profile. A profile with the given name already exists") } else{ - 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, 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") + } } } -} \ No newline at end of file + + UpdateProfileDropDownMenu(){ + this.view.Delete() + this.view.Add(this.ExistingProfilesManager.getFolderNames()) + this.view.Choose(this.currentProfile) + } + + GetHwnd(){ + return this.view.GetHwnd() + } +} + + + +; ; 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 := "" +; ; A constant which is the path to the preset profiles + +; ; TODO dont need these +; PATH_TO_EMPTY_PROFILE := "" +; PATH_TO_PRESET_PROFILES := "" +; PATH_TO_EXISTING_PROFILES := "" +; PATH_TO_META_FILE := "" +; currentProfile := "" +; ; Gui part +; profilesDropDownMenu := "" + +; profiles := "" + +; guiObject := "" + + +; __New(guiObject){ + +; this.guiObject := guiObject +; this.PATH_TO_META_FILE := FilePaths.GetPathToMetaFile() +; this.PATH_TO_EXISTING_PROFILES := FilePaths.GetPathToProfiles() +; this.PATH_TO_EMPTY_PROFILE := FilePaths.GetPathToEmptyProfile() +; this.PATH_TO_PRESET_PROFILES := FilePaths.GetPathToPresetProfiles() + + +; this.ExistingProfilesManager := FolderManager() +; this.PresetProfilesManager := FolderManager() + +; this.PresetProfilesManager.addSubFoldersToRegistryFromFolder(this.PATH_TO_PRESET_PROFILES) +; this.PresetProfilesManager.addFolderToRegistry("EmptyProfile", this.PATH_TO_EMPTY_PROFILE) +; this.ExistingProfilesManager.addSubFoldersToRegistryFromFolder(this.PATH_TO_EXISTING_PROFILES) + +; this.currentProfile := iniRead(this.PATH_TO_META_FILE, "General", "activeUserProfile") + +; this.profiles := this.ExistingProfilesManager.getFolderNames() + + +; } + +; updateProfiles(){ +; this.profiles := this.ExistingProfilesManager.getFolderNames() +; } + +; getGuiObject(){ +; return this.guiObject +; } + +; getProfiles(){ +; return this.profiles +; } + + +; getCurrentProfileIndex(){ +; currentProfileIndex := -1 +; Loop this.profiles.Length{ +; if (this.profiles[A_Index] = FilePaths.GetCurrentProfile()){ +; currentProfileIndex := A_Index +; } +; } +; return currentProfileIndex +; } + +; renameProfile(profileName, newProfileName){ +; renamedSuccesfully := false + +; if (this.ExistingProfilesManager.RenameFolder(profileName, newProfileName)){ +; this.updateProfiles() +; if (profileName = this.currentProfile){ +; this.setCurrentProfile(newProfileName) +; } + +; renamedSuccesfully := true +; } +; else{ +; msgbox("failed to change profile name, perhaps name already exists or illegal characters were used.") +; renamedSuccesfully := false +; } +; return renamedSuccesfully +; } + +; DeleteProfile(profileToDelete){ + +; deletedProfile := false + +; if (this.ExistingProfilesManager.DeleteFolder(profileToDelete)){ +; ; Deleted profile succesfully +; this.updateProfiles() +; if (this.profiles.Length != 0){ +; if (profileToDelete = this.currentProfile){ +; this.setCurrentProfile(this.profiles[1]) +; } +; } + +; deletedProfile := true + +; } +; else{ +; deletedProfile := false +; } +; return deletedProfile +; } + +; AddProfile(profile, profileName){ +; profileAdded := false +; if (this.hasProfile(profileName)){ +; profileAdded := false +; } +; else{ +; try{ +; presetProfileName := profileName +; profilePath := this.PresetProfilesManager.getFolderPathByName(profile) +; this.ExistingProfilesManager.CopyFolderToNewLocation(profilePath, this.PATH_TO_EXISTING_PROFILES . "\" . profileName, profileName, profileName) +; profileAdded := true +; this.updateProfiles() +; } +; catch{ +; profileAdded := false +; } +; } +; return profileAdded +; } + +; getCurrentProfile(){ +; return this.currentProfile +; } + + +; hasProfile(profileName){ +; hasProfile := false +; Loop this.profiles.Length{ +; if (this.profiles[A_Index] = profileName){ +; hasProfile := true +; } +; } +; return hasProfile +; } + +; UpdateProfileDropDownMenu(guiObject){ +; guiObject.Delete() +; guiObject.Add(this.ExistingProfilesManager.getFolderNames()) +; guiObject.Choose(this.currentProfile) +; } + + + +; ; ProfileChangedFromDropDownMenuEvent(profilesDropDownMenu){ +; ; iniWrite(profilesDropDownMenu.Text, this.PATH_TO_META_FILE, "General", "activeUserProfile") +; ; } + + + + +; } \ No newline at end of file diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionModel.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionModel.ahk deleted file mode 100644 index 6105ee7..0000000 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionModel.ahk +++ /dev/null @@ -1,170 +0,0 @@ -#Requires AutoHotkey v2.0 - -#Include -#Include - -; TODO rename this class, -class ProfileRegionModel{ - - ; 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 := "" - ; A constant which is the path to the preset profiles - - ; TODO dont need these - PATH_TO_EMPTY_PROFILE := "" - PATH_TO_PRESET_PROFILES := "" - PATH_TO_EXISTING_PROFILES := "" - PATH_TO_META_FILE := "" - - currentProfile := "" - - ; Gui part - profilesDropDownMenu := "" - - profiles := "" - - guiObject := "" - - - __New(guiObject){ - - this.guiObject := guiObject - this.PATH_TO_META_FILE := FilePaths.GetPathToMetaFile() - this.PATH_TO_EXISTING_PROFILES := FilePaths.GetPathToProfiles() - this.PATH_TO_EMPTY_PROFILE := FilePaths.GetPathToEmptyProfile() - this.PATH_TO_PRESET_PROFILES := FilePaths.GetPathToPresetProfiles() - - - this.ExistingProfilesManager := FolderManager() - this.PresetProfilesManager := FolderManager() - - this.PresetProfilesManager.addSubFoldersToRegistryFromFolder(this.PATH_TO_PRESET_PROFILES) - this.PresetProfilesManager.addFolderToRegistry("EmptyProfile", this.PATH_TO_EMPTY_PROFILE) - this.ExistingProfilesManager.addSubFoldersToRegistryFromFolder(this.PATH_TO_EXISTING_PROFILES) - - this.currentProfile := iniRead(this.PATH_TO_META_FILE, "General", "activeUserProfile") - - this.profiles := this.ExistingProfilesManager.getFolderNames() - - - } - - updateProfiles(){ - this.profiles := this.ExistingProfilesManager.getFolderNames() - } - - getGuiObject(){ - return this.guiObject - } - - getProfiles(){ - return this.profiles - } - - getPresetProfiles(){ - return this.PresetProfilesManager.getFolderNames() - } - - setCurrentProfile(profileName){ - this.currentProfile := profileName - iniWrite(this.currentProfile, this.PATH_TO_META_FILE, "General", "activeUserProfile") - } - - getCurrentProfileIndex(){ - currentProfileIndex := -1 - Loop this.profiles.Length{ - if (this.profiles[A_Index] = FilePaths.GetCurrentProfile()){ - currentProfileIndex := A_Index - } - } - return currentProfileIndex - } - - renameProfile(profileName, newProfileName){ - renamedSuccesfully := false - - if (this.ExistingProfilesManager.RenameFolder(profileName, newProfileName)){ - this.updateProfiles() - if (profileName = this.currentProfile){ - this.setCurrentProfile(newProfileName) - } - - renamedSuccesfully := true - } - else{ - msgbox("failed to change profile name, perhaps name already exists or illegal characters were used.") - renamedSuccesfully := false - } - return renamedSuccesfully - } - - DeleteProfile(profileToDelete){ - - deletedProfile := false - - if (this.ExistingProfilesManager.DeleteFolder(profileToDelete)){ - ; Deleted profile succesfully - this.updateProfiles() - if (this.profiles.Length != 0){ - if (profileToDelete = this.currentProfile){ - this.setCurrentProfile(this.profiles[1]) - } - } - - deletedProfile := true - - } - else{ - deletedProfile := false - } - return deletedProfile - } - - AddProfile(profile, profileName){ - profileAdded := false - if (this.hasProfile(profileName)){ - profileAdded := false - } - else{ - presetProfileName := profileName - profilePath := this.PresetProfilesManager.getFolderPathByName(profile) - this.ExistingProfilesManager.CopyFolderToNewLocation(profilePath, this.PATH_TO_EXISTING_PROFILES . "\" . profileName, profileName, profileName) - profileAdded := true - this.updateProfiles() - } - return profileAdded - } - - getCurrentProfile(){ - return this.currentProfile - } - - - hasProfile(profileName){ - hasProfile := false - Loop this.profiles.Length{ - if (this.profiles[A_Index] = profileName){ - hasProfile := true - } - } - return hasProfile - } - - UpdateProfileDropDownMenu(guiObject){ - guiObject.Delete() - guiObject.Add(this.ExistingProfilesManager.getFolderNames()) - guiObject.Choose(this.currentProfile) - } - - - - ; ProfileChangedFromDropDownMenuEvent(profilesDropDownMenu){ - ; iniWrite(profilesDropDownMenu.Text, this.PATH_TO_META_FILE, "General", "activeUserProfile") - ; } - - - - -} \ No newline at end of file diff --git a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk index 1dfbd42..a3a066a 100644 --- a/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk +++ b/src/Main/Lib/UserInterface/Main/ProfileEditing/ProfileRegionView.ahk @@ -10,10 +10,10 @@ class ProfileRegionView{ profileChangedEventSubscribers := Array() + guiHwnd := "" CreateView(guiObject, controller){ - this.controller := controller guiObject.Add("Text", , "Current Profile:") @@ -22,8 +22,7 @@ class ProfileRegionView{ currentProfileIndex := controller.getCurrentProfileIndex() this.profilesDropDownMenu := this.createProfilesDropDownMenu(guiObject, profiles, currentProfileIndex) - this.profilesDropDownMenu.OnEvent("Change", ObjBindMethod(controller, "HandleProfileChangedEvent")) - this.profilesDropDownMenu.OnEvent("Change", (*) => this.NotifyListenersProfileChanged()) + this.profilesDropDownMenu.OnEvent("Change", (*) => this.NotifyListenersProfileChanged(this.profilesDropDownMenu.Text)) editProfilesButton := guiObject.Add("Button", "Default w80 ym+1", "Edit profiles") @@ -32,18 +31,19 @@ class ProfileRegionView{ exportProfileButton := guiObject.Add("Button", "Default w80 ym+1", "Export profile") - editProfilesButton.OnEvent("Click", (*) => ObjBindMethod(controller, "HandleEditProfilesEvent")()) - addProfileButton.OnEvent("Click", (*) => ObjBindMethod(controller, "HandleAddProfileEvent")()) + editProfilesButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doOpenEditProfileView")()) + addProfileButton.OnEvent("Click", (*) => ObjBindMethod(controller, "doOpenAddProfileDialog")()) ; importProfileButton.OnEvent("Click", (*) => ObjBindMethod(controller, "HandleImportProfileEvent")()) ; exportProfileButton.OnEvent("Click", (*) => ObjBindMethod(controller, "HandleExportProfileEvent")()) + this.guiHwnd := guiObject.GetHwnd() guiObject.Show() } - NotifyListenersProfileChanged(){ + NotifyListenersProfileChanged(newProfileName){ for (event in this.profileChangedEventSubscribers){ - event() + event(newProfileName) } } @@ -59,7 +59,6 @@ class ProfileRegionView{ } } - CreateProfilesDropDownMenu(guiObject, profiles, profileIndex){ ; If for some reason a profile is not selected, then select the first one. @@ -82,7 +81,7 @@ class ProfileRegionView{ return profilesDropDownMenu } - getProfilesDropDownMenu(){ - return this.profilesDropDownMenu + GetHwnd(){ + return this.guiHwnd } } \ No newline at end of file diff --git a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk index 9be93fa..ca3e854 100644 --- a/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk +++ b/src/Main/Lib/UserInterface/Main/util/DomainSpecificGui.ahk @@ -9,21 +9,22 @@ class DomainSpecificGui extends Gui{ super.__New(options, title, this) this.OnEvent('Escape', (*) => this.Destroy()) this.SetColors() - this.SetFont("c6688FF Bold") + this.SetFont("c27eaf1 Bold") } SetColors(){ - this.BackColor := "051336" + this.BackColor := "35326b" ; Top bar or whatever it is called - GuiColorsChanger.DwmSetCaptionColor(this, 0x300f45) ; color is in RGB format + + GuiColorsChanger.DwmSetCaptionColor(this, 0x7800ff) ; color is in RGB format GuiColorsChanger.DwmSetTextColor(this, 0x27eaf1) } Add(ControlType , Options := "", Text := ""){ GuiCtrl := super.Add(ControlType, Options, Text) - controlColor := "060621" + controlColor := "14132b" fontColor := "27eaf1" GuiColorsChanger.setControlColor(GuiCtrl, controlColor) GuiColorsChanger.setControlTextColor(GuiCtrl, fontColor) @@ -58,8 +59,9 @@ class DomainSpecificGui extends Gui{ return this.Hwnd } - SetOwner(owner){ - this.opt("+Owner" . owner) + SetOwner(ownerHwnd := ""){ + if (ownerHwnd != ""){ + this.opt("+Owner" . ownerHwnd) + } } - } diff --git a/src/Main/Lib/Util/KeyboardOverlay/KeyboardOverlay.ahk b/src/Main/Lib/Util/KeyboardOverlay/KeyboardOverlay.ahk index e870bf3..dd34599 100644 --- a/src/Main/Lib/Util/KeyboardOverlay/KeyboardOverlay.ahk +++ b/src/Main/Lib/Util/KeyboardOverlay/KeyboardOverlay.ahk @@ -1,6 +1,8 @@ #Requires AutoHotkey v2.0 -Class KeyboardOverlay{ +#Include + +Class KeyboardOverlay extends Action{ ; Changing this font size will resize the keyboard: fontSize := "10" @@ -41,7 +43,7 @@ Class KeyboardOverlay{ this.keyboardOverlay.Title := "Virtual Keyboard View" } - ShowGui(){ + Show(){ try{ this.keyboardOverlay.Show("xCenter NoActivate") WinGetPos(, , &windowWidth, &windowHeight, "Virtual Keyboard View") @@ -50,13 +52,13 @@ Class KeyboardOverlay{ } } - HideGui(){ + Hide(){ try{ this.keyboardOverlay.Hide() } } - DestroyGui(){ + Destroy(){ this.keyboardOverlay.Destroy() } diff --git a/src/Main/Lib/Util/KeyboardOverlay/KeyboardOverlayRegistry.ahk b/src/Main/Lib/Util/KeyboardOverlay/KeyboardOverlayRegistry.ahk index 8ccf630..16d48b2 100644 --- a/src/Main/Lib/Util/KeyboardOverlay/KeyboardOverlayRegistry.ahk +++ b/src/Main/Lib/Util/KeyboardOverlay/KeyboardOverlayRegistry.ahk @@ -1,6 +1,7 @@ #Requires Autohotkey v2.0 -Class KeyboardOverlayRegistry{ +; TODO dont extends actin, extends overlay or something... +Class KeyboardOverlayRegistry extends Action{ keyboardOverlays := Map() activeOverlay := "" @@ -11,26 +12,26 @@ Class KeyboardOverlayRegistry{ ShowKeyboardOverlay(keyboardOverlayName){ this.activeOverlay := keyboardOverlayName - this.keyboardOverlays[keyboardOverlayName].ShowGui() + this.keyboardOverlays[keyboardOverlayName].Show() this.HideInactiveLayers() } HideKeyboardOverlay(keyboardOverlayName){ this.activeOverlay := keyboardOverlayName - this.keyboardOverlays[keyboardOverlayName].HideGui() + this.keyboardOverlays[keyboardOverlayName].Hide() } HideInactiveLayers(){ for keyboardOverlayName, KeyboardOverlayObject in this.keyboardOverlays{ if (keyboardOverlayName != this.activeOverlay){ - KeyboardOverlayObject.HideGui() + KeyboardOverlayObject.Hide() } } } HideAllLayers(){ for keyboardOverlayName, KeyboardOverlayObject in this.keyboardOverlays{ - KeyboardOverlayObject.HideGui() + KeyboardOverlayObject.Hide() } } diff --git a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/FoldersAndFiles/FolderManager.ahk b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/FoldersAndFiles/FolderManager.ahk index 3cb34d9..465b4a7 100644 --- a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/FoldersAndFiles/FolderManager.ahk +++ b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/FoldersAndFiles/FolderManager.ahk @@ -42,12 +42,12 @@ class FolderManager{ RenameFolder(oldName, newName) { folderChanged := false - if (this.folders.isInRegistry(newName)) { + if (this.folders.hasFolder(newName)) { folderChanged := false } else{ - if (this.folders.isInRegistry(oldName)) { + if (this.folders.hasFolder(oldName)) { oldPath := this.getFolderPathByName(oldName) newPath := this.folders.getNewPath(oldPath, oldName, newName) @@ -76,7 +76,7 @@ class FolderManager{ copiedFolder := false - if(this.folders.isInRegistry(newFolderName)){ + if(this.folders.hasFolder(newFolderName)){ copiedFolder := false } else{ @@ -90,10 +90,9 @@ class FolderManager{ DeleteFolder(folderName) { - folderDeleted := false - if (this.folders.isInRegistry(folderName)) { + if (this.folders.hasFolder(folderName)) { pathToFolderToBeDeleted := this.getFolderPathByName(folderName) @@ -128,4 +127,8 @@ class FolderManager{ getFirstFoundFolderIndex(folderName){ return this.folders.getFirstFoundFolderIndex(folderName) } + + hasFolder(folderName){ + return this.folders.hasFolder(folderName) + } } \ No newline at end of file diff --git a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/FoldersAndFiles/FolderRegistry.ahk b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/FoldersAndFiles/FolderRegistry.ahk index aef45ea..bb9f696 100644 --- a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/FoldersAndFiles/FolderRegistry.ahk +++ b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/FoldersAndFiles/FolderRegistry.ahk @@ -18,7 +18,7 @@ Class FolderRegistry{ addFolder(folderName, folderPath) { folderAdded := false - if (this.isInRegistry(folderName)) { + if (this.hasFolder(folderName)) { folderAdded := false } else{ @@ -34,12 +34,12 @@ Class FolderRegistry{ folderChanged := false - if (this.isInRegistry(newName)) { + if (this.hasFolder(newName)) { folderChanged := false } else{ - if (this.isInRegistry(oldName)) { + if (this.hasFolder(oldName)) { oldPath := this.folders[oldName] newPath := this.getNewPath(oldPath, oldName, newName) @@ -62,7 +62,7 @@ Class FolderRegistry{ DeleteFolder(folderName) { folderDeleted := false - if (this.isInRegistry(folderName)) { + if (this.hasFolder(folderName)) { this.folders.Delete(folderName) folderDeleted := true } @@ -114,7 +114,7 @@ Class FolderRegistry{ ; Returns true if the given folder is already in the registry ; Private method - isInRegistry(folderName){ + hasFolder(folderName){ return this.folders.Has(folderName) } diff --git a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardLayersInfoRegistry.ahk b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardLayersInfoRegistry.ahk index c2c13e1..7a005c5 100644 --- a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardLayersInfoRegistry.ahk +++ b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardLayersInfoRegistry.ahk @@ -1,5 +1,6 @@ #Requires AutoHotkey v2.0 +; TODO perhaps this should work together with the main startupr configurator which creates all the hotkeys class KeyboardLayersInfoRegistry{ KeyboardOverlaysRegistry := "" diff --git a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardsInfo/Hotkeys/entity/HotKeyInfo.ahk b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardsInfo/Hotkeys/entity/HotKeyInfo.ahk index 7fda3ed..494a2ae 100644 --- a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardsInfo/Hotkeys/entity/HotKeyInfo.ahk +++ b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/KeyboardLayouts/KeyboardsInfo/Hotkeys/entity/HotKeyInfo.ahk @@ -2,6 +2,7 @@ #Include +; TODO perhaps this should work together with the main startupr configurator which creates all the hotkeys class HotKeyInfo{ ; The key to press to trigger the "toKey" or the "objectName.methodName(parameters)" action. @@ -97,6 +98,10 @@ class HotKeyInfo{ return stringToReturn } + actionIsSet(){ + return this.actionSet + } + getHotkeyName(){ return this.fromKey } diff --git a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/Objects/ObjectInfo.ahk b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/Objects/ObjectInfo.ahk index 4a4bc18..e3057db 100644 --- a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/Objects/ObjectInfo.ahk +++ b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/Objects/ObjectInfo.ahk @@ -41,4 +41,8 @@ class ObjectInfo{ getMethodsWithDescriptions(){ return this.methodsWithDescriptions } + + DestroyObject(){ + this.objectInstance.Destroy() + } } \ No newline at end of file diff --git a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/Objects/ObjectRegistry.ahk b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/Objects/ObjectRegistry.ahk index 2d47645..83869be 100644 --- a/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/Objects/ObjectRegistry.ahk +++ b/src/Main/Lib/Util/MetaInfo/MetaInfoStorage/Objects/ObjectRegistry.ahk @@ -45,7 +45,12 @@ Class ObjectRegistry{ } } } + } + DestroyObjects(){ + for objectName, objectInfo in this.ObjectMap{ + objectInfo.DestroyObject() + } } } \ No newline at end of file diff --git a/src/Main/Lib/Util/StartupConfiguration/HotkeyInitializer.ahk b/src/Main/Lib/Util/StartupConfiguration/HotkeyInitializer.ahk index 0dea4ac..a43983a 100644 --- a/src/Main/Lib/Util/StartupConfiguration/HotkeyInitializer.ahk +++ b/src/Main/Lib/Util/StartupConfiguration/HotkeyInitializer.ahk @@ -4,26 +4,28 @@ Class HotkeyInitializer{ - layersInformation := "" objectRegistry := "" - __New(layersInformation, objectRegistry){ - this.layersInformation := layersInformation - this.objectRegistry := objectRegistry + __New(){ } - InitializeHotkeys(keyboardLayerName, enableHotkeys := true){ + InitializeHotkeys(layersInformation, objectRegistry, keyboardLayerName, enableHotkeys := true){ + this.objectRegistry := objectRegistry - currentKeyboardLayerInformation := this.layersInformation.GetRegistryByLayerIdentifier(keyboardLayerName) + currentKeyboardLayerInformation := layersInformation.GetRegistryByLayerIdentifier(keyboardLayerName) currentKeyboardLayerHotkeys := currentKeyboardLayerInformation.GetHotkeys() For key, hotkeyInformation in currentKeyboardLayerHotkeys{ - if (hotkeyInformation.hotkeyIsObject()){ - this.InitializeDefaultKeyToFunction(hotkeyInformation, enableHotkeys) - } - else{ - this.InitializeDefaultKeyToNewKey(hotkeyInformation, enableHotkeys) - } + this.InitializeHotkey(hotkeyInformation, enableHotkeys) + } + } + + InitializeHotkey(hotkeyInformation, enableHotkeys := true){ + if (hotkeyInformation.hotkeyIsObject()){ + this.InitializeDefaultKeyToFunction(hotkeyInformation, enableHotkeys) + } + else{ + this.InitializeDefaultKeyToNewKey(hotkeyInformation, enableHotkeys) } } @@ -76,6 +78,17 @@ Class HotkeyInitializer{ } } + ; DisableHotkey(hotkeyInformation){ + ; hotkeyKey := hotkeyInformation.getHotkeyName() + ; if (hotkeyInformation.hotkeyIsObject()){ + + ; } + ; else{ + ; HotKey(hotkeyKey, (ThisHotkey) => this.SendKeysUp(newHotKey, newHotKeyModifiers), "Off") + ; HotKey(hotkeyKey . " Up", (ThisHotkey) => this.SendKeysDown(newHotKey, newHotKeyModifiers), "Off") + ; } + ; } + ; Sends key(s) down, including possible modifiers SendKeysDown(keysDown, modifiers){ keysDown := HotkeyFormatConverter.convertToKeyDownExcecutable(keysDown) diff --git a/src/Main/Lib/Util/StartupConfiguration/MainStartupConfigurator.ahk b/src/Main/Lib/Util/StartupConfiguration/MainStartupConfigurator.ahk index cf00153..2ffff6b 100644 --- a/src/Main/Lib/Util/StartupConfiguration/MainStartupConfigurator.ahk +++ b/src/Main/Lib/Util/StartupConfiguration/MainStartupConfigurator.ahk @@ -24,16 +24,23 @@ Class MainStartupConfigurator{ this.layersInformation := layersInformation this.objectRegistry := objectRegistry if (Type(layersInformation) = "KeyboardLayersInfoRegistry" AND Type(objectRegistry) = "ObjectRegistry"){ - this.HotkeyInitializerInstance := HotkeyInitializer(layersInformation, objectRegistry) + this.HotkeyInitializerInstance := HotkeyInitializer() + ; TODO probably dont pass these arguemnts hereere... this.KeyboardOverlayInitializerInstance := KeyboardOverlaysInitializer(layersInformation, objectRegistry) } else{ - ; throw Error("Invalid parameters passed to MainStartupConfigurator") + throw Error("Invalid parameters passed to MainStartupConfigurator") } } - InitializeLayer(section, enableHotkeys := "on"){ - this.HotkeyInitializerInstance.InitializeHotkeys(section . "-Hotkeys", enableHotkeys) + InitializeLayer(layersInformation, objectRegistry, section, enableHotkeys := "on"){ + if (Type(layersInformation) = "KeyboardLayersInfoRegistry" AND Type(objectRegistry) = "ObjectRegistry"){ + this.HotkeyInitializerInstance.InitializeHotkeys(layersInformation, objectRegistry, section . "-Hotkeys", enableHotkeys) + } + else{ + throw Error("Invalid parameters passed to MainStartupConfigurator") + } + this.KeyboardOverlayInitializerInstance.ChangeHotkeysStateForKeyboardOverlaysByLayerSection(section . "-KeyboardOverlay", enableHotkeys) } diff --git a/src/Main/Lib/Util/StartupConfiguration/ObjectRegistryInitializer.ahk b/src/Main/Lib/Util/StartupConfiguration/ObjectRegistryInitializer.ahk index 8d4e650..93cdf58 100644 --- a/src/Main/Lib/Util/StartupConfiguration/ObjectRegistryInitializer.ahk +++ b/src/Main/Lib/Util/StartupConfiguration/ObjectRegistryInitializer.ahk @@ -14,7 +14,6 @@ class ObjectRegistryInitializer { } InitializeObjects(){ - initializerForObjects := ObjectsInitializer() initializerForObjects.InitializeObjects() this.Objects := initializerForObjects.GetObjects() diff --git a/src/Main/Lib/Util/StartupConfiguration/ObjectsInitializer.ahk b/src/Main/Lib/Util/StartupConfiguration/ObjectsInitializer.ahk index 6cfb605..633eae1 100644 --- a/src/Main/Lib/Util/StartupConfiguration/ObjectsInitializer.ahk +++ b/src/Main/Lib/Util/StartupConfiguration/ObjectsInitializer.ahk @@ -1,6 +1,6 @@ #Requires Autohotkey v2.0 -#Include +#Include #Include #Include @@ -108,6 +108,7 @@ class ObjectsInitializer{ ; |------------Layer indicators------------| ; Used to switch the active layer + ; TODO dont do it like this!? layers := LayerController() layers.addLayerIndicator(1, "Green") layers.addLayerIndicator(2, "Red") diff --git a/src/Main/Main.ahk b/src/Main/Main.ahk index f94a62b..098d94b 100644 --- a/src/Main/Main.ahk +++ b/src/Main/Main.ahk @@ -11,7 +11,6 @@ #Include -#Include #Include #Include @@ -50,12 +49,8 @@ SendMode "Event" ; Run("*RunAs `"" A_ScriptFullPath "`"") ; } -; ------------Global or whatever stusff---------------- - - Class Main{ - keyNames := "" StartupConfigurator := "" ObjectRegister := ObjectRegistry() KeyboardLayersInfoRegister := KeyboardLayersInfoRegistry() @@ -68,11 +63,6 @@ Class Main{ ; Main method used to start the script. Start(){ try{ - if (this.scriptRunning){ - this.SetHotkeysForAllLayers(false) - } - ; TODO check if script is already running - ; TODO if script is already running, show a message box and exit this.RunLogicalStartup() } catch Error as e{ @@ -85,6 +75,14 @@ Class Main{ } RunLogicalStartup(){ + if (this.scriptRunning){ + this.DestroyObjectRegistry() + this.SetHotkeysForAllLayers(false) + this.StartupConfigurator := "" + this.ObjectRegister := ObjectRegistry() + ; TODO probably needs to be destroyed... + this.KeyboardLayersInfoRegister := KeyboardLayersInfoRegistry() + } this.Initialize() this.RunMainStartup() } @@ -92,7 +90,6 @@ Class Main{ Initialize(){ this.InitializeObjectRegistry() this.InitializeKeyboardLayersInfo() - this.InitializeKeyNames() this.InitializeMainStartupConfigurator() } @@ -107,18 +104,16 @@ Class Main{ this.ObjectRegister := objectRegisterInitializer.GetObjectRegistry() } + DestroyObjectRegistry(){ + this.ObjectRegister.DestroyObjects() + } + InitializeKeyboardLayersInfo(){ JsonReaderForKeyboardLayersInfo := KeyboardLayersInfoJsonReader() JsonReaderForKeyboardLayersInfo.ReadKeyboardLayersInfoForCurrentProfile() this.KeyboardLayersInfoRegister := JsonReaderForKeyboardLayersInfo.getKeyboardLayersInfoRegister() } - InitializeKeyNames(){ - keyNamesFileObjReader := KeyNamesReader() - fileObjectOfKeyNames := FileOpen(FilePaths.GetPathToKeyNames(), "rw" , "UTF-8") - this.keyNames := keyNamesFileObjReader.ReadKeyNamesFromTextFileObject(fileObjectOfKeyNames).GetKeyNames() - } - InitializeMainStartupConfigurator(){ ; This is used to read ini files, and create hotkeys from them this.StartupConfigurator := MainStartupConfigurator() @@ -135,26 +130,26 @@ Class Main{ this.StartupConfigurator.CreateGlobalHotkeysForAllKeyboardOverlays() ; Reads and initializes all the hotkeys which are active for every keyboard layer. - this.StartupConfigurator.InitializeLayer("GlobalLayer", enableHotkeys) + this.StartupConfigurator.InitializeLayer(this.KeyboardLayersInfoRegister, this.ObjectRegister, "GlobalLayer", enableHotkeys) HotIf "MainScript.getLayerController().getActiveLayer() == 0" ; Reads and initializes all the hotkeys for the normal keyboard layer. - this.StartupConfigurator.InitializeLayer("NormalLayer", enableHotkeys) + this.StartupConfigurator.InitializeLayer(this.KeyboardLayersInfoRegister, this.ObjectRegister, "NormalLayer", enableHotkeys) HotIf HotIf "MainScript.getLayerController().getActiveLayer() == 1" ; Reads and initializes all the hotkeys for the second keyboard layer. - this.StartupConfigurator.InitializeLayer("SecondaryLayer", enableHotkeys) + this.StartupConfigurator.InitializeLayer(this.KeyboardLayersInfoRegister, this.ObjectRegister, "SecondaryLayer", enableHotkeys) HotIf HotIf "MainScript.getLayerController().getActiveLayer() == 2" ; Reads and initializes all the hotkeys for the third keyboard layer. - this.StartupConfigurator.InitializeLayer("TertiaryLayer", enableHotkeys) + this.StartupConfigurator.InitializeLayer(this.KeyboardLayersInfoRegister, this.ObjectRegister, "TertiaryLayer", enableHotkeys) HotIf } RunAppGui(){ - app := ExtraKeyboardsApp(this.ObjectRegister, this.KeyboardLayersInfoRegister, this, this.keyNames) + app := ExtraKeyboardsApp(this.ObjectRegister, this.KeyboardLayersInfoRegister, this) app.Start() } @@ -189,8 +184,8 @@ ToolTip "Script enabled!" SetTimer () => ToolTip(), -3000 -IsRunning(Path) { - SetTitleMatchMode 2 - DetectHiddenWindows 1 - return !!WinExist(Path) -} \ No newline at end of file +; IsRunning(Path) { +; SetTitleMatchMode 2 +; DetectHiddenWindows 1 +; return !!WinExist(Path) +; } \ No newline at end of file diff --git a/src/controlScript.ahk b/src/controlScript.ahk index d704a8d..df7ddd3 100644 --- a/src/controlScript.ahk +++ b/src/controlScript.ahk @@ -11,7 +11,7 @@ SetWorkingDir(A_ScriptDir) ; Extra layers script ^!l::Run(A_ScriptDir "\Main\Main.ahk") ; For testing -^!i::Run(A_ScriptDir "\..\tests\removeme.ahk") +^!i::Run(A_ScriptDir "\..\tests\destroyingGusi.ahk") ^!u::Run(A_ScriptDir "\ExtraKeyboardsApp.ahk") ^!p::Run(A_ScriptDir "\library\JsonTesting\jsonTest.ahk")