2009-05-03 18:12:11 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2009-2015 Mnemosyne LLC
|
2009-05-03 18:12:11 +00:00
|
|
|
*
|
2014-12-21 23:49:39 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2009-05-03 18:12:11 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "Prefs.h"
|
|
|
|
#include "Session.h"
|
|
|
|
#include "SessionDialog.h"
|
2009-05-03 18:12:11 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void SessionDialog::accept()
|
2009-05-03 18:12:11 +00:00
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
prefs_.set(Prefs::SESSION_IS_REMOTE, ui_.remoteSessionRadio->isChecked());
|
|
|
|
prefs_.set(Prefs::SESSION_REMOTE_HOST, ui_.hostEdit->text());
|
|
|
|
prefs_.set(Prefs::SESSION_REMOTE_PORT, ui_.portSpin->value());
|
|
|
|
prefs_.set(Prefs::SESSION_REMOTE_AUTH, ui_.authCheck->isChecked());
|
|
|
|
prefs_.set(Prefs::SESSION_REMOTE_USERNAME, ui_.usernameEdit->text());
|
|
|
|
prefs_.set(Prefs::SESSION_REMOTE_PASSWORD, ui_.passwordEdit->text());
|
|
|
|
session_.restart();
|
2017-04-19 12:04:45 +00:00
|
|
|
BaseDialog::accept();
|
2009-05-03 18:12:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-09 03:31:02 +00:00
|
|
|
void SessionDialog::resensitize() const
|
2009-05-03 18:12:11 +00:00
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
bool const is_remote = ui_.remoteSessionRadio->isChecked();
|
|
|
|
bool const use_auth = ui_.authCheck->isChecked();
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
for (QWidget* const w : remote_widgets_)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
w->setEnabled(is_remote);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
for (QWidget* const w : auth_widgets_)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
w->setEnabled(is_remote && use_auth);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2009-05-03 18:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
SessionDialog::SessionDialog(Session& session, Prefs& prefs, QWidget* parent)
|
|
|
|
: BaseDialog(parent)
|
|
|
|
, session_(session)
|
|
|
|
, prefs_(prefs)
|
2009-05-03 18:12:11 +00:00
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
ui_.setupUi(this);
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
ui_.localSessionRadio->setChecked(!prefs.get<bool>(Prefs::SESSION_IS_REMOTE));
|
2021-10-24 03:28:16 +00:00
|
|
|
connect(ui_.localSessionRadio, &QAbstractButton::toggled, this, &SessionDialog::resensitize);
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
ui_.remoteSessionRadio->setChecked(prefs.get<bool>(Prefs::SESSION_IS_REMOTE));
|
2021-10-24 03:28:16 +00:00
|
|
|
connect(ui_.remoteSessionRadio, &QAbstractButton::toggled, this, &SessionDialog::resensitize);
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
ui_.hostEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_HOST));
|
|
|
|
remote_widgets_ << ui_.hostLabel << ui_.hostEdit;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
ui_.portSpin->setValue(prefs.get<int>(Prefs::SESSION_REMOTE_PORT));
|
|
|
|
remote_widgets_ << ui_.portLabel << ui_.portSpin;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
ui_.authCheck->setChecked(prefs.get<bool>(Prefs::SESSION_REMOTE_AUTH));
|
2020-10-31 18:56:12 +00:00
|
|
|
connect(ui_.authCheck, &QAbstractButton::toggled, this, &SessionDialog::resensitize);
|
2020-05-27 21:53:12 +00:00
|
|
|
remote_widgets_ << ui_.authCheck;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
ui_.usernameEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_USERNAME));
|
|
|
|
auth_widgets_ << ui_.usernameLabel << ui_.usernameEdit;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2020-05-27 21:53:12 +00:00
|
|
|
ui_.passwordEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_PASSWORD));
|
|
|
|
auth_widgets_ << ui_.passwordLabel << ui_.passwordEdit;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
resensitize();
|
2010-01-05 23:47:50 +00:00
|
|
|
}
|