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 @@
class QString; class QString;
class IconProvider : public QObject class IconProvider final : public QObject
{ {
Q_DISABLE_COPY_MOVE(IconProvider) Q_DISABLE_COPY_MOVE(IconProvider)

2
src/base/logger.h

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

2
src/base/net/downloadmanager.h

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

2
src/base/net/geoipmanager.h

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

2
src/base/rss/rss_session.h

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

2
src/base/search/searchpluginmanager.h

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

4
src/base/settingsstorage.cpp

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

10
src/webui/webui.cpp

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

Loading…
Cancel
Save