add ability to drop images
This commit is contained in:
parent
a8db3985a2
commit
81ea0490cf
3 changed files with 31 additions and 10 deletions
|
@ -88,7 +88,8 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
|
||||||
|
|
||||||
updatePalette();
|
updatePalette();
|
||||||
ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
|
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
|
// Set Icon for Close Button
|
||||||
if (QIcon::hasThemeIcon("dialog-close"))
|
if (QIcon::hasThemeIcon("dialog-close"))
|
||||||
|
@ -1411,7 +1412,15 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
|
||||||
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
|
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
|
||||||
{
|
{
|
||||||
if (!mimeData) return;
|
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()
|
void ProfileInterface::retranslateUi()
|
||||||
|
|
|
@ -26,26 +26,32 @@
|
||||||
|
|
||||||
UiModWidget::UiModWidget(QWidget *parent) : QWidget(parent)
|
UiModWidget::UiModWidget(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
filesMode = false;
|
filesDropEnabled = false;
|
||||||
|
imageDropEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UiModWidget::~UiModWidget()
|
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)
|
void UiModWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
|
||||||
{
|
{
|
||||||
if (filesMode && dragEnterEvent->mimeData()->hasUrls())
|
if (filesDropEnabled && dragEnterEvent->mimeData()->hasUrls())
|
||||||
{
|
{
|
||||||
QStringList pathList;
|
QStringList pathList;
|
||||||
QList<QUrl> urlList = dragEnterEvent->mimeData()->urls();
|
const QList<QUrl> urlList = dragEnterEvent->mimeData()->urls();
|
||||||
|
|
||||||
foreach(const QUrl ¤tUrl, urlList)
|
for (const QUrl ¤tUrl : urlList)
|
||||||
{
|
{
|
||||||
if (currentUrl.isLocalFile())
|
if (currentUrl.isLocalFile())
|
||||||
{
|
{
|
||||||
|
@ -58,6 +64,10 @@ void UiModWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
|
||||||
dragEnterEvent->acceptProposedAction();
|
dragEnterEvent->acceptProposedAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (imageDropEnabled && dragEnterEvent->mimeData()->hasImage())
|
||||||
|
{
|
||||||
|
dragEnterEvent->acceptProposedAction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UiModWidget::dropEvent(QDropEvent *dropEvent)
|
void UiModWidget::dropEvent(QDropEvent *dropEvent)
|
||||||
|
|
|
@ -29,7 +29,8 @@ class UiModWidget : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
UiModWidget(QWidget *parent = 0);
|
UiModWidget(QWidget *parent = 0);
|
||||||
void setFilesMode(bool enabled);
|
void setFilesDropEnabled(bool enabled);
|
||||||
|
void setImageDropEnabled(bool enabled);
|
||||||
~UiModWidget();
|
~UiModWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -38,7 +39,8 @@ protected:
|
||||||
void paintEvent(QPaintEvent *paintEvent);
|
void paintEvent(QPaintEvent *paintEvent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool filesMode;
|
bool filesDropEnabled;
|
||||||
|
bool imageDropEnabled;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dropped(const QMimeData *mimeData);
|
void dropped(const QMimeData *mimeData);
|
||||||
|
|
Loading…
Reference in a new issue