1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 08:13:27 +00:00
transmission/qt/SessionDialog.cc
Mike Gelfand dadffa2c0f Align type qualifiers to the right (code style)
This way all the qualifiers (`const`, `volatile`, `mutable`) are grouped
together, e.g. `T const* const x` vs. `const T* const x`. Also helps reading
types right-to-left, e.g. "constant pointer to constant T" vs. "constant
pointer to T which is constant".
2017-04-20 19:53:20 +03:00

79 lines
2.3 KiB
C++

/*
* This file Copyright (C) 2009-2015 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
*/
#include "Prefs.h"
#include "Session.h"
#include "SessionDialog.h"
/***
****
***/
void SessionDialog::accept()
{
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();
}
void SessionDialog::resensitize()
{
bool const isRemote = ui.remoteSessionRadio->isChecked();
bool const useAuth = ui.authCheck->isChecked();
for (QWidget* const w : myRemoteWidgets)
{
w->setEnabled(isRemote);
}
for (QWidget* const w : myAuthWidgets)
{
w->setEnabled(isRemote && useAuth);
}
}
/***
****
***/
SessionDialog::SessionDialog(Session& session, Prefs& prefs, QWidget* parent) :
BaseDialog(parent),
mySession(session),
myPrefs(prefs)
{
ui.setupUi(this);
ui.localSessionRadio->setChecked(!prefs.get<bool>(Prefs::SESSION_IS_REMOTE));
connect(ui.localSessionRadio, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
ui.remoteSessionRadio->setChecked(prefs.get<bool>(Prefs::SESSION_IS_REMOTE));
connect(ui.remoteSessionRadio, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
ui.hostEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_HOST));
myRemoteWidgets << ui.hostLabel << ui.hostEdit;
ui.portSpin->setValue(prefs.get<int>(Prefs::SESSION_REMOTE_PORT));
myRemoteWidgets << ui.portLabel << ui.portSpin;
ui.authCheck->setChecked(prefs.get<bool>(Prefs::SESSION_REMOTE_AUTH));
connect(ui.authCheck, SIGNAL(toggled(bool)), this, SLOT(resensitize()));
myRemoteWidgets << ui.authCheck;
ui.usernameEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_USERNAME));
myAuthWidgets << ui.usernameLabel << ui.usernameEdit;
ui.passwordEdit->setText(prefs.get<QString>(Prefs::SESSION_REMOTE_PASSWORD));
myAuthWidgets << ui.passwordLabel << ui.passwordEdit;
resensitize();
}