From 4f0ff7b63a9d9126a98c484d4aa19ba19e7e17f5 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 20 Jan 2022 21:09:24 +0000 Subject: [PATCH] Show devices dock panel when not passing --devices --- src/gui/mainwindow.cpp | 16 ++++++++++++++++ src/gui/mainwindow.h | 7 +++++++ src/main.cpp | 2 ++ src/partitionmanager.kcfg | 3 +++ 4 files changed, 28 insertions(+) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 45b6993..52b0a44 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -118,13 +118,29 @@ void MainWindow::setupObjectNames() void MainWindow::setDisallowOtherDevices() { + // We need to store that we are hiding this for this session only + // but only if it's currently visible (ie, the user didn't selected + // that it should be hidden on purpose. + if (m_DockDevices->isVisible() == true) { + Config::self()->setHideDeviceDockWidgetByCmdArgs(true); + } + // because of how Qt works, the user still can enable the // dock widget via a mouse click, so we need to also set it to disabled. // so that the user doesn't select it by mistake. + m_DockDevices->setVisible(false); m_DockDevices->setEnabled(false); } +void MainWindow::showDevicePanelIfPreviouslyHiddenByDisallowOtherDevices() +{ + if (Config::self()->hideDeviceDockWidgetByCmdArgs()) { + m_DockDevices->setVisible(true); + Config::self()->setHideDeviceDockWidgetByCmdArgs(false); + } +} + void MainWindow::init() { treeLog().init(); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index fea5189..f6b691d 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -57,6 +57,13 @@ public: // clicking in the UI. void setDisallowOtherDevices(); + // disallowOtherDevices hides the DockWidget, but unfortunately + // this is saved by the Window State when restored, even if we + // are not disallowing it this time. At the same time the user + // could have hidden it, so we need to restore only if hidden + // just by the call to disallowOtherDevices(). + void showDevicePanelIfPreviouslyHiddenByDisallowOtherDevices(); + Q_SIGNALS: void settingsChanged(); void scanFinished(); diff --git a/src/main.cpp b/src/main.cpp index c984096..a155a9d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -132,6 +132,8 @@ int Q_DECL_IMPORT main(int argc, char* argv[]) mainWindow->setCurrentPartitionByName(selectedDevice); } mainWindow->setDisallowOtherDevices(); + } else { + mainWindow->showDevicePanelIfPreviouslyHiddenByDisallowOtherDevices(); } }); diff --git a/src/partitionmanager.kcfg b/src/partitionmanager.kcfg index 73b37d5..f4d1b1d 100644 --- a/src/partitionmanager.kcfg +++ b/src/partitionmanager.kcfg @@ -167,5 +167,8 @@ SPDX-License-Identifier: GPL-3.0-or-later random + + false +