Browse Source

add ability to drop images

tags/1.6.0
Syping 1 year ago
parent
commit
81ea0490cf
3 changed files with 31 additions and 10 deletions
  1. 11
    2
      ProfileInterface.cpp
  2. 16
    6
      uimod/UiModWidget.cpp
  3. 4
    2
      uimod/UiModWidget.h

+ 11
- 2
ProfileInterface.cpp View File

@@ -88,7 +88,8 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
88 88
 
89 89
     updatePalette();
90 90
     ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
91
-    ui->saProfileContent->setFilesMode(true);
91
+    ui->saProfileContent->setFilesDropEnabled(true);
92
+    ui->saProfileContent->setImageDropEnabled(true);
92 93
 
93 94
     // Set Icon for Close Button
94 95
     if (QIcon::hasThemeIcon("dialog-close"))
@@ -1411,7 +1412,15 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
1411 1412
 void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
1412 1413
 {
1413 1414
     if (!mimeData) return;
1414
-    importUrls(mimeData);
1415
+    if (mimeData->hasImage())
1416
+    {
1417
+        QImage *snapmaticImage = new QImage(qvariant_cast<QImage>(mimeData->imageData()));
1418
+        importImage(snapmaticImage, QDateTime::currentDateTime());
1419
+    }
1420
+    else if (mimeData->hasUrls())
1421
+    {
1422
+        importUrls(mimeData);
1423
+    }
1415 1424
 }
1416 1425
 
1417 1426
 void ProfileInterface::retranslateUi()

+ 16
- 6
uimod/UiModWidget.cpp View File

@@ -26,26 +26,32 @@
26 26
 
27 27
 UiModWidget::UiModWidget(QWidget *parent) : QWidget(parent)
28 28
 {
29
-    filesMode = false;
29
+    filesDropEnabled = false;
30
+    imageDropEnabled = false;
30 31
 }
31 32
 
32 33
 UiModWidget::~UiModWidget()
33 34
 {
34 35
 }
35 36
 
36
-void UiModWidget::setFilesMode(bool filesModeEnabled)
37
+void UiModWidget::setFilesDropEnabled(bool enabled)
37 38
 {
38
-    filesMode = filesModeEnabled;
39
+    filesDropEnabled = enabled;
40
+}
41
+
42
+void UiModWidget::setImageDropEnabled(bool enabled)
43
+{
44
+    imageDropEnabled = enabled;
39 45
 }
40 46
 
41 47
 void UiModWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
42 48
 {
43
-    if (filesMode && dragEnterEvent->mimeData()->hasUrls())
49
+    if (filesDropEnabled && dragEnterEvent->mimeData()->hasUrls())
44 50
     {
45 51
         QStringList pathList;
46
-        QList<QUrl> urlList = dragEnterEvent->mimeData()->urls();
52
+        const QList<QUrl> urlList = dragEnterEvent->mimeData()->urls();
47 53
 
48
-        foreach(const QUrl &currentUrl, urlList)
54
+        for (const QUrl &currentUrl : urlList)
49 55
         {
50 56
             if (currentUrl.isLocalFile())
51 57
             {
@@ -58,6 +64,10 @@ void UiModWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
58 64
             dragEnterEvent->acceptProposedAction();
59 65
         }
60 66
     }
67
+    else if (imageDropEnabled && dragEnterEvent->mimeData()->hasImage())
68
+    {
69
+        dragEnterEvent->acceptProposedAction();
70
+    }
61 71
 }
62 72
 
63 73
 void UiModWidget::dropEvent(QDropEvent *dropEvent)

+ 4
- 2
uimod/UiModWidget.h View File

@@ -29,7 +29,8 @@ class UiModWidget : public QWidget
29 29
     Q_OBJECT
30 30
 public:
31 31
     UiModWidget(QWidget *parent = 0);
32
-    void setFilesMode(bool enabled);
32
+    void setFilesDropEnabled(bool enabled);
33
+    void setImageDropEnabled(bool enabled);
33 34
     ~UiModWidget();
34 35
 
35 36
 protected:
@@ -38,7 +39,8 @@ protected:
38 39
     void paintEvent(QPaintEvent *paintEvent);
39 40
 
40 41
 private:
41
-    bool filesMode;
42
+    bool filesDropEnabled;
43
+    bool imageDropEnabled;
42 44
 
43 45
 signals:
44 46
     void dropped(const QMimeData *mimeData);

Loading…
Cancel
Save