Change the logic for when the style editor asks the user if they wish to update existing lines when renaming a style to be based on whether it is a newly created style rather than whether the style's name starts with "Copy of". Updates #1060.

Originally committed to SVN as r4103.
This commit is contained in:
Thomas Goyne 2010-02-14 22:26:45 +00:00
parent 509f748cfb
commit 429a57ef68
3 changed files with 13 additions and 38 deletions

View file

@ -163,7 +163,7 @@ enum {
/// @param local /// @param local
/// @param _store /// @param _store
/// ///
DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, SubtitlesGrid *_grid,bool local,AssStyleStorage *_store) DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, SubtitlesGrid *_grid,bool local,AssStyleStorage *_store,bool newStyle)
: wxDialog (parent,-1,_("Style Editor"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,_T("DialogStyleEditor")) : wxDialog (parent,-1,_("Style Editor"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,_T("DialogStyleEditor"))
{ {
// Set icon // Set icon
@ -171,6 +171,7 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
// Set variables // Set variables
isLocal = local; isLocal = local;
isNew = newStyle;
store = _store; store = _store;
// Set styles // Set styles
@ -427,15 +428,12 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
LoadPosition(); LoadPosition();
} }
/// @brief Destructor /// @brief Destructor
/// ///
DialogStyleEditor::~DialogStyleEditor () { DialogStyleEditor::~DialogStyleEditor () {
delete work; delete work;
} }
/////////////// ///////////////
// Event table // Event table
BEGIN_EVENT_TABLE(DialogStyleEditor, wxDialog) BEGIN_EVENT_TABLE(DialogStyleEditor, wxDialog)
@ -501,8 +499,6 @@ void DialogStyleEditor::OnSetColor3 (wxCommandEvent &event) { OnSetColor(3); }
/// ///
void DialogStyleEditor::OnSetColor4 (wxCommandEvent &event) { OnSetColor(4); } void DialogStyleEditor::OnSetColor4 (wxCommandEvent &event) { OnSetColor(4); }
/// @brief Replace Style /// @brief Replace Style
/// @param tag /// @param tag
/// @param n /// @param n
@ -520,8 +516,6 @@ void ReplaceStyle(wxString tag,int n,AssOverrideParameter* param,void *userData)
} }
} }
/// @brief Events /// @brief Events
/// @param apply /// @param apply
/// @param close /// @param close
@ -550,7 +544,7 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
// Style name change // Style name change
if (work->name != newStyleName) { if (work->name != newStyleName) {
if (!work->name.StartsWith(_("Copy of ")) && isLocal) { if (!isNew && isLocal) {
// See if user wants to update style name through script // See if user wants to update style name through script
int answer = wxNO; int answer = wxNO;
if (work->name != _T("Default")) answer = wxMessageBox(_("Do you want to change all instances of this style in the script to this new name?"),_("Update script?"),wxYES_NO | wxCANCEL); if (work->name != _T("Default")) answer = wxMessageBox(_("Do you want to change all instances of this style in the script to this new name?"),_("Update script?"),wxYES_NO | wxCANCEL);
@ -612,8 +606,6 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
} }
} }
/// @brief Update work style /// @brief Update work style
/// ///
void DialogStyleEditor::UpdateWorkStyle() { void DialogStyleEditor::UpdateWorkStyle() {
@ -663,8 +655,6 @@ void DialogStyleEditor::UpdateWorkStyle() {
work->strikeout = BoxStrikeout->IsChecked(); work->strikeout = BoxStrikeout->IsChecked();
} }
/// @brief Choose font box /// @brief Choose font box
/// @param event /// @param event
/// ///
@ -692,8 +682,6 @@ void DialogStyleEditor::OnChooseFont (wxCommandEvent &event) {
} }
} }
/// @brief Sets color for one of the four color buttons /// @brief Sets color for one of the four color buttons
/// @param n /// @param n
/// ///
@ -710,8 +698,6 @@ void DialogStyleEditor::OnSetColor (int n) {
if (SubsPreview) SubsPreview->SetStyle(work); if (SubsPreview) SubsPreview->SetStyle(work);
} }
/// @brief Child focus change /// @brief Child focus change
/// @param event /// @param event
/// ///
@ -721,8 +707,6 @@ void DialogStyleEditor::OnChildFocus (wxChildFocusEvent &event) {
event.Skip(); event.Skip();
} }
/// @brief Preview text changed /// @brief Preview text changed
/// @param event /// @param event
/// ///
@ -733,8 +717,6 @@ void DialogStyleEditor::OnPreviewTextChange (wxCommandEvent &event) {
} }
} }
/// @brief Change colour of preview's background /// @brief Change colour of preview's background
/// @param event /// @param event
/// ///
@ -744,8 +726,6 @@ void DialogStyleEditor::OnPreviewColourChange (wxCommandEvent &event) {
Options.Save(); Options.Save();
} }
/// @brief Command event to update preview /// @brief Command event to update preview
/// @param event /// @param event
/// @return /// @return
@ -757,8 +737,6 @@ void DialogStyleEditor::OnCommandPreviewUpdate (wxCommandEvent &event) {
event.Skip(); event.Skip();
} }
/// @brief Converts control value to alignment /// @brief Converts control value to alignment
/// @param n /// @param n
/// @return /// @return
@ -778,8 +756,6 @@ int DialogStyleEditor::ControlToAlign (int n) {
} }
} }
/// @brief Converts alignment value to control /// @brief Converts alignment value to control
/// @param n /// @param n
/// @return /// @return
@ -799,8 +775,6 @@ int DialogStyleEditor::AlignToControl (int n) {
} }
} }
/// @brief Load and save window position for the session /// @brief Load and save window position for the session
/// ///
void DialogStyleEditor::SavePosition() { void DialogStyleEditor::SavePosition() {
@ -817,12 +791,8 @@ void DialogStyleEditor::LoadPosition() {
CentreOnParent(); CentreOnParent();
} }
/// DOCME /// DOCME
wxRect DialogStyleEditor::saved_position; wxRect DialogStyleEditor::saved_position;
/// DOCME /// DOCME
bool DialogStyleEditor::use_saved_position = false; bool DialogStyleEditor::use_saved_position = false;

View file

@ -70,6 +70,11 @@ private:
/// DOCME /// DOCME
bool isLocal; bool isLocal;
/// If true, the style was just created and so the user should not be
/// asked if they want to change any existing lines should they rename
/// the style
bool isNew;
/// DOCME /// DOCME
AssStyle *style; AssStyle *style;
@ -213,7 +218,7 @@ private:
void OnPreviewColourChange (wxCommandEvent &event); void OnPreviewColourChange (wxCommandEvent &event);
public: public:
DialogStyleEditor(wxWindow *parent,AssStyle *style,SubtitlesGrid *grid,bool local,AssStyleStorage *store); DialogStyleEditor(wxWindow *parent,AssStyle *style,SubtitlesGrid *grid,bool local,AssStyleStorage *store,bool newStyle=false);
~DialogStyleEditor(); ~DialogStyleEditor();
void Apply (bool apply,bool close); void Apply (bool apply,bool close);

View file

@ -663,7 +663,7 @@ void DialogStyleManager::OnStorageCopy (wxCommandEvent &event) {
newName += temp->name; newName += temp->name;
temp->name = newName; temp->name = newName;
DialogStyleEditor editor(this,temp,grid,false,&Store); DialogStyleEditor editor(this,temp,grid,false,&Store,true);
int modified = editor.ShowModal(); int modified = editor.ShowModal();
if (modified) { if (modified) {
Store.style.push_back(temp); Store.style.push_back(temp);
@ -689,7 +689,7 @@ void DialogStyleManager::OnCurrentCopy (wxCommandEvent &event) {
newName += temp->name; newName += temp->name;
temp->name = newName; temp->name = newName;
DialogStyleEditor editor(this,temp,grid,true,&Store); DialogStyleEditor editor(this,temp,grid,true,&Store,true);
int modified = editor.ShowModal(); int modified = editor.ShowModal();
if (modified) { if (modified) {
AssFile::top->InsertStyle(temp); AssFile::top->InsertStyle(temp);
@ -812,7 +812,7 @@ void DialogStyleManager::PasteToStorage() {
void DialogStyleManager::OnStorageNew (wxCommandEvent &event) { void DialogStyleManager::OnStorageNew (wxCommandEvent &event) {
AssStyle *temp = new AssStyle; AssStyle *temp = new AssStyle;
DialogStyleEditor editor(this,temp,grid,false,&Store); DialogStyleEditor editor(this,temp,grid,false,&Store,true);
int modified = editor.ShowModal(); int modified = editor.ShowModal();
if (modified) { if (modified) {
Store.style.push_back(temp); Store.style.push_back(temp);
@ -831,7 +831,7 @@ void DialogStyleManager::OnStorageNew (wxCommandEvent &event) {
void DialogStyleManager::OnCurrentNew (wxCommandEvent &event) { void DialogStyleManager::OnCurrentNew (wxCommandEvent &event) {
AssStyle *temp = new AssStyle; AssStyle *temp = new AssStyle;
DialogStyleEditor editor(this,temp,grid,true,&Store); DialogStyleEditor editor(this,temp,grid,true,&Store,true);
int modified = editor.ShowModal(); int modified = editor.ShowModal();
if (modified) { if (modified) {
AssFile::top->InsertStyle(temp); AssFile::top->InsertStyle(temp);