mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fix login dialog causing main window to be non movable (#4121)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com> fixes https://github.com/Chatterino/chatterino2/issues/2378
This commit is contained in:
parent
2a9c15b2de
commit
a8b4eaa431
|
@ -79,6 +79,7 @@
|
||||||
- Minor: Migrated /mods to Helix API. (#4103)
|
- Minor: Migrated /mods to Helix API. (#4103)
|
||||||
- Minor: Add settings tooltips. (#3437)
|
- Minor: Add settings tooltips. (#3437)
|
||||||
- Minor: Improved look of tabs when using a layout other than top. (#3925)
|
- Minor: Improved look of tabs when using a layout other than top. (#3925)
|
||||||
|
- Bugfix: Fixed `Add new account` dialog causing main chatterino window to be non movable. (#4121)
|
||||||
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
|
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
|
||||||
- Bugfix: Fixed `Smooth scrolling on new messages` setting sometimes hiding messages. (#4028)
|
- Bugfix: Fixed `Smooth scrolling on new messages` setting sometimes hiding messages. (#4028)
|
||||||
- Bugfix: Fixed a crash that can occur when closing and quickly reopening a split, then running a command. (#3852)
|
- Bugfix: Fixed a crash that can occur when closing and quickly reopening a split, then running a command. (#3852)
|
||||||
|
|
|
@ -23,8 +23,8 @@ namespace chatterino {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void logInWithCredentials(const QString &userID, const QString &username,
|
bool logInWithCredentials(QWidget *parent, const QString &userID,
|
||||||
const QString &clientID,
|
const QString &username, const QString &clientID,
|
||||||
const QString &oauthToken)
|
const QString &oauthToken)
|
||||||
{
|
{
|
||||||
QStringList errors;
|
QStringList errors;
|
||||||
|
@ -48,20 +48,12 @@ namespace {
|
||||||
|
|
||||||
if (errors.length() > 0)
|
if (errors.length() > 0)
|
||||||
{
|
{
|
||||||
QMessageBox messageBox;
|
QMessageBox messageBox(parent);
|
||||||
// Set error window on top
|
messageBox.setWindowTitle("Invalid account credentials");
|
||||||
#ifdef USEWINSDK
|
|
||||||
::SetWindowPos(HWND(messageBox.winId()), HWND_TOPMOST, 0, 0, 0, 0,
|
|
||||||
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
messageBox.setWindowTitle(
|
|
||||||
"Chatterino - invalid account credentials");
|
|
||||||
messageBox.setIcon(QMessageBox::Critical);
|
messageBox.setIcon(QMessageBox::Critical);
|
||||||
messageBox.setText(errors.join("<br>"));
|
messageBox.setText(errors.join("<br>"));
|
||||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string basePath = "/accounts/uid" + userID.toStdString();
|
std::string basePath = "/accounts/uid" + userID.toStdString();
|
||||||
|
@ -75,6 +67,7 @@ namespace {
|
||||||
|
|
||||||
getApp()->accounts->twitch.reloadUsers();
|
getApp()->accounts->twitch.reloadUsers();
|
||||||
getApp()->accounts->twitch.currentUsername = username;
|
getApp()->accounts->twitch.currentUsername = username;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -116,6 +109,9 @@ BasicLoginWidget::BasicLoginWidget()
|
||||||
QStringList parameters = getClipboardText().split(";");
|
QStringList parameters = getClipboardText().split(";");
|
||||||
QString oauthToken, clientID, username, userID;
|
QString oauthToken, clientID, username, userID;
|
||||||
|
|
||||||
|
// Removing clipboard content to prevent accidental paste of credentials into somewhere
|
||||||
|
crossPlatformCopy("");
|
||||||
|
|
||||||
for (const auto ¶m : parameters)
|
for (const auto ¶m : parameters)
|
||||||
{
|
{
|
||||||
QStringList kvParameters = param.split('=');
|
QStringList kvParameters = param.split('=');
|
||||||
|
@ -148,11 +144,10 @@ BasicLoginWidget::BasicLoginWidget()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logInWithCredentials(userID, username, clientID, oauthToken);
|
if (logInWithCredentials(this, userID, username, clientID, oauthToken))
|
||||||
|
{
|
||||||
// Removing clipboard content to prevent accidental paste of credentials into somewhere
|
|
||||||
crossPlatformCopy("");
|
|
||||||
this->window()->close();
|
this->window()->close();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,14 +207,14 @@ AdvancedLoginWidget::AdvancedLoginWidget()
|
||||||
this->ui_.oauthTokenInput.clear();
|
this->ui_.oauthTokenInput.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked,
|
connect(
|
||||||
[=]() {
|
&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() {
|
||||||
QString userID = this->ui_.userIDInput.text();
|
QString userID = this->ui_.userIDInput.text();
|
||||||
QString username = this->ui_.usernameInput.text();
|
QString username = this->ui_.usernameInput.text();
|
||||||
QString clientID = this->ui_.clientIDInput.text();
|
QString clientID = this->ui_.clientIDInput.text();
|
||||||
QString oauthToken = this->ui_.oauthTokenInput.text();
|
QString oauthToken = this->ui_.oauthTokenInput.text();
|
||||||
|
|
||||||
logInWithCredentials(userID, username, clientID, oauthToken);
|
logInWithCredentials(this, userID, username, clientID, oauthToken);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,15 +233,15 @@ void AdvancedLoginWidget::refreshButtons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginWidget::LoginWidget(QWidget *parent)
|
LoginDialog::LoginDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
#ifdef USEWINSDK
|
this->setMinimumWidth(300);
|
||||||
::SetWindowPos(HWND(this->winId()), HWND_TOPMOST, 0, 0, 0, 0,
|
this->setWindowFlags(
|
||||||
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
(this->windowFlags() & ~(Qt::WindowContextHelpButtonHint)) |
|
||||||
#endif
|
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
|
||||||
|
|
||||||
this->setWindowTitle("Chatterino - add new account");
|
this->setWindowTitle("Add new account");
|
||||||
|
|
||||||
this->setLayout(&this->ui_.mainLayout);
|
this->setLayout(&this->ui_.mainLayout);
|
||||||
this->ui_.mainLayout.addWidget(&this->ui_.tabWidget);
|
this->ui_.mainLayout.addWidget(&this->ui_.tabWidget);
|
||||||
|
|
|
@ -61,10 +61,10 @@ public:
|
||||||
} ui_;
|
} ui_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LoginWidget : public QDialog
|
class LoginDialog : public QDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LoginWidget(QWidget *parent);
|
LoginDialog(QWidget *parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -33,10 +33,8 @@ AccountsPage::AccountsPage()
|
||||||
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
|
||||||
view->addButtonPressed.connect([this] {
|
view->addButtonPressed.connect([this] {
|
||||||
static auto loginWidget = new LoginWidget(this);
|
LoginDialog d(this);
|
||||||
|
d.exec();
|
||||||
loginWidget->show();
|
|
||||||
loginWidget->raise();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
view->getTableView()->setStyleSheet("background: #333");
|
view->getTableView()->setStyleSheet("background: #333");
|
||||||
|
|
Loading…
Reference in a new issue