From 0abcf205661b06157f8d4ea86c10202ea40f5a6e Mon Sep 17 00:00:00 2001 From: Jubal Date: Sun, 17 Dec 2017 08:49:03 -0500 Subject: [PATCH] Save 'Unlock Panels' and 'Show Tabs on Top' settings (#223) * 'Unlock Panels' and 'Show Tabs on Top' now saved to settings * added saveSettings method and renamed doLock to panelLock --- src/MainWindow.cpp | 97 +++++++++++++++++++++++++++++----------------- src/MainWindow.h | 7 +++- 2 files changed, 67 insertions(+), 37 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 7df66288..955c703a 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -107,7 +107,8 @@ MainWindow::MainWindow(QWidget *parent) : sectionsDock(nullptr), consoleDock(nullptr) { - doLock = false; + panelLock = false; + tabsOnTop = false; configuration = new Configuration(); } @@ -439,11 +440,7 @@ void MainWindow::closeEvent(QCloseEvent *event) { if (saveProject(true)) { - QSettings settings; - settings.setValue("geometry", saveGeometry()); - settings.setValue("size", size()); - settings.setValue("pos", pos()); - settings.setValue("state", saveState()); + saveSettings(); QMainWindow::closeEvent(event); } else @@ -453,11 +450,7 @@ void MainWindow::closeEvent(QCloseEvent *event) } else if (ret == QMessageBox::Discard) { - QSettings settings; - settings.setValue("geometry", saveGeometry()); - settings.setValue("size", size()); - settings.setValue("pos", pos()); - settings.setValue("state", saveState()); + saveSettings(); } else { @@ -473,6 +466,59 @@ void MainWindow::readSettings() QByteArray state = settings.value("state", QByteArray()).toByteArray(); restoreState(state); this->responsive = settings.value("responsive").toBool(); + panelLock = settings.value("panelLock").toBool(); + setPanelLock(); + tabsOnTop = settings.value("tabsOnTop").toBool(); + setTabLocation(); +} + +void MainWindow::saveSettings() +{ + QSettings settings; + settings.setValue("geometry", saveGeometry()); + settings.setValue("size", size()); + settings.setValue("pos", pos()); + settings.setValue("state", saveState()); + settings.setValue("panelLock", panelLock); + settings.setValue("tabsOnTop", tabsOnTop); +} + +void MainWindow::setPanelLock() +{ + if (panelLock) + { + foreach (QDockWidget *dockWidget, findChildren()) + { + dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures); + } + + ui->actionLock->setChecked(false); + } + else + { + foreach (QDockWidget *dockWidget, findChildren()) + { + dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures); + } + + ui->actionLock->setChecked(true); + } +} + +void MainWindow::setTabLocation() +{ + if (tabsOnTop) + { + ui->centralTabWidget->setTabPosition(QTabWidget::North); + this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); + ui->actionTabs_on_Top->setChecked(true); + } + else + { + ui->centralTabWidget->setTabPosition(QTabWidget::South); + this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South); + ui->actionTabs_on_Top->setChecked(false); + } } void MainWindow::setDarkTheme() @@ -493,21 +539,8 @@ void MainWindow::refreshAll() void MainWindow::on_actionLock_triggered() { - doLock = !doLock; - if (doLock) - { - foreach (QDockWidget *dockWidget, findChildren()) - { - dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures); - } - } - else - { - foreach (QDockWidget *dockWidget, findChildren()) - { - dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures); - } - } + panelLock = !panelLock; + setPanelLock(); } void MainWindow::lockUnlock_Docks(bool what) @@ -551,16 +584,8 @@ void MainWindow::on_actionLockUnlock_triggered() void MainWindow::on_actionTabs_triggered() { - if (ui->centralTabWidget->tabPosition() == QTabWidget::South) - { - ui->centralTabWidget->setTabPosition(QTabWidget::North); - this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); - } - else - { - ui->centralTabWidget->setTabPosition(QTabWidget::South); - this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South); - } + tabsOnTop = !tabsOnTop; + setTabLocation(); } void MainWindow::on_actionEntry_points_triggered() diff --git a/src/MainWindow.h b/src/MainWindow.h index 21626d44..6d06466f 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -75,6 +75,7 @@ public: void closeEvent(QCloseEvent *event) override; void readSettings(); + void saveSettings(); void setFilename(const QString &fn); void addOutput(const QString &msg); void addDebugOutput(const QString &msg); @@ -86,6 +87,9 @@ public slots: void refreshAll(); + void setPanelLock(); + void setTabLocation(); + void setDarkTheme(); void setDefaultTheme(); @@ -174,7 +178,8 @@ private: //SideBar *sideBar; Configuration *configuration; - bool doLock; + bool panelLock; + bool tabsOnTop; ut64 hexdumpTopOffset; ut64 hexdumpBottomOffset; QString filename;