Register from SettingsDialog

This commit is contained in:
Florian Märkl 2019-08-16 14:53:00 +02:00
commit f6a63b90fc
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
5 changed files with 24 additions and 7 deletions

View file

@ -47,7 +47,7 @@ class RegistDialog : public QDialog
void ValidateInput();
public:
explicit RegistDialog(Settings *settings, QString host = QString(), QWidget *parent = nullptr);
explicit RegistDialog(Settings *settings, const QString &host = QString(), QWidget *parent = nullptr);
~RegistDialog();
public slots:

View file

@ -36,6 +36,7 @@ class SettingsDialog : public QDialog
private slots:
void UpdateRegisteredHosts();
void UpdateRegisteredHostsButtons();
void RegisterNewHost();
void DeleteRegisteredHost();
public:

View file

@ -115,10 +115,15 @@ void MainWindow::ServerItemWidgetTriggered()
return;
const auto &server = display_servers[index];
// TODO: check if already registered and connect
if(server.registered)
{
// TODO: connect
}
else
{
RegistDialog regist_dialog(settings, server.GetHostAddr(), this);
regist_dialog.exec();
}
}
void MainWindow::UpdateDiscoveryEnabled()

View file

@ -33,7 +33,7 @@ Q_DECLARE_METATYPE(ChiakiLogLevel)
static const QRegularExpression pin_re(QString("[0-9]").repeated(PIN_LENGTH));
RegistDialog::RegistDialog(Settings *settings, QString host, QWidget *parent)
RegistDialog::RegistDialog(Settings *settings, const QString &host, QWidget *parent)
: QDialog(parent),
settings(settings)
{
@ -47,6 +47,9 @@ RegistDialog::RegistDialog(Settings *settings, QString host, QWidget *parent)
host_edit = new QLineEdit(this);
form_layout->addRow(tr("Host:"), host_edit);
if(host.isEmpty())
host_edit->setText("255.255.255.255");
else
host_edit->setText(host);
psn_id_edit = new QLineEdit(this);

View file

@ -17,6 +17,7 @@
#include <settingsdialog.h>
#include <settings.h>
#include <registdialog.h>
#include <QVBoxLayout>
#include <QDialogButtonBox>
@ -46,6 +47,7 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
auto register_new_button = new QPushButton(tr("Register New"), this);
registered_hosts_buttons_layout->addWidget(register_new_button);
connect(register_new_button, &QPushButton::clicked, this, &SettingsDialog::RegisterNewHost);
delete_registered_host_button = new QPushButton(tr("Delete"), this);
registered_hosts_buttons_layout->addWidget(delete_registered_host_button);
@ -81,6 +83,12 @@ void SettingsDialog::UpdateRegisteredHostsButtons()
delete_registered_host_button->setEnabled(registered_hosts_list_widget->currentIndex().isValid());
}
void SettingsDialog::RegisterNewHost()
{
RegistDialog dialog(settings, QString(), this);
dialog.exec();
}
void SettingsDialog::DeleteRegisteredHost()
{
auto item = registered_hosts_list_widget->currentItem();