Commit 00caec3e authored by dt's avatar dt
Browse files

Mode switching: On drag & drop, on remote opening, on Open Files

Readd a few mode switchings that I accidentally removed.

Task-Nr: QTCREATORBUG-2405
parent b92004bb
...@@ -228,9 +228,9 @@ void CoreImpl::removeContextObject(IContext *context) ...@@ -228,9 +228,9 @@ void CoreImpl::removeContextObject(IContext *context)
m_mainwindow->removeContextObject(context); m_mainwindow->removeContextObject(context);
} }
void CoreImpl::openFiles(const QStringList &arguments) void CoreImpl::openFiles(const QStringList &arguments, bool switchMode)
{ {
m_mainwindow->openFiles(arguments); m_mainwindow->openFiles(arguments, switchMode);
} }
void CoreImpl::emitNewItemsDialogRequested() void CoreImpl::emitNewItemsDialogRequested()
......
...@@ -88,7 +88,7 @@ public: ...@@ -88,7 +88,7 @@ public:
void addContextObject(IContext *context); void addContextObject(IContext *context);
void removeContextObject(IContext *context); void removeContextObject(IContext *context);
void openFiles(const QStringList &fileNames); void openFiles(const QStringList &fileNames, bool switchMode);
void emitNewItemsDialogRequested(); void emitNewItemsDialogRequested();
......
...@@ -100,7 +100,7 @@ void CorePlugin::extensionsInitialized() ...@@ -100,7 +100,7 @@ void CorePlugin::extensionsInitialized()
void CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args) void CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args)
{ {
m_mainWindow->openFiles(args); m_mainWindow->openFiles(args, true);
m_mainWindow->activateWindow(); m_mainWindow->activateWindow();
} }
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
virtual void addContextObject(IContext *context) = 0; virtual void addContextObject(IContext *context) = 0;
virtual void removeContextObject(IContext *context) = 0; virtual void removeContextObject(IContext *context) = 0;
virtual void openFiles(const QStringList &fileNames) = 0; virtual void openFiles(const QStringList &fileNames, bool switchMode) = 0;
signals: signals:
void coreAboutToOpen(); void coreAboutToOpen();
......
...@@ -416,7 +416,7 @@ void MainWindow::dropEvent(QDropEvent *event) ...@@ -416,7 +416,7 @@ void MainWindow::dropEvent(QDropEvent *event)
QStringList files; QStringList files;
if (isDesktopFileManagerDrop(event->mimeData(), &files)) { if (isDesktopFileManagerDrop(event->mimeData(), &files)) {
event->accept(); event->accept();
openFiles(files); openFiles(files, true);
} else { } else {
event->ignore(); event->ignore();
} }
...@@ -793,7 +793,7 @@ void MainWindow::newFile() ...@@ -793,7 +793,7 @@ void MainWindow::newFile()
void MainWindow::openFile() void MainWindow::openFile()
{ {
openFiles(editorManager()->getOpenFileNames()); openFiles(editorManager()->getOpenFileNames(), true);
} }
static QList<IFileFactory*> getNonEditorFileFactories() static QList<IFileFactory*> getNonEditorFileFactories()
...@@ -823,7 +823,7 @@ static IFileFactory *findFileFactory(const QList<IFileFactory*> &fileFactories, ...@@ -823,7 +823,7 @@ static IFileFactory *findFileFactory(const QList<IFileFactory*> &fileFactories,
} }
// opens either an editor or loads a project // opens either an editor or loads a project
void MainWindow::openFiles(const QStringList &fileNames) void MainWindow::openFiles(const QStringList &fileNames, bool switchMode)
{ {
QList<IFileFactory*> nonEditorFileFactories = getNonEditorFileFactories(); QList<IFileFactory*> nonEditorFileFactories = getNonEditorFileFactories();
...@@ -832,8 +832,13 @@ void MainWindow::openFiles(const QStringList &fileNames) ...@@ -832,8 +832,13 @@ void MainWindow::openFiles(const QStringList &fileNames)
const QString absoluteFilePath = fi.absoluteFilePath(); const QString absoluteFilePath = fi.absoluteFilePath();
if (IFileFactory *fileFactory = findFileFactory(nonEditorFileFactories, mimeDatabase(), fi)) { if (IFileFactory *fileFactory = findFileFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
fileFactory->open(absoluteFilePath); fileFactory->open(absoluteFilePath);
if (switchMode)
Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
} else { } else {
editorManager()->openEditor(absoluteFilePath); EditorManager::OpenEditorFlag flags;
if (switchMode)
flags = EditorManager::ModeSwitch;
editorManager()->openEditor(absoluteFilePath, QString(), flags);
} }
} }
} }
......
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
void removeContextObject(IContext *contex); void removeContextObject(IContext *contex);
void resetContext(); void resetContext();
void openFiles(const QStringList &fileNames); void openFiles(const QStringList &fileNames, bool switchMode);
Core::ActionManager *actionManager() const; Core::ActionManager *actionManager() const;
Core::FileManager *fileManager() const; Core::FileManager *fileManager() const;
......
...@@ -1240,7 +1240,7 @@ void ProjectExplorerPlugin::restoreSession() ...@@ -1240,7 +1240,7 @@ void ProjectExplorerPlugin::restoreSession()
connect(d->m_welcomePage, SIGNAL(requestSession(QString)), this, SLOT(loadSession(QString))); connect(d->m_welcomePage, SIGNAL(requestSession(QString)), this, SLOT(loadSession(QString)));
connect(d->m_welcomePage, SIGNAL(requestProject(QString)), this, SLOT(loadProject(QString))); connect(d->m_welcomePage, SIGNAL(requestProject(QString)), this, SLOT(loadProject(QString)));
Core::ICore::instance()->openFiles(arguments); Core::ICore::instance()->openFiles(arguments, false);
updateActions(); updateActions();
} }
...@@ -2375,7 +2375,7 @@ void ProjectExplorerPlugin::openOpenProjectDialog() ...@@ -2375,7 +2375,7 @@ void ProjectExplorerPlugin::openOpenProjectDialog()
const QString path = fileMananger->useProjectsDirectory() ? fileMananger->projectsDirectory() : QString(); const QString path = fileMananger->useProjectsDirectory() ? fileMananger->projectsDirectory() : QString();
const QStringList files = fileMananger->getOpenFileNames(filters, path, &projectFilesFilter); const QStringList files = fileMananger->getOpenFileNames(filters, path, &projectFilesFilter);
if (!files.isEmpty()) if (!files.isEmpty())
Core::ICore::instance()->openFiles(files); Core::ICore::instance()->openFiles(files, true);
} }
Q_EXPORT_PLUGIN(ProjectExplorerPlugin) Q_EXPORT_PLUGIN(ProjectExplorerPlugin)
...@@ -335,7 +335,7 @@ void GettingStartedWelcomePageWidget::slotOpenExample() ...@@ -335,7 +335,7 @@ void GettingStartedWelcomePageWidget::slotOpenExample()
tryFile = proFileInfo.path() + '/' + proFileInfo.baseName() + ".qml"; tryFile = proFileInfo.path() + '/' + proFileInfo.baseName() + ".qml";
if(QFile::exists(tryFile)) if(QFile::exists(tryFile))
files << tryFile; files << tryFile;
Core::ICore::instance()->openFiles(files); Core::ICore::instance()->openFiles(files, true);
if (!helpFile.isEmpty()) if (!helpFile.isEmpty())
slotOpenContextHelpPage(helpFile); slotOpenContextHelpPage(helpFile);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment