mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-07 21:51:25 -07:00
Redesign main core classes.
This commit is contained in:
parent
60c0939e05
commit
d16d1fdb3a
152 changed files with 11366 additions and 8967 deletions
|
@ -116,15 +116,18 @@ Preferences::~Preferences()
|
|||
save();
|
||||
}
|
||||
|
||||
Preferences * Preferences::instance()
|
||||
Preferences *Preferences::instance()
|
||||
{
|
||||
if (!m_instance)
|
||||
m_instance = new Preferences;
|
||||
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void Preferences::drop()
|
||||
void Preferences::initInstance()
|
||||
{
|
||||
if (!m_instance)
|
||||
m_instance = new Preferences;
|
||||
}
|
||||
|
||||
void Preferences::freeInstance()
|
||||
{
|
||||
if (m_instance) {
|
||||
delete m_instance;
|
||||
|
@ -132,12 +135,11 @@ void Preferences::drop()
|
|||
}
|
||||
}
|
||||
|
||||
void Preferences::save()
|
||||
bool Preferences::save()
|
||||
{
|
||||
QReadLocker locker(&lock);
|
||||
|
||||
if (!dirty)
|
||||
return;
|
||||
if (!dirty) return false;
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
// QSettings delete the file before writing it out. This can result in problems
|
||||
|
@ -160,7 +162,7 @@ void Preferences::save()
|
|||
settings->sync(); // Important to get error status
|
||||
if (settings->status() == QSettings::AccessError) {
|
||||
delete settings;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
QString new_path = settings->fileName();
|
||||
delete settings;
|
||||
|
@ -173,7 +175,7 @@ void Preferences::save()
|
|||
delete settings;
|
||||
#endif
|
||||
|
||||
emit changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
const QVariant Preferences::value(const QString &key, const QVariant &defaultValue) const
|
||||
|
@ -950,12 +952,12 @@ void Preferences::setGlobalMaxRatio(qreal ratio)
|
|||
setValue("Preferences/Bittorrent/MaxRatio", ratio);
|
||||
}
|
||||
|
||||
int Preferences::getMaxRatioAction() const
|
||||
MaxRatioAction Preferences::getMaxRatioAction() const
|
||||
{
|
||||
return value("Preferences/Bittorrent/MaxRatioAction", PAUSE_ACTION).toInt();
|
||||
return value("Preferences/Bittorrent/MaxRatioAction", MaxRatioAction::Pause).toInt();
|
||||
}
|
||||
|
||||
void Preferences::setMaxRatioAction(int act)
|
||||
void Preferences::setMaxRatioAction(MaxRatioAction act)
|
||||
{
|
||||
setValue("Preferences/Bittorrent/MaxRatioAction", act);
|
||||
}
|
||||
|
@ -2477,3 +2479,9 @@ void Preferences::setHostNameCookies(const QString &host_name, const QList<QByte
|
|||
hosts_table.insert(host_name, raw_cookies);
|
||||
setValue("Rss/hosts_cookies", hosts_table);
|
||||
}
|
||||
|
||||
void Preferences::apply()
|
||||
{
|
||||
if (save())
|
||||
emit changed();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue