logic: handled case when selected project location can not be written (issue #735) (#906)

This commit is contained in:
Malte Langkabel
2020-02-04 20:24:59 +01:00
committed by GitHub
parent 7556d171cb
commit 7f9f098c70
5 changed files with 31 additions and 13 deletions
+10 -6
View File
@@ -50,28 +50,32 @@ bool Settings::loadFromString(const std::string& text, bool readOnly)
return true;
}
void Settings::save()
bool Settings::save()
{
if (m_readOnly)
{
return;
return false;
}
bool success = false;
if (m_config.get() && !m_filePath.empty())
{
m_config->save(m_filePath.str());
success = m_config->save(m_filePath.str());
}
else
if (!success)
{
LOG_WARNING(L"Settings were not saved: " + m_filePath.wstr());
}
return success;
}
void Settings::save(const FilePath& filePath)
bool Settings::save(const FilePath& filePath)
{
setFilePath(filePath);
save();
return save();
}
void Settings::clear()
+2 -2
View File
@@ -19,8 +19,8 @@ public:
bool load(const FilePath& filePath, bool readOnly = false);
bool loadFromString(const std::string& text, bool readOnly = false);
void save();
void save(const FilePath& filePath);
bool save();
bool save(const FilePath& filePath);
void clear();
+2 -2
View File
@@ -375,10 +375,10 @@ bool ConfigManager::load(const std::shared_ptr<TextAccess> textAccess)
return true;
}
void ConfigManager::save(const std::string filepath)
bool ConfigManager::save(const std::string filepath)
{
std::string output("");
createXmlDocument(true, filepath, output);
return createXmlDocument(true, filepath, output);
}
void ConfigManager::setWarnOnEmptyKey(bool warnOnEmptyKey) const
+1 -1
View File
@@ -59,7 +59,7 @@ public:
std::vector<std::string> getSublevelKeys(const std::string& key) const;
bool load(const std::shared_ptr<TextAccess> textAccess);
void save(const std::string filepath);
bool save(const std::string filepath);
std::string toString();
void setWarnOnEmptyKey(bool warnOnEmptyKey) const;
@@ -1022,7 +1022,8 @@ void QtProjectWizard::removeSelectedSourceGroup()
QMessageBox msgBox;
msgBox.setText(QStringLiteral("Remove Source Group"));
msgBox.setInformativeText(QStringLiteral("Do you really want to remove this source group from the project?"));
msgBox.setInformativeText(
QStringLiteral("Do you really want to remove this source group from the project?"));
msgBox.addButton(QStringLiteral("Yes"), QMessageBox::ButtonRole::YesRole);
msgBox.addButton(QStringLiteral("No"), QMessageBox::ButtonRole::NoRole);
msgBox.setIcon(QMessageBox::Icon::Question);
@@ -1277,7 +1278,20 @@ void QtProjectWizard::createProject()
m_projectSettings->setVersion(ProjectSettings::VERSION);
m_projectSettings->setAllSourceGroupSettings(m_allSourceGroupSettings);
m_projectSettings->save(path);
if (!m_projectSettings->save(path))
{
MessageStatus(L"Unable to save project to location: " + path.wstr()).dispatch();
QMessageBox msgBox;
msgBox.setText("Could not create Project");
msgBox.setInformativeText(QString::fromStdWString(
L"<p>Sourcetrail was unable to save the project to the specified path. Please pick a "
L"different project location.</p>"));
msgBox.addButton("Ok", QMessageBox::ButtonRole::AcceptRole);
msgBox.exec();
return;
}
bool settingsChanged = false;
if (m_editing)