Add input field to specify the device name on login
This commit is contained in:
parent
3d2e29bfa0
commit
18695d636d
@ -95,6 +95,9 @@ LoginPage::LoginPage(QWidget *parent)
|
|||||||
password_input_->setLabel(tr("Password"));
|
password_input_->setLabel(tr("Password"));
|
||||||
password_input_->setEchoMode(QLineEdit::Password);
|
password_input_->setEchoMode(QLineEdit::Password);
|
||||||
|
|
||||||
|
deviceName_ = new TextField(this);
|
||||||
|
deviceName_->setLabel(tr("Device name"));
|
||||||
|
|
||||||
serverInput_ = new TextField(this);
|
serverInput_ = new TextField(this);
|
||||||
serverInput_->setLabel("Homeserver address");
|
serverInput_->setLabel("Homeserver address");
|
||||||
serverInput_->setPlaceholderText("matrix.org");
|
serverInput_->setPlaceholderText("matrix.org");
|
||||||
@ -104,7 +107,8 @@ LoginPage::LoginPage(QWidget *parent)
|
|||||||
serverLayout_->addWidget(serverInput_, 0, Qt::AlignVCenter);
|
serverLayout_->addWidget(serverInput_, 0, Qt::AlignVCenter);
|
||||||
|
|
||||||
form_layout_->addLayout(matrixidLayout_);
|
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_);
|
form_layout_->addLayout(serverLayout_);
|
||||||
|
|
||||||
button_layout_ = new QHBoxLayout();
|
button_layout_ = new QHBoxLayout();
|
||||||
@ -145,6 +149,7 @@ LoginPage::LoginPage(QWidget *parent)
|
|||||||
connect(login_button_, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked()));
|
connect(login_button_, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked()));
|
||||||
connect(matrixid_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
connect(matrixid_input_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
||||||
connect(password_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(serverInput_, SIGNAL(returnPressed()), login_button_, SLOT(click()));
|
||||||
connect(matrixid_input_, SIGNAL(editingFinished()), this, SLOT(onMatrixIdEntered()));
|
connect(matrixid_input_, SIGNAL(editingFinished()), this, SLOT(onMatrixIdEntered()));
|
||||||
connect(serverInput_, SIGNAL(editingFinished()), this, SLOT(onServerAddressEntered()));
|
connect(serverInput_, SIGNAL(editingFinished()), this, SLOT(onServerAddressEntered()));
|
||||||
@ -269,19 +274,19 @@ LoginPage::onLoginButtonClicked()
|
|||||||
return loginError(tr("Empty password"));
|
return loginError(tr("Empty password"));
|
||||||
|
|
||||||
http::client()->set_server(serverInput_->text().toStdString());
|
http::client()->set_server(serverInput_->text().toStdString());
|
||||||
http::client()->login(user.localpart(),
|
http::client()->login(
|
||||||
password_input_->text().toStdString(),
|
user.localpart(),
|
||||||
initialDeviceName(),
|
password_input_->text().toStdString(),
|
||||||
[this](const mtx::responses::Login &res, mtx::http::RequestErr err) {
|
deviceName_->text().isEmpty() ? initialDeviceName() : deviceName_->text().toStdString(),
|
||||||
if (err) {
|
[this](const mtx::responses::Login &res, mtx::http::RequestErr err) {
|
||||||
emit loginError(
|
if (err) {
|
||||||
QString::fromStdString(err->matrix_error.error));
|
emit loginError(QString::fromStdString(err->matrix_error.error));
|
||||||
emit errorOccurred();
|
emit errorOccurred();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit loginOk(res);
|
emit loginOk(res);
|
||||||
});
|
});
|
||||||
|
|
||||||
emit loggingIn();
|
emit loggingIn();
|
||||||
}
|
}
|
||||||
|
@ -86,13 +86,13 @@ private:
|
|||||||
std::string initialDeviceName()
|
std::string initialDeviceName()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
return "nheko on macOS";
|
return "Nheko on macOS";
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
return "nheko on Linux";
|
return "Nheko on Linux";
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
return "nheko on Windows";
|
return "Nheko on Windows";
|
||||||
#else
|
#else
|
||||||
return "nheko";
|
return "Nheko";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,5 +120,6 @@ private:
|
|||||||
|
|
||||||
TextField *matrixid_input_;
|
TextField *matrixid_input_;
|
||||||
TextField *password_input_;
|
TextField *password_input_;
|
||||||
|
TextField *deviceName_;
|
||||||
TextField *serverInput_;
|
TextField *serverInput_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user