config: save on preferences dialog accept

This commit is contained in:
itsmattkc
2022-05-14 15:02:32 -07:00
parent c75ee6014c
commit 8853665187
7 changed files with 35 additions and 22 deletions
+1 -1
View File
@@ -368,7 +368,7 @@ void Core::DialogImportShow()
void Core::DialogPreferencesShow()
{
PreferencesDialog pd(main_window_, main_window_->menuBar());
PreferencesDialog pd(main_window_);
pd.exec();
}
+3 -5
View File
@@ -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();
}
+2
View File
@@ -44,6 +44,8 @@ private slots:
protected:
void AddTab(ConfigDialogBaseTab* tab, const QString& title);
virtual void AcceptEvent(){}
private:
QListWidget* list_widget_;
+9 -3
View File
@@ -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();
}
}
+7 -10
View File
@@ -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;
};
@@ -27,9 +27,12 @@
#include <QPushButton>
#include <QVBoxLayout>
#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;i<key_shortcut_fields_.size();i++) {
key_shortcut_fields_.at(i)->set_action_shortcut();
}
main_window_->SaveLayout();
}
void PreferencesKeyboardTab::setup_kbd_shortcuts(QMenuBar* menubar) {
@@ -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<KeySequenceEditor*> key_shortcut_fields_;
MainWindow *main_window_;
};
}