Add label that shows up if the log in link didn't open properly

This basically takes the official advice from https://github.com/Chatterino/chatterino2/issues/1779#issuecomment-699235396 and tells the user what they can do as a workaround.

Relevant issue: #1779
This commit is contained in:
Rasmus Karlsson
2020-09-26 10:24:29 +02:00
parent 64d2fc6344
commit 470fe5a58a
2 changed files with 18 additions and 3 deletions
+17 -3
View File
@@ -84,19 +84,33 @@ namespace {
BasicLoginWidget::BasicLoginWidget() BasicLoginWidget::BasicLoginWidget()
{ {
const QString logInLink = "https://chatterino.com/client_login";
this->setLayout(&this->ui_.layout); this->setLayout(&this->ui_.layout);
this->ui_.loginButton.setText("Log in (Opens in browser)"); this->ui_.loginButton.setText("Log in (Opens in browser)");
this->ui_.pasteCodeButton.setText("Paste login info"); this->ui_.pasteCodeButton.setText("Paste login info");
this->ui_.unableToOpenBrowserHelper.setWordWrap(true);
this->ui_.unableToOpenBrowserHelper.hide();
this->ui_.unableToOpenBrowserHelper.setText(
"An error occured while attempting to open <a href='" + logInLink +
"'>the log in link (" + logInLink + ")</a> " +
" - open it manually in your browser and proceed from there.");
this->ui_.unableToOpenBrowserHelper.setOpenExternalLinks(true);
this->ui_.horizontalLayout.addWidget(&this->ui_.loginButton); this->ui_.horizontalLayout.addWidget(&this->ui_.loginButton);
this->ui_.horizontalLayout.addWidget(&this->ui_.pasteCodeButton); this->ui_.horizontalLayout.addWidget(&this->ui_.pasteCodeButton);
this->ui_.layout.addLayout(&this->ui_.horizontalLayout); this->ui_.layout.addLayout(&this->ui_.horizontalLayout);
this->ui_.layout.addWidget(&this->ui_.unableToOpenBrowserHelper);
connect(&this->ui_.loginButton, &QPushButton::clicked, []() { connect(&this->ui_.loginButton, &QPushButton::clicked, [this, logInLink]() {
printf("open login in browser\n"); qDebug() << "open login in browser";
QDesktopServices::openUrl(QUrl("https://chatterino.com/client_login")); auto res = QDesktopServices::openUrl(QUrl(logInLink));
if (!res)
{
qDebug() << "open login in browser failed";
this->ui_.unableToOpenBrowserHelper.show();
}
}); });
connect(&this->ui_.pasteCodeButton, &QPushButton::clicked, [this]() { connect(&this->ui_.pasteCodeButton, &QPushButton::clicked, [this]() {
+1
View File
@@ -29,6 +29,7 @@ public:
QHBoxLayout horizontalLayout; QHBoxLayout horizontalLayout;
QPushButton loginButton; QPushButton loginButton;
QPushButton pasteCodeButton; QPushButton pasteCodeButton;
QLabel unableToOpenBrowserHelper;
} ui_; } ui_;
}; };