Save last clicked tab in NewFileDialog

This commit is contained in:
xarkes 2018-07-07 10:47:46 +02:00
parent c0fe9e2c3f
commit b222aaa094
4 changed files with 33 additions and 2 deletions

View File

@ -63,9 +63,8 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
ui->logoSvgWidget->load(Config()->getLogoFile()); ui->logoSvgWidget->load(Config()->getLogoFile());
fillRecentFilesList(); fillRecentFilesList();
bool projectsExist = fillProjectsList();
if (projectsExist) { if (Config()->getNewFileLastClicked() == TAB_PROJECTS) {
ui->tabWidget->setCurrentWidget(ui->projectsTab); ui->tabWidget->setCurrentWidget(ui->projectsTab);
} else { } else {
ui->tabWidget->setCurrentWidget(ui->filesTab); ui->tabWidget->setCurrentWidget(ui->filesTab);
@ -340,3 +339,8 @@ void NewFileDialog::loadProject(const QString &project)
close(); close();
} }
void NewFileDialog::on_tabWidget_currentChanged(int index)
{
Config()->setNewFileLastClicked(index);
}

View File

@ -16,6 +16,7 @@ class NewFileDialog : public QDialog
public: public:
explicit NewFileDialog(QWidget *parent = nullptr); explicit NewFileDialog(QWidget *parent = nullptr);
~NewFileDialog(); ~NewFileDialog();
enum newFileTabs { TAB_FILES = 0, TAB_PROJECTS };
private slots: private slots:
void on_loadFileButton_clicked(); void on_loadFileButton_clicked();
@ -36,6 +37,8 @@ private slots:
void on_actionClear_all_triggered(); void on_actionClear_all_triggered();
void on_actionRemove_project_triggered(); void on_actionRemove_project_triggered();
void on_tabWidget_currentChanged(int index);
protected: protected:
void dragEnterEvent(QDragEnterEvent *event); void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event); void dropEvent(QDropEvent *event);

View File

@ -74,6 +74,21 @@ void Configuration::setDirProjects(const QString &dir)
s.setValue("dir.projects", 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() void Configuration::resetAll()
{ {
Core()->cmd("e-"); Core()->cmd("e-");
@ -292,6 +307,12 @@ QString Configuration::getConfigString(const QString &key)
return getConfigVar(key).toString(); 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) void Configuration::setConfig(const QString &key, const QVariant &value)
{ {
if (asmOptions.contains(key)) { if (asmOptions.contains(key)) {

View File

@ -51,6 +51,9 @@ public:
QString getDirProjects(); QString getDirProjects();
void setDirProjects(const QString& dir); void setDirProjects(const QString& dir);
void setNewFileLastClicked(int lastClicked);
int getNewFileLastClicked();
// Images // Images
QString getLogoFile(); QString getLogoFile();