Show devices dock panel when not passing --devices

This commit is contained in:
Tomaz Canabrava 2022-01-20 21:09:24 +00:00 committed by Andrius Štikonas
parent 90f6cb74d2
commit 4f0ff7b63a
4 changed files with 28 additions and 0 deletions

View File

@ -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();

View File

@ -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();

View File

@ -132,6 +132,8 @@ int Q_DECL_IMPORT main(int argc, char* argv[])
mainWindow->setCurrentPartitionByName(selectedDevice);
}
mainWindow->setDisallowOtherDevices();
} else {
mainWindow->showDevicePanelIfPreviouslyHiddenByDisallowOtherDevices();
}
});

View File

@ -167,5 +167,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
</choices>
<default>random</default>
</entry>
<entry key="hideDeviceDockWidgetByCmdArgs" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>