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)
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()
......
......@@ -88,7 +88,7 @@ public:
void addContextObject(IContext *context);
void removeContextObject(IContext *context);
void openFiles(const QStringList &fileNames);
void openFiles(const QStringList &fileNames, bool switchMode);
void emitNewItemsDialogRequested();
......
......@@ -100,7 +100,7 @@ void CorePlugin::extensionsInitialized()
void CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args)
{
m_mainWindow->openFiles(args);
m_mainWindow->openFiles(args, true);
m_mainWindow->activateWindow();
}
......
......@@ -119,7 +119,7 @@ public:
virtual void addContextObject(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:
void coreAboutToOpen();
......
......@@ -416,7 +416,7 @@ void MainWindow::dropEvent(QDropEvent *event)
QStringList files;
if (isDesktopFileManagerDrop(event->mimeData(), &files)) {
event->accept();
openFiles(files);
openFiles(files, true);
} else {
event->ignore();
}
......@@ -793,7 +793,7 @@ void MainWindow::newFile()
void MainWindow::openFile()
{
openFiles(editorManager()->getOpenFileNames());
openFiles(editorManager()->getOpenFileNames(), true);
}
static QList<IFileFactory*> getNonEditorFileFactories()
......@@ -823,7 +823,7 @@ static IFileFactory *findFileFactory(const QList<IFileFactory*> &fileFactories,
}
// 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();
......@@ -832,8 +832,13 @@ void MainWindow::openFiles(const QStringList &fileNames)
const QString absoluteFilePath = fi.absoluteFilePath();
if (IFileFactory *fileFactory = findFileFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
fileFactory->open(absoluteFilePath);
if (switchMode)
Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
} else {
editorManager()->openEditor(absoluteFilePath);
EditorManager::OpenEditorFlag flags;
if (switchMode)
flags = EditorManager::ModeSwitch;
editorManager()->openEditor(absoluteFilePath, QString(), flags);
}
}
}
......
......@@ -97,7 +97,7 @@ public:
void removeContextObject(IContext *contex);
void resetContext();
void openFiles(const QStringList &fileNames);
void openFiles(const QStringList &fileNames, bool switchMode);
Core::ActionManager *actionManager() const;
Core::FileManager *fileManager() const;
......
......@@ -1240,7 +1240,7 @@ void ProjectExplorerPlugin::restoreSession()
connect(d->m_welcomePage, SIGNAL(requestSession(QString)), this, SLOT(loadSession(QString)));
connect(d->m_welcomePage, SIGNAL(requestProject(QString)), this, SLOT(loadProject(QString)));
Core::ICore::instance()->openFiles(arguments);
Core::ICore::instance()->openFiles(arguments, false);
updateActions();
}
......@@ -2375,7 +2375,7 @@ void ProjectExplorerPlugin::openOpenProjectDialog()
const QString path = fileMananger->useProjectsDirectory() ? fileMananger->projectsDirectory() : QString();
const QStringList files = fileMananger->getOpenFileNames(filters, path, &projectFilesFilter);
if (!files.isEmpty())
Core::ICore::instance()->openFiles(files);
Core::ICore::instance()->openFiles(files, true);
}
Q_EXPORT_PLUGIN(ProjectExplorerPlugin)
......@@ -335,7 +335,7 @@ void GettingStartedWelcomePageWidget::slotOpenExample()
tryFile = proFileInfo.path() + '/' + proFileInfo.baseName() + ".qml";
if(QFile::exists(tryFile))
files << tryFile;
Core::ICore::instance()->openFiles(files);
Core::ICore::instance()->openFiles(files, true);
if (!helpFile.isEmpty())
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