mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-19 06:57:24 -06:00
Migrate everything to use the new Preferences class and not access directly the qbittorrent.ini file.
This commit is contained in:
22
src/main.cpp
22
src/main.cpp
@@ -32,6 +32,7 @@
|
||||
#include <QTranslator>
|
||||
#include <QFile>
|
||||
#include <QLibraryInfo>
|
||||
#include <QDebug>
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
#if defined(QBT_STATIC_QT)
|
||||
@@ -62,7 +63,6 @@ Q_IMPORT_PLUGIN(qico)
|
||||
#endif
|
||||
|
||||
#include "preferences.h"
|
||||
#include "qinisettings.h"
|
||||
#if defined(Q_OS_UNIX)
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
std::cout << '\t' << prg_name << " -d | --daemon: " << qPrintable(tr("run in daemon-mode (background)")) << std::endl;
|
||||
#endif
|
||||
std::cout << '\t' << prg_name << " --help: " << qPrintable(tr("displays this help message")) << std::endl;
|
||||
std::cout << '\t' << prg_name << " --webui-port=x: " << qPrintable(tr("changes the webui port (current: %1)").arg(QString::number(Preferences().getWebUiPort()))) << std::endl;
|
||||
std::cout << '\t' << prg_name << " --webui-port=x: " << qPrintable(tr("changes the webui port (current: %1)").arg(QString::number(Preferences::instance()->getWebUiPort()))) << std::endl;
|
||||
std::cout << '\t' << prg_name << " " << qPrintable(tr("[files or urls]: downloads the torrents passed by the user (optional)")) << std::endl;
|
||||
}
|
||||
};
|
||||
@@ -106,8 +106,8 @@ class LegalNotice: public QObject {
|
||||
|
||||
public:
|
||||
static bool userAgreesWithNotice() {
|
||||
QIniSettings settings;
|
||||
if (settings.value(QString::fromUtf8("LegalNotice/Accepted"), false).toBool()) // Already accepted once
|
||||
Preferences* const pref = Preferences::instance();
|
||||
if (pref->getAcceptedLegal()) // Already accepted once
|
||||
return true;
|
||||
#ifdef DISABLE_GUI
|
||||
std::cout << std::endl << "*** " << qPrintable(tr("Legal Notice")) << " ***" << std::endl;
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
char ret = getchar(); // Read pressed key
|
||||
if (ret == 'y' || ret == 'Y') {
|
||||
// Save the answer
|
||||
settings.setValue(QString::fromUtf8("LegalNotice/Accepted"), true);
|
||||
pref->setAcceptedLegal(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
msgBox.exec();
|
||||
if (msgBox.clickedButton() == agree_button) {
|
||||
// Save the answer
|
||||
settings.setValue(QString::fromUtf8("LegalNotice/Accepted"), true);
|
||||
pref->setAcceptedLegal(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -249,7 +249,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
srand(time(0));
|
||||
Preferences pref;
|
||||
Preferences* const pref = Preferences::instance();
|
||||
#ifndef DISABLE_GUI
|
||||
bool no_splash = false;
|
||||
#else
|
||||
@@ -260,12 +260,12 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
// Load translation
|
||||
QString locale = pref.getLocale();
|
||||
QString locale = pref->getLocale();
|
||||
QTranslator qtTranslator;
|
||||
QTranslator translator;
|
||||
if (locale.isEmpty()) {
|
||||
locale = QLocale::system().name();
|
||||
pref.setLocale(locale);
|
||||
pref->setLocale(locale);
|
||||
}
|
||||
if (qtTranslator.load(
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
@@ -317,7 +317,7 @@ int main(int argc, char *argv[]) {
|
||||
bool ok = false;
|
||||
int new_port = parts.last().toInt(&ok);
|
||||
if (ok && new_port > 0 && new_port <= 65535) {
|
||||
Preferences().setWebUiPort(new_port);
|
||||
Preferences::instance()->setWebUiPort(new_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,7 +328,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
if (pref.isSlashScreenDisabled()) {
|
||||
if (pref->isSlashScreenDisabled()) {
|
||||
no_splash = true;
|
||||
}
|
||||
QSplashScreen *splash = 0;
|
||||
|
||||
Reference in New Issue
Block a user