mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 21:13:12 -07:00
Register from SettingsDialog
This commit is contained in:
parent
c993ca611e
commit
f6a63b90fc
5 changed files with 24 additions and 7 deletions
|
@ -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:
|
||||
|
|
|
@ -36,6 +36,7 @@ class SettingsDialog : public QDialog
|
|||
private slots:
|
||||
void UpdateRegisteredHosts();
|
||||
void UpdateRegisteredHostsButtons();
|
||||
void RegisterNewHost();
|
||||
void DeleteRegisteredHost();
|
||||
|
||||
public:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue