Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
swirl 2022-02-02 11:17:04 -05:00
commit 407f9d9ef0
No known key found for this signature in database
GPG Key ID: 46507311CD292A08
5 changed files with 68 additions and 3 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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(

View File

@ -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();

View File

@ -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>