From 2efc5b95466940956638fd1b2c4ada049ef534a3 Mon Sep 17 00:00:00 2001
From: Kyle Grymonprez <1175063+kylegrymonprez@users.noreply.github.com>
Date: Thu, 22 Aug 2024 04:12:51 -0700
Subject: [PATCH] Issue #4675 - Support the ability to set the alias behavior
for renaming models (#4739)
* https://github.com/xLightsSequencer/xLights/issues/4675
Added the ability to set the behavior for alias setting on renaming models. The default is the current behavior. The user can set "Always Yes" or "Always No" per their preference, or leave it to always prompt.
* Undo default size change for the "OtherSettingsPanel"
* Undo default size change for the "OtherSettingsPanel"
---------
Co-authored-by: Kyle Grymonprez <>
---
xLights/models/Model.cpp | 6 +-
xLights/preferences/OtherSettingsPanel.cpp | 97 ++++++++++++----------
xLights/preferences/OtherSettingsPanel.h | 46 +++++-----
xLights/wxsmith/OtherSettingsPanel.wxs | 33 +++++++-
xLights/xLightsMain.cpp | 13 +++
xLights/xLightsMain.h | 4 +
6 files changed, 134 insertions(+), 65 deletions(-)
mode change 100644 => 100755 xLights/preferences/OtherSettingsPanel.cpp
mode change 100644 => 100755 xLights/preferences/OtherSettingsPanel.h
mode change 100644 => 100755 xLights/wxsmith/OtherSettingsPanel.wxs
diff --git a/xLights/models/Model.cpp b/xLights/models/Model.cpp
index ac21a4a100..f1658df9fd 100644
--- a/xLights/models/Model.cpp
+++ b/xLights/models/Model.cpp
@@ -549,11 +549,15 @@ void Model::Rename(std::string const& newName)
ModelXml->DeleteAttribute("name");
ModelXml->AddAttribute("name", name);
- if (oldname != "" && newName != "Iamgoingtodeletethismodel") {
+ if (oldname != "" && newName != "Iamgoingtodeletethismodel" && modelManager.GetXLightsFrame()->GetRenameModelAliasPromptBehavior() == "Always Prompt" ) {
if (wxMessageBox("Would you like to save the old name as an alias for this prop. This could be useful if you have sequences already sequenced against this prop using the old name.", "Save old name as alias", wxYES_NO | wxICON_QUESTION, GetModelManager().GetXLightsFrame()) == wxYES) {
AddAlias("oldname:" + oldname);
}
}
+
+ if( modelManager.GetXLightsFrame()->GetRenameModelAliasPromptBehavior() == "Always Yes" ) {
+ AddAlias("oldname:" + oldname);
+ }
}
void Model::SetStartChannel(std::string const& startChannel)
diff --git a/xLights/preferences/OtherSettingsPanel.cpp b/xLights/preferences/OtherSettingsPanel.cpp
old mode 100644
new mode 100755
index 4e0f87e555..414bd04725
--- a/xLights/preferences/OtherSettingsPanel.cpp
+++ b/xLights/preferences/OtherSettingsPanel.cpp
@@ -33,27 +33,29 @@ extern bool isMetalComputeSupported();
#endif
//(*IdInit(OtherSettingsPanel)
-const long OtherSettingsPanel::ID_STATICTEXT1 = wxNewId();
-const long OtherSettingsPanel::ID_CHOICE1 = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX1 = wxNewId();
-const long OtherSettingsPanel::ID_CHOICE4 = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX7 = wxNewId();
-const long OtherSettingsPanel::ID_STATICTEXT3 = wxNewId();
-const long OtherSettingsPanel::ID_CHOICE_CODEC = wxNewId();
-const long OtherSettingsPanel::ID_STATICTEXT5 = wxNewId();
-const long OtherSettingsPanel::ID_SPINCTRLDOUBLE_BITRATE = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX2 = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX3 = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX4 = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX6 = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX5 = wxNewId();
-const long OtherSettingsPanel::ID_STATICTEXT4 = wxNewId();
-const long OtherSettingsPanel::ID_CHOICE3 = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX8 = wxNewId();
-const long OtherSettingsPanel::ID_STATICTEXT2 = wxNewId();
-const long OtherSettingsPanel::ID_CHOICE2 = wxNewId();
-const long OtherSettingsPanel::ID_TEXTCTRL1 = wxNewId();
-const long OtherSettingsPanel::ID_CHECKBOX9 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_STATICTEXT1 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHOICE1 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX1 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHOICE4 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX7 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_STATICTEXT3 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHOICE_CODEC = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_STATICTEXT5 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_SPINCTRLDOUBLE_BITRATE = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX2 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX3 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX4 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX6 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX5 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_STATICTEXT4 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHOICE3 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX8 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_STATICTEXT2 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHOICE2 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_STATICTEXT6 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHOICE_ALIASPROMPT = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_TEXTCTRL1 = wxNewId();
+const wxWindowID OtherSettingsPanel::ID_CHECKBOX9 = wxNewId();
//*)
BEGIN_EVENT_TABLE(OtherSettingsPanel,wxPanel)
@@ -71,6 +73,7 @@ OtherSettingsPanel::OtherSettingsPanel(wxWindow* parent, xLightsFrame* f, wxWind
wxFlexGridSizer* FlexGridSizer4;
wxFlexGridSizer* FlexGridSizer5;
wxFlexGridSizer* FlexGridSizer6;
+ wxFlexGridSizer* FlexGridSizer7;
wxGridBagSizer* GridBagSizer1;
wxGridBagSizer* GridBagSizer2;
wxStaticBoxSizer* StaticBoxSizer1;
@@ -141,7 +144,7 @@ OtherSettingsPanel::OtherSettingsPanel(wxWindow* parent, xLightsFrame* f, wxWind
GridBagSizer1->Add(CheckBox_PurgeDownloadCache, wxGBPosition(5, 0), wxDefaultSpan, wxALL|wxEXPAND, 5);
CheckBox_IgnoreVendorModelRecommendations = new wxCheckBox(this, ID_CHECKBOX5, _("Ignore vendor model recommendations"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX5"));
CheckBox_IgnoreVendorModelRecommendations->SetValue(false);
- GridBagSizer1->Add(CheckBox_IgnoreVendorModelRecommendations, wxGBPosition(8, 0), wxDefaultSpan, wxALL|wxEXPAND, 5);
+ GridBagSizer1->Add(CheckBox_IgnoreVendorModelRecommendations, wxGBPosition(9, 0), wxDefaultSpan, wxALL|wxEXPAND, 5);
StaticBoxSizer3 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Tip Of The Day"));
FlexGridSizer2 = new wxFlexGridSizer(0, 2, 0, 0);
StaticText5 = new wxStaticText(this, ID_STATICTEXT4, _("Minimum Tip Level"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
@@ -167,6 +170,15 @@ OtherSettingsPanel::OtherSettingsPanel(wxWindow* parent, xLightsFrame* f, wxWind
Choice_LinkControllerUpload->Append(_("Inputs and Outputs"));
FlexGridSizer5->Add(Choice_LinkControllerUpload, 1, wxALL|wxEXPAND, 5);
GridBagSizer1->Add(FlexGridSizer5, wxGBPosition(7, 0), wxDefaultSpan, wxALL|wxEXPAND, 0);
+ FlexGridSizer7 = new wxFlexGridSizer(0, 2, 0, 0);
+ StaticText7 = new wxStaticText(this, ID_STATICTEXT6, _("Model renaming alias behavior"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6"));
+ FlexGridSizer7->Add(StaticText7, 1, wxALL|wxEXPAND, 5);
+ Choice_AliasPromptBehavior = new wxChoice(this, ID_CHOICE_ALIASPROMPT, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE_ALIASPROMPT"));
+ Choice_AliasPromptBehavior->SetSelection( Choice_AliasPromptBehavior->Append(_("Always Prompt")) );
+ Choice_AliasPromptBehavior->Append(_("Always Yes"));
+ Choice_AliasPromptBehavior->Append(_("Always No"));
+ FlexGridSizer7->Add(Choice_AliasPromptBehavior, 1, wxALL|wxEXPAND, 5);
+ GridBagSizer1->Add(FlexGridSizer7, wxGBPosition(8, 0), wxDefaultSpan, wxALL|wxEXPAND, 0);
FlexGridSizer6 = new wxFlexGridSizer(0, 2, 0, 0);
StaticText1 = new wxStaticText(this, wxID_ANY, _("eMail Address:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
FlexGridSizer6->Add(StaticText1, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
@@ -178,27 +190,26 @@ OtherSettingsPanel::OtherSettingsPanel(wxWindow* parent, xLightsFrame* f, wxWind
GPURenderCheckbox->SetToolTip(_("Some effects can be rendered on the GPU if this is enabled."));
GridBagSizer1->Add(GPURenderCheckbox, wxGBPosition(2, 0), wxDefaultSpan, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(GridBagSizer1);
- GridBagSizer1->Fit(this);
- GridBagSizer1->SetSizeHints(this);
- Connect(ID_CHOICE1,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHECKBOX1,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHOICE4,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHECKBOX7,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHOICE_CODEC,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_SPINCTRLDOUBLE_BITRATE,wxEVT_SPINCTRLDOUBLE,(wxObjectEventFunction)&OtherSettingsPanel::OnSpinCtrlDoubleBitrateChange);
- Connect(ID_CHECKBOX2,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHECKBOX3,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHECKBOX4,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHECKBOX6,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHECKBOX5,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHOICE3,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHECKBOX8,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHOICE2,wxEVT_COMMAND_CHOICE_SELECTED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_ENTER,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(ID_CHECKBOX9,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
- Connect(wxEVT_PAINT,(wxObjectEventFunction)&OtherSettingsPanel::OnPaint);
+ Connect(ID_CHOICE1, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHECKBOX1, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHOICE4, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHECKBOX7, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHOICE_CODEC, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_SPINCTRLDOUBLE_BITRATE, wxEVT_SPINCTRLDOUBLE, (wxObjectEventFunction)&OtherSettingsPanel::OnSpinCtrlDoubleBitrateChange);
+ Connect(ID_CHECKBOX2, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHECKBOX3, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHECKBOX4, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHECKBOX6, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHECKBOX5, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHOICE3, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHECKBOX8, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHOICE2, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHOICE_ALIASPROMPT, wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_TEXTCTRL1, wxEVT_COMMAND_TEXT_UPDATED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_TEXTCTRL1, wxEVT_COMMAND_TEXT_ENTER, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(ID_CHECKBOX9, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&OtherSettingsPanel::OnControlChanged);
+ Connect(wxEVT_PAINT, (wxObjectEventFunction)&OtherSettingsPanel::OnPaint);
//*)
#ifdef __LINUX__
@@ -239,6 +250,7 @@ bool OtherSettingsPanel::TransferDataFromWindow() {
frame->SetUserEMAIL(eMailTextControl->GetValue());
frame->SetLinkedSave(Choice_LinkSave->GetStringSelection());
frame->SetLinkedControllerUpload(Choice_LinkControllerUpload->GetStringSelection());
+ frame->SetRenameModelAliasPromptBehavior(Choice_AliasPromptBehavior->GetStringSelection());
frame->SetPromptBatchRenderIssues(CheckBox_BatchRenderPromptIssues->GetValue());
frame->SetIgnoreVendorModelRecommendations(CheckBox_IgnoreVendorModelRecommendations->GetValue());
frame->SetPurgeDownloadCacheOnStart(CheckBox_PurgeDownloadCache->GetValue());
@@ -262,6 +274,7 @@ bool OtherSettingsPanel::TransferDataToWindow() {
eMailTextControl->ChangeValue(frame->UserEMAIL());
Choice_LinkSave->SetStringSelection(frame->GetLinkedSave());
Choice_LinkControllerUpload->SetStringSelection(frame->GetLinkedControllerUpload());
+ Choice_AliasPromptBehavior->SetStringSelection(frame->GetRenameModelAliasPromptBehavior());
CheckBox_BatchRenderPromptIssues->SetValue(frame->GetPromptBatchRenderIssues());
CheckBox_IgnoreVendorModelRecommendations->SetValue(frame->GetIgnoreVendorModelRecommendations());
CheckBox_PurgeDownloadCache->SetValue(frame->GetPurgeDownloadCacheOnStart());
diff --git a/xLights/preferences/OtherSettingsPanel.h b/xLights/preferences/OtherSettingsPanel.h
old mode 100644
new mode 100755
index 0d8bc5fe1b..1e0730aecd
--- a/xLights/preferences/OtherSettingsPanel.h
+++ b/xLights/preferences/OtherSettingsPanel.h
@@ -43,6 +43,7 @@ class OtherSettingsPanel: public wxPanel
wxCheckBox* HardwareVideoDecodingCheckBox;
wxCheckBox* ShaderCheckbox;
wxChoice* ChoiceCodec;
+ wxChoice* Choice_AliasPromptBehavior;
wxChoice* Choice_LinkControllerUpload;
wxChoice* Choice_LinkSave;
wxChoice* Choice_MinTipLevel;
@@ -53,6 +54,7 @@ class OtherSettingsPanel: public wxPanel
wxStaticText* StaticText4;
wxStaticText* StaticText5;
wxStaticText* StaticText6;
+ wxStaticText* StaticText7;
wxTextCtrl* eMailTextControl;
//*)
@@ -62,27 +64,29 @@ class OtherSettingsPanel: public wxPanel
protected:
//(*Identifiers(OtherSettingsPanel)
- static const long ID_STATICTEXT1;
- static const long ID_CHOICE1;
- static const long ID_CHECKBOX1;
- static const long ID_CHOICE4;
- static const long ID_CHECKBOX7;
- static const long ID_STATICTEXT3;
- static const long ID_CHOICE_CODEC;
- static const long ID_STATICTEXT5;
- static const long ID_SPINCTRLDOUBLE_BITRATE;
- static const long ID_CHECKBOX2;
- static const long ID_CHECKBOX3;
- static const long ID_CHECKBOX4;
- static const long ID_CHECKBOX6;
- static const long ID_CHECKBOX5;
- static const long ID_STATICTEXT4;
- static const long ID_CHOICE3;
- static const long ID_CHECKBOX8;
- static const long ID_STATICTEXT2;
- static const long ID_CHOICE2;
- static const long ID_TEXTCTRL1;
- static const long ID_CHECKBOX9;
+ static const wxWindowID ID_STATICTEXT1;
+ static const wxWindowID ID_CHOICE1;
+ static const wxWindowID ID_CHECKBOX1;
+ static const wxWindowID ID_CHOICE4;
+ static const wxWindowID ID_CHECKBOX7;
+ static const wxWindowID ID_STATICTEXT3;
+ static const wxWindowID ID_CHOICE_CODEC;
+ static const wxWindowID ID_STATICTEXT5;
+ static const wxWindowID ID_SPINCTRLDOUBLE_BITRATE;
+ static const wxWindowID ID_CHECKBOX2;
+ static const wxWindowID ID_CHECKBOX3;
+ static const wxWindowID ID_CHECKBOX4;
+ static const wxWindowID ID_CHECKBOX6;
+ static const wxWindowID ID_CHECKBOX5;
+ static const wxWindowID ID_STATICTEXT4;
+ static const wxWindowID ID_CHOICE3;
+ static const wxWindowID ID_CHECKBOX8;
+ static const wxWindowID ID_STATICTEXT2;
+ static const wxWindowID ID_CHOICE2;
+ static const wxWindowID ID_STATICTEXT6;
+ static const wxWindowID ID_CHOICE_ALIASPROMPT;
+ static const wxWindowID ID_TEXTCTRL1;
+ static const wxWindowID ID_CHECKBOX9;
//*)
private:
diff --git a/xLights/wxsmith/OtherSettingsPanel.wxs b/xLights/wxsmith/OtherSettingsPanel.wxs
old mode 100644
new mode 100755
index 20586946d7..80015b3f66
--- a/xLights/wxsmith/OtherSettingsPanel.wxs
+++ b/xLights/wxsmith/OtherSettingsPanel.wxs
@@ -208,7 +208,7 @@