diff --git a/app/core.cpp b/app/core.cpp index 1b85ae09a..5f00a7b69 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -368,7 +368,7 @@ void Core::DialogImportShow() void Core::DialogPreferencesShow() { - PreferencesDialog pd(main_window_, main_window_->menuBar()); + PreferencesDialog pd(main_window_); pd.exec(); } diff --git a/app/dialog/configbase/configdialogbase.cpp b/app/dialog/configbase/configdialogbase.cpp index 2bd7db4e0..13bbafbb5 100644 --- a/app/dialog/configbase/configdialogbase.cpp +++ b/app/dialog/configbase/configdialogbase.cpp @@ -73,11 +73,9 @@ void ConfigDialogBase::accept() tab->Accept(command); } - if (command->child_count() == 0) { - delete command; - } else { - Core::instance()->undo_stack()->push(command); - } + Core::instance()->undo_stack()->pushIfHasChildren(command); + + AcceptEvent(); QDialog::accept(); } diff --git a/app/dialog/configbase/configdialogbase.h b/app/dialog/configbase/configdialogbase.h index 57266562e..35592175e 100644 --- a/app/dialog/configbase/configdialogbase.h +++ b/app/dialog/configbase/configdialogbase.h @@ -44,6 +44,8 @@ private slots: protected: void AddTab(ConfigDialogBaseTab* tab, const QString& title); + virtual void AcceptEvent(){} + private: QListWidget* list_widget_; diff --git a/app/dialog/preferences/preferences.cpp b/app/dialog/preferences/preferences.cpp index 6b2c9d04a..5777e929d 100644 --- a/app/dialog/preferences/preferences.cpp +++ b/app/dialog/preferences/preferences.cpp @@ -32,11 +32,12 @@ #include "tabs/preferencesdisktab.h" #include "tabs/preferencesaudiotab.h" #include "tabs/preferenceskeyboardtab.h" +#include "window/mainwindow/mainwindow.h" namespace olive { -PreferencesDialog::PreferencesDialog(QWidget *parent, QMenuBar* main_menu_bar) : - ConfigDialogBase(parent) +PreferencesDialog::PreferencesDialog(MainWindow *main_window) : + ConfigDialogBase(main_window) { setWindowTitle(tr("Preferences")); @@ -45,7 +46,12 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, QMenuBar* main_menu_bar) : AddTab(new PreferencesBehaviorTab(), tr("Behavior")); AddTab(new PreferencesDiskTab(), tr("Disk")); AddTab(new PreferencesAudioTab(), tr("Audio")); - AddTab(new PreferencesKeyboardTab(main_menu_bar), tr("Keyboard")); + AddTab(new PreferencesKeyboardTab(main_window), tr("Keyboard")); +} + +void PreferencesDialog::AcceptEvent() +{ + Config::Save(); } } diff --git a/app/dialog/preferences/preferences.h b/app/dialog/preferences/preferences.h index c6ec2b5a6..87cdb7266 100644 --- a/app/dialog/preferences/preferences.h +++ b/app/dialog/preferences/preferences.h @@ -32,25 +32,22 @@ namespace olive { +class MainWindow; + /** * @brief The PreferencesDialog class * - * A dialog for the global application settings. Mostly an interface for Config. Can be loaded from any part of the - * application. + * A dialog for the global application settings. Mostly an interface for Config. */ class PreferencesDialog : public ConfigDialogBase { Q_OBJECT public: - /** - * @brief PreferencesDialog Constructor - * - * @param parent - * - * QWidget parent. Usually MainWindow. - */ - PreferencesDialog(QWidget *parent, QMenuBar* main_menu_bar); + PreferencesDialog(MainWindow *main_window); + +protected: + virtual void AcceptEvent() override; }; diff --git a/app/dialog/preferences/tabs/preferenceskeyboardtab.cpp b/app/dialog/preferences/tabs/preferenceskeyboardtab.cpp index d1eaa7823..37eab5abc 100644 --- a/app/dialog/preferences/tabs/preferenceskeyboardtab.cpp +++ b/app/dialog/preferences/tabs/preferenceskeyboardtab.cpp @@ -27,9 +27,12 @@ #include #include +#include "window/mainwindow/mainwindow.h" + namespace olive { -PreferencesKeyboardTab::PreferencesKeyboardTab(QMenuBar *menubar) +PreferencesKeyboardTab::PreferencesKeyboardTab(MainWindow *main_window) : + main_window_(main_window) { QVBoxLayout* shortcut_layout = new QVBoxLayout(this); @@ -67,7 +70,7 @@ PreferencesKeyboardTab::PreferencesKeyboardTab(QMenuBar *menubar) shortcut_layout->addLayout(reset_shortcut_layout); - setup_kbd_shortcuts(menubar); + setup_kbd_shortcuts(main_window_->menuBar()); } void PreferencesKeyboardTab::Accept(MultiUndoCommand *command) @@ -78,6 +81,8 @@ void PreferencesKeyboardTab::Accept(MultiUndoCommand *command) for (int i=0;iset_action_shortcut(); } + + main_window_->SaveLayout(); } void PreferencesKeyboardTab::setup_kbd_shortcuts(QMenuBar* menubar) { diff --git a/app/dialog/preferences/tabs/preferenceskeyboardtab.h b/app/dialog/preferences/tabs/preferenceskeyboardtab.h index 9df2bdfb9..f66e61f57 100644 --- a/app/dialog/preferences/tabs/preferenceskeyboardtab.h +++ b/app/dialog/preferences/tabs/preferenceskeyboardtab.h @@ -29,11 +29,13 @@ namespace olive { +class MainWindow; + class PreferencesKeyboardTab : public ConfigDialogBaseTab { Q_OBJECT public: - PreferencesKeyboardTab(QMenuBar* menubar); + PreferencesKeyboardTab(MainWindow* main_window); virtual void Accept(MultiUndoCommand* command) override; @@ -132,6 +134,9 @@ private: * key_shortcut_actions and key_shortcut_fields) */ QVector key_shortcut_fields_; + + MainWindow *main_window_; + }; }