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

updatePalette();
ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
ui->saProfileContent->setFilesMode(true);
ui->saProfileContent->setFilesDropEnabled(true);
ui->saProfileContent->setImageDropEnabled(true);

// Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close"))
@@ -1411,7 +1412,15 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
{
if (!mimeData) return;
importUrls(mimeData);
if (mimeData->hasImage())
{
QImage *snapmaticImage = new QImage(qvariant_cast<QImage>(mimeData->imageData()));
importImage(snapmaticImage, QDateTime::currentDateTime());
}
else if (mimeData->hasUrls())
{
importUrls(mimeData);
}
}

void ProfileInterface::retranslateUi()

+ 16
- 6
uimod/UiModWidget.cpp View File

@@ -26,26 +26,32 @@

UiModWidget::UiModWidget(QWidget *parent) : QWidget(parent)
{
filesMode = false;
filesDropEnabled = false;
imageDropEnabled = false;
}

UiModWidget::~UiModWidget()
{
}

void UiModWidget::setFilesMode(bool filesModeEnabled)
void UiModWidget::setFilesDropEnabled(bool enabled)
{
filesMode = filesModeEnabled;
filesDropEnabled = enabled;
}

void UiModWidget::setImageDropEnabled(bool enabled)
{
imageDropEnabled = enabled;
}

void UiModWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
{
if (filesMode && dragEnterEvent->mimeData()->hasUrls())
if (filesDropEnabled && dragEnterEvent->mimeData()->hasUrls())
{
QStringList pathList;
QList<QUrl> urlList = dragEnterEvent->mimeData()->urls();
const QList<QUrl> urlList = dragEnterEvent->mimeData()->urls();

foreach(const QUrl &currentUrl, urlList)
for (const QUrl &currentUrl : urlList)
{
if (currentUrl.isLocalFile())
{
@@ -58,6 +64,10 @@ void UiModWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
dragEnterEvent->acceptProposedAction();
}
}
else if (imageDropEnabled && dragEnterEvent->mimeData()->hasImage())
{
dragEnterEvent->acceptProposedAction();
}
}

void UiModWidget::dropEvent(QDropEvent *dropEvent)

+ 4
- 2
uimod/UiModWidget.h View File

@@ -29,7 +29,8 @@ class UiModWidget : public QWidget
Q_OBJECT
public:
UiModWidget(QWidget *parent = 0);
void setFilesMode(bool enabled);
void setFilesDropEnabled(bool enabled);
void setImageDropEnabled(bool enabled);
~UiModWidget();

protected:
@@ -38,7 +39,8 @@ protected:
void paintEvent(QPaintEvent *paintEvent);

private:
bool filesMode;
bool filesDropEnabled;
bool imageDropEnabled;

signals:
void dropped(const QMimeData *mimeData);

Loading…
Cancel
Save