Compare commits

...

3 Commits

Author SHA1 Message Date
Andrius Štikonas bb6cd82f6d Fix a comment. 2022-01-22 01:05:38 +00:00
Tomaz Canabrava 4f0ff7b63a Show devices dock panel when not passing --devices 2022-01-22 01:03:28 +00:00
Tomaz Canabrava 90f6cb74d2 Blocks the user to select a different device if --device is specified
So the user can't select a different device by mistake.
2022-01-22 01:03:28 +00:00
4 changed files with 45 additions and 0 deletions

View File

@ -116,6 +116,31 @@ void MainWindow::setupObjectNames()
m_ScanProgressDialog->setObjectName(QStringLiteral("m_ScanProgressDialog"));
}
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 select
// 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

@ -50,6 +50,20 @@ public:
void setCurrentPartitionByName(const QString& partitionNumber);
// forbids the user to select another device.
// this is used in conjunction with --device
// rationale is that if the user specifies a device,
// we can't allow him to select another one by mistake while
// 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

@ -131,6 +131,9 @@ int Q_DECL_IMPORT main(int argc, char* argv[])
if (partitionNr.length()) {
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>