forked from qt-creator/qt-creator
ClangFormat: Fix UI issues
- 'Default' values remain so after save/load - the language is fixed to C++ - the project settings are shown correctly - fix parsing configuration file - do not trigger slots when we fill the table Change-Id: I91b477721b5084803324cd38d0cfeb9d5650dd9f Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -318,6 +318,32 @@ clang::format::FormatStyle styleForFile(Utils::FileName fileName)
|
||||
return styleForFile(fileName, true);
|
||||
}
|
||||
|
||||
static std::string readFile(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
clang::format::FormatStyle defaultStyle = qtcStyle();
|
||||
return clang::format::configurationAsText(defaultStyle);
|
||||
}
|
||||
|
||||
const QByteArray content = file.readAll();
|
||||
file.close();
|
||||
|
||||
return content.toStdString();
|
||||
}
|
||||
|
||||
std::string currentProjectConfigText()
|
||||
{
|
||||
const QString configPath = projectPath().appendPath(Constants::SETTINGS_FILE_NAME).toString();
|
||||
return readFile(configPath);
|
||||
}
|
||||
|
||||
std::string currentGlobalConfigText()
|
||||
{
|
||||
const QString configPath = globalPath().appendPath(Constants::SETTINGS_FILE_NAME).toString();
|
||||
return readFile(configPath);
|
||||
}
|
||||
|
||||
clang::format::FormatStyle currentProjectStyle()
|
||||
{
|
||||
return styleForFile(projectPath().appendPath(Constants::SAMPLE_FILE_NAME), false);
|
||||
|
||||
Reference in New Issue
Block a user