Commit 18bbf484 authored by twanvl's avatar twanvl

Open sets in a new window.

 TODO: don't allow the same set file to be opened twice, fork a window for it instead
parent caa50107
......@@ -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)
......
......@@ -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;
......
......@@ -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&) {
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment