mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 05:38:06 -06:00
committed by
GitHub
parent
1c231ce014
commit
b5d16dfeee
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2021-2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2021-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -32,10 +32,16 @@
|
||||
#include <QJsonValue>
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/utils/string.h"
|
||||
|
||||
const QString OPTION_SAVEPATH = u"save_path"_s;
|
||||
const QString OPTION_DOWNLOADPATH = u"download_path"_s;
|
||||
|
||||
const QString OPTION_RATIOLIMIT = u"ratio_limit"_s;
|
||||
const QString OPTION_SEEDINGTIMELIMIT = u"seeding_time_limit"_s;
|
||||
const QString OPTION_INACTIVESEEDINGTIMELIMIT = u"inactive_seeding_time_limit"_s;
|
||||
const QString OPTION_SHARELIMITACTION = u"share_limit_action"_s;
|
||||
|
||||
BitTorrent::CategoryOptions BitTorrent::CategoryOptions::fromJSON(const QJsonObject &jsonObj)
|
||||
{
|
||||
CategoryOptions options;
|
||||
@@ -47,6 +53,11 @@ BitTorrent::CategoryOptions BitTorrent::CategoryOptions::fromJSON(const QJsonObj
|
||||
else if (downloadPathValue.isString())
|
||||
options.downloadPath = {true, Path(downloadPathValue.toString())};
|
||||
|
||||
options.ratioLimit = jsonObj.value(OPTION_RATIOLIMIT).toDouble(DEFAULT_RATIO_LIMIT);
|
||||
options.seedingTimeLimit = jsonObj.value(OPTION_SEEDINGTIMELIMIT).toInt(DEFAULT_SEEDING_TIME_LIMIT);
|
||||
options.inactiveSeedingTimeLimit = jsonObj.value(OPTION_INACTIVESEEDINGTIMELIMIT).toInt(DEFAULT_SEEDING_TIME_LIMIT);
|
||||
options.shareLimitAction = Utils::String::toEnum<ShareLimitAction>(jsonObj.value(OPTION_SHARELIMITACTION).toString(), ShareLimitAction::Default);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -63,12 +74,10 @@ QJsonObject BitTorrent::CategoryOptions::toJSON() const
|
||||
|
||||
return {
|
||||
{OPTION_SAVEPATH, savePath.data()},
|
||||
{OPTION_DOWNLOADPATH, downloadPathValue}
|
||||
{OPTION_DOWNLOADPATH, downloadPathValue},
|
||||
{OPTION_RATIOLIMIT, ratioLimit},
|
||||
{OPTION_SEEDINGTIMELIMIT, seedingTimeLimit},
|
||||
{OPTION_INACTIVESEEDINGTIMELIMIT, inactiveSeedingTimeLimit},
|
||||
{OPTION_SHARELIMITACTION, Utils::String::fromEnum(shareLimitAction)}
|
||||
};
|
||||
}
|
||||
|
||||
bool BitTorrent::operator==(const BitTorrent::CategoryOptions &left, const BitTorrent::CategoryOptions &right)
|
||||
{
|
||||
return ((left.savePath == right.savePath)
|
||||
&& (left.downloadPath == right.downloadPath));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user