Move remaining Porymap config settings to Preferences

This commit is contained in:
GriffinR 2023-09-11 16:54:15 -04:00
parent 30a01b7061
commit a508677b1d
6 changed files with 72 additions and 43 deletions

View file

@ -3012,9 +3012,6 @@
<property name="title">
<string>Options</string>
</property>
<addaction name="actionMonitor_Project_Files"/>
<addaction name="actionOpen_Recent_Project_On_Launch"/>
<addaction name="separator"/>
<addaction name="actionProject_Settings"/>
<addaction name="actionPreferences"/>
<addaction name="actionShortcuts"/>
@ -3064,22 +3061,6 @@
<string>Ctrl+S</string>
</property>
</action>
<action name="actionMonitor_Project_Files">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Monitor Project Files</string>
</property>
</action>
<action name="actionOpen_Recent_Project_On_Launch">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Open Recent Project On Launch</string>
</property>
</action>
<action name="action_NewMap">
<property name="text">
<string>New Map...</string>

View file

@ -18,6 +18,58 @@
<property name="spacing">
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Miscellaneous</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="checkBox_OpenRecentProject">
<property name="text">
<string>Open recent project on launch</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_MonitorProjectFiles">
<property name="text">
<string>Monitor project files</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_Themes">
<property name="sizePolicy">
@ -65,8 +117,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>582</width>
<height>372</height>
<width>570</width>
<height>322</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">

View file

@ -199,8 +199,6 @@ private slots:
void on_checkBox_AllowBiking_stateChanged(int selected);
void on_checkBox_AllowEscaping_stateChanged(int selected);
void on_spinBox_FloorNumber_valueChanged(int offset);
void on_actionMonitor_Project_Files_triggered(bool checked);
void on_actionOpen_Recent_Project_On_Launch_triggered(bool checked);
void on_actionShortcuts_triggered();
void on_actionZoom_In_triggered();

View file

@ -18,6 +18,7 @@ class PreferenceEditor : public QMainWindow
public:
explicit PreferenceEditor(QWidget *parent = nullptr);
~PreferenceEditor();
void updateFields();
signals:
void preferencesSaved();
@ -27,9 +28,10 @@ private:
Ui::PreferenceEditor *ui;
NoScrollComboBox *themeSelector;
void populateFields();
void initFields();
void saveFields();
private slots:
void dialogButtonClicked(QAbstractButton *button);
};

View file

@ -452,8 +452,6 @@ void MainWindow::loadUserSettings() {
ui->horizontalSlider_MetatileZoom->blockSignals(true);
ui->horizontalSlider_MetatileZoom->setValue(porymapConfig.getMetatilesZoom());
ui->horizontalSlider_MetatileZoom->blockSignals(false);
ui->actionMonitor_Project_Files->setChecked(porymapConfig.getMonitorFiles());
ui->actionOpen_Recent_Project_On_Launch->setChecked(porymapConfig.getReopenOnLaunch());
setTheme(porymapConfig.getTheme());
}
@ -524,8 +522,11 @@ bool MainWindow::openProject(QString dir) {
QObject::connect(editor->project, &Project::reloadProject, this, &MainWindow::on_action_Reload_Project_triggered);
QObject::connect(editor->project, &Project::mapCacheCleared, this, &MainWindow::onMapCacheCleared);
QObject::connect(editor->project, &Project::disableWildEncountersUI, [this]() { this->setWildEncountersUIEnabled(false); });
QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this]() { ui->actionMonitor_Project_Files->setChecked(false); });
on_actionMonitor_Project_Files_triggered(porymapConfig.getMonitorFiles());
QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this]() {
porymapConfig.setMonitorFiles(false);
if (this->preferenceEditor)
this->preferenceEditor->updateFields();
});
editor->project->set_root(dir);
success = loadDataStructures()
&& populateMapList()
@ -1770,16 +1771,6 @@ void MainWindow::on_actionCursor_Tile_Outline_triggered()
}
}
void MainWindow::on_actionMonitor_Project_Files_triggered(bool checked)
{
porymapConfig.setMonitorFiles(checked);
}
void MainWindow::on_actionOpen_Recent_Project_On_Launch_triggered(bool checked)
{
porymapConfig.setReopenOnLaunch(checked);
}
void MainWindow::on_actionShortcuts_triggered()
{
if (!shortcutsEditor)

View file

@ -21,7 +21,8 @@ PreferenceEditor::PreferenceEditor(QWidget *parent) :
setAttribute(Qt::WA_DeleteOnClose);
connect(ui->buttonBox, &QDialogButtonBox::clicked,
this, &PreferenceEditor::dialogButtonClicked);
populateFields();
initFields();
updateFields();
}
PreferenceEditor::~PreferenceEditor()
@ -29,7 +30,7 @@ PreferenceEditor::~PreferenceEditor()
delete ui;
}
void PreferenceEditor::populateFields() {
void PreferenceEditor::initFields() {
QStringList themes = { "default" };
static const QRegularExpression re(":/themes/([A-z0-9_-]+).qss");
QDirIterator it(":/themes", QDirIterator::Subdirectories);
@ -38,11 +39,14 @@ void PreferenceEditor::populateFields() {
themes.append(themeName);
}
themeSelector->addItems(themes);
}
void PreferenceEditor::updateFields() {
themeSelector->setCurrentText(porymapConfig.getTheme());
ui->lineEdit_TextEditorOpenFolder->setText(porymapConfig.getTextEditorOpenFolder());
ui->lineEdit_TextEditorGotoLine->setText(porymapConfig.getTextEditorGotoLine());
ui->checkBox_MonitorProjectFiles->setChecked(porymapConfig.getMonitorFiles());
ui->checkBox_OpenRecentProject->setChecked(porymapConfig.getReopenOnLaunch());
}
void PreferenceEditor::saveFields() {
@ -53,8 +57,9 @@ void PreferenceEditor::saveFields() {
}
porymapConfig.setTextEditorOpenFolder(ui->lineEdit_TextEditorOpenFolder->text());
porymapConfig.setTextEditorGotoLine(ui->lineEdit_TextEditorGotoLine->text());
porymapConfig.setMonitorFiles(ui->checkBox_MonitorProjectFiles->isChecked());
porymapConfig.setReopenOnLaunch(ui->checkBox_OpenRecentProject->isChecked());
emit preferencesSaved();
}