Browse Source

Replace wrappers in base/utils/fs.h with Profile::SpecialFolders::location()

adaptive-webui-19844
Eugene Shalygin 8 years ago
parent
commit
0bf7fa15c1
  1. 3
      src/app/application.cpp
  2. 2
      src/app/upgrade.h
  3. 7
      src/base/bittorrent/session.cpp
  4. 5
      src/base/net/geoipmanager.cpp
  5. 6
      src/base/profile.h
  6. 3
      src/base/searchengine.cpp
  7. 26
      src/base/utils/fs.cpp
  8. 7
      src/base/utils/fs.h
  9. 4
      src/gui/rss/htmlbrowser.cpp

3
src/app/application.cpp

@ -174,7 +174,8 @@ void Application::setFileLoggerEnabled(bool value) @@ -174,7 +174,8 @@ void Application::setFileLoggerEnabled(bool value)
QString Application::fileLoggerPath() const
{
return settings()->loadValue(KEY_FILELOGGER_PATH, QVariant(Utils::Fs::QDesktopServicesDataLocation() + LOG_FOLDER)).toString();
return settings()->loadValue(KEY_FILELOGGER_PATH,
QVariant(specialFolderLocation(SpecialFolder::Data) + LOG_FOLDER)).toString();
}
void Application::setFileLoggerPath(const QString &value)

2
src/app/upgrade.h

@ -148,7 +148,7 @@ bool upgrade(bool ask = true) @@ -148,7 +148,7 @@ bool upgrade(bool ask = true)
// Upgrade preferences
Preferences::instance()->upgrade();
QString backupFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + "BT_backup");
QString backupFolderPath = Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Data) + "BT_backup");
QDir backupFolderDir(backupFolderPath);
// ****************************************************************************************

7
src/base/bittorrent/session.cpp

@ -66,6 +66,7 @@ @@ -66,6 +66,7 @@
#include <libtorrent/torrent_info.hpp>
#include "base/logger.h"
#include "base/profile.h"
#include "base/net/downloadhandler.h"
#include "base/net/downloadmanager.h"
#include "base/net/portforwarder.h"
@ -132,7 +133,7 @@ namespace @@ -132,7 +133,7 @@ namespace
return tmp;
}
QString normalizeSavePath(QString path, const QString &defaultPath = Utils::Fs::QDesktopServicesDownloadLocation())
QString normalizeSavePath(QString path, const QString &defaultPath = specialFolderLocation(SpecialFolder::Downloads))
{
path = path.trimmed();
if (path.isEmpty())
@ -266,7 +267,7 @@ Session::Session(QObject *parent) @@ -266,7 +267,7 @@ Session::Session(QObject *parent)
, m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY("ProxyPeerConnections"), false)
, m_storedCategories(BITTORRENT_SESSION_KEY("Categories"))
, m_maxRatioAction(BITTORRENT_SESSION_KEY("MaxRatioAction"), Pause)
, m_defaultSavePath(BITTORRENT_SESSION_KEY("DefaultSavePath"), Utils::Fs::QDesktopServicesDownloadLocation(), normalizePath)
, m_defaultSavePath(BITTORRENT_SESSION_KEY("DefaultSavePath"), specialFolderLocation(SpecialFolder::Downloads), normalizePath)
, m_tempPath(BITTORRENT_SESSION_KEY("TempPath"), defaultSavePath() + "temp/", normalizePath)
, m_isSubcategoriesEnabled(BITTORRENT_SESSION_KEY("SubcategoriesEnabled"), false)
, m_isTempPathEnabled(BITTORRENT_SESSION_KEY("TempPathEnabled"), false)
@ -3003,7 +3004,7 @@ bool Session::hasPerTorrentRatioLimit() const @@ -3003,7 +3004,7 @@ bool Session::hasPerTorrentRatioLimit() const
void Session::initResumeFolder()
{
m_resumeFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + RESUME_FOLDER);
m_resumeFolderPath = Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Data) + RESUME_FOLDER);
QDir resumeFolderDir(m_resumeFolderPath);
if (resumeFolderDir.exists() || resumeFolderDir.mkpath(resumeFolderDir.absolutePath())) {
m_resumeFolderLock.setFileName(resumeFolderDir.absoluteFilePath("session.lock"));

5
src/base/net/geoipmanager.cpp

@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
#include "base/logger.h"
#include "base/preferences.h"
#include "base/profile.h"
#include "base/utils/fs.h"
#include "base/utils/gzip.h"
#include "downloadmanager.h"
@ -94,7 +95,7 @@ void GeoIPManager::loadDatabase() @@ -94,7 +95,7 @@ void GeoIPManager::loadDatabase()
}
QString filepath = Utils::Fs::expandPathAbs(
QString("%1%2/%3").arg(Utils::Fs::QDesktopServicesDataLocation())
QString("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data))
.arg(GEOIP_FOLDER).arg(GEOIP_FILENAME));
QString error;
@ -431,7 +432,7 @@ void GeoIPManager::downloadFinished(const QString &url, QByteArray data) @@ -431,7 +432,7 @@ void GeoIPManager::downloadFinished(const QString &url, QByteArray data)
.arg(m_geoIPDatabase->type()).arg(m_geoIPDatabase->buildEpoch().toString()),
Log::INFO);
QString targetPath = Utils::Fs::expandPathAbs(
Utils::Fs::QDesktopServicesDataLocation() + GEOIP_FOLDER);
specialFolderLocation(SpecialFolder::Data) + GEOIP_FOLDER);
if (!QDir(targetPath).exists())
QDir().mkpath(targetPath);
QFile targetFile(QString("%1/%2").arg(targetPath).arg(GEOIP_FILENAME));

6
src/base/profile.h

@ -77,4 +77,10 @@ private: @@ -77,4 +77,10 @@ private:
QScopedPointer<Private::Profile> m_impl;
static Profile *m_instance;
};
inline QString specialFolderLocation(SpecialFolder folder)
{
return Profile::instance().location(folder);
}
#endif // QBT_PROFILE_H

3
src/base/searchengine.cpp

@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/preferences.h"
#include "base/profile.h"
#include "base/net/downloadmanager.h"
#include "base/net/downloadhandler.h"
#include "searchengine.h"
@ -325,7 +326,7 @@ QString SearchEngine::engineLocation() @@ -325,7 +326,7 @@ QString SearchEngine::engineLocation()
QString folder = "nova";
if (Utils::Misc::pythonVersion() >= 3)
folder = "nova3";
const QString location = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + folder);
const QString location = Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Data) + folder);
QDir locationDir(location);
if (!locationDir.exists())
locationDir.mkpath(locationDir.absolutePath());

26
src/base/utils/fs.cpp

@ -50,8 +50,6 @@ @@ -50,8 +50,6 @@
#include <Windows.h>
#endif
#include "base/profile.h"
/**
* Converts a path to a string suitable for display.
* This function makes sure the directory separator used is consistent
@ -317,30 +315,6 @@ QString Utils::Fs::expandPathAbs(const QString& path) @@ -317,30 +315,6 @@ QString Utils::Fs::expandPathAbs(const QString& path)
return ret;
}
QString Utils::Fs::QDesktopServicesDataLocation()
{
return Profile::instance().location(SpecialFolder::Data);
}
QString Utils::Fs::QDesktopServicesCacheLocation()
{
return Profile::instance().location(SpecialFolder::Cache);
}
QString Utils::Fs::QDesktopServicesDownloadLocation()
{
return Profile::instance().location(SpecialFolder::Downloads);
}
QString Utils::Fs::cacheLocation()
{
QString location = expandPathAbs(QDesktopServicesCacheLocation());
QDir locationDir(location);
if (!locationDir.exists())
locationDir.mkpath(locationDir.absolutePath());
return location;
}
QString Utils::Fs::tempPath()
{
static const QString path = QDir::tempPath() + "/.qBittorrent/";

7
src/base/utils/fs.h

@ -60,13 +60,6 @@ namespace Utils @@ -60,13 +60,6 @@ namespace Utils
bool forceRemove(const QString& file_path);
void removeDirRecursive(const QString& dirName);
/* Ported from Qt4 to drop dependency on QtGui */
QString QDesktopServicesDataLocation();
QString QDesktopServicesCacheLocation();
QString QDesktopServicesDownloadLocation();
/* End of Qt4 code */
QString cacheLocation();
QString tempPath();
}
}

4
src/gui/rss/htmlbrowser.cpp

@ -10,14 +10,14 @@ @@ -10,14 +10,14 @@
#include <QDateTime>
#include <QScrollBar>
#include "base/utils/fs.h"
#include "base/profile.h"
HtmlBrowser::HtmlBrowser(QWidget* parent)
: QTextBrowser(parent)
{
m_netManager = new QNetworkAccessManager(this);
m_diskCache = new QNetworkDiskCache(this);
m_diskCache->setCacheDirectory(QDir::cleanPath(Utils::Fs::cacheLocation() + "/rss"));
m_diskCache->setCacheDirectory(QDir::cleanPath(specialFolderLocation(SpecialFolder::Cache) + "/rss"));
m_diskCache->setMaximumCacheSize(50 * 1024 * 1024);
qDebug() << "HtmlBrowser cache path:" << m_diskCache->cacheDirectory() << " max size:" << m_diskCache->maximumCacheSize() / 1024 / 1024 << "MB";
m_netManager->setCache(m_diskCache);

Loading…
Cancel
Save