mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
preferences: use std::string in struct preferences
This is a messy commit, because the "qPref" system relies heavily on QString, which means lots of conversions between the two worlds. Ultimately, I plan to base the preferences system on std::string and only convert to QString when pushing through Qt's property system or when writing into Qt's settings. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
82fc9de40b
commit
ccdd92aeb7
78 changed files with 645 additions and 694 deletions
|
@ -549,8 +549,8 @@ void MainWindow::updateLastUsedDir(const QString &dir)
|
|||
|
||||
static QString get_current_filename()
|
||||
{
|
||||
return existing_filename.empty() ? QString(prefs.default_filename)
|
||||
: QString::fromStdString(existing_filename);
|
||||
return QString::fromStdString(existing_filename.empty() ? prefs.default_filename
|
||||
: existing_filename);
|
||||
}
|
||||
void MainWindow::on_actionPrint_triggered()
|
||||
{
|
||||
|
@ -1100,7 +1100,7 @@ void MainWindow::loadRecentFiles()
|
|||
QString file = s.value(key).toString();
|
||||
|
||||
// never add our cloud URL to the recent files
|
||||
if (file.startsWith(prefs.cloud_base_url))
|
||||
if (file.startsWith(QString::fromStdString(prefs.cloud_base_url)))
|
||||
continue;
|
||||
// but allow local git repos
|
||||
QRegularExpression gitrepo("(.*)\\[[^]]+]");
|
||||
|
@ -1138,7 +1138,7 @@ void MainWindow::updateRecentFilesMenu()
|
|||
void MainWindow::addRecentFile(const QString &file, bool update)
|
||||
{
|
||||
// never add Subsurface cloud file to the recent files - it has its own menu entry
|
||||
if (file.startsWith(prefs.cloud_base_url))
|
||||
if (file.startsWith(QString::fromStdString(prefs.cloud_base_url)))
|
||||
return;
|
||||
QString localFile = QDir::toNativeSeparators(file);
|
||||
int index = recentFiles.indexOf(localFile);
|
||||
|
@ -1201,7 +1201,7 @@ int MainWindow::file_save_as()
|
|||
selection_dialog.setFileMode(QFileDialog::AnyFile);
|
||||
selection_dialog.setDefaultSuffix("");
|
||||
if (default_filename.empty()) {
|
||||
QFileInfo defaultFile(system_default_filename());
|
||||
QFileInfo defaultFile(QString::fromStdString(system_default_filename()));
|
||||
selection_dialog.setDirectory(qPrintable(defaultFile.absolutePath()));
|
||||
}
|
||||
/* if the exit/cancel button is pressed return */
|
||||
|
@ -1231,7 +1231,6 @@ int MainWindow::file_save_as()
|
|||
|
||||
int MainWindow::file_save()
|
||||
{
|
||||
const char *current_default;
|
||||
bool is_cloud = false;
|
||||
|
||||
if (existing_filename.empty())
|
||||
|
@ -1241,11 +1240,11 @@ int MainWindow::file_save()
|
|||
if (is_cloud && !saveToCloudOK())
|
||||
return -1;
|
||||
|
||||
current_default = prefs.default_filename;
|
||||
const std::string ¤t_default = prefs.default_filename;
|
||||
if (existing_filename == current_default) {
|
||||
/* if we are using the default filename the directory
|
||||
* that we are creating the file in may not exist */
|
||||
QDir current_def_dir = QFileInfo(current_default).absoluteDir();
|
||||
QDir current_def_dir = QFileInfo(QString::fromStdString(current_default)).absoluteDir();
|
||||
if (!current_def_dir.exists())
|
||||
current_def_dir.mkpath(current_def_dir.absolutePath());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue