From dc84c9b334aa581c4e81bbc9d883ca09bc33556d Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 13 Feb 2019 00:27:20 +0100 Subject: [PATCH] Hint for "anonymous" login * utility function for hyperlink * info about login --- src/blackgui/components/dblogincomponent.cpp | 14 ++++++++------ src/blackgui/components/dblogincomponent.h | 3 ++- src/blackgui/components/dblogincomponent.ui | 11 ++++++----- src/blackmisc/htmlutils.cpp | 7 +++++++ src/blackmisc/htmlutils.h | 5 ++++- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/blackgui/components/dblogincomponent.cpp b/src/blackgui/components/dblogincomponent.cpp index be24391d4..72206ad10 100644 --- a/src/blackgui/components/dblogincomponent.cpp +++ b/src/blackgui/components/dblogincomponent.cpp @@ -7,17 +7,18 @@ * contained in the LICENSE file. */ +#include "ui_dblogincomponent.h" #include "blackcore/data/globalsetup.h" #include "blackgui/components/dblogincomponent.h" #include "blackgui/guiapplication.h" #include "blackgui/guiutility.h" #include "blackgui/overlaymessagesframe.h" -#include "blackmisc/logmessage.h" #include "blackmisc/network/authenticateduser.h" #include "blackmisc/network/url.h" +#include "blackmisc/htmlutils.h" +#include "blackmisc/logmessage.h" #include "blackmisc/statusmessage.h" #include "blackmisc/verify.h" -#include "ui_dblogincomponent.h" #include #include @@ -46,10 +47,11 @@ namespace BlackGui Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui"); ui->setupUi(this); this->setModeLogin(true); - CUrl url(sGui->getGlobalSetup().getDbHomePageUrl()); + const CUrl url(sGui->getGlobalSetup().getDbHomePageUrl()); + const QString urlString = asHyperlink(url.getFullUrl()); QString html = ui->tbr_InfoAndHints->toHtml(); - html = html.replace("##swiftDB##", url.getFullUrl(), Qt::CaseInsensitive); - html = html.replace("##swiftEnableSSO##", url.getFullUrl(), Qt::CaseInsensitive); + html = html.replace("##swiftDB##", urlString, Qt::CaseInsensitive); + html = html.replace("##swiftEnableSSO##", urlString, Qt::CaseInsensitive); ui->tbr_InfoAndHints->setHtml(html); ui->tbr_InfoAndHints->setOpenExternalLinks(true); @@ -58,7 +60,7 @@ namespace BlackGui ui->comp_DebugSetup->setVisible(devEnv); const QString dbUrl = sGui->getGlobalSetup().getDbHomePageUrl().toQString(); - ui->lbl_DatabaseName->setText("" + dbUrl + ""); + ui->lbl_DatabaseName->setText(asHyperlink(dbUrl)); ui->lbl_DatabaseName->setTextFormat(Qt::RichText); ui->lbl_DatabaseName->setTextInteractionFlags(Qt::TextBrowserInteraction); ui->lbl_DatabaseName->setOpenExternalLinks(true); diff --git a/src/blackgui/components/dblogincomponent.h b/src/blackgui/components/dblogincomponent.h index 42f0b980c..4c66d9c8d 100644 --- a/src/blackgui/components/dblogincomponent.h +++ b/src/blackgui/components/dblogincomponent.h @@ -32,7 +32,8 @@ namespace BlackGui * Login to DB */ class BLACKGUI_EXPORT CDbLoginComponent : - public QFrame, public BlackGui::CLoadIndicatorEnabled + public QFrame, + public CLoadIndicatorEnabled { Q_OBJECT diff --git a/src/blackgui/components/dblogincomponent.ui b/src/blackgui/components/dblogincomponent.ui index ae4cb22e0..5416a2862 100644 --- a/src/blackgui/components/dblogincomponent.ui +++ b/src/blackgui/components/dblogincomponent.ui @@ -380,19 +380,20 @@ - Login hints + true <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><title>Login hints</title><style type="text/css"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.1pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:7.875pt;"> </span></p> -<ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-family:'Arial'; font-size:7.875pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You can go directly to the swift DB: <a href="##swiftDb##"><span style=" text-decoration: underline; color:#0000ff;">##swiftDb##</span></a></li> -<li style=" font-family:'Arial'; font-size:7.875pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If you want to use VATSIM SSO, you need to enable it once <a href="##swiftEnableSSO##"><span style=" text-decoration: underline; color:#0000ff;">##swiftEnableSSO##</span></a></li></ol></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> +<ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-size:8pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You can go directly to the swift DB: ##swiftDb## </li> +<li style=" font-size:8pt;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If you want to use VATSIM SSO, you need to enable it once ##swiftEnableSSO## </li> +<li style=" font-size:8pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">In case you do not have a password you can try &quot;anonymous&quot;/&quot;anonymous&quot;. No guarantee it will work, but worth a trial. </li></ol></body></html> Qt::TextBrowserInteraction diff --git a/src/blackmisc/htmlutils.cpp b/src/blackmisc/htmlutils.cpp index c1088f3b8..27f3f7b12 100644 --- a/src/blackmisc/htmlutils.cpp +++ b/src/blackmisc/htmlutils.cpp @@ -39,4 +39,11 @@ namespace BlackMisc return u"

" % text % u"

"; } + QString asHyperlink(const QString &url, const QString &text) + { + return text.isEmpty() ? + u"" % url % u"" : + u"" % text % u""; + } + } // ns diff --git a/src/blackmisc/htmlutils.h b/src/blackmisc/htmlutils.h index 520b36ba1..1c95d19ca 100644 --- a/src/blackmisc/htmlutils.h +++ b/src/blackmisc/htmlutils.h @@ -12,8 +12,8 @@ #ifndef BLACKMISC_HTMLUTILS_H #define BLACKMISC_HTMLUTILS_H -#include "blackmisc/blackmiscexport.h" #include "blackmisc/propertyindexlist.h" +#include "blackmisc/blackmiscexport.h" #include //! Free functions in BlackMisc @@ -42,6 +42,9 @@ namespace BlackMisc //! As white space preformatted BLACKMISC_EXPORT QString unwrappedTooltip(const QString &text); + //! As hyperlink + BLACKMISC_EXPORT QString asHyperlink(const QString &url, const QString &text = ""); + } // ns #endif // guard