1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

[DataPaths] Don't add trailing slash to paths

Qt API is not adding trailing slashes to dir paths either.
This commit is contained in:
nowrep 2014-03-09 22:17:13 +01:00
parent 214279e3bb
commit 969f262cf8
21 changed files with 92 additions and 104 deletions

View File

@ -150,7 +150,7 @@ AdBlockSubscription* AdBlockManager::addSubscription(const QString &title, const
} }
QString fileName = QzTools::filterCharsFromFilename(title.toLower()) + ".txt"; 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(); 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; return;
} }
QDir adblockDir(DataPaths::currentProfilePath() + "adblock"); QDir adblockDir(DataPaths::currentProfilePath() + "/adblock");
// Create if neccessary // Create if neccessary
if (!adblockDir.exists()) { if (!adblockDir.exists()) {
QDir(DataPaths::currentProfilePath()).mkdir("adblock"); QDir(DataPaths::currentProfilePath()).mkdir("adblock");
@ -261,7 +261,7 @@ void AdBlockManager::load()
if (m_subscriptions.isEmpty()) { if (m_subscriptions.isEmpty()) {
AdBlockSubscription* easyList = new AdBlockSubscription(tr("EasyList"), this); AdBlockSubscription* easyList = new AdBlockSubscription(tr("EasyList"), this);
easyList->setUrl(QUrl(ADBLOCK_EASYLIST_URL)); 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())); connect(easyList, SIGNAL(subscriptionUpdated()), mApp, SLOT(reloadUserStyleSheet()));
m_subscriptions.prepend(easyList); m_subscriptions.prepend(easyList);

View File

@ -458,7 +458,7 @@ AdBlockSubscription::~AdBlockSubscription()
AdBlockCustomList::AdBlockCustomList(QObject* parent) AdBlockCustomList::AdBlockCustomList(QObject* parent)
: AdBlockSubscription(tr("Custom Rules"), parent) : AdBlockSubscription(tr("Custom Rules"), parent)
{ {
setFilePath(DataPaths::currentProfilePath() + "adblock/customlist.txt"); setFilePath(DataPaths::currentProfilePath() + QLatin1String("/adblock/customlist.txt"));
} }
void AdBlockCustomList::saveSubscription() void AdBlockCustomList::saveSubscription()

View File

@ -42,13 +42,10 @@ void DataPaths::setPortableVersion()
d->m_paths[Config] = d->m_paths[AppData]; d->m_paths[Config] = d->m_paths[AppData];
d->m_paths[Profiles] = d->m_paths[Config]; d->m_paths[Profiles] = d->m_paths[Config];
d->m_paths[Profiles].first().append(QLatin1String("profiles/")); 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[Temp] = d->m_paths[Config]; 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 // static
@ -85,16 +82,16 @@ void DataPaths::init()
// AppData // AppData
#if defined(Q_OS_MAC) #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) #elif defined(Q_OS_UNIX) && !defined(NO_SYSTEM_DATAPATH)
m_paths[AppData].append(USE_DATADIR "/"); m_paths[AppData].append(USE_DATADIR);
#else #else
m_paths[AppData].append(QApplication::applicationDirPath() + QLatin1Char('/')); m_paths[AppData].append(QApplication::applicationDirPath());
#endif #endif
m_paths[Translations].append(m_paths[AppData].first() + QLatin1String("locale/")); m_paths[Translations].append(m_paths[AppData].first() + QLatin1String("/locale"));
m_paths[Themes].append(m_paths[AppData].first() + QLatin1String("themes/")); m_paths[Themes].append(m_paths[AppData].first() + QLatin1String("/themes"));
m_paths[Plugins].append(m_paths[AppData].first() + QLatin1String("plugins/")); m_paths[Plugins].append(m_paths[AppData].first() + QLatin1String("/plugins"));
// Config // Config
#if defined(Q_OS_WIN) || defined(Q_OS_OS2) #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
@ -106,29 +103,29 @@ void DataPaths::init()
#endif #endif
// Backwards compatibility // Backwards compatibility
if (dataLocation.isEmpty()) { if (dataLocation.isEmpty()) {
dataLocation = QDir::homePath() + QLatin1String("/.config/qupzilla/"); dataLocation = QDir::homePath() + QLatin1String("/.config/qupzilla");
} }
QDir confPath = QDir(dataLocation); QDir confPath = QDir(dataLocation);
QDir homePath = QDir(QDir::homePath() + QLatin1String("/.qupzilla/")); QDir homePath = QDir(QDir::homePath() + QLatin1String("/.qupzilla"));
if (!homePath.exists()) { if (!homePath.exists()) {
homePath = QDir::homePath() + QLatin1String("/.config/qupzilla/"); homePath = QDir::homePath() + QLatin1String("/.config/qupzilla");
} }
#else // Unix #else // Unix
QDir confPath = QDir(QDir::homePath() + QLatin1String("/.config/qupzilla/")); QDir confPath = QDir(QDir::homePath() + QLatin1String("/.config/qupzilla"));
QDir homePath = QDir(QDir::homePath() + QLatin1String("/.qupzilla/")); QDir homePath = QDir(QDir::homePath() + QLatin1String("/.qupzilla"));
#endif #endif
if (homePath.exists() && !confPath.exists()) { 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: Using deprecated configuration path" << homePath.absolutePath();
qWarning() << "WARNING: This path may not be supported in future versions!"; qWarning() << "WARNING: This path may not be supported in future versions!";
qWarning() << "WARNING: Please move your configuration into" << confPath.absolutePath(); qWarning() << "WARNING: Please move your configuration into" << confPath.absolutePath();
} }
else { else {
m_paths[Config].append(confPath.absolutePath() + QLatin1Char('/')); m_paths[Config].append(confPath.absolutePath());
} }
// Make sure the Config path exists // Make sure the Config path exists
@ -136,35 +133,30 @@ void DataPaths::init()
dir.mkpath(m_paths[Config].first()); dir.mkpath(m_paths[Config].first());
// Profiles // Profiles
m_paths[Profiles].append(m_paths[Config].first() + QLatin1String("profiles/")); m_paths[Profiles].append(m_paths[Config].first() + QLatin1String("/profiles"));
// Crashlogs
m_paths[CrashLogs].append(m_paths[Config].first() + QLatin1String("crashlogs/"));
// Temp // Temp
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
dir.mkpath(QDir::tempPath() + QLatin1String("/qupzilla/tmp")); 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 #else
m_paths[Temp].append(m_paths[Config].first() + QLatin1String("tmp/")); m_paths[Temp].append(m_paths[Config].first() + QLatin1String("/tmp"));
#endif #endif
// We also allow to load data from Config path // We also allow to load data from Config path
m_paths[Translations].append(m_paths[Config].first() + QLatin1String("locale/")); m_paths[Translations].append(m_paths[Config].first() + QLatin1String("/locale"));
m_paths[Themes].append(m_paths[Config].first() + QLatin1String("themes/")); m_paths[Themes].append(m_paths[Config].first() + QLatin1String("/themes"));
m_paths[Plugins].append(m_paths[Config].first() + QLatin1String("plugins/")); m_paths[Plugins].append(m_paths[Config].first() + QLatin1String("/plugins"));
#ifdef USE_LIBPATH #ifdef USE_LIBPATH
m_paths[Plugins].append(QLatin1String(USE_LIBPATH "/qupzilla/")); m_paths[Plugins].append(QLatin1String(USE_LIBPATH "/qupzilla"));
#else #else
// FIXME: This should use QUPZILLA_PREFIX // FIXME: This should use QUPZILLA_PREFIX
m_paths[Plugins].append(QLatin1String("/usr/lib/qupzilla/")); m_paths[Plugins].append(QLatin1String("/usr/lib/qupzilla"));
#endif #endif
} }
void DataPaths::initCurrentProfile(const QString &profilePath) void DataPaths::initCurrentProfile(const QString &profilePath)
{ {
Q_ASSERT(profilePath.endsWith('/'));
m_paths[CurrentProfile].append(profilePath); m_paths[CurrentProfile].append(profilePath);
} }

View File

@ -25,15 +25,14 @@ class DataPaths
{ {
public: public:
enum Path { enum Path {
AppData, // /usr/share/qupzilla/ or . or ../Resources/ AppData, // /usr/share/qupzilla or . or ../Resources
Translations, // $AppData/locale/ Translations, // $AppData/locale
Themes, // $AppData/themes/ Themes, // $AppData/themes
Plugins, // $AppData/plugins/ Plugins, // $AppData/plugins
Config, // ~/.config/qupzilla/ or %LOCALAPPDATA%/qupzilla/ or $AppData/data (portable) Config, // ~/.config/qupzilla or %LOCALAPPDATA%/qupzilla or $AppData/data (portable)
Profiles, // $Config/profiles/ Profiles, // $Config/profiles
CurrentProfile, // $Profiles/current_profile/ CurrentProfile, // $Profiles/current_profile
CrashLogs, // $Config/crashlogs/ Temp // $Config/tmp
Temp // $Config/tmp/
}; };
explicit DataPaths(); explicit DataPaths();

View File

@ -225,7 +225,7 @@ MainApplication::MainApplication(int &argc, char** argv)
profileManager.initConfigDir(); profileManager.initConfigDir();
profileManager.initCurrentProfile(startProfile); profileManager.initCurrentProfile(startProfile);
Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("settings.ini")); Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini"));
m_autoSaver = new AutoSaver(this); m_autoSaver = new AutoSaver(this);
connect(m_autoSaver, SIGNAL(save()), this, SLOT(saveStateSlot())); 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); const QStringList themePaths = DataPaths::allPaths(DataPaths::Themes);
foreach (const QString &path, themePaths) { foreach (const QString &path, themePaths) {
const QString theme = path + name + "/"; const QString theme = QString("%1/%2").arg(path, name);
if (QFile::exists(theme + "main.css")) { if (QFile::exists(theme + "/main.css")) {
activeThemePath = theme; activeThemePath = theme;
break; break;
} }
@ -631,10 +631,10 @@ void MainApplication::loadTheme(const QString &name)
if (activeThemePath.isEmpty()) { if (activeThemePath.isEmpty()) {
qWarning() << "Cannot load theme " << name; 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); cssFile.open(QFile::ReadOnly);
QString css = cssFile.readAll(); QString css = cssFile.readAll();
cssFile.close(); cssFile.close();
@ -644,8 +644,8 @@ void MainApplication::loadTheme(const QString &name)
* should be enough instead of loading special stylesheets * should be enough instead of loading special stylesheets
*/ */
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
if (QFile(activeThemePath + "linux.css").exists()) { if (QFile(activeThemePath + "/linux.css").exists()) {
cssFile.setFileName(activeThemePath + "linux.css"); cssFile.setFileName(activeThemePath + "/linux.css");
cssFile.open(QFile::ReadOnly); cssFile.open(QFile::ReadOnly);
css.append(cssFile.readAll()); css.append(cssFile.readAll());
cssFile.close(); cssFile.close();
@ -653,8 +653,8 @@ void MainApplication::loadTheme(const QString &name)
#endif #endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
if (QFile(activeThemePath + "mac.css").exists()) { if (QFile(activeThemePath + "/mac.css").exists()) {
cssFile.setFileName(activeThemePath + "mac.css"); cssFile.setFileName(activeThemePath + "/mac.css");
cssFile.open(QFile::ReadOnly); cssFile.open(QFile::ReadOnly);
css.append(cssFile.readAll()); css.append(cssFile.readAll());
cssFile.close(); cssFile.close();
@ -662,8 +662,8 @@ void MainApplication::loadTheme(const QString &name)
#endif #endif
#if defined(Q_OS_WIN) || defined(Q_OS_OS2) #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
if (QFile(activeThemePath + "windows.css").exists()) { if (QFile(activeThemePath + "/windows.css").exists()) {
cssFile.setFileName(activeThemePath + "windows.css"); cssFile.setFileName(activeThemePath + "/windows.css");
cssFile.open(QFile::ReadOnly); cssFile.open(QFile::ReadOnly);
css.append(cssFile.readAll()); css.append(cssFile.readAll());
cssFile.close(); cssFile.close();
@ -672,8 +672,8 @@ void MainApplication::loadTheme(const QString &name)
// RTL Support // RTL Support
// Loading 'rtl.css' when layout is right to left! // Loading 'rtl.css' when layout is right to left!
if (isRightToLeft() && QFile(activeThemePath + "rtl.css").exists()) { if (isRightToLeft() && QFile(activeThemePath + "/rtl.css").exists()) {
cssFile.setFileName(activeThemePath + "rtl.css"); cssFile.setFileName(activeThemePath + "/rtl.css");
cssFile.open(QFile::ReadOnly); cssFile.open(QFile::ReadOnly);
css.append(cssFile.readAll()); css.append(cssFile.readAll());
cssFile.close(); cssFile.close();
@ -739,7 +739,7 @@ void MainApplication::backupSavedSessions()
// session.dat.old - first backup // session.dat.old - first backup
// session.dat.old1 - second 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)) { if (!QFile::exists(sessionFile)) {
return; return;
@ -816,7 +816,7 @@ void MainApplication::saveSettings()
qzSettings->saveSettings(); qzSettings->saveSettings();
AdBlockManager::instance()->save(); AdBlockManager::instance()->save();
IconProvider::instance()->saveIconsToDatabase(); IconProvider::instance()->saveIconsToDatabase();
QFile::remove(DataPaths::currentProfilePath() + QLatin1String("WebpageIcons.db")); QFile::remove(DataPaths::currentProfilePath() + QLatin1String("/WebpageIcons.db"));
Settings::syncSettings(); Settings::syncSettings();
} }
@ -1109,7 +1109,7 @@ bool MainApplication::saveStateSlot()
qupzilla_->tabWidget()->savePinnedTabs(); qupzilla_->tabWidget()->savePinnedTabs();
} }
QFile file(DataPaths::currentProfilePath() + QLatin1String("session.dat")); QFile file(DataPaths::currentProfilePath() + QLatin1String("/session.dat"));
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(data); file.write(data);
file.close(); file.close();

View File

@ -73,7 +73,7 @@ void ProfileManager::initConfigDir() const
void ProfileManager::initCurrentProfile(const QString &profileName) void ProfileManager::initCurrentProfile(const QString &profileName)
{ {
QString profilePath = DataPaths::path(DataPaths::Profiles); QString profilePath = DataPaths::path(DataPaths::Profiles) + QLatin1Char('/');
if (profileName.isEmpty()) { if (profileName.isEmpty()) {
profilePath.append(startingProfile()); profilePath.append(startingProfile());
@ -82,7 +82,7 @@ void ProfileManager::initCurrentProfile(const QString &profileName)
profilePath.append(profileName); profilePath.append(profileName);
} }
DataPaths::setCurrentProfilePath(profilePath + QLatin1Char('/')); DataPaths::setCurrentProfilePath(profilePath);
updateCurrentProfile(); updateCurrentProfile();
connectDatabase(); connectDatabase();
@ -126,9 +126,6 @@ bool ProfileManager::removeProfile(const QString &profileName)
QString ProfileManager::currentProfile() const QString ProfileManager::currentProfile() const
{ {
//const QString path = DataPaths::currentProfilePath();
//return path.mid(path.lastIndexOf(QLatin1Char('/')) + 1);
QString path = DataPaths::currentProfilePath(); QString path = DataPaths::currentProfilePath();
path = path.mid(0, path.size() - 1); path = path.mid(0, path.size() - 1);
return path.mid(path.lastIndexOf(QLatin1Char('/')) + 1); return path.mid(path.lastIndexOf(QLatin1Char('/')) + 1);
@ -136,13 +133,13 @@ QString ProfileManager::currentProfile() const
QString ProfileManager::startingProfile() 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(); return settings.value(QLatin1String("Profiles/startProfile"), QLatin1String("default")).toString();
} }
void ProfileManager::setStartingProfile(const QString &profileName) 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); settings.setValue(QLatin1String("Profiles/startProfile"), profileName);
} }
@ -249,7 +246,7 @@ void ProfileManager::copyDataToProfile()
void ProfileManager::connectDatabase() void ProfileManager::connectDatabase()
{ {
const QString dbFile = DataPaths::currentProfilePath() + QLatin1String("browsedata.db"); const QString dbFile = DataPaths::currentProfilePath() + QLatin1String("/browsedata.db");
// Reconnect // Reconnect
if (m_databaseConnected) { if (m_databaseConnected) {

View File

@ -115,7 +115,7 @@ void CookieJar::restoreCookies()
return; return;
} }
const QString cookiesFile = DataPaths::currentProfilePath() + QLatin1String("cookies.dat"); const QString cookiesFile = DataPaths::currentProfilePath() + QLatin1String("/cookies.dat");
QDateTime now = QDateTime::currentDateTime(); QDateTime now = QDateTime::currentDateTime();
QList<QNetworkCookie> restoredCookies; QList<QNetworkCookie> 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); file.open(QIODevice::WriteOnly);
QDataStream stream(&file); QDataStream stream(&file);
int count = cookies.count(); int count = cookies.count();

View File

@ -35,9 +35,9 @@ CaBundleUpdater::CaBundleUpdater(NetworkManager* manager, QObject* parent)
, m_reply(0) , m_reply(0)
, m_latestBundleVersion(0) , m_latestBundleVersion(0)
{ {
m_bundleVersionFileName = DataPaths::path(DataPaths::Config) + "certificates/bundle_version"; m_bundleVersionFileName = DataPaths::path(DataPaths::Config) + "/certificates/bundle_version";
m_bundleFileName = DataPaths::path(DataPaths::Config) + "certificates/ca-bundle.crt"; m_bundleFileName = DataPaths::path(DataPaths::Config) + "/certificates/ca-bundle.crt";
m_lastUpdateFileName = DataPaths::path(DataPaths::Config) + "certificates/last_update"; m_lastUpdateFileName = DataPaths::path(DataPaths::Config) + "/certificates/last_update";
int updateTime = 30 * 1000; int updateTime = 30 * 1000;

View File

@ -112,7 +112,7 @@ void NetworkManager::loadSettings()
m_acceptLanguage = AcceptLanguage::generateHeader(settings.value("Language/acceptLanguage", AcceptLanguage::defaultLanguage()).toStringList()); m_acceptLanguage = AcceptLanguage::generateHeader(settings.value("Language/acceptLanguage", AcceptLanguage::defaultLanguage()).toStringList());
#if defined(Q_OS_WIN) || defined(Q_OS_HAIKU) || defined(Q_OS_OS2) #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 bundlePath = certDir + "/ca-bundle.crt";
QString bundleVersionPath = certDir + "/bundle_version"; QString bundleVersionPath = certDir + "/bundle_version";
@ -594,7 +594,7 @@ void NetworkManager::removeLocalCertificate(const QSslCertificate &cert)
// Delete cert file from profile // Delete cert file from profile
bool deleted = false; 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()) { while (it.hasNext()) {
const QString filePath = it.next(); const QString filePath = it.next();
const QList<QSslCertificate> &certs = QSslCertificate::fromPath(filePath); const QList<QSslCertificate> &certs = QSslCertificate::fromPath(filePath);
@ -634,7 +634,7 @@ void NetworkManager::addLocalCertificate(const QSslCertificate &cert)
} }
QString certFileName = fileNameForCert(cert); QString certFileName = fileNameForCert(cert);
QString fileName = QzTools::ensureUniqueFilename(DataPaths::currentProfilePath() + "certificates/" + certFileName); QString fileName = QzTools::ensureUniqueFilename(DataPaths::currentProfilePath() + "/certificates/" + certFileName);
QFile file(fileName); QFile file(fileName);
if (file.open(QFile::WriteOnly)) { if (file.open(QFile::WriteOnly)) {
@ -726,7 +726,7 @@ void NetworkManager::loadCertificates()
} }
// Local Certificates // Local Certificates
#ifdef Q_OS_WIN #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()) { while (it_.hasNext()) {
QString filePath = it_.next(); QString filePath = it_.next();
if (!filePath.endsWith(QLatin1String(".crt"))) { if (!filePath.endsWith(QLatin1String(".crt"))) {
@ -739,7 +739,7 @@ void NetworkManager::loadCertificates()
} }
} }
#else #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 #endif
QSslSocket::setDefaultCaCertificates(m_caCerts + m_localCerts); QSslSocket::setDefaultCaCertificates(m_caCerts + m_localCerts);

View File

@ -99,7 +99,7 @@ void PacManager::replyFinished()
m_reply->deleteLater(); m_reply->deleteLater();
m_reply = 0; m_reply = 0;
QFile file(DataPaths::currentProfilePath() + "proxy.pac"); QFile file(DataPaths::currentProfilePath() + "/proxy.pac");
if (!file.open(QFile::WriteOnly)) { if (!file.open(QFile::WriteOnly)) {
qWarning() << "PacManager: Cannot open PAC file for writing" << file.fileName(); qWarning() << "PacManager: Cannot open PAC file for writing" << file.fileName();
@ -118,7 +118,7 @@ void PacManager::reloadScript()
m_pacrunner = new ProxyAutoConfig(this); 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)) { if (!file.open(QFile::ReadOnly)) {
qWarning() << "PacManager: Cannot open PAC file for reading" << file.fileName(); qWarning() << "PacManager: Cannot open PAC file for reading" << file.fileName();

View File

@ -397,9 +397,9 @@ QString QupZillaSchemeReply::configPage()
cPage.replace(QLatin1String("%PATHS-TEXT%"), cPage.replace(QLatin1String("%PATHS-TEXT%"),
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Profile"), DataPaths::currentProfilePath()) + QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Profile"), DataPaths::currentProfilePath()) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Settings"), DataPaths::currentProfilePath() + "settings.ini") + QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Settings"), DataPaths::currentProfilePath() + "/settings.ini") +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Saved session"), DataPaths::currentProfilePath() + "session.dat") + QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Saved session"), DataPaths::currentProfilePath() + "/session.dat") +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Pinned tabs"), DataPaths::currentProfilePath() + "pinnedtabs.dat") + QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Pinned tabs"), DataPaths::currentProfilePath() + "/pinnedtabs.dat") +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Data"), DataPaths::path(DataPaths::AppData)) + QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Data"), DataPaths::path(DataPaths::AppData)) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Themes"), DataPaths::path(DataPaths::Themes)) + QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Themes"), DataPaths::path(DataPaths::Themes)) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Translations"), DataPaths::path(DataPaths::Translations))); QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Translations"), DataPaths::path(DataPaths::Translations)));

View File

@ -68,7 +68,7 @@ void ClearPrivateData::clearLocalStorage()
{ {
const QString profile = DataPaths::currentProfilePath(); const QString profile = DataPaths::currentProfilePath();
QzTools::removeDir(profile + "LocalStorage"); QzTools::removeDir(profile + "/LocalStorage");
} }
void ClearPrivateData::clearWebDatabases() void ClearPrivateData::clearWebDatabases()
@ -76,7 +76,7 @@ void ClearPrivateData::clearWebDatabases()
const QString profile = DataPaths::currentProfilePath(); const QString profile = DataPaths::currentProfilePath();
QWebDatabase::removeAllDatabases(); QWebDatabase::removeAllDatabases();
QzTools::removeDir(profile + "Databases"); QzTools::removeDir(profile + "/Databases");
} }
void ClearPrivateData::clearCache() void ClearPrivateData::clearCache()
@ -84,7 +84,7 @@ void ClearPrivateData::clearCache()
mApp->networkCache()->clear(); mApp->networkCache()->clear();
mApp->webSettings()->clearMemoryCaches(); mApp->webSettings()->clearMemoryCaches();
QFile::remove(DataPaths::currentProfilePath() + "ApplicationCache.db"); QFile::remove(DataPaths::currentProfilePath() + "/ApplicationCache.db");
} }
void ClearPrivateData::clearIcons() void ClearPrivateData::clearIcons()
@ -175,12 +175,12 @@ void ClearPrivateData::optimizeDb()
{ {
mApp->setOverrideCursor(Qt::WaitCursor); mApp->setOverrideCursor(Qt::WaitCursor);
QString profilePath = DataPaths::currentProfilePath(); const QString profilePath = DataPaths::currentProfilePath();
QString sizeBefore = QzTools::fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); QString sizeBefore = QzTools::fileSizeToString(QFileInfo(profilePath + "/browsedata.db").size());
mApp->history()->optimizeHistory(); mApp->history()->optimizeHistory();
QString sizeAfter = QzTools::fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); QString sizeAfter = QzTools::fileSizeToString(QFileInfo(profilePath + "/browsedata.db").size());
mApp->restoreOverrideCursor(); mApp->restoreOverrideCursor();

View File

@ -125,7 +125,7 @@ void Plugins::loadPlugins()
return; return;
} }
QDir settingsDir(DataPaths::currentProfilePath() + "extensions/"); QDir settingsDir(DataPaths::currentProfilePath() + "/extensions/");
if (!settingsDir.exists()) { if (!settingsDir.exists()) {
settingsDir.mkdir(settingsDir.absolutePath()); settingsDir.mkdir(settingsDir.absolutePath());
} }
@ -213,7 +213,7 @@ PluginInterface* Plugins::initPlugin(PluginInterface::InitState state, PluginInt
return 0; return 0;
} }
interface->init(state, DataPaths::currentProfilePath() + "extensions/"); interface->init(state, DataPaths::currentProfilePath() + "/extensions/");
if (!interface->testPlugin()) { if (!interface->testPlugin()) {
interface->unload(); interface->unload();

View File

@ -37,7 +37,7 @@ SpellCheckDialog::SpellCheckDialog(QWidget* parent)
ui->dictPath->setText(Speller::instance()->dictionaryPath()); ui->dictPath->setText(Speller::instance()->dictionaryPath());
QFile file(DataPaths::currentProfilePath() + "userdictionary.txt"); QFile file(DataPaths::currentProfilePath() + "/userdictionary.txt");
if (!file.open(QFile::ReadOnly)) { if (!file.open(QFile::ReadOnly)) {
qWarning() << "SpellCheckDialog: Cannot open file" << file.fileName() << "for reading!"; qWarning() << "SpellCheckDialog: Cannot open file" << file.fileName() << "for reading!";
} }
@ -114,7 +114,7 @@ void SpellCheckDialog::saveSettings()
return; return;
} }
QFile file(DataPaths::currentProfilePath() + "userdictionary.txt"); QFile file(DataPaths::currentProfilePath() + "/userdictionary.txt");
if (!file.open(QFile::WriteOnly | QFile::Truncate)) { if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
qWarning() << "SpellCheckDialog: Cannot open file" << file.fileName() << "for reading!"; qWarning() << "SpellCheckDialog: Cannot open file" << file.fileName() << "for reading!";
return; return;

View File

@ -65,7 +65,7 @@ void Speller::loadSettings()
m_language.name = nameForLanguage(m_language.code); m_language.name = nameForLanguage(m_language.code);
settings.endGroup(); settings.endGroup();
m_userDictionary.setFileName(DataPaths::currentProfilePath() + "userdictionary.txt"); m_userDictionary.setFileName(DataPaths::currentProfilePath() + "/userdictionary.txt");
if (m_enabled) { if (m_enabled) {
initialize(); initialize();
@ -393,7 +393,7 @@ QString Speller::getDictionaryPath() const
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
const QString defaultDicPath = "/usr/share/hunspell/"; const QString defaultDicPath = "/usr/share/hunspell/";
#else #else
const QString defaultDicPath = DataPaths::path(DataPaths::AppData) + "hunspell/"; const QString defaultDicPath = DataPaths::path(DataPaths::AppData) + "/hunspell/";
#endif #endif
QString dicPath = QString::fromLocal8Bit(qgetenv("DICPATH")).trimmed(); QString dicPath = QString::fromLocal8Bit(qgetenv("DICPATH")).trimmed();

View File

@ -63,7 +63,7 @@ void SpeedDial::loadSettings()
} }
changed(allPages); changed(allPages);
m_thumbnailsDir = DataPaths::currentProfilePath() + "thumbnails/"; m_thumbnailsDir = DataPaths::currentProfilePath() + "/thumbnails/";
// If needed, create thumbnails directory // If needed, create thumbnails directory
if (!QDir(m_thumbnailsDir).exists()) { if (!QDir(m_thumbnailsDir).exists()) {

View File

@ -290,6 +290,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
ui->allowCache->setChecked(settings.value("AllowLocalCache", true).toBool()); ui->allowCache->setChecked(settings.value("AllowLocalCache", true).toBool());
ui->cacheMB->setValue(settings.value("LocalCacheSize", 50).toInt()); ui->cacheMB->setValue(settings.value("LocalCacheSize", 50).toInt());
ui->MBlabel->setText(settings.value("LocalCacheSize", 50).toString() + " MB"); ui->MBlabel->setText(settings.value("LocalCacheSize", 50).toString() + " MB");
// FIXME: !!!
ui->cachePath->setText(settings.value("CachePath", QString("%1networkcache/").arg(DataPaths::currentProfilePath())).toString()); ui->cachePath->setText(settings.value("CachePath", QString("%1networkcache/").arg(DataPaths::currentProfilePath())).toString());
connect(ui->allowCache, SIGNAL(clicked(bool)), this, SLOT(allowCacheChanged(bool))); connect(ui->allowCache, SIGNAL(clicked(bool)), this, SLOT(allowCacheChanged(bool)));
connect(ui->cacheMB, SIGNAL(valueChanged(int)), this, SLOT(cacheValueChanged(int))); 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.setValue("ProxyExceptions", ui->proxyExceptions->text().split(QLatin1Char(','), QString::SkipEmptyParts));
settings.endGroup(); settings.endGroup();
//Profiles ProfileManager profileManager;
QSettings profileSettings(DataPaths::path(DataPaths::Config) + "profiles/profiles.ini", QSettings::IniFormat); profileManager.setStartingProfile(ui->startProfile->currentText());
profileSettings.setValue("Profiles/startProfile", ui->startProfile->currentText());
m_pluginsList->save(); m_pluginsList->save();
m_themesManager->save(); m_themesManager->save();

View File

@ -47,7 +47,7 @@ ThemeManager::ThemeManager(QWidget* parent, Preferences* preferences)
QDir dir(path); QDir dir(path);
QStringList list = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); QStringList list = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
foreach (const QString &name, list) { foreach (const QString &name, list) {
Theme themeInfo = parseTheme(dir.absoluteFilePath(name) + "/", name); Theme themeInfo = parseTheme(dir.absoluteFilePath(name) + QLatin1Char('/'), name);
if (!themeInfo.isValid) { if (!themeInfo.isValid) {
continue; continue;
} }

View File

@ -23,7 +23,7 @@
RestoreManager::RestoreManager() RestoreManager::RestoreManager()
{ {
createFromFile(DataPaths::currentProfilePath() + QLatin1String("session.dat")); createFromFile(DataPaths::currentProfilePath() + QLatin1String("/session.dat"));
} }
RestoreData RestoreManager::restoreData() const RestoreData RestoreManager::restoreData() const

View File

@ -901,7 +901,7 @@ void TabWidget::savePinnedTabs()
stream << tabs; stream << tabs;
stream << tabsHistory; stream << tabsHistory;
QFile file(DataPaths::currentProfilePath() + "pinnedtabs.dat"); QFile file(DataPaths::currentProfilePath() + "/pinnedtabs.dat");
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(data); file.write(data);
file.close(); file.close();
@ -913,7 +913,7 @@ void TabWidget::restorePinnedTabs()
return; return;
} }
QFile file(DataPaths::currentProfilePath() + "pinnedtabs.dat"); QFile file(DataPaths::currentProfilePath() + "/pinnedtabs.dat");
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
QByteArray sd = file.readAll(); QByteArray sd = file.readAll();
file.close(); file.close();

View File

@ -123,7 +123,7 @@ void SBI_NetworkManager::applyCurrentProxy()
} }
// Manually modify settings to apply proxy configuration // 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"); settings.beginGroup("Web-Proxy");
m_currentProxy->saveToSettings(settings); m_currentProxy->saveToSettings(settings);
settings.endGroup(); settings.endGroup();