8 #include <QPlainTextEdit>
15 #include "ui_dblogincomponent.h"
33 using namespace swift::config;
35 using namespace swift::misc::network;
39 CDbLoginComponent::CDbLoginComponent(QWidget *parent)
42 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"Missing sGui");
44 this->setModeLogin(
true);
46 QString html = ui->tbr_InfoAndHints->toHtml();
47 html = html.replace(
"##swiftDB##", urlString, Qt::CaseInsensitive);
48 html = html.replace(
"##swiftEnableSSO##", urlString, Qt::CaseInsensitive);
50 ui->tbr_InfoAndHints->setHtml(html);
51 ui->tbr_InfoAndHints->setOpenExternalLinks(
true);
55 ui->lbl_DatabaseName->setTextFormat(Qt::RichText);
56 ui->lbl_DatabaseName->setTextInteractionFlags(Qt::TextBrowserInteraction);
57 ui->lbl_DatabaseName->setOpenExternalLinks(
true);
59 connect(ui->pb_Login, &QPushButton::clicked,
this, &CDbLoginComponent::onLoginClicked);
60 connect(ui->pb_Logoff, &QPushButton::clicked,
this, &CDbLoginComponent::onLogoffClicked);
61 connect(ui->le_Password, &QLineEdit::returnPressed,
this, &CDbLoginComponent::onLoginClicked);
62 connect(&m_loginService, &CDatabaseAuthenticationService::userAuthenticationFinished,
this,
63 &CDbLoginComponent::onAuthenticationFinished, Qt::QueuedConnection);
65 if (CBuildConfig::isLocalDeveloperDebugBuild())
68 ui->pb_Login->setToolTip(url);
90 void CDbLoginComponent::onLoginClicked()
92 using namespace std::chrono_literals;
93 const QString un(ui->le_Username->text().trimmed());
94 const QString pw(ui->le_Password->text().trimmed());
99 CLogMessage::preformatted(msgs);
100 displayOverlayMessages(msgs);
103 else if (!msgs.
isEmpty()) { CLogMessage::preformatted(msgs); }
107 void CDbLoginComponent::onLogoffClicked()
110 this->setModeLogin(
true);
117 this->setUserInfo(user);
120 this->displayOverlayMessages(statusMsgs);
121 CLogMessage::preformatted(statusMsgs);
122 ui->le_Info->setText(
"Authentication failed, see hints");
126 void CDbLoginComponent::setModeLogin(
bool modeLogin) { ui->sw_LoginLogoff->setCurrentIndex(modeLogin ? 0 : 1); }
134 this->setModeLogin(
false);
138 else { ui->le_Info->setText(
"You can create model change requests"); }
141 CCrashHandler::instance()->crashAndLogInfoUserName(user.
getRealNameAndId());
142 CCrashHandler::instance()->crashAndLogAppendInfo(
147 ui->le_Name->clear();
148 ui->te_Roles->clear();
149 this->setModeLogin(
true);
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
data::CGlobalSetup getGlobalSetup() const
Global setup.
bool isShuttingDown() const
Is application shutting down?
swift::misc::network::CUrl getDbHomePageUrl() const
Home page url.
swift::misc::network::CUrl getDbLoginServiceUrl() const
Login service.
swift::misc::network::CAuthenticatedUser getDbUser() const
DB user.
bool isUserAuthenticated() const
User authenticated.
static COverlayMessagesFrame * nextOverlayMessageFrame(QWidget *widget, int maxLevels=10)
Find next COverlayMessagesFrame.
Enable widget class for load indicator.
void showLoading(std::chrono::milliseconds timeout=std::chrono::milliseconds(0), bool processEvents=true)
Show load indicator.
void hideLoading()
Hide load indicator.
void showOverlayMessages(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages.
Using this class provides a QFrame with the overlay functionality already integrated.
virtual ~CDbLoginComponent()
Destructor.
bool isUserAuthenticated() const
Is user authenticated?
swift::misc::network::CAuthenticatedUser getDbUser() const
DB user.
Class for emitting a log message.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
bool isEmpty() const
Synonym for empty.
Status messages, e.g. from Core -> GUI.
bool hasWarningOrErrorMessages() const
Warning or error messages.
QString toQString(bool i18n=false) const
Cast as QString.
Value object encapsulating information of an authentiated user.
bool isAuthenticated() const
Authenticated.
bool canDirectlyWriteModels() const
Entitled to directly update models.
QString getRolesAsString() const
Roles.
QString getRealNameAndId() const
Full name + id.
QString getFullUrl(bool withQuery=true) const
Qualified name.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Classes interacting with the swift database (aka "datastore").
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Free functions in swift::misc.
QString asHyperlink(const QString &url, const QString &text)
As hyperlink.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.