forked from qt-creator/qt-creator
QmakePM: Respect editor settings when adding files to project
If the user wants to indent with tabs, then consider that when adding source files via the UI. But try not to mix: If the respective variable already uses a different indentation consistently, then keep using that one. Fixes: QTCREATORBUG-8016 Change-Id: I037c9ac4d4e7fbbe5753a846e57d938bbb440d6a Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -36,10 +36,14 @@
|
||||
#include <coreplugin/iversioncontrol.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
#include <cpptools/cpptoolsconstants.h>
|
||||
#include <projectexplorer/editorconfiguration.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qtsupport/profilereader.h>
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/filesystemwatcher.h>
|
||||
@@ -378,6 +382,19 @@ void QmakePriFile::watchFolders(const QSet<FileName> &folders)
|
||||
m_watchedFolders = folderStrings;
|
||||
}
|
||||
|
||||
QString QmakePriFile::continuationIndent() const
|
||||
{
|
||||
const EditorConfiguration *editorConf = project()->editorConfiguration();
|
||||
const TextEditor::TabSettings &tabSettings = editorConf->useGlobalSettings()
|
||||
? TextEditor::TextEditorSettings::codeStyle()->tabSettings()
|
||||
: editorConf->codeStyle()->tabSettings();
|
||||
if (tabSettings.m_continuationAlignBehavior == TextEditor::TabSettings::ContinuationAlignWithIndent
|
||||
&& tabSettings.m_tabPolicy == TextEditor::TabSettings::TabsOnlyTabPolicy) {
|
||||
return QString("\t");
|
||||
}
|
||||
return QString(tabSettings.m_indentSize, ' ');
|
||||
}
|
||||
|
||||
bool QmakePriFile::knowsFile(const FileName &filePath) const
|
||||
{
|
||||
return m_recursiveEnumerateFiles.contains(filePath);
|
||||
@@ -747,7 +764,8 @@ bool QmakePriFile::renameFile(const QString &oldName,
|
||||
|
||||
ProWriter::addFiles(includeFile, &lines,
|
||||
QStringList(newName),
|
||||
varNameForAdding(mimeType));
|
||||
varNameForAdding(mimeType),
|
||||
continuationIndent());
|
||||
if (mode == Change::Save)
|
||||
save(lines);
|
||||
includeFile->deref();
|
||||
@@ -777,7 +795,8 @@ void QmakePriFile::changeFiles(const QString &mimeType,
|
||||
|
||||
if (change == AddToProFile) {
|
||||
// Use the first variable for adding.
|
||||
ProWriter::addFiles(includeFile, &lines, filePaths, varNameForAdding(mimeType));
|
||||
ProWriter::addFiles(includeFile, &lines, filePaths, varNameForAdding(mimeType),
|
||||
continuationIndent());
|
||||
notChanged->clear();
|
||||
} else { // RemoveFromProFile
|
||||
QDir priFileDir = QDir(m_qmakeProFile->directoryPath().toString());
|
||||
@@ -818,7 +837,7 @@ bool QmakePriFile::setProVariable(const QString &var, const QStringList &values,
|
||||
|
||||
ProWriter::putVarValues(includeFile, &lines, values, var,
|
||||
ProWriter::PutFlags(flags),
|
||||
scope);
|
||||
scope, continuationIndent());
|
||||
|
||||
save(lines);
|
||||
includeFile->deref();
|
||||
|
||||
Reference in New Issue
Block a user