Browse Source

Merge pull request #19277 from Chocobo1/ctor

Don't update settings when it hasn't changed
adaptive-webui-19844
Chocobo1 1 year ago committed by GitHub
parent
commit
fff7b1dcbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/base/iconprovider.h
  2. 2
      src/base/logger.h
  3. 2
      src/base/net/downloadmanager.h
  4. 2
      src/base/net/geoipmanager.h
  5. 459
      src/base/preferences.cpp
  6. 8
      src/base/preferences.h
  7. 2
      src/base/rss/rss_session.h
  8. 2
      src/base/search/searchpluginmanager.h
  9. 4
      src/base/settingsstorage.cpp
  10. 10
      src/webui/webui.cpp

2
src/base/iconprovider.h

@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
class QString;
class IconProvider : public QObject
class IconProvider final : public QObject
{
Q_DISABLE_COPY_MOVE(IconProvider)

2
src/base/logger.h

@ -69,7 +69,7 @@ namespace Log @@ -69,7 +69,7 @@ namespace Log
Q_DECLARE_OPERATORS_FOR_FLAGS(Log::MsgTypes)
class Logger : public QObject
class Logger final : public QObject
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(Logger)

2
src/base/net/downloadmanager.h

@ -126,7 +126,7 @@ namespace Net @@ -126,7 +126,7 @@ namespace Net
class DownloadHandlerImpl;
class DownloadManager : public QObject
class DownloadManager final : public QObject
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(DownloadManager)

2
src/base/net/geoipmanager.h

@ -40,7 +40,7 @@ namespace Net @@ -40,7 +40,7 @@ namespace Net
{
struct DownloadResult;
class GeoIPManager : public QObject
class GeoIPManager final : public QObject
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(GeoIPManager)

459
src/base/preferences.cpp

File diff suppressed because it is too large Load Diff

8
src/base/preferences.h

@ -86,7 +86,7 @@ namespace TrayIcon @@ -86,7 +86,7 @@ namespace TrayIcon
Q_ENUM_NS(Style)
}
class Preferences : public QObject
class Preferences final : public QObject
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(Preferences)
@ -142,7 +142,7 @@ public: @@ -142,7 +142,7 @@ public:
QString getMailNotificationEmail() const;
void setMailNotificationEmail(const QString &mail);
QString getMailNotificationSMTP() const;
void setMailNotificationSMTP(const QString &smtp_server);
void setMailNotificationSMTP(const QString &smtpServer);
bool getMailNotificationSMTPSSL() const;
void setMailNotificationSMTPSSL(bool use);
bool getMailNotificationSMTPAuth() const;
@ -291,14 +291,14 @@ public: @@ -291,14 +291,14 @@ public:
bool neverCheckFileAssoc() const;
void setNeverCheckFileAssoc(bool check = true);
static bool isTorrentFileAssocSet();
static bool isMagnetLinkAssocSet();
static void setTorrentFileAssoc(bool set);
static bool isMagnetLinkAssocSet();
static void setMagnetLinkAssoc(bool set);
#endif
#ifdef Q_OS_MACOS
static bool isTorrentFileAssocSet();
static bool isMagnetLinkAssocSet();
static void setTorrentFileAssoc();
static bool isMagnetLinkAssocSet();
static void setMagnetLinkAssoc();
#endif
int getTrackerPort() const;

2
src/base/rss/rss_session.h

@ -88,7 +88,7 @@ namespace RSS @@ -88,7 +88,7 @@ namespace RSS
class Folder;
class Item;
class Session : public QObject
class Session final : public QObject
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(Session)

2
src/base/search/searchpluginmanager.h

@ -58,7 +58,7 @@ struct PluginInfo @@ -58,7 +58,7 @@ struct PluginInfo
class SearchDownloadHandler;
class SearchHandler;
class SearchPluginManager : public QObject
class SearchPluginManager final : public QObject
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(SearchPluginManager)

4
src/base/settingsstorage.cpp

@ -79,8 +79,10 @@ SettingsStorage *SettingsStorage::instance() @@ -79,8 +79,10 @@ SettingsStorage *SettingsStorage::instance()
bool SettingsStorage::save()
{
// return `true` only when settings is different AND is saved successfully
const QWriteLocker locker(&m_lock); // guard for `m_dirty` too
if (!m_dirty) return true;
if (!m_dirty) return false;
if (!writeNativeSettings())
{

10
src/webui/webui.cpp

@ -68,6 +68,9 @@ void WebUI::configure() @@ -68,6 +68,9 @@ void WebUI::configure()
// http server
const QString serverAddressString = pref->getWebUiAddress();
const auto serverAddress = ((serverAddressString == u"*") || serverAddressString.isEmpty())
? QHostAddress::Any : QHostAddress(serverAddressString);
if (!m_httpServer)
{
m_webapp = new WebApplication(app(), this);
@ -75,8 +78,7 @@ void WebUI::configure() @@ -75,8 +78,7 @@ void WebUI::configure()
}
else
{
if ((m_httpServer->serverAddress().toString() != serverAddressString)
|| (m_httpServer->serverPort() != port))
if ((m_httpServer->serverAddress() != serverAddress) || (m_httpServer->serverPort() != port))
m_httpServer->close();
}
@ -103,9 +105,7 @@ void WebUI::configure() @@ -103,9 +105,7 @@ void WebUI::configure()
if (!m_httpServer->isListening())
{
const auto address = ((serverAddressString == u"*") || serverAddressString.isEmpty())
? QHostAddress::Any : QHostAddress(serverAddressString);
bool success = m_httpServer->listen(address, port);
const bool success = m_httpServer->listen(serverAddress, port);
if (success)
{
LogMsg(tr("Web UI: Now listening on IP: %1, port: %2").arg(serverAddressString).arg(port));

Loading…
Cancel
Save