aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/instance/ScreenshotsPage.cpp
diff options
context:
space:
mode:
authorGhosty <ghosty141@gmail.com>2021-12-03 03:02:58 +0100
committerGhosty <ghosty141@gmail.com>2021-12-03 03:11:53 +0100
commit75f2dab3c87d9d88979553792473a5aace4c96bf (patch)
treeedda76f09432b6c6ff594e49da444d4e1cfb8b6e /launcher/ui/pages/instance/ScreenshotsPage.cpp
parentffcef673de9fe848a92d23e02a2abed8df16eb9f (diff)
downloadPrismLauncher-75f2dab3c87d9d88979553792473a5aace4c96bf.tar.gz
PrismLauncher-75f2dab3c87d9d88979553792473a5aace4c96bf.tar.bz2
PrismLauncher-75f2dab3c87d9d88979553792473a5aace4c96bf.zip
NOISSUE Implemented copy screenshots to the clipboard
- Added context-menu entry - Ctrl+C keybind works as well - If multiple screenshots are selected, only the first one gets copied
Diffstat (limited to 'launcher/ui/pages/instance/ScreenshotsPage.cpp')
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp
index 06c4379f..e391b95d 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.cpp
+++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp
@@ -250,6 +250,12 @@ bool ScreenshotsPage::eventFilter(QObject *obj, QEvent *evt)
return QWidget::eventFilter(obj, evt);
}
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(evt);
+
+ if (keyEvent->matches(QKeySequence::Copy)) {
+ on_actionCopy_triggered();
+ return true;
+ }
+
switch (keyEvent->key())
{
case Qt::Key_Delete:
@@ -372,6 +378,22 @@ void ScreenshotsPage::on_actionUpload_triggered()
m_uploadActive = false;
}
+void ScreenshotsPage::on_actionCopy_triggered()
+{
+ auto selection = ui->listView->selectionModel()->selectedRows();
+ if(selection.size() < 1)
+ {
+ return;
+ }
+
+ // You can only copy one image to the clipboard. In the case of multiple selected files, only the first one gets copied.
+ auto item = selection[0];
+ auto info = m_model->fileInfo(item);
+ QImage image(info.absoluteFilePath());
+ Q_ASSERT(!image.isNull());
+ QApplication::clipboard()->setImage(image, QClipboard::Clipboard);
+}
+
void ScreenshotsPage::on_actionDelete_triggered()
{
auto mbox = CustomMessageBox::selectable(