add a select device submenu to the device menu
svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1128594
This commit is contained in:
parent
d8d7b82862
commit
696b368463
|
@ -621,6 +621,48 @@ void MainWindow::on_m_DeviceScanner_finished()
|
|||
// first device
|
||||
if (!listDevices().setSelectedDevice(savedSelectedDeviceNode()) && !operationStack().previewDevices().isEmpty())
|
||||
listDevices().setSelectedDevice(operationStack().previewDevices()[0]->deviceNode());
|
||||
|
||||
updateSeletedDeviceMenu();
|
||||
}
|
||||
|
||||
void MainWindow::updateSeletedDeviceMenu()
|
||||
{
|
||||
KMenu* devicesMenu = static_cast<KMenu*>(guiFactory()->container("selectedDevice", this));
|
||||
devicesMenu->clear();
|
||||
|
||||
devicesMenu->setEnabled(!operationStack().previewDevices().isEmpty());
|
||||
|
||||
foreach(const Device* d, operationStack().previewDevices())
|
||||
{
|
||||
QAction* action = new QAction(d->prettyName(), devicesMenu);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(d->deviceNode() == pmWidget().selectedDevice()->deviceNode());
|
||||
action->setData(d->deviceNode());
|
||||
connect(action, SIGNAL(triggered(bool)), SLOT(onSelectedDeviceMenuTriggered(bool)));
|
||||
devicesMenu->addAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onSelectedDeviceMenuTriggered(bool)
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
KMenu* devicesMenu = static_cast<KMenu*>(guiFactory()->container("selectedDevice", this));
|
||||
|
||||
if (action == NULL || action->parent() != devicesMenu)
|
||||
return;
|
||||
|
||||
foreach (QAction* entry, qFindChildren<QAction*>(devicesMenu))
|
||||
entry->setChecked(entry == action);
|
||||
|
||||
listDevices().setSelectedDevice(action->data().toString());
|
||||
}
|
||||
|
||||
void MainWindow::on_m_ListDevices_selectionChanged(const QString& device_node)
|
||||
{
|
||||
KMenu* devicesMenu = static_cast<KMenu*>(guiFactory()->container("selectedDevice", this));
|
||||
|
||||
foreach (QAction* entry, qFindChildren<QAction*>(devicesMenu))
|
||||
entry->setChecked(entry->data().toString() == device_node);
|
||||
}
|
||||
|
||||
void MainWindow::onRefreshDevices()
|
||||
|
|
|
@ -65,6 +65,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
|
|||
void loadConfig();
|
||||
void saveConfig() const;
|
||||
void updateWindowTitle();
|
||||
void updateSeletedDeviceMenu();
|
||||
|
||||
void enableActions();
|
||||
|
||||
|
@ -139,6 +140,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
|
|||
void on_m_ApplyProgressDialog_finished();
|
||||
|
||||
void on_m_ListDevices_contextMenuRequested(const QPoint& pos);
|
||||
void on_m_ListDevices_selectionChanged(const QString& device_node);
|
||||
|
||||
void on_m_TreeLog_contextMenuRequested(const QPoint& pos);
|
||||
void on_m_ListOperations_contextMenuRequested(const QPoint& pos);
|
||||
|
@ -163,6 +165,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
|
|||
|
||||
void onSmartStatusDevice();
|
||||
void onPropertiesDevice(const QString& device_node = QString());
|
||||
void onSelectedDeviceMenuTriggered(bool);
|
||||
|
||||
private:
|
||||
KActionCollection* m_ActionCollection;
|
||||
|
|
|
@ -44,6 +44,10 @@
|
|||
</Menu>
|
||||
<Menu name="device">
|
||||
<text context="@title:menu">Device</text>
|
||||
<Menu name="selectedDevice">
|
||||
<text context="@title:menu">Select Current Device</text>
|
||||
</Menu>
|
||||
<separator/>
|
||||
<Action name="createNewPartitionTable"/>
|
||||
<separator/>
|
||||
<Action name="exportPartitionTable"/>
|
||||
|
|
Loading…
Reference in New Issue