NOISSUE Added Copy File(s) feature for the screenshot page

- Ctrl+C now copies the file instead of the image data
- Renamed Copy to Copy Image
This commit is contained in:
Ghosty 2021-12-03 16:08:11 +01:00
parent 75f2dab3c8
commit e9c52ec696
3 changed files with 37 additions and 7 deletions

View File

@ -252,7 +252,7 @@ bool ScreenshotsPage::eventFilter(QObject *obj, QEvent *evt)
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(evt); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(evt);
if (keyEvent->matches(QKeySequence::Copy)) { if (keyEvent->matches(QKeySequence::Copy)) {
on_actionCopy_triggered(); on_actionCopy_File_s_triggered();
return true; return true;
} }
@ -378,7 +378,7 @@ void ScreenshotsPage::on_actionUpload_triggered()
m_uploadActive = false; m_uploadActive = false;
} }
void ScreenshotsPage::on_actionCopy_triggered() void ScreenshotsPage::on_actionCopy_Image_triggered()
{ {
auto selection = ui->listView->selectionModel()->selectedRows(); auto selection = ui->listView->selectionModel()->selectedRows();
if(selection.size() < 1) if(selection.size() < 1)
@ -394,6 +394,26 @@ void ScreenshotsPage::on_actionCopy_triggered()
QApplication::clipboard()->setImage(image, QClipboard::Clipboard); 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() void ScreenshotsPage::on_actionDelete_triggered()
{ {
auto mbox = CustomMessageBox::selectable( auto mbox = CustomMessageBox::selectable(

View File

@ -73,7 +73,8 @@ protected:
private slots: private slots:
void on_actionUpload_triggered(); void on_actionUpload_triggered();
void on_actionCopy_triggered(); void on_actionCopy_Image_triggered();
void on_actionCopy_File_s_triggered();
void on_actionDelete_triggered(); void on_actionDelete_triggered();
void on_actionRename_triggered(); void on_actionRename_triggered();
void on_actionView_Folder_triggered(); void on_actionView_Folder_triggered();

View File

@ -50,7 +50,8 @@
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<addaction name="actionUpload"/> <addaction name="actionUpload"/>
<addaction name="actionCopy"/> <addaction name="actionCopy_Image"/>
<addaction name="actionCopy_File_s"/>
<addaction name="actionDelete"/> <addaction name="actionDelete"/>
<addaction name="actionRename"/> <addaction name="actionRename"/>
<addaction name="actionView_Folder"/> <addaction name="actionView_Folder"/>
@ -75,12 +76,20 @@
<string>View Folder</string> <string>View Folder</string>
</property> </property>
</action> </action>
<action name="actionCopy"> <action name="actionCopy_Image">
<property name="text"> <property name="text">
<string>Copy</string> <string>Copy Image</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Copy</string> <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> </property>
</action> </action>
</widget> </widget>