Hint for "anonymous" login

* utility function for hyperlink
* info about login
This commit is contained in:
Klaus Basan
2019-02-13 00:27:20 +01:00
committed by Mat Sutcliffe
parent 731d39d783
commit dc84c9b334
5 changed files with 27 additions and 13 deletions

View File

@@ -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 <QLabel>
#include <QLineEdit>
@@ -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("<a href=\"" + dbUrl + "\">" + dbUrl + "</a>");
ui->lbl_DatabaseName->setText(asHyperlink(dbUrl));
ui->lbl_DatabaseName->setTextFormat(Qt::RichText);
ui->lbl_DatabaseName->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_DatabaseName->setOpenExternalLinks(true);

View File

@@ -32,7 +32,8 @@ namespace BlackGui
* Login to DB
*/
class BLACKGUI_EXPORT CDbLoginComponent :
public QFrame, public BlackGui::CLoadIndicatorEnabled
public QFrame,
public CLoadIndicatorEnabled
{
Q_OBJECT

View File

@@ -380,19 +380,20 @@
<item>
<widget class="QTextBrowser" name="tbr_InfoAndHints">
<property name="documentTitle">
<string>Login hints</string>
<string/>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;title&gt;Login hints&lt;/title&gt;&lt;style type=&quot;text/css&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.1pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Arial'; font-size:7.875pt;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
&lt;ol style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; font-family:'Arial'; font-size:7.875pt;&quot; style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;You can go directly to the swift DB: &lt;a href=&quot;##swiftDb##&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;##swiftDb##&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot; font-family:'Arial'; font-size:7.875pt;&quot; style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;If you want to use VATSIM SSO, you need to enable it once &lt;a href=&quot;##swiftEnableSSO##&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;##swiftEnableSSO##&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;ol style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; font-size:8pt;&quot; style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;You can go directly to the swift DB: ##swiftDb## &lt;/li&gt;
&lt;li style=&quot; font-size:8pt;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;If you want to use VATSIM SSO, you need to enable it once ##swiftEnableSSO## &lt;/li&gt;
&lt;li style=&quot; font-size:8pt;&quot; style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;In case you do not have a password you can try &amp;quot;anonymous&amp;quot;/&amp;quot;anonymous&amp;quot;. No guarantee it will work, but worth a trial. &lt;/li&gt;&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>

View File

@@ -39,4 +39,11 @@ namespace BlackMisc
return u"<p style='white-space:pre'>" % text % u"</p>";
}
QString asHyperlink(const QString &url, const QString &text)
{
return text.isEmpty() ?
u"<a href=\"" % url % u"\">" % url % u"</a>" :
u"<a href=\"" % url % u"\">" % text % u"</a>";
}
} // ns

View File

@@ -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 <QStringBuilder>
//! 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