diff --git a/BUILD.md b/BUILD.md index 84e5b34f..0c2bdd63 100644 --- a/BUILD.md +++ b/BUILD.md @@ -25,7 +25,6 @@ The rest of the documentation assumes you have already cloned the repository. Getting the project to build and run on Linux is easy if you use any modern and up-to-date linux distribution. ## Build dependencies - - A C++ compiler capable of building C++11 code. - Qt Development tools 5.6 or newer (`qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5` on Debian-based system) - cmake 3.1 or newer (`cmake` on Debian-based system) @@ -116,7 +115,7 @@ The path to the rpm packages will be printed when the build is complete. ### Building a flatpak -You only need to clone the flatpak sources +You only need to clone the flatpak sources `flatpak` and `flatpak-builder` need to be installed on your system ```sh diff --git a/README.md b/README.md index d6ee4e26..c422b3ae 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,6 @@ If you want to contribute to PolyMC you might find it useful to join our Discord If you want to build PolyMC yourself, check [BUILD.md](BUILD.md) for build instructions. ## Code formatting - Just follow the existing formatting. In general, in order of importance: 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(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 @@ false + + @@ -74,6 +76,22 @@ View Folder + + + Copy Image + + + Copy Image + + + + + Copy File(s) + + + Copy File(s) + +