From b222aaa09431e58d05277d94613073a14cd9a4f6 Mon Sep 17 00:00:00 2001 From: xarkes Date: Sat, 7 Jul 2018 10:47:46 +0200 Subject: [PATCH] Save last clicked tab in NewFileDialog --- src/dialogs/NewFileDialog.cpp | 8 ++++++-- src/dialogs/NewFileDialog.h | 3 +++ src/utils/Configuration.cpp | 21 +++++++++++++++++++++ src/utils/Configuration.h | 3 +++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index 41b26632..49248eaf 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -63,9 +63,8 @@ NewFileDialog::NewFileDialog(QWidget *parent) : ui->logoSvgWidget->load(Config()->getLogoFile()); fillRecentFilesList(); - bool projectsExist = fillProjectsList(); - if (projectsExist) { + if (Config()->getNewFileLastClicked() == TAB_PROJECTS) { ui->tabWidget->setCurrentWidget(ui->projectsTab); } else { ui->tabWidget->setCurrentWidget(ui->filesTab); @@ -340,3 +339,8 @@ void NewFileDialog::loadProject(const QString &project) close(); } + +void NewFileDialog::on_tabWidget_currentChanged(int index) +{ + Config()->setNewFileLastClicked(index); +} diff --git a/src/dialogs/NewFileDialog.h b/src/dialogs/NewFileDialog.h index 0f78f07b..bcb2dadf 100644 --- a/src/dialogs/NewFileDialog.h +++ b/src/dialogs/NewFileDialog.h @@ -16,6 +16,7 @@ class NewFileDialog : public QDialog public: explicit NewFileDialog(QWidget *parent = nullptr); ~NewFileDialog(); + enum newFileTabs { TAB_FILES = 0, TAB_PROJECTS }; private slots: void on_loadFileButton_clicked(); @@ -36,6 +37,8 @@ private slots: void on_actionClear_all_triggered(); void on_actionRemove_project_triggered(); + void on_tabWidget_currentChanged(int index); + protected: void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); diff --git a/src/utils/Configuration.cpp b/src/utils/Configuration.cpp index 0a53829a..b7759d7e 100644 --- a/src/utils/Configuration.cpp +++ b/src/utils/Configuration.cpp @@ -74,6 +74,21 @@ void Configuration::setDirProjects(const QString &dir) s.setValue("dir.projects", dir); } +/** + * @brief Configuration::setFilesTabLastClicked + * Set the new file dialog last clicked tab + * @param lastClicked + */ +void Configuration::setNewFileLastClicked(int lastClicked) +{ + s.setValue("newFileLastClicked", lastClicked); +} + +int Configuration::getNewFileLastClicked() +{ + return s.value("newFileLastClicked").toInt(); +} + void Configuration::resetAll() { Core()->cmd("e-"); @@ -292,6 +307,12 @@ QString Configuration::getConfigString(const QString &key) return getConfigVar(key).toString(); } +/** + * @brief Configuration::setConfig + * Set radare2 configuration value (e.g. "asm.lines") + * @param key + * @param value + */ void Configuration::setConfig(const QString &key, const QVariant &value) { if (asmOptions.contains(key)) { diff --git a/src/utils/Configuration.h b/src/utils/Configuration.h index 653a6d4c..c448c385 100644 --- a/src/utils/Configuration.h +++ b/src/utils/Configuration.h @@ -51,6 +51,9 @@ public: QString getDirProjects(); void setDirProjects(const QString& dir); + void setNewFileLastClicked(int lastClicked); + int getNewFileLastClicked(); + // Images QString getLogoFile();