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:
@@ -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]() {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public:
|
|||||||
QHBoxLayout horizontalLayout;
|
QHBoxLayout horizontalLayout;
|
||||||
QPushButton loginButton;
|
QPushButton loginButton;
|
||||||
QPushButton pasteCodeButton;
|
QPushButton pasteCodeButton;
|
||||||
|
QLabel unableToOpenBrowserHelper;
|
||||||
} ui_;
|
} ui_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user