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
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
myPrefs.set(Prefs::SESSION_IS_REMOTE, ui.remoteSessionRadio->isChecked());
|
|
|
|
myPrefs.set(Prefs::SESSION_REMOTE_HOST, ui.hostEdit->text());
|
|
|
|
myPrefs.set(Prefs::SESSION_REMOTE_PORT, ui.portSpin->value());
|
|
|
|
myPrefs.set(Prefs::SESSION_REMOTE_AUTH, ui.authCheck->isChecked());
|
|
|
|
myPrefs.set(Prefs::SESSION_REMOTE_USERNAME, ui.usernameEdit->text());
|
|
|
|
myPrefs.set(Prefs::SESSION_REMOTE_PASSWORD, ui.passwordEdit->text());
|
|
|
|
mySession.restart();
|
|
|
|
BaseDialog::accept();
|
2009-05-03 18:12:11 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void SessionDialog::resensitize()
|
2009-05-03 18:12:11 +00:00
|
|
|
{
|
2017-04-20 16:02:19 +00:00
|
|
|
bool const isRemote = ui.remoteSessionRadio->isChecked();
|
|
|
|
bool const useAuth = ui.authCheck->isChecked();
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
for (QWidget* const w : myRemoteWidgets)
|
|
|
|
{
|
|
|
|
w->setEnabled(isRemote);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (QWidget* const w : myAuthWidgets)
|
|
|
|
{
|
|
|
|
w->setEnabled(isRemote && useAuth);
|
|
|
|
}
|
2009-05-03 18:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
SessionDialog::SessionDialog(Session& session, Prefs& prefs, QWidget* parent) :
|
|
|
|
BaseDialog(parent),
|
|
|
|
mySession(session),
|
|
|
|
myPrefs(prefs)
|
2009-05-03 18:12:11 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
ui.setupUi(this);
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
ui.localSessionRadio->setChecked(!prefs.get<bool>(Prefs::SESSION_IS_REMOTE));
|
|
|
|
connect(ui.localSessionRadio, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
ui.remoteSessionRadio->setChecked(prefs.get<bool>(Prefs::SESSION_IS_REMOTE));
|
|
|
|
connect(ui.remoteSessionRadio, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
ui.hostEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_HOST));
|
|
|
|
myRemoteWidgets << ui.hostLabel << ui.hostEdit;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
ui.portSpin->setValue(prefs.get<int>(Prefs::SESSION_REMOTE_PORT));
|
|
|
|
myRemoteWidgets << ui.portLabel << ui.portSpin;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
ui.authCheck->setChecked(prefs.get<bool>(Prefs::SESSION_REMOTE_AUTH));
|
|
|
|
connect(ui.authCheck, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
|
|
|
|
myRemoteWidgets << ui.authCheck;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
ui.usernameEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_USERNAME));
|
|
|
|
myAuthWidgets << ui.usernameLabel << ui.usernameEdit;
|
2014-12-21 23:46:31 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
ui.passwordEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_PASSWORD));
|
|
|
|
myAuthWidgets << 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
|
|
|
}
|