mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Add input field to specify the device name on login
This commit is contained in:
parent
3d2e29bfa0
commit
18695d636d
2 changed files with 23 additions and 17 deletions
|
@ -95,6 +95,9 @@ LoginPage::LoginPage(QWidget *parent)
|
|||
password_input_->setLabel(tr("Password"));
|
||||
password_input_->setEchoMode(QLineEdit::Password);
|
||||
|
||||
deviceName_ = new TextField(this);
|
||||
deviceName_->setLabel(tr("Device name"));
|
||||
|
||||
serverInput_ = new TextField(this);
|
||||
serverInput_->setLabel("Homeserver address");
|
||||
serverInput_->setPlaceholderText("matrix.org");
|
||||
|
@ -104,7 +107,8 @@ LoginPage::LoginPage(QWidget *parent)
|
|||
serverLayout_->addWidget(serverInput_, 0, Qt::AlignVCenter);
|
||||
|
||||
form_layout_->addLayout(matrixidLayout_);
|
||||
form_layout_->addWidget(password_input_, Qt::AlignHCenter, 0);
|
||||
form_layout_->addWidget(password_input_);
|
||||
form_layout_->addWidget(deviceName_, Qt::AlignHCenter, 0);
|
||||
form_layout_->addLayout(serverLayout_);
|
||||
|
||||
button_layout_ = new QHBoxLayout();
|
||||
|
@ -145,6 +149,7 @@ LoginPage::LoginPage(QWidget *parent)
|
|||
connect(login_button_, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked()));
|
||||
connect(matrixid_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
||||
connect(password_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
||||
connect(deviceName_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
||||
connect(serverInput_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
||||
connect(matrixid_input_, SIGNAL(editingFinished()), this, SLOT(onMatrixIdEntered()));
|
||||
connect(serverInput_, SIGNAL(editingFinished()), this, SLOT(onServerAddressEntered()));
|
||||
|
@ -269,13 +274,13 @@ LoginPage::onLoginButtonClicked()
|
|||
return loginError(tr("Empty password"));
|
||||
|
||||
http::client()->set_server(serverInput_->text().toStdString());
|
||||
http::client()->login(user.localpart(),
|
||||
http::client()->login(
|
||||
user.localpart(),
|
||||
password_input_->text().toStdString(),
|
||||
initialDeviceName(),
|
||||
deviceName_->text().isEmpty() ? initialDeviceName() : deviceName_->text().toStdString(),
|
||||
[this](const mtx::responses::Login &res, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
emit loginError(
|
||||
QString::fromStdString(err->matrix_error.error));
|
||||
emit loginError(QString::fromStdString(err->matrix_error.error));
|
||||
emit errorOccurred();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -86,13 +86,13 @@ private:
|
|||
std::string initialDeviceName()
|
||||
{
|
||||
#if defined(Q_OS_MAC)
|
||||
return "nheko on macOS";
|
||||
return "Nheko on macOS";
|
||||
#elif defined(Q_OS_LINUX)
|
||||
return "nheko on Linux";
|
||||
return "Nheko on Linux";
|
||||
#elif defined(Q_OS_WIN)
|
||||
return "nheko on Windows";
|
||||
return "Nheko on Windows";
|
||||
#else
|
||||
return "nheko";
|
||||
return "Nheko";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -120,5 +120,6 @@ private:
|
|||
|
||||
TextField *matrixid_input_;
|
||||
TextField *password_input_;
|
||||
TextField *deviceName_;
|
||||
TextField *serverInput_;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue