mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
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:
parent
64d2fc6344
commit
470fe5a58a
|
@ -84,19 +84,33 @@ namespace {
|
|||
|
||||
BasicLoginWidget::BasicLoginWidget()
|
||||
{
|
||||
const QString logInLink = "https://chatterino.com/client_login";
|
||||
this->setLayout(&this->ui_.layout);
|
||||
|
||||
this->ui_.loginButton.setText("Log in (Opens in browser)");
|
||||
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_.pasteCodeButton);
|
||||
|
||||
this->ui_.layout.addLayout(&this->ui_.horizontalLayout);
|
||||
this->ui_.layout.addWidget(&this->ui_.unableToOpenBrowserHelper);
|
||||
|
||||
connect(&this->ui_.loginButton, &QPushButton::clicked, []() {
|
||||
printf("open login in browser\n");
|
||||
QDesktopServices::openUrl(QUrl("https://chatterino.com/client_login"));
|
||||
connect(&this->ui_.loginButton, &QPushButton::clicked, [this, logInLink]() {
|
||||
qDebug() << "open login in browser";
|
||||
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]() {
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
QHBoxLayout horizontalLayout;
|
||||
QPushButton loginButton;
|
||||
QPushButton pasteCodeButton;
|
||||
QLabel unableToOpenBrowserHelper;
|
||||
} ui_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue