diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 8747b299..181a65e6 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -150,6 +150,7 @@ Settings::Settings() , set_window_width (790) , set_window_height (300) , card_notes_height (40) + , open_sets_in_new_window(true) , symbol_grid_size (30) , symbol_grid (true) , symbol_grid_snap (false) diff --git a/src/data/settings.hpp b/src/data/settings.hpp index 3acb8e0b..66db6c61 100644 --- a/src/data/settings.hpp +++ b/src/data/settings.hpp @@ -129,11 +129,12 @@ class Settings { /// Add a file to the list of recent files void addRecentFile(const String& filename); - // --------------------------------------------------- : Set window size + // --------------------------------------------------- : Set window bool set_window_maximized; UInt set_window_width; UInt set_window_height; UInt card_notes_height; + bool open_sets_in_new_window; // --------------------------------------------------- : Symbol editor UInt symbol_grid_size; diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 2a721feb..5ad9c3d7 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -368,6 +368,16 @@ bool SetWindow::askSaveAndContinue() { } } +void SetWindow::switchSet(const SetP& new_set) { + if (new_set) { + if (settings.open_sets_in_new_window) { + (new SetWindow(nullptr, new_set))->Show(); + } else { + setSet(new_set); + } + } +} + // ----------------------------------------------------------------------------- : Window events - update UI void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) { @@ -439,18 +449,19 @@ void SetWindow::updateRecentSets() { void SetWindow::onFileNew(wxCommandEvent&) { - if (isOnlyWithSet() && !askSaveAndContinue()) return; + if (!settings.open_sets_in_new_window && isOnlyWithSet() && !askSaveAndContinue()) return; // new set? SetP new_set = new_set_window(this); - if (new_set) setSet(new_set); + switchSet(new_set); } void SetWindow::onFileOpen(wxCommandEvent&) { - if (isOnlyWithSet() && !askSaveAndContinue()) return; + if (!settings.open_sets_in_new_window && isOnlyWithSet() && !askSaveAndContinue()) return; wxFileDialog dlg(this, _TITLE_("open set"), _(""), _(""), import_formats(), wxOPEN); if (dlg.ShowModal() == wxID_OK) { wxBusyCursor busy; - setSet(import_set(dlg.GetPath())); + SetP new_set = import_set(dlg.GetPath()); + switchSet(new_set); } } @@ -579,7 +590,7 @@ void SetWindow::onFileReload(wxCommandEvent&) { void SetWindow::onFileRecent(wxCommandEvent& ev) { wxBusyCursor busy; - setSet(import_set(settings.recent_sets.at(ev.GetId() - ID_FILE_RECENT))); + switchSet(import_set(settings.recent_sets.at(ev.GetId() - ID_FILE_RECENT))); } void SetWindow::onFileExit(wxCommandEvent&) { diff --git a/src/gui/set/window.hpp b/src/gui/set/window.hpp index 380f0dfa..d79e16b1 100644 --- a/src/gui/set/window.hpp +++ b/src/gui/set/window.hpp @@ -66,6 +66,9 @@ class SetWindow : public wxFrame, public SetView { /// Is this the only window that has this set? bool isOnlyWithSet(); + /// Switch this window to the new set, or open another window for it (depending on the settings) + void switchSet(const SetP& new_set); + // --------------------------------------------------- : Action related protected: /// We want to respond to set changes