aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@users.noreply.github.com>2022-01-30 16:11:47 +0100
committerGitHub <noreply@github.com>2022-01-30 16:11:47 +0100
commit2cf04d034a681153896de0afef4d1282bee18c92 (patch)
tree539c0155c40968689419c8c655476be8ae746027 /launcher
parent049aafd0a16869aea9812a9aea7e111ce4201319 (diff)
parenta97d0a36f4807e082273d0f137186a5cebf6cd5d (diff)
downloadPrismLauncher-2cf04d034a681153896de0afef4d1282bee18c92.tar.gz
PrismLauncher-2cf04d034a681153896de0afef4d1282bee18c92.tar.bz2
PrismLauncher-2cf04d034a681153896de0afef4d1282bee18c92.zip
Merge pull request #4300 from Ghosty141/feature/screenshot_copy
GH-4044 Implemented copy screenshots to the clipboard
Diffstat (limited to 'launcher')
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.cpp47
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.h2
-rw-r--r--launcher/ui/pages/instance/ScreenshotsPage.ui18
3 files changed, 67 insertions, 0 deletions
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp
index f568ef0d..4011d88c 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_File_s_triggered();
+ return true;
+ }
+
switch (keyEvent->key())
{
case Qt::Key_Delete:
@@ -272,6 +278,11 @@ ScreenshotsPage::~ScreenshotsPage()
void ScreenshotsPage::ShowContextMenu(const QPoint& pos)
{
auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
+
+ if (ui->listView->selectionModel()->selectedRows().size() > 1) {
+ menu->removeAction( ui->actionCopy_Image );
+ }
+
menu->exec(ui->listView->mapToGlobal(pos));
delete menu;
}
@@ -377,6 +388,42 @@ void ScreenshotsPage::on_actionUpload_triggered()
m_uploadActive = false;
}
+void ScreenshotsPage::on_actionCopy_Image_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_actionCopy_File_s_triggered()
+{
+ auto selection = ui->listView->selectionModel()->selectedRows();
+ if(selection.size() < 1)
+ {
+ // Don't do anything so we don't empty the users clipboard
+ return;
+ }
+
+ QString buf = "";
+ for (auto item : selection)
+ {
+ auto info = m_model->fileInfo(item);
+ buf += "file:///" + info.absoluteFilePath() + "\r\n";
+ }
+ QMimeData* mimeData = new QMimeData();
+ mimeData->setData("text/uri-list", buf.toLocal8Bit());
+ QApplication::clipboard()->setMimeData(mimeData);
+}
+
void ScreenshotsPage::on_actionDelete_triggered()
{
auto mbox = CustomMessageBox::selectable(
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.h b/launcher/ui/pages/instance/ScreenshotsPage.h
index d2f44837..2a1fdeee 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.h
+++ b/launcher/ui/pages/instance/ScreenshotsPage.h
@@ -73,6 +73,8 @@ protected:
private slots:
void on_actionUpload_triggered();
+ void on_actionCopy_Image_triggered();
+ void on_actionCopy_File_s_triggered();
void on_actionDelete_triggered();
void on_actionRename_triggered();
void on_actionView_Folder_triggered();
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.ui b/launcher/ui/pages/instance/ScreenshotsPage.ui
index ec461087..2e2227a2 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.ui
+++ b/launcher/ui/pages/instance/ScreenshotsPage.ui
@@ -50,6 +50,8 @@
<bool>false</bool>
</attribute>
<addaction name="actionUpload"/>
+ <addaction name="actionCopy_Image"/>
+ <addaction name="actionCopy_File_s"/>
<addaction name="actionDelete"/>
<addaction name="actionRename"/>
<addaction name="actionView_Folder"/>
@@ -74,6 +76,22 @@
<string>View Folder</string>
</property>
</action>
+ <action name="actionCopy_Image">
+ <property name="text">
+ <string>Copy Image</string>
+ </property>
+ <property name="toolTip">
+ <string>Copy Image</string>
+ </property>
+ </action>
+ <action name="actionCopy_File_s">
+ <property name="text">
+ <string>Copy File(s)</string>
+ </property>
+ <property name="toolTip">
+ <string>Copy File(s)</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>