From 7fe938a7ca527a148e2a7824beac8d55c8bedfe2 Mon Sep 17 00:00:00 2001 From: apprb Date: Sat, 30 Aug 2014 15:28:00 +0700 Subject: [PATCH] filenames and paths processing little fix --- core.cpp | 4 ++-- settings.cpp | 6 +++--- smileypack.cpp | 2 +- widget/filetransfertwidget.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core.cpp b/core.cpp index 3c6a3057e..658908066 100644 --- a/core.cpp +++ b/core.cpp @@ -811,7 +811,7 @@ void Core::checkConnection() void Core::loadConfiguration() { - QString path = Settings::getSettingsDirPath() + '/' + CONFIG_FILE_NAME; + QString path = QDir(Settings::getSettingsDirPath()).filePath(CONFIG_FILE_NAME); QFile configurationFile(path); @@ -862,7 +862,7 @@ void Core::saveConfiguration() return; } - path += '/' + CONFIG_FILE_NAME; + path = directory.filePath(CONFIG_FILE_NAME); QSaveFile configurationFile(path); if (!configurationFile.open(QIODevice::WriteOnly)) { qCritical() << "File " << path << " cannot be opened"; diff --git a/settings.cpp b/settings.cpp index 1662e44b0..b2193e453 100644 --- a/settings.cpp +++ b/settings.cpp @@ -55,7 +55,7 @@ void Settings::load() if (portableSettings.exists()) makeToxPortable=true; - QString filePath = getSettingsDirPath() + '/' + FILENAME; + QString filePath = QDir(getSettingsDirPath()).filePath(FILENAME); //if no settings file exist -- use the default one QFile file(filePath); @@ -125,7 +125,7 @@ void Settings::load() void Settings::save() { - QString filePath = getSettingsDirPath() + '/' + FILENAME; + QString filePath = QDir(getSettingsDirPath()).filePath(FILENAME); save(filePath); } @@ -194,7 +194,7 @@ QString Settings::getSettingsDirPath() #ifdef Q_OS_WIN return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); #else - return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + '/' + "tox" + '/'; + return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QDir::separator() + "tox"); #endif } diff --git a/smileypack.cpp b/smileypack.cpp index dba5ac0c5..cca56583c 100644 --- a/smileypack.cpp +++ b/smileypack.cpp @@ -163,7 +163,7 @@ QIcon SmileyPack::getAsIcon(const QString &key) void SmileyPack::cacheSmiley(const QString &name) { QSize size(16, 16); // TODO: adapt to text size - QString filename = path % '/' % name; + QString filename = QDir(path).filePath(name); QImage img(filename); if (!img.isNull()) diff --git a/widget/filetransfertwidget.cpp b/widget/filetransfertwidget.cpp index 773900b25..6c0a30ff7 100644 --- a/widget/filetransfertwidget.cpp +++ b/widget/filetransfertwidget.cpp @@ -278,7 +278,7 @@ void FileTransfertWidget::acceptRecvRequest() QString path; while (true) { - path = QFileDialog::getSaveFileName(this,tr("Save a file","Title of the file saving dialog"),QDir::currentPath()+'/'+filename->text()); + path = QFileDialog::getSaveFileName(this, tr("Save a file","Title of the file saving dialog"), QDir::current().filePath(filename->text())); if (path.isEmpty()) return; else