34
37
#include "serverdialog.h"
35
38
#include "channeldialog.h"
36
39
#include "identitydialog.h"
40
#include "servergroupdialogui.h"
38
42
namespace Konversation
41
45
ServerGroupDialog::ServerGroupDialog(const QString& title, QWidget *parent, const char *name)
42
: KDialogBase(Plain, title, Ok|Cancel, Ok, parent, name)
46
: KDialogBase(Swallow, title, Ok|Cancel, Ok, parent, name)
45
49
m_identitiesNeedsUpdate = false;
46
50
m_editedServer = false;
48
QFrame* mainWidget = plainPage();
49
QGridLayout* mainLayout = new QGridLayout(mainWidget, 1, 2, 0, spacingHint());
50
mainLayout->setColStretch(1, 10);
52
QLabel* nameLbl = new QLabel(i18n("&Network:"), mainWidget);
53
m_nameEdit = new QLineEdit(mainWidget);
54
QWhatsThis::add(m_nameEdit, i18n("Enter the name of the Network here. You may create as many entries in the Server List screen with the same Network as you like."));
55
nameLbl->setBuddy(m_nameEdit);
57
QLabel* identityLbl = new QLabel(i18n("&Identity:"), mainWidget);
58
m_identityCBox = new QComboBox(mainWidget);
59
QWhatsThis::add(m_identityCBox,i18n("Choose an existing Identity or click the Edit button to add a new Identity or edit an existing one. The Identity will identify you and determine your nickname when you connect to the network."));
60
identityLbl->setBuddy(m_identityCBox);
61
QPushButton* editIdentityBtn = new QPushButton(i18n("Edit..."), mainWidget);
62
connect(editIdentityBtn, SIGNAL(clicked()), this, SLOT(editIdentity()));
52
m_mainWidget = new ServerGroupDialogUI(this);
53
setMainWidget(m_mainWidget);
55
QWhatsThis::add(m_mainWidget->m_nameEdit, i18n("Enter the name of the Network here. You may create as many entries in the Server List screen with the same Network as you like."));
56
m_mainWidget->m_networkLabel->setBuddy(m_mainWidget->m_nameEdit);
58
QWhatsThis::add(m_mainWidget->m_identityCBox,i18n("Choose an existing Identity or click the Edit button to add a new Identity or edit an existing one. The Identity will identify you and determine your nickname when you connect to the network."));
59
m_mainWidget->m_identityLabel->setBuddy(m_mainWidget->m_identityCBox);
60
connect(m_mainWidget->m_editIdentityButton, SIGNAL(clicked()), this, SLOT(editIdentity()));
64
62
QValueList<IdentityPtr> identities = Preferences::identityList();
66
64
for(QValueList<IdentityPtr>::iterator it = identities.begin(); it != identities.end(); ++it)
68
m_identityCBox->insertItem((*it)->getName());
66
m_mainWidget->m_identityCBox->insertItem((*it)->getName());
71
QLabel* commandLbl = new QLabel(i18n("Co&mmands:"), mainWidget);
72
m_commandEdit = new QLineEdit(mainWidget);
73
QWhatsThis::add(m_commandEdit, i18n("Optional. This command will be sent to the server after connecting. Example: <b>/msg NickServ IDENTIFY <i>konvirocks</i></b>. This example is for the freenode network, which requires users to register their nickname with a password and login when connecting. <i>konvirocks<i> is the password for the nickname given in Identity. You may enter more than one command by separating them with semicolons."));
74
commandLbl->setBuddy(m_commandEdit);
76
m_autoConnectCBox = new QCheckBox(i18n("Connect on &application start up"), mainWidget);
77
QWhatsThis::add(m_autoConnectCBox, i18n("Check here if you want Konversation to automatically connect to this network whenever you open Konversation."));
79
QWidget* groupWidget = new QWidget(mainWidget);
80
QGridLayout* groupLayout = new QGridLayout(groupWidget, 1, 2, 0, spacingHint());
82
QGroupBox* serverGBox = new QGroupBox(0, Qt::Horizontal, i18n("Servers"), groupWidget);
83
serverGBox->setMargin(marginHint());
84
QGridLayout* serverLayout = new QGridLayout(serverGBox->layout(), 1, 2, spacingHint());
86
m_serverLBox = new QListBox(serverGBox);
87
QWhatsThis::add(m_serverLBox, i18n("This is a list of IRC Servers in the network. When connecting to the network, Konversation will attempt to connect to the top server first. If this fails, it will attempt the second server. If this fails, it will attempt the third, and so on. At least one server must be specified. Click a server to highlight it."));
88
QPushButton* addServerBtn = new QPushButton(i18n("Add..."), serverGBox);
89
QPushButton* changeServerBtn = new QPushButton(i18n("Edit..."), serverGBox);
90
QPushButton* removeServerBtn = new QPushButton(i18n("Delete"), serverGBox);
91
m_upServerBtn = new QToolButton(serverGBox);
92
m_upServerBtn->setIconSet(SmallIconSet("up"));
93
m_upServerBtn->setAutoRepeat(true);
94
m_upServerBtn->setEnabled(false);
95
m_downServerBtn = new QToolButton(serverGBox);
96
m_downServerBtn->setIconSet(SmallIconSet("down"));
97
m_downServerBtn->setAutoRepeat(true);
98
m_downServerBtn->setEnabled(false);
100
connect(addServerBtn, SIGNAL(clicked()), this, SLOT(addServer()));
101
connect(changeServerBtn, SIGNAL(clicked()), this, SLOT(editServer()));
102
connect(removeServerBtn, SIGNAL(clicked()), this, SLOT(deleteServer()));
103
connect(m_serverLBox, SIGNAL(selectionChanged()), this, SLOT(updateServerArrows()));
104
connect(m_upServerBtn, SIGNAL(clicked()), this, SLOT(moveServerUp()));
105
connect(m_downServerBtn, SIGNAL(clicked()), this, SLOT(moveServerDown()));
107
serverLayout->setColStretch(0, 10);
108
serverLayout->setRowStretch(4, 10);
109
serverLayout->addMultiCellWidget(m_serverLBox, 0, 4, 0, 0);
110
serverLayout->addMultiCellWidget(addServerBtn, 0, 0, 1, 4);
111
serverLayout->addMultiCellWidget(changeServerBtn, 1, 1, 1, 4);
112
serverLayout->addMultiCellWidget(removeServerBtn, 2, 2, 1, 4);
113
serverLayout->addWidget(m_upServerBtn, 3, 2);
114
serverLayout->addWidget(m_downServerBtn, 3, 3);
116
QGroupBox* channelGBox = new QGroupBox(0, Qt::Horizontal, i18n("Auto Join Channels"), groupWidget);
117
channelGBox->setMargin(marginHint());
118
QGridLayout* channelLayout = new QGridLayout(channelGBox->layout(), 1, 2, spacingHint());
120
m_channelLBox = new QListBox(channelGBox);
121
QWhatsThis::add(m_channelLBox, i18n("Optional. This is a list of the channels that will be automatically joined once Konversation has connected to a server. You may leave this blank if you wish to not automatically join any channels."));
122
QPushButton* addChannelBtn = new QPushButton(i18n("Add..."), channelGBox);
123
QPushButton* changeChannelBtn = new QPushButton(i18n("Edit..."), channelGBox);
124
QPushButton* removeChannelBtn = new QPushButton(i18n("Delete"), channelGBox);
125
m_upChannelBtn = new QToolButton(channelGBox);
126
m_upChannelBtn->setIconSet(SmallIconSet("up"));
127
m_upChannelBtn->setAutoRepeat(true);
128
m_upChannelBtn->setEnabled(false);
129
m_downChannelBtn = new QToolButton(channelGBox);
130
m_downChannelBtn->setIconSet(SmallIconSet("down"));
131
m_downChannelBtn->setAutoRepeat(true);
132
m_downChannelBtn->setEnabled(false);
134
connect(addChannelBtn, SIGNAL(clicked()), this, SLOT(addChannel()));
135
connect(changeChannelBtn, SIGNAL(clicked()), this, SLOT(editChannel()));
136
connect(removeChannelBtn, SIGNAL(clicked()), this, SLOT(deleteChannel()));
137
connect(m_channelLBox, SIGNAL(selectionChanged()), this, SLOT(updateChannelArrows()));
138
connect(m_upChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelUp()));
139
connect(m_downChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelDown()));
141
channelLayout->setColStretch(0, 10);
142
channelLayout->setRowStretch(4, 10);
143
channelLayout->addMultiCellWidget(m_channelLBox, 0, 4, 0, 0);
144
channelLayout->addMultiCellWidget(addChannelBtn, 0, 0, 1, 4);
145
channelLayout->addMultiCellWidget(changeChannelBtn, 1, 1, 1, 4);
146
channelLayout->addMultiCellWidget(removeChannelBtn, 2, 2, 1, 4);
147
channelLayout->addWidget(m_upChannelBtn, 3, 2);
148
channelLayout->addWidget(m_downChannelBtn, 3, 3);
150
mainLayout->addWidget(nameLbl, 0, 0);
151
mainLayout->addMultiCellWidget(m_nameEdit, 0, 0, 1, 2);
152
mainLayout->addWidget(identityLbl, 2, 0);
153
mainLayout->addWidget(m_identityCBox, 2, 1);
154
mainLayout->addWidget(editIdentityBtn, 2, 2);
155
mainLayout->addWidget(commandLbl, 3, 0);
156
mainLayout->addMultiCellWidget(m_commandEdit, 3, 3, 1, 2);
157
mainLayout->addMultiCellWidget(m_autoConnectCBox, 4, 4, 0, 2);
158
mainLayout->addMultiCellWidget(groupWidget, 5, 5, 0, 2);
159
mainLayout->setColStretch(1, 10);
160
groupLayout->addWidget(serverGBox, 0, 0);
161
groupLayout->addWidget(channelGBox, 0, 1);
69
QWhatsThis::add(m_mainWidget->m_commandEdit, i18n("Optional. This command will be sent to the server after connecting. Example: <b>/msg NickServ IDENTIFY <i>konvirocks</i></b>. This example is for the freenode network, which requires users to register their nickname with a password and login when connecting. <i>konvirocks<i> is the password for the nickname given in Identity. You may enter more than one command by separating them with semicolons."));
70
m_mainWidget->m_commandsLabel->setBuddy(m_mainWidget->m_commandEdit);
72
QWhatsThis::add(m_mainWidget->m_autoConnectCBox, i18n("Check here if you want Konversation to automatically connect to this network whenever you open Konversation."));
74
QWhatsThis::add(m_mainWidget->m_serverLBox, i18n("This is a list of IRC Servers in the network. When connecting to the network, Konversation will attempt to connect to the top server first. If this fails, it will attempt the second server. If this fails, it will attempt the third, and so on. At least one server must be specified. Click a server to highlight it."));
75
m_mainWidget->m_removeServerButton->setIconSet(SmallIconSet("editdelete"));
76
m_mainWidget->m_removeServerButton->setTextLabel(i18n("Delete"));
77
m_mainWidget->m_upServerBtn->setIconSet(SmallIconSet("up"));
78
m_mainWidget->m_downServerBtn->setIconSet(SmallIconSet("down"));
80
connect(m_mainWidget->m_addServerButton, SIGNAL(clicked()), this, SLOT(addServer()));
81
connect(m_mainWidget->m_changeServerButton, SIGNAL(clicked()), this, SLOT(editServer()));
82
connect(m_mainWidget->m_removeServerButton, SIGNAL(clicked()), this, SLOT(deleteServer()));
83
connect(m_mainWidget->m_serverLBox, SIGNAL(selectionChanged()), this, SLOT(updateServerArrows()));
84
connect(m_mainWidget->m_upServerBtn, SIGNAL(clicked()), this, SLOT(moveServerUp()));
85
connect(m_mainWidget->m_downServerBtn, SIGNAL(clicked()), this, SLOT(moveServerDown()));
87
QWhatsThis::add(m_mainWidget->m_channelLBox, i18n("Optional. This is a list of the channels that will be automatically joined once Konversation has connected to a server. You may leave this blank if you wish to not automatically join any channels."));
88
m_mainWidget->m_removeChannelButton->setIconSet(SmallIconSet("editdelete"));
89
m_mainWidget->m_removeChannelButton->setTextLabel(i18n("Delete"));
90
m_mainWidget->m_upChannelBtn->setIconSet(SmallIconSet("up"));
91
m_mainWidget->m_downChannelBtn->setIconSet(SmallIconSet("down"));
93
connect(m_mainWidget->m_addChannelButton, SIGNAL(clicked()), this, SLOT(addChannel()));
94
connect(m_mainWidget->m_changeChannelButton, SIGNAL(clicked()), this, SLOT(editChannel()));
95
connect(m_mainWidget->m_removeChannelButton, SIGNAL(clicked()), this, SLOT(deleteChannel()));
96
connect(m_mainWidget->m_channelLBox, SIGNAL(selectionChanged()), this, SLOT(updateChannelArrows()));
97
connect(m_mainWidget->m_upChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelUp()));
98
connect(m_mainWidget->m_downChannelBtn, SIGNAL(clicked()), this, SLOT(moveChannelDown()));
163
100
setButtonOK(KGuiItem(i18n("&OK"), "button_ok", i18n("Change network information")));
164
101
setButtonCancel(KGuiItem(i18n("&Cancel"), "button_cancel", i18n("Discards all changes made")));
166
m_nameEdit->setFocus();
103
m_mainWidget->m_nameEdit->setFocus();
169
106
ServerGroupDialog::~ServerGroupDialog()