The complete source code of IdealIRC
http://www.idealirc.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
3.9 KiB
133 lines
3.9 KiB
/*
|
|
* IdealIRC - Internet Relay Chat client
|
|
* Copyright (C) 2021 Tom-Andre Barstad.
|
|
* This software is licensed under the Software Attribution License.
|
|
* See LICENSE for more information.
|
|
*/
|
|
|
|
#include "IConfigServers.h"
|
|
#include "ui_IConfigServers.h"
|
|
#include "ConfigMgr.h"
|
|
#include "ServerItem.h"
|
|
#include <QDebug>
|
|
|
|
IConfigServers::IConfigServers(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::IConfigServers)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
ConfigMgr& conf = ConfigMgr::instance();
|
|
cf_Realname = conf.connection("Realname");
|
|
cf_Username = conf.connection("Username");
|
|
cf_Nickname = conf.connection("Nickname");
|
|
cf_AltNickame = conf.connection("AltNickname");
|
|
cf_Server = conf.connection("Server");
|
|
cf_Password = conf.connection("Password");
|
|
cf_SSL = conf.connection("SSL").toInt();
|
|
|
|
ui->edRealName->setText(cf_Realname);
|
|
ui->edUsername->setText(cf_Username);
|
|
ui->edNickname->setText(cf_Nickname);
|
|
ui->edAltNickname->setText(cf_AltNickame);
|
|
ui->edServer->setText(cf_Server);
|
|
ui->edServerPassword->setText(cf_Password);
|
|
ui->chkSSL->setChecked(cf_SSL);
|
|
|
|
ui->servers->setModel(&smodel);
|
|
}
|
|
|
|
IConfigServers::~IConfigServers()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
bool IConfigServers::isChanged() const
|
|
{
|
|
return cf_Realname != ui->edRealName->text()
|
|
|| cf_Username != ui->edUsername->text()
|
|
|| cf_Nickname != ui->edNickname->text()
|
|
|| cf_AltNickame != ui->edAltNickname->text()
|
|
|| cf_Server != ui->edServer->text()
|
|
|| cf_Password != ui->edServerPassword->text()
|
|
|| cf_SSL != ui->chkSSL->isChecked();
|
|
}
|
|
|
|
bool IConfigServers::connectToNewStatus() const
|
|
{
|
|
return ui->chkNewStatus->isChecked();
|
|
}
|
|
|
|
void IConfigServers::unsetConnectToNewStatus()
|
|
{
|
|
ui->chkNewStatus->setChecked(false);
|
|
}
|
|
|
|
void IConfigServers::save()
|
|
{
|
|
ConfigMgr& conf = ConfigMgr::instance();
|
|
conf.setConnection("Realname", ui->edRealName->text());
|
|
conf.setConnection("Username", ui->edUsername->text());
|
|
conf.setConnection("Nickname", ui->edNickname->text());
|
|
conf.setConnection("AltNickname", ui->edAltNickname->text());
|
|
conf.setConnection("Server", ui->edServer->text());
|
|
conf.setConnection("Password", ui->edServerPassword->text());
|
|
conf.setConnection("SSL", QString::number(ui->chkSSL->isChecked()));
|
|
|
|
cf_Realname = conf.connection("Realname");
|
|
cf_Username = conf.connection("Username");
|
|
cf_Nickname = conf.connection("Nickname");
|
|
cf_AltNickame = conf.connection("AltNickname");
|
|
cf_Server = conf.connection("Server");
|
|
cf_Password = conf.connection("Password");
|
|
cf_SSL = conf.connection("SSL").toInt();
|
|
}
|
|
|
|
void IConfigServers::reset()
|
|
{
|
|
ui->edRealName->setText(cf_Realname);
|
|
ui->edUsername->setText(cf_Username);
|
|
ui->edNickname->setText(cf_Nickname);
|
|
ui->edAltNickname->setText(cf_AltNickame);
|
|
ui->edServer->setText(cf_Server);
|
|
ui->edServerPassword->setText(cf_Password);
|
|
}
|
|
|
|
|
|
void IConfigServers::on_btnShowPassword_toggled(bool checked)
|
|
{
|
|
ui->edServerPassword->setEchoMode(checked ? QLineEdit::Normal : QLineEdit::Password);
|
|
}
|
|
|
|
void IConfigServers::on_btnEditServers_clicked()
|
|
{
|
|
/*
|
|
editor = new ServerEditor(smodel, this);
|
|
ui->servers->setModel(&smodel);
|
|
connect(editor, &ServerEditor::saveClicked,
|
|
this, &IConfigServers::onServerEditorSaved);
|
|
|
|
QModelIndex sindex = smodel.indexFromHost(cf_Server);
|
|
if (sindex.isValid())
|
|
ui->servers->selectionModel()->setCurrentIndex(sindex, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
|
|
|
editor->show();
|
|
*/
|
|
}
|
|
|
|
void IConfigServers::on_servers_clicked(const QModelIndex& index)
|
|
{
|
|
auto* item = static_cast<const ServerItem*>(index.internalPointer());
|
|
|
|
ui->edServer->setText( item->address() );
|
|
ui->edServerPassword->setText( item->password() );
|
|
ui->chkSSL->setChecked( item->ssl() );
|
|
}
|
|
|
|
void IConfigServers::onServerEditorSaved()
|
|
{
|
|
auto index = ui->servers->selectionModel()->currentIndex();
|
|
if (!index.isValid())
|
|
return;
|
|
on_servers_clicked(index);
|
|
}
|
|
|