From 969f262cf8a40a79c2fc26d8a6208e8e903f08cb Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 9 Mar 2014 22:17:13 +0100 Subject: [PATCH] [DataPaths] Don't add trailing slash to paths Qt API is not adding trailing slashes to dir paths either. --- src/lib/adblock/adblockmanager.cpp | 6 +-- src/lib/adblock/adblocksubscription.cpp | 2 +- src/lib/app/datapaths.cpp | 54 ++++++++----------- src/lib/app/datapaths.h | 17 +++--- src/lib/app/mainapplication.cpp | 32 +++++------ src/lib/app/profilemanager.cpp | 13 ++--- src/lib/cookies/cookiejar.cpp | 4 +- src/lib/network/cabundleupdater.cpp | 6 +-- src/lib/network/networkmanager.cpp | 10 ++-- src/lib/network/pac/pacmanager.cpp | 4 +- .../schemehandlers/qupzillaschemehandler.cpp | 6 +-- src/lib/other/clearprivatedata.cpp | 12 ++--- src/lib/plugins/plugins.cpp | 4 +- .../qtwebkit/spellcheck/spellcheckdialog.cpp | 4 +- .../plugins/qtwebkit/spellcheck/speller.cpp | 4 +- src/lib/plugins/speeddial.cpp | 2 +- src/lib/preferences/preferences.cpp | 6 +-- src/lib/preferences/thememanager.cpp | 2 +- src/lib/session/restoremanager.cpp | 2 +- src/lib/webview/tabwidget.cpp | 4 +- .../StatusBarIcons/sbi_networkmanager.cpp | 2 +- 21 files changed, 92 insertions(+), 104 deletions(-) diff --git a/src/lib/adblock/adblockmanager.cpp b/src/lib/adblock/adblockmanager.cpp index a0085d1c9..8f9d61ac0 100644 --- a/src/lib/adblock/adblockmanager.cpp +++ b/src/lib/adblock/adblockmanager.cpp @@ -150,7 +150,7 @@ AdBlockSubscription* AdBlockManager::addSubscription(const QString &title, const } QString fileName = QzTools::filterCharsFromFilename(title.toLower()) + ".txt"; - QString filePath = QzTools::ensureUniqueFilename(DataPaths::currentProfilePath() + "adblock/" + fileName); + QString filePath = QzTools::ensureUniqueFilename(DataPaths::currentProfilePath() + "/adblock/" + fileName); QByteArray data = QString("Title: %1\nUrl: %2\n[Adblock Plus 1.1.1]").arg(title, url).toLatin1(); @@ -222,7 +222,7 @@ void AdBlockManager::load() return; } - QDir adblockDir(DataPaths::currentProfilePath() + "adblock"); + QDir adblockDir(DataPaths::currentProfilePath() + "/adblock"); // Create if neccessary if (!adblockDir.exists()) { QDir(DataPaths::currentProfilePath()).mkdir("adblock"); @@ -261,7 +261,7 @@ void AdBlockManager::load() if (m_subscriptions.isEmpty()) { AdBlockSubscription* easyList = new AdBlockSubscription(tr("EasyList"), this); easyList->setUrl(QUrl(ADBLOCK_EASYLIST_URL)); - easyList->setFilePath(DataPaths::currentProfilePath() + "adblock/easylist.txt"); + easyList->setFilePath(DataPaths::currentProfilePath() + QLatin1String("/adblock/easylist.txt")); connect(easyList, SIGNAL(subscriptionUpdated()), mApp, SLOT(reloadUserStyleSheet())); m_subscriptions.prepend(easyList); diff --git a/src/lib/adblock/adblocksubscription.cpp b/src/lib/adblock/adblocksubscription.cpp index b911ffca0..d4968243f 100644 --- a/src/lib/adblock/adblocksubscription.cpp +++ b/src/lib/adblock/adblocksubscription.cpp @@ -458,7 +458,7 @@ AdBlockSubscription::~AdBlockSubscription() AdBlockCustomList::AdBlockCustomList(QObject* parent) : AdBlockSubscription(tr("Custom Rules"), parent) { - setFilePath(DataPaths::currentProfilePath() + "adblock/customlist.txt"); + setFilePath(DataPaths::currentProfilePath() + QLatin1String("/adblock/customlist.txt")); } void AdBlockCustomList::saveSubscription() diff --git a/src/lib/app/datapaths.cpp b/src/lib/app/datapaths.cpp index ca86c1e3d..899fc3b45 100644 --- a/src/lib/app/datapaths.cpp +++ b/src/lib/app/datapaths.cpp @@ -42,13 +42,10 @@ void DataPaths::setPortableVersion() d->m_paths[Config] = d->m_paths[AppData]; d->m_paths[Profiles] = d->m_paths[Config]; - d->m_paths[Profiles].first().append(QLatin1String("profiles/")); - - d->m_paths[CrashLogs] = d->m_paths[Config]; - d->m_paths[CrashLogs].first().append(QLatin1String("crashlogs/")); + d->m_paths[Profiles].first().append(QLatin1String("/profiles")); d->m_paths[Temp] = d->m_paths[Config]; - d->m_paths[Temp].first().append(QLatin1String("tmp/")); + d->m_paths[Temp].first().append(QLatin1String("/tmp")); } // static @@ -85,16 +82,16 @@ void DataPaths::init() // AppData #if defined(Q_OS_MAC) - m_paths[AppData].append(QApplication::applicationDirPath() + QLatin1String("../Resources/")); + m_paths[AppData].append(QApplication::applicationDirPath() + QLatin1String("/../Resources")); #elif defined(Q_OS_UNIX) && !defined(NO_SYSTEM_DATAPATH) - m_paths[AppData].append(USE_DATADIR "/"); + m_paths[AppData].append(USE_DATADIR); #else - m_paths[AppData].append(QApplication::applicationDirPath() + QLatin1Char('/')); + m_paths[AppData].append(QApplication::applicationDirPath()); #endif - m_paths[Translations].append(m_paths[AppData].first() + QLatin1String("locale/")); - m_paths[Themes].append(m_paths[AppData].first() + QLatin1String("themes/")); - m_paths[Plugins].append(m_paths[AppData].first() + QLatin1String("plugins/")); + m_paths[Translations].append(m_paths[AppData].first() + QLatin1String("/locale")); + m_paths[Themes].append(m_paths[AppData].first() + QLatin1String("/themes")); + m_paths[Plugins].append(m_paths[AppData].first() + QLatin1String("/plugins")); // Config #if defined(Q_OS_WIN) || defined(Q_OS_OS2) @@ -106,29 +103,29 @@ void DataPaths::init() #endif // Backwards compatibility if (dataLocation.isEmpty()) { - dataLocation = QDir::homePath() + QLatin1String("/.config/qupzilla/"); + dataLocation = QDir::homePath() + QLatin1String("/.config/qupzilla"); } QDir confPath = QDir(dataLocation); - QDir homePath = QDir(QDir::homePath() + QLatin1String("/.qupzilla/")); + QDir homePath = QDir(QDir::homePath() + QLatin1String("/.qupzilla")); if (!homePath.exists()) { - homePath = QDir::homePath() + QLatin1String("/.config/qupzilla/"); + homePath = QDir::homePath() + QLatin1String("/.config/qupzilla"); } #else // Unix - QDir confPath = QDir(QDir::homePath() + QLatin1String("/.config/qupzilla/")); - QDir homePath = QDir(QDir::homePath() + QLatin1String("/.qupzilla/")); + QDir confPath = QDir(QDir::homePath() + QLatin1String("/.config/qupzilla")); + QDir homePath = QDir(QDir::homePath() + QLatin1String("/.qupzilla")); #endif if (homePath.exists() && !confPath.exists()) { - m_paths[Config].append(homePath.absolutePath() + QLatin1Char('/')); + m_paths[Config].append(homePath.absolutePath()); qWarning() << "WARNING: Using deprecated configuration path" << homePath.absolutePath(); qWarning() << "WARNING: This path may not be supported in future versions!"; qWarning() << "WARNING: Please move your configuration into" << confPath.absolutePath(); } else { - m_paths[Config].append(confPath.absolutePath() + QLatin1Char('/')); + m_paths[Config].append(confPath.absolutePath()); } // Make sure the Config path exists @@ -136,35 +133,30 @@ void DataPaths::init() dir.mkpath(m_paths[Config].first()); // Profiles - m_paths[Profiles].append(m_paths[Config].first() + QLatin1String("profiles/")); - - // Crashlogs - m_paths[CrashLogs].append(m_paths[Config].first() + QLatin1String("crashlogs/")); + m_paths[Profiles].append(m_paths[Config].first() + QLatin1String("/profiles")); // Temp #ifdef Q_OS_UNIX dir.mkpath(QDir::tempPath() + QLatin1String("/qupzilla/tmp")); - m_paths[Temp].append(QDir::tempPath() + QLatin1String("/qupzilla/tmp/")); + m_paths[Temp].append(QDir::tempPath() + QLatin1String("/qupzilla/tmp")); #else - m_paths[Temp].append(m_paths[Config].first() + QLatin1String("tmp/")); + m_paths[Temp].append(m_paths[Config].first() + QLatin1String("/tmp")); #endif // We also allow to load data from Config path - m_paths[Translations].append(m_paths[Config].first() + QLatin1String("locale/")); - m_paths[Themes].append(m_paths[Config].first() + QLatin1String("themes/")); - m_paths[Plugins].append(m_paths[Config].first() + QLatin1String("plugins/")); + m_paths[Translations].append(m_paths[Config].first() + QLatin1String("/locale")); + m_paths[Themes].append(m_paths[Config].first() + QLatin1String("/themes")); + m_paths[Plugins].append(m_paths[Config].first() + QLatin1String("/plugins")); #ifdef USE_LIBPATH - m_paths[Plugins].append(QLatin1String(USE_LIBPATH "/qupzilla/")); + m_paths[Plugins].append(QLatin1String(USE_LIBPATH "/qupzilla")); #else // FIXME: This should use QUPZILLA_PREFIX - m_paths[Plugins].append(QLatin1String("/usr/lib/qupzilla/")); + m_paths[Plugins].append(QLatin1String("/usr/lib/qupzilla")); #endif } void DataPaths::initCurrentProfile(const QString &profilePath) { - Q_ASSERT(profilePath.endsWith('/')); - m_paths[CurrentProfile].append(profilePath); } diff --git a/src/lib/app/datapaths.h b/src/lib/app/datapaths.h index 6ea971990..a8b4e8cf0 100644 --- a/src/lib/app/datapaths.h +++ b/src/lib/app/datapaths.h @@ -25,15 +25,14 @@ class DataPaths { public: enum Path { - AppData, // /usr/share/qupzilla/ or . or ../Resources/ - Translations, // $AppData/locale/ - Themes, // $AppData/themes/ - Plugins, // $AppData/plugins/ - Config, // ~/.config/qupzilla/ or %LOCALAPPDATA%/qupzilla/ or $AppData/data (portable) - Profiles, // $Config/profiles/ - CurrentProfile, // $Profiles/current_profile/ - CrashLogs, // $Config/crashlogs/ - Temp // $Config/tmp/ + AppData, // /usr/share/qupzilla or . or ../Resources + Translations, // $AppData/locale + Themes, // $AppData/themes + Plugins, // $AppData/plugins + Config, // ~/.config/qupzilla or %LOCALAPPDATA%/qupzilla or $AppData/data (portable) + Profiles, // $Config/profiles + CurrentProfile, // $Profiles/current_profile + Temp // $Config/tmp }; explicit DataPaths(); diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index bc6fb9038..79527fcf3 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -225,7 +225,7 @@ MainApplication::MainApplication(int &argc, char** argv) profileManager.initConfigDir(); profileManager.initCurrentProfile(startProfile); - Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("settings.ini")); + Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini")); m_autoSaver = new AutoSaver(this); connect(m_autoSaver, SIGNAL(save()), this, SLOT(saveStateSlot())); @@ -622,8 +622,8 @@ void MainApplication::loadTheme(const QString &name) const QStringList themePaths = DataPaths::allPaths(DataPaths::Themes); foreach (const QString &path, themePaths) { - const QString theme = path + name + "/"; - if (QFile::exists(theme + "main.css")) { + const QString theme = QString("%1/%2").arg(path, name); + if (QFile::exists(theme + "/main.css")) { activeThemePath = theme; break; } @@ -631,10 +631,10 @@ void MainApplication::loadTheme(const QString &name) if (activeThemePath.isEmpty()) { qWarning() << "Cannot load theme " << name; - activeThemePath = DataPaths::path(DataPaths::Themes) + DEFAULT_THEME_NAME + QLatin1Char('/'); + activeThemePath = DataPaths::path(DataPaths::Themes) + DEFAULT_THEME_NAME; } - QFile cssFile(activeThemePath + "main.css"); + QFile cssFile(activeThemePath + "/main.css"); cssFile.open(QFile::ReadOnly); QString css = cssFile.readAll(); cssFile.close(); @@ -644,8 +644,8 @@ void MainApplication::loadTheme(const QString &name) * should be enough instead of loading special stylesheets */ #ifdef Q_OS_UNIX - if (QFile(activeThemePath + "linux.css").exists()) { - cssFile.setFileName(activeThemePath + "linux.css"); + if (QFile(activeThemePath + "/linux.css").exists()) { + cssFile.setFileName(activeThemePath + "/linux.css"); cssFile.open(QFile::ReadOnly); css.append(cssFile.readAll()); cssFile.close(); @@ -653,8 +653,8 @@ void MainApplication::loadTheme(const QString &name) #endif #ifdef Q_OS_MAC - if (QFile(activeThemePath + "mac.css").exists()) { - cssFile.setFileName(activeThemePath + "mac.css"); + if (QFile(activeThemePath + "/mac.css").exists()) { + cssFile.setFileName(activeThemePath + "/mac.css"); cssFile.open(QFile::ReadOnly); css.append(cssFile.readAll()); cssFile.close(); @@ -662,8 +662,8 @@ void MainApplication::loadTheme(const QString &name) #endif #if defined(Q_OS_WIN) || defined(Q_OS_OS2) - if (QFile(activeThemePath + "windows.css").exists()) { - cssFile.setFileName(activeThemePath + "windows.css"); + if (QFile(activeThemePath + "/windows.css").exists()) { + cssFile.setFileName(activeThemePath + "/windows.css"); cssFile.open(QFile::ReadOnly); css.append(cssFile.readAll()); cssFile.close(); @@ -672,8 +672,8 @@ void MainApplication::loadTheme(const QString &name) // RTL Support // Loading 'rtl.css' when layout is right to left! - if (isRightToLeft() && QFile(activeThemePath + "rtl.css").exists()) { - cssFile.setFileName(activeThemePath + "rtl.css"); + if (isRightToLeft() && QFile(activeThemePath + "/rtl.css").exists()) { + cssFile.setFileName(activeThemePath + "/rtl.css"); cssFile.open(QFile::ReadOnly); css.append(cssFile.readAll()); cssFile.close(); @@ -739,7 +739,7 @@ void MainApplication::backupSavedSessions() // session.dat.old - first backup // session.dat.old1 - second backup - const QString sessionFile = DataPaths::currentProfilePath() + QLatin1String("session.dat"); + const QString sessionFile = DataPaths::currentProfilePath() + QLatin1String("/session.dat"); if (!QFile::exists(sessionFile)) { return; @@ -816,7 +816,7 @@ void MainApplication::saveSettings() qzSettings->saveSettings(); AdBlockManager::instance()->save(); IconProvider::instance()->saveIconsToDatabase(); - QFile::remove(DataPaths::currentProfilePath() + QLatin1String("WebpageIcons.db")); + QFile::remove(DataPaths::currentProfilePath() + QLatin1String("/WebpageIcons.db")); Settings::syncSettings(); } @@ -1109,7 +1109,7 @@ bool MainApplication::saveStateSlot() qupzilla_->tabWidget()->savePinnedTabs(); } - QFile file(DataPaths::currentProfilePath() + QLatin1String("session.dat")); + QFile file(DataPaths::currentProfilePath() + QLatin1String("/session.dat")); file.open(QIODevice::WriteOnly); file.write(data); file.close(); diff --git a/src/lib/app/profilemanager.cpp b/src/lib/app/profilemanager.cpp index 09f827215..95a63a14f 100644 --- a/src/lib/app/profilemanager.cpp +++ b/src/lib/app/profilemanager.cpp @@ -73,7 +73,7 @@ void ProfileManager::initConfigDir() const void ProfileManager::initCurrentProfile(const QString &profileName) { - QString profilePath = DataPaths::path(DataPaths::Profiles); + QString profilePath = DataPaths::path(DataPaths::Profiles) + QLatin1Char('/'); if (profileName.isEmpty()) { profilePath.append(startingProfile()); @@ -82,7 +82,7 @@ void ProfileManager::initCurrentProfile(const QString &profileName) profilePath.append(profileName); } - DataPaths::setCurrentProfilePath(profilePath + QLatin1Char('/')); + DataPaths::setCurrentProfilePath(profilePath); updateCurrentProfile(); connectDatabase(); @@ -126,9 +126,6 @@ bool ProfileManager::removeProfile(const QString &profileName) QString ProfileManager::currentProfile() const { - //const QString path = DataPaths::currentProfilePath(); - //return path.mid(path.lastIndexOf(QLatin1Char('/')) + 1); - QString path = DataPaths::currentProfilePath(); path = path.mid(0, path.size() - 1); return path.mid(path.lastIndexOf(QLatin1Char('/')) + 1); @@ -136,13 +133,13 @@ QString ProfileManager::currentProfile() const QString ProfileManager::startingProfile() const { - QSettings settings(DataPaths::path(DataPaths::Profiles) + QLatin1String("profiles.ini"), QSettings::IniFormat); + QSettings settings(DataPaths::path(DataPaths::Profiles) + QLatin1String("/profiles.ini"), QSettings::IniFormat); return settings.value(QLatin1String("Profiles/startProfile"), QLatin1String("default")).toString(); } void ProfileManager::setStartingProfile(const QString &profileName) { - QSettings settings(DataPaths::path(DataPaths::Profiles) + QLatin1String("profiles.ini"), QSettings::IniFormat); + QSettings settings(DataPaths::path(DataPaths::Profiles) + QLatin1String("/profiles.ini"), QSettings::IniFormat); settings.setValue(QLatin1String("Profiles/startProfile"), profileName); } @@ -249,7 +246,7 @@ void ProfileManager::copyDataToProfile() void ProfileManager::connectDatabase() { - const QString dbFile = DataPaths::currentProfilePath() + QLatin1String("browsedata.db"); + const QString dbFile = DataPaths::currentProfilePath() + QLatin1String("/browsedata.db"); // Reconnect if (m_databaseConnected) { diff --git a/src/lib/cookies/cookiejar.cpp b/src/lib/cookies/cookiejar.cpp index 81d50236d..da223b734 100644 --- a/src/lib/cookies/cookiejar.cpp +++ b/src/lib/cookies/cookiejar.cpp @@ -115,7 +115,7 @@ void CookieJar::restoreCookies() return; } - const QString cookiesFile = DataPaths::currentProfilePath() + QLatin1String("cookies.dat"); + const QString cookiesFile = DataPaths::currentProfilePath() + QLatin1String("/cookies.dat"); QDateTime now = QDateTime::currentDateTime(); QList restoredCookies; @@ -165,7 +165,7 @@ void CookieJar::saveCookies() } } - QFile file(DataPaths::currentProfilePath() + QLatin1String("cookies.dat")); + QFile file(DataPaths::currentProfilePath() + QLatin1String("/cookies.dat")); file.open(QIODevice::WriteOnly); QDataStream stream(&file); int count = cookies.count(); diff --git a/src/lib/network/cabundleupdater.cpp b/src/lib/network/cabundleupdater.cpp index 4db5be56c..dd4a91a2b 100644 --- a/src/lib/network/cabundleupdater.cpp +++ b/src/lib/network/cabundleupdater.cpp @@ -35,9 +35,9 @@ CaBundleUpdater::CaBundleUpdater(NetworkManager* manager, QObject* parent) , m_reply(0) , m_latestBundleVersion(0) { - m_bundleVersionFileName = DataPaths::path(DataPaths::Config) + "certificates/bundle_version"; - m_bundleFileName = DataPaths::path(DataPaths::Config) + "certificates/ca-bundle.crt"; - m_lastUpdateFileName = DataPaths::path(DataPaths::Config) + "certificates/last_update"; + m_bundleVersionFileName = DataPaths::path(DataPaths::Config) + "/certificates/bundle_version"; + m_bundleFileName = DataPaths::path(DataPaths::Config) + "/certificates/ca-bundle.crt"; + m_lastUpdateFileName = DataPaths::path(DataPaths::Config) + "/certificates/last_update"; int updateTime = 30 * 1000; diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 854127c4e..fe7cde190 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -112,7 +112,7 @@ void NetworkManager::loadSettings() m_acceptLanguage = AcceptLanguage::generateHeader(settings.value("Language/acceptLanguage", AcceptLanguage::defaultLanguage()).toStringList()); #if defined(Q_OS_WIN) || defined(Q_OS_HAIKU) || defined(Q_OS_OS2) - QString certDir = DataPaths::currentProfilePath() + "certificates"; + QString certDir = DataPaths::currentProfilePath() + "/certificates"; QString bundlePath = certDir + "/ca-bundle.crt"; QString bundleVersionPath = certDir + "/bundle_version"; @@ -594,7 +594,7 @@ void NetworkManager::removeLocalCertificate(const QSslCertificate &cert) // Delete cert file from profile bool deleted = false; - QDirIterator it(DataPaths::currentProfilePath() + "certificates", QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); + QDirIterator it(DataPaths::currentProfilePath() + "/certificates", QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); while (it.hasNext()) { const QString filePath = it.next(); const QList &certs = QSslCertificate::fromPath(filePath); @@ -634,7 +634,7 @@ void NetworkManager::addLocalCertificate(const QSslCertificate &cert) } QString certFileName = fileNameForCert(cert); - QString fileName = QzTools::ensureUniqueFilename(DataPaths::currentProfilePath() + "certificates/" + certFileName); + QString fileName = QzTools::ensureUniqueFilename(DataPaths::currentProfilePath() + "/certificates/" + certFileName); QFile file(fileName); if (file.open(QFile::WriteOnly)) { @@ -726,7 +726,7 @@ void NetworkManager::loadCertificates() } // Local Certificates #ifdef Q_OS_WIN - QDirIterator it_(DataPaths::currentProfilePath() + "certificates", QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); + QDirIterator it_(DataPaths::currentProfilePath() + "/certificates", QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); while (it_.hasNext()) { QString filePath = it_.next(); if (!filePath.endsWith(QLatin1String(".crt"))) { @@ -739,7 +739,7 @@ void NetworkManager::loadCertificates() } } #else - m_localCerts = QSslCertificate::fromPath(DataPaths::currentProfilePath() + "certificates/*.crt", QSsl::Pem, QRegExp::Wildcard); + m_localCerts = QSslCertificate::fromPath(DataPaths::currentProfilePath() + "/certificates/*.crt", QSsl::Pem, QRegExp::Wildcard); #endif QSslSocket::setDefaultCaCertificates(m_caCerts + m_localCerts); diff --git a/src/lib/network/pac/pacmanager.cpp b/src/lib/network/pac/pacmanager.cpp index bbc19412d..b2acc8739 100644 --- a/src/lib/network/pac/pacmanager.cpp +++ b/src/lib/network/pac/pacmanager.cpp @@ -99,7 +99,7 @@ void PacManager::replyFinished() m_reply->deleteLater(); m_reply = 0; - QFile file(DataPaths::currentProfilePath() + "proxy.pac"); + QFile file(DataPaths::currentProfilePath() + "/proxy.pac"); if (!file.open(QFile::WriteOnly)) { qWarning() << "PacManager: Cannot open PAC file for writing" << file.fileName(); @@ -118,7 +118,7 @@ void PacManager::reloadScript() m_pacrunner = new ProxyAutoConfig(this); } - QFile file(m_url.scheme() == QLatin1String("file") ? m_url.path() : DataPaths::currentProfilePath() + "proxy.pac"); + QFile file(m_url.scheme() == QLatin1String("file") ? m_url.path() : DataPaths::currentProfilePath() + "/proxy.pac"); if (!file.open(QFile::ReadOnly)) { qWarning() << "PacManager: Cannot open PAC file for reading" << file.fileName(); diff --git a/src/lib/network/schemehandlers/qupzillaschemehandler.cpp b/src/lib/network/schemehandlers/qupzillaschemehandler.cpp index 88af4438b..d3510ba17 100644 --- a/src/lib/network/schemehandlers/qupzillaschemehandler.cpp +++ b/src/lib/network/schemehandlers/qupzillaschemehandler.cpp @@ -397,9 +397,9 @@ QString QupZillaSchemeReply::configPage() cPage.replace(QLatin1String("%PATHS-TEXT%"), QString("
%1
%2
").arg(tr("Profile"), DataPaths::currentProfilePath()) + - QString("
%1
%2
").arg(tr("Settings"), DataPaths::currentProfilePath() + "settings.ini") + - QString("
%1
%2
").arg(tr("Saved session"), DataPaths::currentProfilePath() + "session.dat") + - QString("
%1
%2
").arg(tr("Pinned tabs"), DataPaths::currentProfilePath() + "pinnedtabs.dat") + + QString("
%1
%2
").arg(tr("Settings"), DataPaths::currentProfilePath() + "/settings.ini") + + QString("
%1
%2
").arg(tr("Saved session"), DataPaths::currentProfilePath() + "/session.dat") + + QString("
%1
%2
").arg(tr("Pinned tabs"), DataPaths::currentProfilePath() + "/pinnedtabs.dat") + QString("
%1
%2
").arg(tr("Data"), DataPaths::path(DataPaths::AppData)) + QString("
%1
%2
").arg(tr("Themes"), DataPaths::path(DataPaths::Themes)) + QString("
%1
%2
").arg(tr("Translations"), DataPaths::path(DataPaths::Translations))); diff --git a/src/lib/other/clearprivatedata.cpp b/src/lib/other/clearprivatedata.cpp index 4c5c951f1..50dc1f657 100644 --- a/src/lib/other/clearprivatedata.cpp +++ b/src/lib/other/clearprivatedata.cpp @@ -68,7 +68,7 @@ void ClearPrivateData::clearLocalStorage() { const QString profile = DataPaths::currentProfilePath(); - QzTools::removeDir(profile + "LocalStorage"); + QzTools::removeDir(profile + "/LocalStorage"); } void ClearPrivateData::clearWebDatabases() @@ -76,7 +76,7 @@ void ClearPrivateData::clearWebDatabases() const QString profile = DataPaths::currentProfilePath(); QWebDatabase::removeAllDatabases(); - QzTools::removeDir(profile + "Databases"); + QzTools::removeDir(profile + "/Databases"); } void ClearPrivateData::clearCache() @@ -84,7 +84,7 @@ void ClearPrivateData::clearCache() mApp->networkCache()->clear(); mApp->webSettings()->clearMemoryCaches(); - QFile::remove(DataPaths::currentProfilePath() + "ApplicationCache.db"); + QFile::remove(DataPaths::currentProfilePath() + "/ApplicationCache.db"); } void ClearPrivateData::clearIcons() @@ -175,12 +175,12 @@ void ClearPrivateData::optimizeDb() { mApp->setOverrideCursor(Qt::WaitCursor); - QString profilePath = DataPaths::currentProfilePath(); - QString sizeBefore = QzTools::fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); + const QString profilePath = DataPaths::currentProfilePath(); + QString sizeBefore = QzTools::fileSizeToString(QFileInfo(profilePath + "/browsedata.db").size()); mApp->history()->optimizeHistory(); - QString sizeAfter = QzTools::fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); + QString sizeAfter = QzTools::fileSizeToString(QFileInfo(profilePath + "/browsedata.db").size()); mApp->restoreOverrideCursor(); diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index 4339431df..ccb2fa62e 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -125,7 +125,7 @@ void Plugins::loadPlugins() return; } - QDir settingsDir(DataPaths::currentProfilePath() + "extensions/"); + QDir settingsDir(DataPaths::currentProfilePath() + "/extensions/"); if (!settingsDir.exists()) { settingsDir.mkdir(settingsDir.absolutePath()); } @@ -213,7 +213,7 @@ PluginInterface* Plugins::initPlugin(PluginInterface::InitState state, PluginInt return 0; } - interface->init(state, DataPaths::currentProfilePath() + "extensions/"); + interface->init(state, DataPaths::currentProfilePath() + "/extensions/"); if (!interface->testPlugin()) { interface->unload(); diff --git a/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp b/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp index ea5cfab4c..4a6ade6c9 100644 --- a/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp +++ b/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp @@ -37,7 +37,7 @@ SpellCheckDialog::SpellCheckDialog(QWidget* parent) ui->dictPath->setText(Speller::instance()->dictionaryPath()); - QFile file(DataPaths::currentProfilePath() + "userdictionary.txt"); + QFile file(DataPaths::currentProfilePath() + "/userdictionary.txt"); if (!file.open(QFile::ReadOnly)) { qWarning() << "SpellCheckDialog: Cannot open file" << file.fileName() << "for reading!"; } @@ -114,7 +114,7 @@ void SpellCheckDialog::saveSettings() return; } - QFile file(DataPaths::currentProfilePath() + "userdictionary.txt"); + QFile file(DataPaths::currentProfilePath() + "/userdictionary.txt"); if (!file.open(QFile::WriteOnly | QFile::Truncate)) { qWarning() << "SpellCheckDialog: Cannot open file" << file.fileName() << "for reading!"; return; diff --git a/src/lib/plugins/qtwebkit/spellcheck/speller.cpp b/src/lib/plugins/qtwebkit/spellcheck/speller.cpp index 4b6908e9b..ef146a6d2 100644 --- a/src/lib/plugins/qtwebkit/spellcheck/speller.cpp +++ b/src/lib/plugins/qtwebkit/spellcheck/speller.cpp @@ -65,7 +65,7 @@ void Speller::loadSettings() m_language.name = nameForLanguage(m_language.code); settings.endGroup(); - m_userDictionary.setFileName(DataPaths::currentProfilePath() + "userdictionary.txt"); + m_userDictionary.setFileName(DataPaths::currentProfilePath() + "/userdictionary.txt"); if (m_enabled) { initialize(); @@ -393,7 +393,7 @@ QString Speller::getDictionaryPath() const #ifdef Q_OS_UNIX const QString defaultDicPath = "/usr/share/hunspell/"; #else - const QString defaultDicPath = DataPaths::path(DataPaths::AppData) + "hunspell/"; + const QString defaultDicPath = DataPaths::path(DataPaths::AppData) + "/hunspell/"; #endif QString dicPath = QString::fromLocal8Bit(qgetenv("DICPATH")).trimmed(); diff --git a/src/lib/plugins/speeddial.cpp b/src/lib/plugins/speeddial.cpp index 2fe5320d9..95e333ae0 100644 --- a/src/lib/plugins/speeddial.cpp +++ b/src/lib/plugins/speeddial.cpp @@ -63,7 +63,7 @@ void SpeedDial::loadSettings() } changed(allPages); - m_thumbnailsDir = DataPaths::currentProfilePath() + "thumbnails/"; + m_thumbnailsDir = DataPaths::currentProfilePath() + "/thumbnails/"; // If needed, create thumbnails directory if (!QDir(m_thumbnailsDir).exists()) { diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 610e8b51d..b3c1b88f8 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -290,6 +290,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent) ui->allowCache->setChecked(settings.value("AllowLocalCache", true).toBool()); ui->cacheMB->setValue(settings.value("LocalCacheSize", 50).toInt()); ui->MBlabel->setText(settings.value("LocalCacheSize", 50).toString() + " MB"); + // FIXME: !!! ui->cachePath->setText(settings.value("CachePath", QString("%1networkcache/").arg(DataPaths::currentProfilePath())).toString()); connect(ui->allowCache, SIGNAL(clicked(bool)), this, SLOT(allowCacheChanged(bool))); connect(ui->cacheMB, SIGNAL(valueChanged(int)), this, SLOT(cacheValueChanged(int))); @@ -1068,9 +1069,8 @@ void Preferences::saveSettings() settings.setValue("ProxyExceptions", ui->proxyExceptions->text().split(QLatin1Char(','), QString::SkipEmptyParts)); settings.endGroup(); - //Profiles - QSettings profileSettings(DataPaths::path(DataPaths::Config) + "profiles/profiles.ini", QSettings::IniFormat); - profileSettings.setValue("Profiles/startProfile", ui->startProfile->currentText()); + ProfileManager profileManager; + profileManager.setStartingProfile(ui->startProfile->currentText()); m_pluginsList->save(); m_themesManager->save(); diff --git a/src/lib/preferences/thememanager.cpp b/src/lib/preferences/thememanager.cpp index fdb5b38f0..cc1723840 100644 --- a/src/lib/preferences/thememanager.cpp +++ b/src/lib/preferences/thememanager.cpp @@ -47,7 +47,7 @@ ThemeManager::ThemeManager(QWidget* parent, Preferences* preferences) QDir dir(path); QStringList list = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); foreach (const QString &name, list) { - Theme themeInfo = parseTheme(dir.absoluteFilePath(name) + "/", name); + Theme themeInfo = parseTheme(dir.absoluteFilePath(name) + QLatin1Char('/'), name); if (!themeInfo.isValid) { continue; } diff --git a/src/lib/session/restoremanager.cpp b/src/lib/session/restoremanager.cpp index 9b618d616..c20eb7fdf 100644 --- a/src/lib/session/restoremanager.cpp +++ b/src/lib/session/restoremanager.cpp @@ -23,7 +23,7 @@ RestoreManager::RestoreManager() { - createFromFile(DataPaths::currentProfilePath() + QLatin1String("session.dat")); + createFromFile(DataPaths::currentProfilePath() + QLatin1String("/session.dat")); } RestoreData RestoreManager::restoreData() const diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index e2112b7c9..e9116e23b 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -901,7 +901,7 @@ void TabWidget::savePinnedTabs() stream << tabs; stream << tabsHistory; - QFile file(DataPaths::currentProfilePath() + "pinnedtabs.dat"); + QFile file(DataPaths::currentProfilePath() + "/pinnedtabs.dat"); file.open(QIODevice::WriteOnly); file.write(data); file.close(); @@ -913,7 +913,7 @@ void TabWidget::restorePinnedTabs() return; } - QFile file(DataPaths::currentProfilePath() + "pinnedtabs.dat"); + QFile file(DataPaths::currentProfilePath() + "/pinnedtabs.dat"); file.open(QIODevice::ReadOnly); QByteArray sd = file.readAll(); file.close(); diff --git a/src/plugins/StatusBarIcons/sbi_networkmanager.cpp b/src/plugins/StatusBarIcons/sbi_networkmanager.cpp index 49868576a..9b6c624cf 100644 --- a/src/plugins/StatusBarIcons/sbi_networkmanager.cpp +++ b/src/plugins/StatusBarIcons/sbi_networkmanager.cpp @@ -123,7 +123,7 @@ void SBI_NetworkManager::applyCurrentProxy() } // Manually modify settings to apply proxy configuration - QSettings settings(DataPaths::currentProfilePath() + "settings.ini", QSettings::IniFormat); + QSettings settings(DataPaths::currentProfilePath() + "/settings.ini", QSettings::IniFormat); settings.beginGroup("Web-Proxy"); m_currentProxy->saveToSettings(settings); settings.endGroup();