From c44ee3cc262b5e6df7fff32273e9df5bf932c159 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 13 Jun 2017 02:30:15 +0300 Subject: Show server sources in server info window. --- src/gui/windows/serverinfowindow.cpp | 54 ++++++++++++++++++++++++++++++++++++ src/gui/windows/serverinfowindow.h | 3 ++ 2 files changed, 57 insertions(+) diff --git a/src/gui/windows/serverinfowindow.cpp b/src/gui/windows/serverinfowindow.cpp index 274fd97ce..22931fa80 100644 --- a/src/gui/windows/serverinfowindow.cpp +++ b/src/gui/windows/serverinfowindow.cpp @@ -103,4 +103,58 @@ void ServerInfoWindow::handleLink(const std::string &link, void ServerInfoWindow::showServerInfo() { + const ServerFreeTypeT type = mServerInfo.freeType; + if (type == ServerFreeType::Free) + { + // TRANSLATORS: server info comment + mBrowserBox->addRow(_("Server with free license.")); + } + else if (type == ServerFreeType::NonFree) + { + // TRANSLATORS: server info comment + mBrowserBox->addRow(_("Server with non free license.")); + } + else if (type == ServerFreeType::Unknown || + type == ServerFreeType::NotSet) + { + // TRANSLATORS: server info comment + mBrowserBox->addRow(_("Server unknown licesne.")); + } + addSourcesList(mServerInfo.nonFreeSources, + // TRANSLATORS: server info non free comment + _("##BNon free sources")); + addSourcesList(mServerInfo.freeSources, + // TRANSLATORS: server info non free comment + _("##BFree sources")); +} + +void ServerInfoWindow::addSourcesList(const std::vector &list, + const std::string &comment) +{ + if (!list.empty()) + { + mBrowserBox->addRow(""); + mBrowserBox->addRow(comment); + FOR_EACH (std::vector::const_iterator, it, list) + { + const ServerUrlInfo &info = *it; + const std::string url = info.url; + std::string str; + if (strStartWith(url, "http://") || + strStartWith(url, "https://")) + { + str = strprintf("%s: @@%s|@@##0", + info.name.c_str(), + url.c_str()); + } + else + { + str = strprintf("%s: %s", + info.name.c_str(), + url.c_str()); + } + mBrowserBox->addRow(str); + } + mBrowserBox->addRow(""); + } } diff --git a/src/gui/windows/serverinfowindow.h b/src/gui/windows/serverinfowindow.h index c0cf5c786..5165102cd 100644 --- a/src/gui/windows/serverinfowindow.h +++ b/src/gui/windows/serverinfowindow.h @@ -54,6 +54,9 @@ class ServerInfoWindow final : public Window, protected: void showServerInfo(); + void addSourcesList(const std::vector &list, + const std::string &comment); + private: ServerInfo mServerInfo; BrowserBox *mBrowserBox A_NONNULLPOINTER; -- cgit v1.2.3-70-g09d2