Fix WebUI greeting for qbittorrent-nox

* Check if WebUI is enabled and print an appropriate message otherwise.
* Print an actual runtime server scheme, address and port.

PR #19696.
This commit is contained in:
Hanabishi
2023-10-16 11:48:32 +05:00
committed by GitHub
parent e6ec3d0c2b
commit 90e023f138
5 changed files with 57 additions and 13 deletions

View File

@@ -52,8 +52,9 @@ void WebUI::configure()
const QString portForwardingProfile = u"webui"_s;
const Preferences *pref = Preferences::instance();
const quint16 port = pref->getWebUiPort();
m_isEnabled = pref->isWebUiEnabled();
if (pref->isWebUiEnabled())
if (m_isEnabled)
{
// Port forwarding
auto *portForwarder = Net::PortForwarder::instance();
@@ -145,7 +146,30 @@ void WebUI::configure()
}
}
bool WebUI::isEnabled() const
{
return m_isEnabled;
}
bool WebUI::isErrored() const
{
return m_isErrored;
}
bool WebUI::isHttps() const
{
if (!m_httpServer) return false;
return m_httpServer->isHttps();
}
QHostAddress WebUI::hostAddress() const
{
if (!m_httpServer) return {};
return m_httpServer->serverAddress();
}
quint16 WebUI::port() const
{
if (!m_httpServer) return 0;
return m_httpServer->serverPort();
}

View File

@@ -28,6 +28,7 @@
#pragma once
#include <QHostAddress>
#include <QObject>
#include <QPointer>
@@ -53,7 +54,11 @@ class WebUI final : public ApplicationComponent<QObject>
public:
explicit WebUI(IApplication *app);
bool isEnabled() const;
bool isErrored() const;
bool isHttps() const;
QHostAddress hostAddress() const;
quint16 port() const;
signals:
void fatalError();
@@ -62,6 +67,7 @@ private slots:
void configure();
private:
bool m_isEnabled = false;
bool m_isErrored = false;
QPointer<Http::Server> m_httpServer;
QPointer<Net::DNSUpdater> m_dnsUpdater;