Open files when they are dropped on the main window.

This commit is contained in:
Leonardo Zide 2016-10-15 12:13:31 -07:00
parent ed0e3a252f
commit 7e7e562d45
2 changed files with 18 additions and 1 deletions

View file

@ -60,7 +60,8 @@ lcMainWindow::~lcMainWindow()
void lcMainWindow::CreateWidgets() void lcMainWindow::CreateWidgets()
{ {
setWindowIcon(QIcon(":/resources/leocad.png")); setAcceptDrops(true);
setWindowIcon(QIcon(":/resources/icon64.png"));
setWindowFilePath(QString()); setWindowFilePath(QString());
CreateActions(); CreateActions();
@ -687,6 +688,20 @@ void lcMainWindow::closeEvent(QCloseEvent *event)
event->ignore(); event->ignore();
} }
void lcMainWindow::dragEnterEvent(QDragEnterEvent* Event)
{
if (Event->mimeData()->hasUrls())
Event->acceptProposedAction();
}
void lcMainWindow::dropEvent(QDropEvent* Event)
{
const QMimeData* MimeData = Event->mimeData();
foreach (const QUrl &Url, MimeData->urls())
if (OpenProject(Url.toLocalFile()))
break;
}
QMenu* lcMainWindow::createPopupMenu() QMenu* lcMainWindow::createPopupMenu()
{ {
QMenu* Menu = new QMenu(this); QMenu* Menu = new QMenu(this);

View file

@ -275,6 +275,8 @@ protected slots:
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void dragEnterEvent(QDragEnterEvent* Event);
void dropEvent(QDropEvent* Event);
QMenu* createPopupMenu(); QMenu* createPopupMenu();
void CreateActions(); void CreateActions();