From b1aef06ac85b1ed7db7725e50b2dbfcdfd1a0925 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 3 Mar 2010 07:48:55 -0700 Subject: Connect to a server when it's double clicked Reviewed-by: Bernd Wachter --- src/gui/serverdialog.cpp | 18 +++++++++++++++--- src/gui/serverdialog.h | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index da95b6a1..44998bcc 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -169,6 +169,8 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): mServersListModel = new ServersListModel(&mServers, this); mServersList = new ListBox(mServersListModel); + mServersList->addMouseListener(this); + ScrollArea *usedScroll = new ScrollArea(mServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -371,20 +373,30 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &) mPortField->setText(toString(myServer.port)); switch (myServer.type) { - case ServerInfo::UNKNOWN: - mTypeField->setSelected(2); - break; case ServerInfo::EATHENA: mTypeField->setSelected(0); break; case ServerInfo::MANASERV: mTypeField->setSelected(1); + default: + mTypeField->setSelected(2); + break; } setFieldsReadOnly(true); mDeleteButton->setEnabled(myServer.save); } +void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) +{ + if (mouseEvent.getClickCount() == 2 && + mouseEvent.getSource() == mServersList) + { + action(gcn::ActionEvent(mConnectButton, + mConnectButton->getActionEventId())); + } +} + void ServerDialog::logic() { { diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index 6a7091c2..3d7dca9d 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -134,6 +135,8 @@ class ServerDialog : public Window, */ void valueChanged(const gcn::SelectionEvent &event); + void mouseClicked(gcn::MouseEvent &mouseEvent); + void logic(); protected: -- cgit v1.2.3-70-g09d2