cmake-gui: Support non-ASCII chars on Windows with Qt6

Since commit baead1e2a8 (Encoding: Remove option to use ANSI code page
internally, 2016-11-01, v3.8.0-rc1~358^2), we always use UTF-8 strings
internally.  Using fromLocal8Bit/toLocal8Bit + QTextCodec is no longer
needed.  Convert to fromStdString/toStdString instead, which should work
both with Qt5 and Qt6.

Fixes: #23565
This commit is contained in:
Mehdi Chinoune
2022-06-09 21:19:19 +01:00
committed by Brad King
parent efbbae9705
commit 497397bd17
5 changed files with 81 additions and 105 deletions
+13 -30
View File
@@ -10,15 +10,6 @@
#include <QTranslator> #include <QTranslator>
#include <QtPlugin> #include <QtPlugin>
// FIXME(#23565): Qt6 has QTextCodec in Core5Compat, but using its
// `setCodecForLocale` does not make cmake-gui support non-ASCII chars
// on Windows. For now we only support them with Qt5. How do we support
// them with Qt6, preferably without Core5Compat?
#if defined(Q_OS_WIN) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
# include <QTextCodec>
# define CMAKE_HAVE_QTEXTCODEC
#endif
#include "cmsys/CommandLineArguments.hxx" #include "cmsys/CommandLineArguments.hxx"
#include "cmsys/Encoding.hxx" #include "cmsys/Encoding.hxx"
#include "cmsys/SystemTools.hxx" #include "cmsys/SystemTools.hxx"
@@ -133,11 +124,6 @@ int main(int argc, char** argv)
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
#ifdef CMAKE_HAVE_QTEXTCODEC
QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(utf8_codec);
#endif
// tell the cmake library where cmake is // tell the cmake library where cmake is
QDir cmExecDir(QApplication::applicationDirPath()); QDir cmExecDir(QApplication::applicationDirPath());
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
@@ -146,7 +132,7 @@ int main(int argc, char** argv)
// pick up translation files if they exists in the data directory // pick up translation files if they exists in the data directory
QDir translationsDir = cmExecDir; QDir translationsDir = cmExecDir;
translationsDir.cd(QString::fromLocal8Bit(".." CMAKE_DATA_DIR)); translationsDir.cd(".." CMAKE_DATA_DIR);
translationsDir.cd("i18n"); translationsDir.cd("i18n");
QTranslator translator; QTranslator translator;
if (translator.load(QLocale(), "cmake", "_", translationsDir.path())) { if (translator.load(QLocale(), "cmake", "_", translationsDir.path())) {
@@ -185,8 +171,7 @@ int main(int argc, char** argv)
} }
} }
sourceDirectory = sourceDirectory = cmSystemTools::CollapseFullPath(path.toStdString());
cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
cmSystemTools::ConvertToUnixSlashes(sourceDirectory); cmSystemTools::ConvertToUnixSlashes(sourceDirectory);
} else if (arg.startsWith("-B")) { } else if (arg.startsWith("-B")) {
QString path = arg.mid(2); QString path = arg.mid(2);
@@ -203,8 +188,7 @@ int main(int argc, char** argv)
} }
} }
binaryDirectory = binaryDirectory = cmSystemTools::CollapseFullPath(path.toStdString());
cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
cmSystemTools::ConvertToUnixSlashes(binaryDirectory); cmSystemTools::ConvertToUnixSlashes(binaryDirectory);
} else if (arg.startsWith("--preset=")) { } else if (arg.startsWith("--preset=")) {
QString preset = arg.mid(cmStrLen("--preset=")); QString preset = arg.mid(cmStrLen("--preset="));
@@ -212,7 +196,7 @@ int main(int argc, char** argv)
std::cerr << "No preset specified for --preset" << std::endl; std::cerr << "No preset specified for --preset" << std::endl;
return 1; return 1;
} }
presetName = preset.toLocal8Bit().data(); presetName = preset.toStdString();
} else if (arg == "--browse-manual") { } else if (arg == "--browse-manual") {
OpenReferenceManual(); OpenReferenceManual();
return 0; return 0;
@@ -220,21 +204,20 @@ int main(int argc, char** argv)
} }
if (!sourceDirectory.empty() && if (!sourceDirectory.empty() &&
(!binaryDirectory.empty() || !presetName.empty())) { (!binaryDirectory.empty() || !presetName.empty())) {
dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str())); dialog.setSourceDirectory(QString::fromStdString(sourceDirectory));
if (!binaryDirectory.empty()) { if (!binaryDirectory.empty()) {
dialog.setBinaryDirectory( dialog.setBinaryDirectory(QString::fromStdString(binaryDirectory));
QString::fromLocal8Bit(binaryDirectory.c_str()));
if (!presetName.empty()) { if (!presetName.empty()) {
dialog.setStartupBinaryDirectory(true); dialog.setStartupBinaryDirectory(true);
} }
} }
if (!presetName.empty()) { if (!presetName.empty()) {
dialog.setDeferredPreset(QString::fromLocal8Bit(presetName.c_str())); dialog.setDeferredPreset(QString::fromStdString(presetName));
} }
} else { } else {
if (args.count() == 2) { if (args.count() == 2) {
std::string filePath = std::string filePath =
cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data()); cmSystemTools::CollapseFullPath(args[1].toStdString());
// check if argument is a directory containing CMakeCache.txt // check if argument is a directory containing CMakeCache.txt
std::string buildFilePath = cmStrCat(filePath, "/CMakeCache.txt"); std::string buildFilePath = cmStrCat(filePath, "/CMakeCache.txt");
@@ -249,12 +232,12 @@ int main(int argc, char** argv)
std::string srcFilePath = cmStrCat(filePath, "/CMakeLists.txt"); std::string srcFilePath = cmStrCat(filePath, "/CMakeLists.txt");
if (cmSystemTools::FileExists(buildFilePath.c_str())) { if (cmSystemTools::FileExists(buildFilePath.c_str())) {
dialog.setBinaryDirectory(QString::fromLocal8Bit( dialog.setBinaryDirectory(QString::fromStdString(
cmSystemTools::GetFilenamePath(buildFilePath).c_str())); cmSystemTools::GetFilenamePath(buildFilePath)));
} else if (cmSystemTools::FileExists(srcFilePath.c_str())) { } else if (cmSystemTools::FileExists(srcFilePath.c_str())) {
dialog.setSourceDirectory(QString::fromLocal8Bit(filePath.c_str())); dialog.setSourceDirectory(QString::fromStdString(filePath));
dialog.setBinaryDirectory(QString::fromLocal8Bit( dialog.setBinaryDirectory(
cmSystemTools::CollapseFullPath(".").c_str())); QString::fromStdString(cmSystemTools::CollapseFullPath(".")));
} }
} }
} }
+2 -2
View File
@@ -50,7 +50,7 @@ void OpenReferenceManual()
if (!cmSystemTools::GetHTMLDoc().empty()) { if (!cmSystemTools::GetHTMLDoc().empty()) {
url = QUrl::fromLocalFile( url = QUrl::fromLocalFile(
QDir(QString::fromLocal8Bit(cmSystemTools::GetHTMLDoc().data())) QDir(QString::fromStdString(cmSystemTools::GetHTMLDoc()))
.filePath("index.html")); .filePath("index.html"));
} }
@@ -735,7 +735,7 @@ void CMakeSetupDialog::showPresetLoadError(
{ {
QMessageBox::warning( QMessageBox::warning(
this, "Error Reading CMake Presets", this, "Error Reading CMake Presets",
QString::fromLocal8Bit("Could not read presets from %1: %2") QString("Could not read presets from %1: %2")
.arg(dir, cmCMakePresetsGraph::ResultToString(result))); .arg(dir, cmCMakePresetsGraph::ResultToString(result)));
} }
+7 -8
View File
@@ -107,22 +107,21 @@ void StartCompilerSetup::setGenerators(
QStringList generator_list; QStringList generator_list;
for (cmake::GeneratorInfo const& gen : gens) { for (cmake::GeneratorInfo const& gen : gens) {
generator_list.append(QString::fromLocal8Bit(gen.name.c_str())); generator_list.append(QString::fromStdString(gen.name));
if (gen.supportsPlatform) { if (gen.supportsPlatform) {
this->GeneratorsSupportingPlatform.append( this->GeneratorsSupportingPlatform.append(
QString::fromLocal8Bit(gen.name.c_str())); QString::fromStdString(gen.name));
this this->GeneratorDefaultPlatform[QString::fromStdString(gen.name)] =
->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] = QString::fromStdString(gen.defaultPlatform);
QString::fromLocal8Bit(gen.defaultPlatform.c_str());
auto platformIt = gen.supportedPlatforms.cbegin(); auto platformIt = gen.supportedPlatforms.cbegin();
while (platformIt != gen.supportedPlatforms.cend()) { while (platformIt != gen.supportedPlatforms.cend()) {
this->GeneratorSupportedPlatforms.insert( this->GeneratorSupportedPlatforms.insert(
QString::fromLocal8Bit(gen.name.c_str()), QString::fromStdString(gen.name),
QString::fromLocal8Bit((*platformIt).c_str())); QString::fromStdString((*platformIt)));
platformIt++; platformIt++;
} }
@@ -130,7 +129,7 @@ void StartCompilerSetup::setGenerators(
if (gen.supportsToolset) { if (gen.supportsToolset) {
this->GeneratorsSupportingToolset.append( this->GeneratorsSupportingToolset.append(
QString::fromLocal8Bit(gen.name.c_str())); QString::fromStdString(gen.name));
} }
} }
+56 -62
View File
@@ -70,7 +70,7 @@ QCMake::QCMake(QObject* p)
this->loadPresets(); this->loadPresets();
if (!this->PresetName.isEmpty() && if (!this->PresetName.isEmpty() &&
this->CMakePresetsGraph.ConfigurePresets.find( this->CMakePresetsGraph.ConfigurePresets.find(
std::string(this->PresetName.toLocal8Bit())) == std::string(this->PresetName.toStdString())) ==
this->CMakePresetsGraph.ConfigurePresets.end()) { this->CMakePresetsGraph.ConfigurePresets.end()) {
this->setPreset(QString{}); this->setPreset(QString{});
} }
@@ -87,8 +87,8 @@ void QCMake::loadCache(const QString& dir)
void QCMake::setSourceDirectory(const QString& _dir) void QCMake::setSourceDirectory(const QString& _dir)
{ {
QString dir = QString::fromLocal8Bit( QString dir = QString::fromStdString(
cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str()); cmSystemTools::GetActualCaseForPath(_dir.toStdString()));
if (this->SourceDirectory != dir) { if (this->SourceDirectory != dir) {
this->SourceDirectory = QDir::fromNativeSeparators(dir); this->SourceDirectory = QDir::fromNativeSeparators(dir);
emit this->sourceDirChanged(this->SourceDirectory); emit this->sourceDirChanged(this->SourceDirectory);
@@ -99,8 +99,8 @@ void QCMake::setSourceDirectory(const QString& _dir)
void QCMake::setBinaryDirectory(const QString& _dir) void QCMake::setBinaryDirectory(const QString& _dir)
{ {
QString dir = QString::fromLocal8Bit( QString dir = QString::fromStdString(
cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str()); cmSystemTools::GetActualCaseForPath(_dir.toStdString()));
if (this->BinaryDirectory != dir) { if (this->BinaryDirectory != dir) {
this->BinaryDirectory = QDir::fromNativeSeparators(dir); this->BinaryDirectory = QDir::fromNativeSeparators(dir);
emit this->binaryDirChanged(this->BinaryDirectory); emit this->binaryDirChanged(this->BinaryDirectory);
@@ -108,8 +108,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
this->setGenerator(QString()); this->setGenerator(QString());
this->setToolset(QString()); this->setToolset(QString());
this->setPlatform(QString()); this->setPlatform(QString());
if (!this->CMakeInstance->LoadCache( if (!this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString())) {
this->BinaryDirectory.toLocal8Bit().data())) {
QDir testDir(this->BinaryDirectory); QDir testDir(this->BinaryDirectory);
if (testDir.exists("CMakeCache.txt")) { if (testDir.exists("CMakeCache.txt")) {
cmSystemTools::Error( cmSystemTools::Error(
@@ -124,7 +123,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
emit this->propertiesChanged(props); emit this->propertiesChanged(props);
cmValue homeDir = state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"); cmValue homeDir = state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
if (homeDir) { if (homeDir) {
setSourceDirectory(QString::fromLocal8Bit(homeDir->c_str())); setSourceDirectory(QString(homeDir->c_str()));
} }
cmValue gen = state->GetCacheEntryValue("CMAKE_GENERATOR"); cmValue gen = state->GetCacheEntryValue("CMAKE_GENERATOR");
if (gen) { if (gen) {
@@ -133,17 +132,17 @@ void QCMake::setBinaryDirectory(const QString& _dir)
std::string curGen = std::string curGen =
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(*gen, cmExternalMakefileProjectGenerator::CreateFullGeneratorName(*gen,
*extraGen); *extraGen);
this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); this->setGenerator(QString::fromStdString(curGen));
} }
cmValue platform = state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM"); cmValue platform = state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM");
if (platform) { if (platform) {
this->setPlatform(QString::fromLocal8Bit(platform->c_str())); this->setPlatform(QString(platform->c_str()));
} }
cmValue toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET"); cmValue toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET");
if (toolset) { if (toolset) {
this->setToolset(QString::fromLocal8Bit(toolset->c_str())); this->setToolset(QString(toolset->c_str()));
} }
checkOpenPossible(); checkOpenPossible();
@@ -157,13 +156,13 @@ void QCMake::setPreset(const QString& name, bool setBinary)
emit this->presetChanged(this->PresetName); emit this->presetChanged(this->PresetName);
if (!name.isNull()) { if (!name.isNull()) {
std::string presetName(name.toLocal8Bit()); std::string presetName(name.toStdString());
auto const& expandedPreset = auto const& expandedPreset =
this->CMakePresetsGraph.ConfigurePresets[presetName].Expanded; this->CMakePresetsGraph.ConfigurePresets[presetName].Expanded;
if (expandedPreset) { if (expandedPreset) {
if (setBinary && !expandedPreset->BinaryDir.empty()) { if (setBinary && !expandedPreset->BinaryDir.empty()) {
QString binaryDir = QString binaryDir =
QString::fromLocal8Bit(expandedPreset->BinaryDir.data()); QString::fromStdString(expandedPreset->BinaryDir);
this->setBinaryDirectory(binaryDir); this->setBinaryDirectory(binaryDir);
} }
if (expandedPreset->WarnDev) { if (expandedPreset->WarnDev) {
@@ -190,8 +189,8 @@ void QCMake::setPreset(const QString& name, bool setBinary)
this->Environment = this->StartEnvironment; this->Environment = this->StartEnvironment;
for (auto const& v : expandedPreset->Environment) { for (auto const& v : expandedPreset->Environment) {
if (v.second) { if (v.second) {
this->Environment.insert(QString::fromLocal8Bit(v.first.data()), this->Environment.insert(QString::fromStdString(v.first),
QString::fromLocal8Bit(v.second->data())); QString::fromStdString(v.second.value()));
} }
} }
} }
@@ -240,17 +239,14 @@ void QCMake::configure()
UINT lastErrorMode = SetErrorMode(0); UINT lastErrorMode = SetErrorMode(0);
#endif #endif
this->CMakeInstance->SetHomeDirectory( this->CMakeInstance->SetHomeDirectory(this->SourceDirectory.toStdString());
this->SourceDirectory.toLocal8Bit().data());
this->CMakeInstance->SetHomeOutputDirectory( this->CMakeInstance->SetHomeOutputDirectory(
this->BinaryDirectory.toLocal8Bit().data()); this->BinaryDirectory.toStdString());
this->CMakeInstance->SetGlobalGenerator( this->CMakeInstance->SetGlobalGenerator(
this->CMakeInstance->CreateGlobalGenerator( this->CMakeInstance->CreateGlobalGenerator(
this->Generator.toLocal8Bit().data())); this->Generator.toStdString()));
this->CMakeInstance->SetGeneratorPlatform( this->CMakeInstance->SetGeneratorPlatform(this->Platform.toStdString());
this->Platform.toLocal8Bit().data()); this->CMakeInstance->SetGeneratorToolset(this->Toolset.toStdString());
this->CMakeInstance->SetGeneratorToolset(
this->Toolset.toLocal8Bit().data());
this->CMakeInstance->LoadCache(); this->CMakeInstance->LoadCache();
this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode); this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
this->CMakeInstance->PreLoadCMakeFiles(); this->CMakeInstance->PreLoadCMakeFiles();
@@ -303,8 +299,8 @@ void QCMake::open()
InterruptFlag = 0; InterruptFlag = 0;
cmSystemTools::ResetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag();
auto successful = this->CMakeInstance->Open( auto successful =
this->BinaryDirectory.toLocal8Bit().data(), false); this->CMakeInstance->Open(this->BinaryDirectory.toStdString(), false);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
SetErrorMode(lastErrorMode); SetErrorMode(lastErrorMode);
@@ -329,10 +325,10 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
} }
QCMakeProperty prop; QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(key.c_str()); prop.Key = QString::fromStdString(key);
int idx = props.indexOf(prop); int idx = props.indexOf(prop);
if (idx == -1) { if (idx == -1) {
toremove.append(QString::fromLocal8Bit(key.c_str())); toremove.append(QString::fromStdString(key));
} else { } else {
prop = props[idx]; prop = props[idx];
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
@@ -343,8 +339,7 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
if (isBool) { if (isBool) {
state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF"); state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF");
} else { } else {
state->SetCacheEntryValue(key, state->SetCacheEntryValue(key, prop.Value.toString().toStdString());
prop.Value.toString().toLocal8Bit().data());
} }
props.removeAt(idx); props.removeAt(idx);
} }
@@ -352,35 +347,35 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
// remove some properties // remove some properties
foreach (QString const& s, toremove) { foreach (QString const& s, toremove) {
this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data()); this->CMakeInstance->UnwatchUnusedCli(s.toStdString());
state->RemoveCacheEntry(s.toLocal8Bit().data()); state->RemoveCacheEntry(s.toStdString());
} }
// add some new properties // add some new properties
foreach (QCMakeProperty const& s, props) { foreach (QCMakeProperty const& s, props) {
this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data()); this->CMakeInstance->WatchUnusedCli(s.Key.toStdString());
if (s.Type == QCMakeProperty::BOOL) { if (s.Type == QCMakeProperty::BOOL) {
this->CMakeInstance->AddCacheEntry( this->CMakeInstance->AddCacheEntry(
s.Key.toLocal8Bit().data(), s.Value.toBool() ? "ON" : "OFF", s.Key.toStdString(), s.Value.toBool() ? "ON" : "OFF",
s.Help.toLocal8Bit().data(), cmStateEnums::BOOL); s.Help.toStdString().c_str(), cmStateEnums::BOOL);
} else if (s.Type == QCMakeProperty::STRING) { } else if (s.Type == QCMakeProperty::STRING) {
this->CMakeInstance->AddCacheEntry( this->CMakeInstance->AddCacheEntry(
s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), s.Key.toStdString(), s.Value.toString().toStdString(),
s.Help.toLocal8Bit().data(), cmStateEnums::STRING); s.Help.toStdString().c_str(), cmStateEnums::STRING);
} else if (s.Type == QCMakeProperty::PATH) { } else if (s.Type == QCMakeProperty::PATH) {
this->CMakeInstance->AddCacheEntry( this->CMakeInstance->AddCacheEntry(
s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), s.Key.toStdString(), s.Value.toString().toStdString(),
s.Help.toLocal8Bit().data(), cmStateEnums::PATH); s.Help.toStdString().c_str(), cmStateEnums::PATH);
} else if (s.Type == QCMakeProperty::FILEPATH) { } else if (s.Type == QCMakeProperty::FILEPATH) {
this->CMakeInstance->AddCacheEntry( this->CMakeInstance->AddCacheEntry(
s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), s.Key.toStdString(), s.Value.toString().toStdString(),
s.Help.toLocal8Bit().data(), cmStateEnums::FILEPATH); s.Help.toStdString().c_str(), cmStateEnums::FILEPATH);
} }
} }
this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data()); this->CMakeInstance->SaveCache(this->BinaryDirectory.toStdString());
} }
QCMakePropertyList QCMake::properties() const QCMakePropertyList QCMake::properties() const
@@ -399,11 +394,11 @@ QCMakePropertyList QCMake::properties() const
cmValue cachedValue = state->GetCacheEntryValue(key); cmValue cachedValue = state->GetCacheEntryValue(key);
QCMakeProperty prop; QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(key.c_str()); prop.Key = QString::fromStdString(key);
if (cmValue hs = state->GetCacheEntryProperty(key, "HELPSTRING")) { if (cmValue hs = state->GetCacheEntryProperty(key, "HELPSTRING")) {
prop.Help = QString::fromLocal8Bit(hs->c_str()); prop.Help = QString(hs->c_str());
} }
prop.Value = QString::fromLocal8Bit(cachedValue->c_str()); prop.Value = QString(cachedValue->c_str());
prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED"); prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED");
if (t == cmStateEnums::BOOL) { if (t == cmStateEnums::BOOL) {
prop.Type = QCMakeProperty::BOOL; prop.Type = QCMakeProperty::BOOL;
@@ -416,8 +411,7 @@ QCMakePropertyList QCMake::properties() const
prop.Type = QCMakeProperty::STRING; prop.Type = QCMakeProperty::STRING;
cmValue stringsProperty = state->GetCacheEntryProperty(key, "STRINGS"); cmValue stringsProperty = state->GetCacheEntryProperty(key, "STRINGS");
if (stringsProperty) { if (stringsProperty) {
prop.Strings = prop.Strings = QString(stringsProperty->c_str()).split(";");
QString::fromLocal8Bit(stringsProperty->c_str()).split(";");
} }
} }
@@ -425,7 +419,7 @@ QCMakePropertyList QCMake::properties() const
} }
if (!this->PresetName.isNull()) { if (!this->PresetName.isNull()) {
std::string presetName(this->PresetName.toLocal8Bit()); std::string presetName(this->PresetName.toStdString());
auto const& p = auto const& p =
this->CMakePresetsGraph.ConfigurePresets.at(presetName).Expanded; this->CMakePresetsGraph.ConfigurePresets.at(presetName).Expanded;
if (p) { if (p) {
@@ -434,8 +428,8 @@ QCMakePropertyList QCMake::properties() const
continue; continue;
} }
QCMakeProperty prop; QCMakeProperty prop;
prop.Key = QString::fromLocal8Bit(v.first.data()); prop.Key = QString::fromStdString(v.first);
prop.Value = QString::fromLocal8Bit(v.second->Value.data()); prop.Value = QString::fromStdString(v.second->Value);
prop.Type = QCMakeProperty::STRING; prop.Type = QCMakeProperty::STRING;
if (!v.second->Type.empty()) { if (!v.second->Type.empty()) {
auto type = cmState::StringToCacheEntryType(v.second->Type); auto type = cmState::StringToCacheEntryType(v.second->Type);
@@ -523,18 +517,18 @@ void QCMake::setUpEnvironment() const
{ {
auto env = QProcessEnvironment::systemEnvironment(); auto env = QProcessEnvironment::systemEnvironment();
for (auto const& key : env.keys()) { for (auto const& key : env.keys()) {
cmSystemTools::UnsetEnv(key.toLocal8Bit().data()); cmSystemTools::UnsetEnv(key.toStdString().c_str());
} }
for (auto const& var : this->Environment.toStringList()) { for (auto const& var : this->Environment.toStringList()) {
cmSystemTools::PutEnv(var.toLocal8Bit().data()); cmSystemTools::PutEnv(var.toStdString());
} }
} }
void QCMake::loadPresets() void QCMake::loadPresets()
{ {
auto result = this->CMakePresetsGraph.ReadProjectPresets( auto result = this->CMakePresetsGraph.ReadProjectPresets(
this->SourceDirectory.toLocal8Bit().data(), true); this->SourceDirectory.toStdString(), true);
if (result != this->LastLoadPresetsResult && if (result != this->LastLoadPresetsResult &&
result != cmCMakePresetsGraph::ReadFileResult::READ_OK) { result != cmCMakePresetsGraph::ReadFileResult::READ_OK) {
emit this->presetLoadError(this->SourceDirectory, result); emit this->presetLoadError(this->SourceDirectory, result);
@@ -550,14 +544,14 @@ void QCMake::loadPresets()
} }
QCMakePreset preset; QCMakePreset preset;
preset.name = QString::fromLocal8Bit(p.Name.data()); preset.name = QString::fromStdString(p.Name);
preset.displayName = QString::fromLocal8Bit(p.DisplayName.data()); preset.displayName = QString::fromStdString(p.DisplayName);
preset.description = QString::fromLocal8Bit(p.Description.data()); preset.description = QString::fromStdString(p.Description);
preset.generator = QString::fromLocal8Bit(p.Generator.data()); preset.generator = QString::fromStdString(p.Generator);
preset.architecture = QString::fromLocal8Bit(p.Architecture.data()); preset.architecture = QString::fromStdString(p.Architecture);
preset.setArchitecture = !p.ArchitectureStrategy || preset.setArchitecture = !p.ArchitectureStrategy ||
p.ArchitectureStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set; p.ArchitectureStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set;
preset.toolset = QString::fromLocal8Bit(p.Toolset.data()); preset.toolset = QString::fromStdString(p.Toolset);
preset.setToolset = !p.ToolsetStrategy || preset.setToolset = !p.ToolsetStrategy ||
p.ToolsetStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set; p.ToolsetStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set;
preset.enabled = it.Expanded && it.Expanded->ConditionResult && preset.enabled = it.Expanded && it.Expanded->ConditionResult &&
@@ -599,9 +593,9 @@ std::vector<cmake::GeneratorInfo> const& QCMake::availableGenerators() const
void QCMake::deleteCache() void QCMake::deleteCache()
{ {
// delete cache // delete cache
this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data()); this->CMakeInstance->DeleteCache(this->BinaryDirectory.toStdString());
// reload to make our cache empty // reload to make our cache empty
this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString());
// emit no generator and no properties // emit no generator and no properties
this->setGenerator(QString()); this->setGenerator(QString());
this->setToolset(QString()); this->setToolset(QString());
@@ -615,7 +609,7 @@ void QCMake::reloadCache()
QCMakePropertyList props; QCMakePropertyList props;
emit this->propertiesChanged(props); emit this->propertiesChanged(props);
// reload // reload
this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString());
// emit new cache properties // emit new cache properties
props = this->properties(); props = this->properties();
emit this->propertiesChanged(props); emit this->propertiesChanged(props);
@@ -681,7 +675,7 @@ void QCMake::setWarnUninitializedMode(bool value)
void QCMake::checkOpenPossible() void QCMake::checkOpenPossible()
{ {
std::string data = this->BinaryDirectory.toLocal8Bit().data(); std::string data = this->BinaryDirectory.toStdString();
auto possible = this->CMakeInstance->Open(data, true); auto possible = this->CMakeInstance->Open(data, true);
emit openPossible(possible); emit openPossible(possible);
} }
+3 -3
View File
@@ -17,12 +17,12 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const
// AccessibleDescriptionRole. This was determined by looking at // AccessibleDescriptionRole. This was determined by looking at
// QComboBoxDelegate::isSeparator() (located in qcombobox_p.h.) // QComboBoxDelegate::isSeparator() (located in qcombobox_p.h.)
if (index.internalId() == SEPARATOR_INDEX) { if (index.internalId() == SEPARATOR_INDEX) {
return QString::fromLocal8Bit("separator"); return QString("separator");
} }
return QString{}; return QString{};
case Qt::DisplayRole: { case Qt::DisplayRole: {
if (index.internalId() == CUSTOM_INDEX) { if (index.internalId() == CUSTOM_INDEX) {
return QString::fromLocal8Bit("<custom>"); return QString("<custom>");
} }
if (index.internalId() == SEPARATOR_INDEX) { if (index.internalId() == SEPARATOR_INDEX) {
return QVariant{}; return QVariant{};
@@ -32,7 +32,7 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const
} }
case Qt::ToolTipRole: case Qt::ToolTipRole:
if (index.internalId() == CUSTOM_INDEX) { if (index.internalId() == CUSTOM_INDEX) {
return QString::fromLocal8Bit("Specify all settings manually"); return QString("Specify all settings manually");
} }
if (index.internalId() == SEPARATOR_INDEX) { if (index.internalId() == SEPARATOR_INDEX) {
return QVariant{}; return QVariant{};