1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 11:52:08 +01:00

Added support for drag&drop

This commit is contained in:
Martin Tůma 2016-10-04 10:16:46 +02:00
parent 09631de5a2
commit 9d90b97ba3
3 changed files with 26 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include <QLabel> #include <QLabel>
#include <QSettings> #include <QSettings>
#include <QLocale> #include <QLocale>
#include <QMimeData>
#include <QPixmapCache> #include <QPixmapCache>
#include "config.h" #include "config.h"
#include "icons.h" #include "icons.h"
@ -1173,6 +1174,28 @@ void GUI::closeEvent(QCloseEvent *event)
event->accept(); event->accept();
} }
void GUI::dragEnterEvent(QDragEnterEvent *event)
{
if (!event->mimeData()->hasUrls())
return;
if (event->proposedAction() != Qt::CopyAction)
return;
QList<QUrl> urls = event->mimeData()->urls();
for (int i = 0; i < urls.size(); i++)
if (!urls.at(i).isLocalFile())
return;
event->acceptProposedAction();
}
void GUI::dropEvent(QDropEvent *event)
{
QList<QUrl> urls = event->mimeData()->urls();
for (int i = 0; i < urls.size(); i++)
openFile(urls.at(i).toLocalFile());
}
void GUI::writeSettings() void GUI::writeSettings()
{ {
QSettings settings(APP_NAME, APP_NAME); QSettings settings(APP_NAME, APP_NAME);

View File

@ -110,6 +110,8 @@ private:
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
QToolBar *_fileToolBar; QToolBar *_fileToolBar;
QToolBar *_showToolBar; QToolBar *_showToolBar;

View File

@ -26,6 +26,7 @@ PathView::PathView(QWidget *parent)
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setRenderHints(QPainter::Antialiasing); setRenderHints(QPainter::Antialiasing);
setAcceptDrops(false);
_mapScale = new ScaleItem(); _mapScale = new ScaleItem();
_mapScale->setZValue(2.0); _mapScale->setZValue(2.0);