Commit ef17855a authored by David Faure's avatar David Faure

Port from QStandardPaths::DataLocation to QStandardPaths::AppDataLocation

They are the same on Linux (but DataLocation is deprecated). On Windows this enables the use of the roaming path.

NO_CHANGELOG
parent af8c6ffd
......@@ -497,7 +497,7 @@ void KGet::load( QString filename ) // krazy:exclude=passbyvalue
qCDebug(KGET_DEBUG) << "(" << filename << ")";
if(filename.isEmpty()) {
filename = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
filename = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
// make sure that the DataLocation directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(filename)) {
QDir().mkpath(filename);
......@@ -581,7 +581,7 @@ void KGet::save( QString filename, bool plain ) // krazy:exclude=passbyvalue
return;
if(filename.isEmpty()) {
filename = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
filename = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
// make sure that the DataLocation directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(filename)) {
QDir().mkpath(filename);
......
......@@ -130,19 +130,19 @@ QList <TransferHistoryItem> TransferHistoryStore::items() const
TransferHistoryStore *TransferHistoryStore::getStore()
{
// make sure that the DataLocation directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
}
switch(Settings::historyBackend())
{
case TransferHistoryStore::SQLite:
#ifdef HAVE_SQLITE
return new SQLiteStore(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/transferhistory.db"));
return new SQLiteStore(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/transferhistory.db"));
break;
#endif
case TransferHistoryStore::Xml:
default:
return new XmlStore(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/transferhistory.kgt"));
return new XmlStore(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/transferhistory.kgt"));
}
}
......
......@@ -409,7 +409,7 @@ void MainWindow::slotDownloadFinishedActions()
void MainWindow::init()
{
//Here we import the user's transfers.
KGet::load( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/transfers.kgt")) ;
KGet::load( QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/transfers.kgt")) ;
if(Settings::enableSystemTray()) {
m_dock = new Tray(this);
......
......@@ -36,11 +36,11 @@ BTDataSource::BTDataSource(const QUrl &srcUrl, QObject *parent)
m_torrentSource(QUrl())
{
// make sure that the DataLocation directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
}
bt::InitLog(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/torrentlog.log"));//initialize the torrent-log
bt::InitLog(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/torrentlog.log"));//initialize the torrent-log
bt::SetClientInfo("KGet",2,1,0,bt::NORMAL,"KG");//Set client info to KGet, WARNING: Pls change this for every release
......@@ -85,7 +85,7 @@ void BTDataSource::start()
{
if (m_torrentSource.isEmpty())
{
QString tmpDirName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/tmp/");
QString tmpDirName = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/tmp/");
// make sure that the /tmp directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(tmpDirName)) {
QDir().mkpath(tmpDirName);
......
......@@ -55,14 +55,14 @@ BTTransfer::BTTransfer(TransferGroup* parent, TransferFactory* factory,
const QDomElement * e)
: Transfer(parent, factory, scheduler, src, dest, e),
torrent(nullptr),
m_tmp(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/tmp/")),
m_tmp(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/tmp/")),
m_ready(false),
m_downloadFinished(false),
m_movingFile(false),
m_fileModel(nullptr),
m_updateCounter(0)
{
QString tmpDirName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/tmp/");
QString tmpDirName = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/tmp/");
// make sure that the /tmp directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(tmpDirName)) {
QDir().mkpath(tmpDirName);
......@@ -133,7 +133,7 @@ void BTTransfer::start()
if (!m_source.isLocalFile())
{
qCDebug(KGET_DEBUG) << m_dest.path();
QString tmpDirName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/tmp/");
QString tmpDirName = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/tmp/");
m_tmpTorrentFile = tmpDirName + m_dest.fileName();
Download *download = new Download(m_source, QUrl::fromLocalFile(m_tmpTorrentFile));
......@@ -428,7 +428,7 @@ void BTTransfer::btTransferInit(const QUrl &src, const QByteArray &data)
setStatus(Job::Stopped, i18n("Analyzing torrent...."), SmallIcon("document-preview")); // jpetso says: you should probably use the "process-working" icon here (from the animations category), but that's a multi-frame PNG so it's hard for me to test
setTransferChange(Tc_Status, true);
bt::InitLog(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/torrentlog.log"), false, false);//initialize the torrent-log
bt::InitLog(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/torrentlog.log"), false, false);//initialize the torrent-log
bt::SetClientInfo("KGet", KGET_VERSION_MAJOR, KGET_VERSION_MINOR, KGET_VERSION_PATCH, bt::NORMAL, "KG");//Set client info to KGet
......
......@@ -59,7 +59,7 @@ void ChecksumSearchController::registerSearch(ChecksumSearchTransferDataSource *
qCDebug(KGET_DEBUG) << "Creating download for" << baseUrl;
static int files = 0;
const QUrl dest = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/checksumsearch/") + QString::number(files++));
const QUrl dest = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/checksumsearch/") + QString::number(files++));
if (QFile::exists(dest.toLocalFile())) {
KIO::Job *del = KIO::del(dest, KIO::HideProgressInfo);
if (!del->exec()) {
......
......@@ -48,7 +48,7 @@ bool ScriptConfigAdaptor::setFile(const QString &filename,
QString default_path;
// put the config file in default user directory
// like ~/.kde4/share/app/kget/content_scrips_setting/
default_path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/contentfetch_scripts_setting/");
default_path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/contentfetch_scripts_setting/");
m_config = new KConfig(default_path + filename);
return true;
}
......
......@@ -81,10 +81,10 @@ void Metalink::downloadMetalink()
setStatus(Job::Stopped, i18n("Downloading Metalink File...."), SmallIcon("document-save"));
setTransferChange(Tc_Status, true);
// make sure that the DataLocation directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
}
Download *download = new Download(m_source, QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/metalinks/") + m_source.fileName());
Download *download = new Download(m_source, QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/metalinks/") + m_source.fileName());
connect(download, SIGNAL(finishedSuccessfully(QUrl,QByteArray)), SLOT(metalinkInit(QUrl,QByteArray)));
}
......
......@@ -222,10 +222,10 @@ bool MetalinkHttp::metalinkHttpInit()
//Add OpenPGP signatures
if (m_signatureUrl != QUrl()) {
// make sure that the DataLocation directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
}
const QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/metalinks/") + m_source.fileName();
const QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/metalinks/") + m_source.fileName();
Download *signat_download = new Download(m_signatureUrl, QUrl::fromLocalFile(path));
connect(signat_download, SIGNAL(finishedSuccessfully(QUrl,QByteArray)), SLOT(setSignature(QUrl,QByteArray)));
}
......
......@@ -78,10 +78,10 @@ void MetalinkXml::downloadMetalink()
setStatus(Job::Running, i18n("Downloading Metalink File...."), SmallIcon("document-save"));
setTransferChange(Tc_Status, true);
// make sure that the DataLocation directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
}
const QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/metalinks/") + m_source.fileName();
const QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/metalinks/") + m_source.fileName();
Download *download = new Download(m_source, QUrl::fromLocalFile(path));
connect(download, &Download::finishedSuccessfully, this, &MetalinkXml::metalinkInit);
}
......
......@@ -34,10 +34,10 @@ MmsTransfer::MmsTransfer(TransferGroup * parent, TransferFactory * factory,
m_retryDownload(false)
{
// make sure that the DataLocation directory exists (earlier this used to be handled by KStandardDirs)
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
}
m_fileTemp = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + m_dest.fileName();
m_fileTemp = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1Char('/') + m_dest.fileName();
qCDebug(KGET_DEBUG) << "Mms transfer initialized: " + m_source.toString();
}
......
......@@ -82,7 +82,7 @@ TransferHistory::TransferHistory(QWidget *parent)
setLayout(vboxLayout);
watcher = new QFileSystemWatcher();
watcher->addPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QString());
watcher->addPath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1Char('/') + QString());
qCDebug(KGET_DEBUG) << watcher->directories();
m_store = TransferHistoryStore::getStore();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment