Merge branch 'qbittorrent:master' into i2p-support
This commit is contained in:
@ -88,6 +88,7 @@
|
||||
#include "base/version.h"
|
||||
#include "applicationinstancemanager.h"
|
||||
#include "filelogger.h"
|
||||
#include "upgrade.h"
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
#include "gui/addnewtorrentdialog.h"
|
||||
@ -173,6 +174,18 @@ Application::Application(int &argc, char **argv)
|
||||
SettingsStorage::initInstance();
|
||||
Preferences::initInstance();
|
||||
|
||||
const bool firstTimeUser = !Preferences::instance()->getAcceptedLegal();
|
||||
if (!firstTimeUser)
|
||||
{
|
||||
if (!upgrade())
|
||||
throw RuntimeError(u"Failed migration of old settings"_qs); // Not translatable. Translation isn't configured yet.
|
||||
handleChangedDefaults(DefaultPreferencesMode::Legacy);
|
||||
}
|
||||
else
|
||||
{
|
||||
handleChangedDefaults(DefaultPreferencesMode::Current);
|
||||
}
|
||||
|
||||
initializeTranslation();
|
||||
|
||||
connect(this, &QCoreApplication::aboutToQuit, this, &Application::cleanup);
|
||||
@ -802,7 +815,6 @@ try
|
||||
});
|
||||
|
||||
disconnect(m_desktopIntegration, &DesktopIntegration::activationRequested, this, &Application::createStartupProgressDialog);
|
||||
// we must not delete menu while it is used by DesktopIntegration
|
||||
#ifndef Q_OS_MACOS
|
||||
const WindowState windowState = !m_startupProgressDialog ? WindowState::Hidden
|
||||
: (m_startupProgressDialog->windowState() & Qt::WindowMinimized) ? WindowState::Minimized
|
||||
|
@ -221,26 +221,6 @@ int main(int argc, char *argv[])
|
||||
app->setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif
|
||||
|
||||
if (!firstTimeUser)
|
||||
{
|
||||
handleChangedDefaults(DefaultPreferencesMode::Legacy);
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
if (!upgrade()) return EXIT_FAILURE;
|
||||
#elif defined(Q_OS_WIN)
|
||||
if (!upgrade(_isatty(_fileno(stdin))
|
||||
&& _isatty(_fileno(stdout)))) return EXIT_FAILURE;
|
||||
#else
|
||||
if (!upgrade(!params.shouldDaemonize
|
||||
&& isatty(fileno(stdin))
|
||||
&& isatty(fileno(stdout)))) return EXIT_FAILURE;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
handleChangedDefaults(DefaultPreferencesMode::Current);
|
||||
}
|
||||
|
||||
#if defined(DISABLE_GUI) && !defined(Q_OS_WIN)
|
||||
if (params.shouldDaemonize)
|
||||
{
|
||||
@ -274,6 +254,11 @@ int main(int argc, char *argv[])
|
||||
displayBadArgMessage(er.message());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const RuntimeError &er)
|
||||
{
|
||||
qDebug() << er.message();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_GUI)
|
||||
|
@ -398,9 +398,21 @@ namespace
|
||||
settingsStorage->storeValue(u"GUI/StartUpWindowState"_qs, windowState);
|
||||
}
|
||||
}
|
||||
|
||||
void migrateChineseLocale()
|
||||
{
|
||||
auto *settingsStorage = SettingsStorage::instance();
|
||||
const auto key = u"Preferences/General/Locale"_qs;
|
||||
if (settingsStorage->hasKey(key))
|
||||
{
|
||||
const auto locale = settingsStorage->loadValue<QString>(key);
|
||||
if (locale.compare(u"zh"_qs, Qt::CaseInsensitive) == 0)
|
||||
settingsStorage->storeValue(key, u"zh_CN"_qs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool upgrade(const bool /*ask*/)
|
||||
bool upgrade()
|
||||
{
|
||||
CachedSettingValue<int> version {MIGRATION_VERSION_KEY, 0};
|
||||
|
||||
@ -428,7 +440,10 @@ bool upgrade(const bool /*ask*/)
|
||||
#endif
|
||||
|
||||
if (version < 5)
|
||||
{
|
||||
migrateStartupWindowState();
|
||||
migrateChineseLocale();
|
||||
}
|
||||
|
||||
version = MIGRATION_VERSION;
|
||||
}
|
||||
|
@ -35,5 +35,5 @@ enum class DefaultPreferencesMode
|
||||
};
|
||||
|
||||
void handleChangedDefaults(DefaultPreferencesMode mode);
|
||||
bool upgrade(bool ask = true);
|
||||
bool upgrade();
|
||||
void setCurrentMigrationVersion();
|
||||
|
@ -156,8 +156,11 @@ WebApplication::WebApplication(IApplication *app, QObject *parent)
|
||||
m_sessionCookieName = Preferences::instance()->getWebAPISessionCookieName();
|
||||
if (!isValidCookieName(m_sessionCookieName))
|
||||
{
|
||||
LogMsg(tr("Unacceptable session cookie name is specified: '%1'. Default one is used.")
|
||||
.arg(m_sessionCookieName), Log::WARNING);
|
||||
if (!m_sessionCookieName.isEmpty())
|
||||
{
|
||||
LogMsg(tr("Unacceptable session cookie name is specified: '%1'. Default one is used.")
|
||||
.arg(m_sessionCookieName), Log::WARNING);
|
||||
}
|
||||
m_sessionCookieName = DEFAULT_SESSION_COOKIE_NAME;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user