Merge pull request #471 from DanielSvoboda/Copy_submenu
Copy info - submenu
This commit is contained in:
commit
360b7e1d71
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QClipboard>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
@ -53,6 +54,18 @@ public:
|
||||||
menu.addAction(&openSfoViewer);
|
menu.addAction(&openSfoViewer);
|
||||||
menu.addAction(&openTrophyViewer);
|
menu.addAction(&openTrophyViewer);
|
||||||
|
|
||||||
|
// "Copy" submenu.
|
||||||
|
QMenu* copyMenu = new QMenu("Copy info", widget);
|
||||||
|
QAction* copyName = new QAction("Copy Name", widget);
|
||||||
|
QAction* copySerial = new QAction("Copy Serial", widget);
|
||||||
|
QAction* copyNameAll = new QAction("Copy All", widget);
|
||||||
|
|
||||||
|
copyMenu->addAction(copyName);
|
||||||
|
copyMenu->addAction(copySerial);
|
||||||
|
copyMenu->addAction(copyNameAll);
|
||||||
|
|
||||||
|
menu.addMenu(copyMenu);
|
||||||
|
|
||||||
// Show menu.
|
// Show menu.
|
||||||
auto selected = menu.exec(global_pos);
|
auto selected = menu.exec(global_pos);
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
|
@ -191,6 +204,27 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle the "Copy" actions
|
||||||
|
if (selected == copyName) {
|
||||||
|
QClipboard* clipboard = QGuiApplication::clipboard();
|
||||||
|
clipboard->setText(QString::fromStdString(m_games[itemID].name));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected == copySerial) {
|
||||||
|
QClipboard* clipboard = QGuiApplication::clipboard();
|
||||||
|
clipboard->setText(QString::fromStdString(m_games[itemID].serial));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected == copyNameAll) {
|
||||||
|
QClipboard* clipboard = QGuiApplication::clipboard();
|
||||||
|
QString combinedText = QString("Name:%1 | Serial:%2 | Version:%3 | Size:%4")
|
||||||
|
.arg(QString::fromStdString(m_games[itemID].name))
|
||||||
|
.arg(QString::fromStdString(m_games[itemID].serial))
|
||||||
|
.arg(QString::fromStdString(m_games[itemID].version))
|
||||||
|
.arg(QString::fromStdString(m_games[itemID].size));
|
||||||
|
clipboard->setText(combinedText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetRowIndex(QTreeWidget* treeWidget, QTreeWidgetItem* item) {
|
int GetRowIndex(QTreeWidget* treeWidget, QTreeWidgetItem* item) {
|
||||||
|
|
Loading…
Reference in New Issue