Add dir.projects cutter setting (#416)

This commit is contained in:
David Roman 2018-03-25 18:58:34 +02:00 committed by xarkes
parent 0ecc0ed113
commit 87ee023235
4 changed files with 31 additions and 4 deletions

View File

@ -98,7 +98,8 @@ void NewFileDialog::on_selectProjectsDirButton_clicked()
QFileDialog dialog(this); QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::DirectoryOnly); dialog.setFileMode(QFileDialog::DirectoryOnly);
QString currentDir = CutterCore::getInstance()->getConfig("dir.projects"); auto currentDir = Config()->getDirProjects();
if (currentDir.startsWith("~")) { if (currentDir.startsWith("~")) {
currentDir = QDir::homePath() + currentDir.mid(1); currentDir = QDir::homePath() + currentDir.mid(1);
} }
@ -112,7 +113,7 @@ void NewFileDialog::on_selectProjectsDirButton_clicked()
QString dir = dialog.selectedFiles().first(); QString dir = dialog.selectedFiles().first();
if (!dir.isEmpty()) { if (!dir.isEmpty()) {
CutterCore::getInstance()->setConfig("dir.projects", dir); Config()->setDirProjects(dir);
fillProjectsList(); fillProjectsList();
} }
} }
@ -161,6 +162,9 @@ void NewFileDialog::on_actionRemove_item_triggered()
// Remove selected item from recents list // Remove selected item from recents list
QListWidgetItem *item = ui->recentsListWidget->currentItem(); QListWidgetItem *item = ui->recentsListWidget->currentItem();
if (item == nullptr)
return;
QVariant data = item->data(Qt::UserRole); QVariant data = item->data(Qt::UserRole);
QString sitem = data.toString(); QString sitem = data.toString();
@ -251,7 +255,9 @@ bool NewFileDialog::fillProjectsList()
{ {
CutterCore *core = CutterCore::getInstance(); CutterCore *core = CutterCore::getInstance();
ui->projectsDirEdit->setText(core->getConfig("dir.projects")); auto currentDir = Config()->getDirProjects();
ui->projectsDirEdit->setText(currentDir);
QStringList projects = core->getProjectNames(); QStringList projects = core->getProjectNames();
projects.sort(Qt::CaseInsensitive); projects.sort(Qt::CaseInsensitive);

View File

@ -5,6 +5,7 @@
#include "SaveProjectDialog.h" #include "SaveProjectDialog.h"
#include "ui_SaveProjectDialog.h" #include "ui_SaveProjectDialog.h"
#include "utils/TempConfig.h" #include "utils/TempConfig.h"
#include "utils/Configuration.h"
SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) : SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -24,7 +25,7 @@ SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) :
} }
ui->nameEdit->setText(core->getConfig("prj.name")); ui->nameEdit->setText(core->getConfig("prj.name"));
ui->projectsDirEdit->setText(core->getConfig("dir.projects")); ui->projectsDirEdit->setText(Config()->getDirProjects());
ui->simpleCheckBox->setChecked(core->getConfigb("prj.simple")); ui->simpleCheckBox->setChecked(core->getConfigb("prj.simple"));
ui->filesCheckBox->setChecked(core->getConfigb("prj.files")); ui->filesCheckBox->setChecked(core->getConfigb("prj.files"));
ui->gitCheckBox->setChecked(core->getConfigb("prj.git")); ui->gitCheckBox->setChecked(core->getConfigb("prj.git"));

View File

@ -58,6 +58,23 @@ void Configuration::loadInitial()
applySavedAsmOptions(); applySavedAsmOptions();
} }
QString Configuration::getDirProjects()
{
auto projectsDir = s.value("dir.projects").toString();
if (projectsDir == "") {
projectsDir = Core()->getConfig("dir.projects");
setDirProjects(projectsDir);
}
return projectsDir;
}
void Configuration::setDirProjects(const QString &dir)
{
Core()->setConfig("dir.projects", dir);
s.setValue("dir.projects", dir);
}
void Configuration::resetAll() void Configuration::resetAll()
{ {
Core()->cmd("e-"); Core()->cmd("e-");

View File

@ -47,6 +47,9 @@ public:
return s.value("dark").toBool(); return s.value("dark").toBool();
} }
QString getDirProjects();
void setDirProjects(const QString& dir);
// Images // Images
QString getLogoFile(); QString getLogoFile();