Merge pull request #5979 from lemondrops/manager-5
Manager: Machine list context menu tweaks
This commit is contained in:
@@ -114,41 +114,6 @@ VMManagerMain::VMManagerMain(QWidget *parent) :
|
||||
});
|
||||
nameChangeAction.setEnabled(!selected_sysconfig->window_obscured);
|
||||
|
||||
QAction openSystemFolderAction(tr("&Open folder..."));
|
||||
contextMenu.addAction(&openSystemFolderAction);
|
||||
connect(&openSystemFolderAction, &QAction::triggered, [indexAt] {
|
||||
if (const auto configDir = indexAt.data(VMManagerModel::Roles::ConfigDir).toString(); !configDir.isEmpty()) {
|
||||
QDir dir(configDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
|
||||
QAction openPrinterFolderAction(tr("Open &printer tray..."));
|
||||
contextMenu.addAction(&openPrinterFolderAction);
|
||||
connect(&openPrinterFolderAction, &QAction::triggered, [indexAt] {
|
||||
if (const auto printerDir = indexAt.data(VMManagerModel::Roles::ConfigDir).toString() + QString("/printer/"); !printerDir.isEmpty()) {
|
||||
QDir dir(printerDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
|
||||
QAction openScreenshotsFolderAction(tr("Open screenshots &folder..."));
|
||||
contextMenu.addAction(&openScreenshotsFolderAction);
|
||||
connect(&openScreenshotsFolderAction, &QAction::triggered, [indexAt] {
|
||||
if (const auto screenshotsDir = indexAt.data(VMManagerModel::Roles::ConfigDir).toString() + QString("/screenshots/"); !screenshotsDir.isEmpty()) {
|
||||
QDir dir(screenshotsDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
|
||||
QAction setSystemIcon(tr("Set &icon..."));
|
||||
contextMenu.addAction(&setSystemIcon);
|
||||
@@ -162,6 +127,8 @@ VMManagerMain::VMManagerMain(QWidget *parent) :
|
||||
});
|
||||
setSystemIcon.setEnabled(!selected_sysconfig->window_obscured);
|
||||
|
||||
contextMenu.addSeparator();
|
||||
|
||||
QAction cloneMachine(tr("C&lone..."));
|
||||
contextMenu.addAction(&cloneMachine);
|
||||
connect(&cloneMachine, &QAction::triggered, [this] {
|
||||
@@ -325,6 +292,42 @@ illegal_chars:
|
||||
|
||||
contextMenu.addSeparator();
|
||||
|
||||
QAction openSystemFolderAction(tr("&Open folder..."));
|
||||
contextMenu.addAction(&openSystemFolderAction);
|
||||
connect(&openSystemFolderAction, &QAction::triggered, [indexAt] {
|
||||
if (const auto configDir = indexAt.data(VMManagerModel::Roles::ConfigDir).toString(); !configDir.isEmpty()) {
|
||||
QDir dir(configDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
|
||||
QAction openPrinterFolderAction(tr("Open &printer tray..."));
|
||||
contextMenu.addAction(&openPrinterFolderAction);
|
||||
connect(&openPrinterFolderAction, &QAction::triggered, [indexAt] {
|
||||
if (const auto printerDir = indexAt.data(VMManagerModel::Roles::ConfigDir).toString() + QString("/printer/"); !printerDir.isEmpty()) {
|
||||
QDir dir(printerDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
|
||||
QAction openScreenshotsFolderAction(tr("Open screenshots &folder..."));
|
||||
contextMenu.addAction(&openScreenshotsFolderAction);
|
||||
connect(&openScreenshotsFolderAction, &QAction::triggered, [indexAt] {
|
||||
if (const auto screenshotsDir = indexAt.data(VMManagerModel::Roles::ConfigDir).toString() + QString("/screenshots/"); !screenshotsDir.isEmpty()) {
|
||||
QDir dir(screenshotsDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
|
||||
QAction showRawConfigFile(tr("Show &config file"));
|
||||
contextMenu.addAction(&showRawConfigFile);
|
||||
connect(&showRawConfigFile, &QAction::triggered, [this, indexAt] {
|
||||
@@ -333,6 +336,14 @@ illegal_chars:
|
||||
}
|
||||
});
|
||||
|
||||
contextMenu.exec(ui->listView->viewport()->mapToGlobal(pos));
|
||||
} else {
|
||||
QMenu contextMenu(tr("Context Menu"), ui->listView);
|
||||
|
||||
QAction newMachineAction(tr("New machine..."));
|
||||
contextMenu.addAction(&newMachineAction);
|
||||
connect(&newMachineAction, &QAction::triggered, this, &VMManagerMain::newMachineWizard);
|
||||
|
||||
contextMenu.exec(ui->listView->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user