summaryrefslogtreecommitdiff
path: root/src/gui/serverdialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-07 00:37:14 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-07 00:37:14 +0300
commit07e638798767239e4ea5fa39f17e9e8576fb1f14 (patch)
tree2b52e6ddb5778085f3c343a624cde230dd8c23ad /src/gui/serverdialog.cpp
parent671ca11caba0dc80636ff76035f55b6b8fc3893e (diff)
downloadplus-07e638798767239e4ea5fa39f17e9e8576fb1f14.tar.gz
plus-07e638798767239e4ea5fa39f17e9e8576fb1f14.tar.bz2
plus-07e638798767239e4ea5fa39f17e9e8576fb1f14.tar.xz
plus-07e638798767239e4ea5fa39f17e9e8576fb1f14.zip
Add connect button to edit server dialog.
Diffstat (limited to 'src/gui/serverdialog.cpp')
-rw-r--r--src/gui/serverdialog.cpp78
1 files changed, 42 insertions, 36 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 0badba504..80e793cd2 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -339,68 +339,74 @@ ServerDialog::~ServerDialog()
mServersListModel = nullptr;
}
-void ServerDialog::action(const gcn::ActionEvent &event)
+void ServerDialog::connectToSelectedServer()
{
- if (event.getId() == "connect")
- {
- if (Client::getState() == STATE_CONNECT_SERVER)
- return;
+ if (Client::getState() == STATE_CONNECT_SERVER)
+ return;
- int index = mServersList->getSelected();
- if (index < 0)
- return;
+ int index = mServersList->getSelected();
+ if (index < 0)
+ return;
- if (mDownload)
- mDownload->cancel();
+ if (mDownload)
+ mDownload->cancel();
- mQuitButton->setEnabled(false);
- mConnectButton->setEnabled(false);
- mLoadButton->setEnabled(false);
+ mQuitButton->setEnabled(false);
+ mConnectButton->setEnabled(false);
+ mLoadButton->setEnabled(false);
- ServerInfo server = mServers.at(index);
- mServerInfo->hostname = server.hostname;
- mServerInfo->port = server.port;
- mServerInfo->type = server.type;
- mServerInfo->name = server.name;
- mServerInfo->description = server.description;
- mServerInfo->save = true;
+ ServerInfo server = mServers.at(index);
+ mServerInfo->hostname = server.hostname;
+ mServerInfo->port = server.port;
+ mServerInfo->type = server.type;
+ mServerInfo->name = server.name;
+ mServerInfo->description = server.description;
+ mServerInfo->save = true;
- if (chatLogger)
- chatLogger->setServerName(mServerInfo->hostname);
+ if (chatLogger)
+ chatLogger->setServerName(mServerInfo->hostname);
- saveCustomServers(*mServerInfo);
+ saveCustomServers(*mServerInfo);
- if (!LoginDialog::savedPasswordKey.empty())
- {
- if (mServerInfo->hostname != LoginDialog::savedPasswordKey)
- LoginDialog::savedPassword = "";
- }
+ if (!LoginDialog::savedPasswordKey.empty())
+ {
+ if (mServerInfo->hostname != LoginDialog::savedPasswordKey)
+ LoginDialog::savedPassword = "";
+ }
- config.setValue("usePersistentIP",
- mPersistentIPCheckBox->isSelected());
- Client::setState(STATE_CONNECT_SERVER);
+ config.setValue("usePersistentIP",
+ mPersistentIPCheckBox->isSelected());
+ Client::setState(STATE_CONNECT_SERVER);
+}
+
+void ServerDialog::action(const gcn::ActionEvent &event)
+{
+ const std::string &eventId = event.getId();
+ if (eventId == "connect")
+ {
+ connectToSelectedServer();
}
- else if (event.getId() == "quit")
+ else if (eventId == "quit")
{
if (mDownload)
mDownload->cancel();
Client::setState(STATE_FORCE_QUIT);
}
- else if (event.getId() == "load")
+ else if (eventId == "load")
{
downloadServerList();
}
- else if (event.getId() == "addEntry")
+ else if (eventId == "addEntry")
{
new EditServerDialog(this, ServerInfo(), -1);
}
- else if (event.getId() == "editEntry")
+ else if (eventId == "editEntry")
{
int index = mServersList->getSelected();
if (index >= 0)
new EditServerDialog(this, mServers.at(index), index);
}
- else if (event.getId() == "remove")
+ else if (eventId == "remove")
{
int index = mServersList->getSelected();
if (index >= 0)