aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/coreplugin/editormanager/editormanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/coreplugin/editormanager/editormanager.cpp')
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 1ec3a0cf93..afb4404878 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -52,7 +52,6 @@
#include <coreplugin/find/searchresultitem.h>
#include <coreplugin/icore.h>
#include <coreplugin/imode.h>
-#include <coreplugin/infobar.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/outputpane.h>
@@ -68,6 +67,7 @@
#include <utils/executeondestruction.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
+#include <utils/infobar.h>
#include <utils/macroexpander.h>
#include <utils/mimetypes/mimedatabase.h>
#include <utils/mimetypes/mimetype.h>
@@ -173,7 +173,9 @@ void EditorManagerPlaceHolder::showEvent(QShowEvent *)
/*!
\class Core::EditorManager
+ \inheaderfile coreplugin/editormanager/editormanager.h
\inmodule QtCreator
+
\brief The EditorManager class manages the editors created for files
according to their MIME type.
@@ -609,7 +611,7 @@ bool EditorManagerPrivate::skipOpeningBigTextFile(const QString &filePath)
.arg(fileInfo.fileName())
.arg(fileSizeInMB, 0, 'f', 2);
- CheckableMessageBox messageBox(ICore::mainWindow());
+ CheckableMessageBox messageBox(ICore::dialogParent());
messageBox.setWindowTitle(title);
messageBox.setText(text);
messageBox.setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::No);
@@ -738,7 +740,11 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
.arg(FilePath::fromString(realFn).toUserOutput());
}
- QMessageBox msgbox(QMessageBox::Critical, EditorManager::tr("File Error"), errorString, QMessageBox::Open | QMessageBox::Cancel, ICore::mainWindow());
+ QMessageBox msgbox(QMessageBox::Critical,
+ EditorManager::tr("File Error"),
+ errorString,
+ QMessageBox::Open | QMessageBox::Cancel,
+ ICore::dialogParent());
IEditorFactory *selectedFactory = nullptr;
if (!factories.isEmpty()) {
@@ -801,7 +807,7 @@ IEditor *EditorManagerPrivate::openEditorAt(EditorView *view, const QString &fil
return editor;
}
-IEditor *EditorManagerPrivate::openEditorWith(const QString &fileName, Core::Id editorId)
+IEditor *EditorManagerPrivate::openEditorWith(const QString &fileName, Utils::Id editorId)
{
// close any open editors that have this file open
// remember the views to open new editors in there
@@ -872,8 +878,7 @@ MakeWritableResult EditorManagerPrivate::makeFileWritable(IDocument *document)
{
if (!document)
return Failed;
- // TODO: dialog parent is wrong
- ReadOnlyFilesDialog roDialog(document, ICore::mainWindow(), document->isSaveAsAllowed());
+ ReadOnlyFilesDialog roDialog(document, ICore::dialogParent(), document->isSaveAsAllowed());
switch (roDialog.exec()) {
case ReadOnlyFilesDialog::RO_MakeWritable:
case ReadOnlyFilesDialog::RO_OpenVCS:
@@ -1039,7 +1044,7 @@ Id EditorManagerPrivate::getOpenWithEditorId(const QString &fileName, bool *isEx
return Id();
QTC_ASSERT(allEditorIds.size() == allEditorDisplayNames.size(), return Id());
// Run dialog.
- OpenWithDialog dialog(fileName, ICore::mainWindow());
+ OpenWithDialog dialog(fileName, ICore::dialogParent());
dialog.setEditors(allEditorDisplayNames);
dialog.setCurrentEditor(0);
if (dialog.exec() != QDialog::Accepted)
@@ -2082,7 +2087,7 @@ void EditorManagerPrivate::vcsOpenCurrentEditor()
if (!versionControl->vcsOpen(document->filePath().toString())) {
// TODO: wrong dialog parent
- QMessageBox::warning(ICore::mainWindow(), tr("Cannot Open File"),
+ QMessageBox::warning(ICore::dialogParent(), tr("Cannot Open File"),
tr("Cannot open the file for editing with VCS."));
}
}
@@ -2156,7 +2161,8 @@ void EditorManagerPrivate::autoSave()
errors << errorString;
}
if (!errors.isEmpty())
- QMessageBox::critical(ICore::mainWindow(), tr("File Error"),
+ QMessageBox::critical(ICore::dialogParent(),
+ tr("File Error"),
errors.join(QLatin1Char('\n')));
emit m_instance->autoSaved();
}
@@ -2343,10 +2349,12 @@ void EditorManagerPrivate::revertToSaved(IDocument *document)
if (fileName.isEmpty())
return;
if (document->isModified()) {
- // TODO: wrong dialog parent
- QMessageBox msgBox(QMessageBox::Question, tr("Revert to Saved"),
- tr("You will lose your current changes if you proceed reverting %1.").arg(QDir::toNativeSeparators(fileName)),
- QMessageBox::Yes|QMessageBox::No, ICore::mainWindow());
+ QMessageBox msgBox(QMessageBox::Question,
+ tr("Revert to Saved"),
+ tr("You will lose your current changes if you proceed reverting %1.")
+ .arg(QDir::toNativeSeparators(fileName)),
+ QMessageBox::Yes | QMessageBox::No,
+ ICore::dialogParent());
msgBox.button(QMessageBox::Yes)->setText(tr("Proceed"));
msgBox.button(QMessageBox::No)->setText(tr("Cancel"));
@@ -2367,7 +2375,7 @@ void EditorManagerPrivate::revertToSaved(IDocument *document)
}
QString errorString;
if (!document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents))
- QMessageBox::critical(ICore::mainWindow(), tr("File Error"), errorString);
+ QMessageBox::critical(ICore::dialogParent(), tr("File Error"), errorString);
}
void EditorManagerPrivate::autoSuspendDocuments()
@@ -2397,7 +2405,8 @@ void EditorManagerPrivate::showInGraphicalShell()
{
if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty())
return;
- FileUtils::showInGraphicalShell(ICore::mainWindow(), d->m_contextMenuEntry->fileName().toString());
+ FileUtils::showInGraphicalShell(ICore::dialogParent(),
+ d->m_contextMenuEntry->fileName().toString());
}
void EditorManagerPrivate::openTerminal()
@@ -2713,7 +2722,7 @@ void EditorManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
if (anyMatches) {
// Add all suitable editors
foreach (IEditorFactory *editorFactory, factories) {
- Core::Id editorId = editorFactory->id();
+ Utils::Id editorId = editorFactory->id();
// Add action to open with this very editor factory
QString const actionTitle = editorFactory->displayName();
QAction *action = menu->addAction(actionTitle);
@@ -2729,7 +2738,7 @@ void EditorManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
// Add all suitable external editors
foreach (IExternalEditor *externalEditor, extEditors) {
QAction *action = menu->addAction(externalEditor->displayName());
- Core::Id editorId = externalEditor->id();
+ Utils::Id editorId = externalEditor->id();
connect(action, &QAction::triggered, [fileName, editorId]() {
EditorManager::openExternalEditor(fileName, editorId);
});
@@ -2983,7 +2992,7 @@ bool EditorManager::openExternalEditor(const QString &fileName, Id editorId)
const bool ok = ee->startEditor(fileName, &errorMessage);
QApplication::restoreOverrideCursor();
if (!ok)
- QMessageBox::critical(ICore::mainWindow(), tr("Opening File"), errorMessage);
+ QMessageBox::critical(ICore::dialogParent(), tr("Opening File"), errorMessage);
return ok;
}