forked from qt-creator/qt-creator
Dropping project blocks other programs (like file explorer).
We have to delay or drop event handling, so the Qt code that delivers the event can return control. The commit also prevents dropping another file while we are currently already handling a drop. Task-number: QTCREATORBUG-3344
This commit is contained in:
@@ -401,7 +401,7 @@ static bool isDesktopFileManagerDrop(const QMimeData *d, QStringList *files = 0)
|
||||
|
||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (isDesktopFileManagerDrop(event->mimeData())) {
|
||||
if (isDesktopFileManagerDrop(event->mimeData()) && m_filesToOpenDelayed.isEmpty()) {
|
||||
event->accept();
|
||||
} else {
|
||||
event->ignore();
|
||||
@@ -413,12 +413,23 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||
QStringList files;
|
||||
if (isDesktopFileManagerDrop(event->mimeData(), &files)) {
|
||||
event->accept();
|
||||
openFiles(files, ICore::SwitchMode);
|
||||
m_filesToOpenDelayed.append(files);
|
||||
QTimer::singleShot(50, this, SLOT(openDelayedFiles()));
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::openDelayedFiles()
|
||||
{
|
||||
if (m_filesToOpenDelayed.isEmpty())
|
||||
return;
|
||||
activateWindow();
|
||||
raise();
|
||||
openFiles(m_filesToOpenDelayed, ICore::SwitchMode);
|
||||
m_filesToOpenDelayed.clear();
|
||||
}
|
||||
|
||||
IContext *MainWindow::currentContextObject() const
|
||||
{
|
||||
return m_activeContext;
|
||||
|
||||
@@ -161,6 +161,7 @@ private slots:
|
||||
void updateFocusWidget(QWidget *old, QWidget *now);
|
||||
void setSidebarVisible(bool visible);
|
||||
void destroyVersionDialog();
|
||||
void openDelayedFiles();
|
||||
|
||||
private:
|
||||
void updateContextObject(IContext *context);
|
||||
@@ -222,6 +223,8 @@ private:
|
||||
|
||||
QToolButton *m_toggleSideBarButton;
|
||||
QColor m_overrideColor;
|
||||
|
||||
QStringList m_filesToOpenDelayed;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user