diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-16 17:00:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-16 17:00:23 +0300 |
commit | e50013d92b22faeffb8711d07a8f344ab71e9e57 (patch) | |
tree | 2069b52249be03c4b6491059ee9078fd26572108 | |
parent | b8412102b392310c5f7748bb2da36b3600e0fe08 (diff) | |
download | manaverse-e50013d92b22faeffb8711d07a8f344ab71e9e57.tar.gz manaverse-e50013d92b22faeffb8711d07a8f344ab71e9e57.tar.bz2 manaverse-e50013d92b22faeffb8711d07a8f344ab71e9e57.tar.xz manaverse-e50013d92b22faeffb8711d07a8f344ab71e9e57.zip |
Move openurllistener into separate file.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/gui/widgets/itemlinkhandler.cpp | 21 | ||||
-rw-r--r-- | src/gui/windows/logindialog.cpp | 21 | ||||
-rw-r--r-- | src/listeners/openurllistener.h | 48 |
5 files changed, 55 insertions, 37 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a0c4bdce9..e4307f1d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -882,6 +882,7 @@ SET(SRCS gui/models/magicschoolmodel.h events/mouseevent.h listeners/mouselistener.h + listeners/openurllistener.h listeners/playerlistener.cpp listeners/playerlistener.h gui/rect.h diff --git a/src/Makefile.am b/src/Makefile.am index 0194bf7fc..1bf27a9fe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -176,6 +176,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/models/magicschoolmodel.h \ events/mouseevent.h \ listeners/mouselistener.h \ + listeners/openurllistener.h \ listeners/playerlistener.cpp \ listeners/playerlistener.h \ gui/rect.h \ diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index efc6ef175..b1d277957 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -35,7 +35,7 @@ #include "resources/db/itemdb.h" -#include "listeners/actionlistener.h" +#include "listeners/openurllistener.h" #include "input/mouseinput.h" @@ -47,24 +47,7 @@ namespace { - struct OpenUrlListener : public ActionListener - { - OpenUrlListener() : - ActionListener(), - url() - { - } - - A_DELETE_COPY(OpenUrlListener) - - void action(const ActionEvent &event) override final - { - if (event.getId() == "yes") - openBrowser(url); - } - - std::string url; - } listener; + OpenUrlListener listener; } // namespace ItemLinkHandler::ItemLinkHandler() : diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index f3fcec167..9979bf8b1 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -29,6 +29,8 @@ #include "input/keydata.h" +#include "listeners/openurllistener.h" + #include "gui/models/updatelistmodel.h" #include "gui/models/updatetypemodel.h" @@ -57,24 +59,7 @@ std::string LoginDialog::savedPasswordKey(""); namespace { - struct OpenUrlListener : public ActionListener - { - OpenUrlListener() : - ActionListener(), - url() - { - } - - A_DELETE_COPY(OpenUrlListener) - - void action(const ActionEvent &event) override final - { - if (event.getId() == "yes") - openBrowser(url); - } - - std::string url; - } urlListener; + OpenUrlListener urlListener; } // namespace LoginDialog::LoginDialog(LoginData *const data, std::string serverName, diff --git a/src/listeners/openurllistener.h b/src/listeners/openurllistener.h new file mode 100644 index 000000000..2fdd6b945 --- /dev/null +++ b/src/listeners/openurllistener.h @@ -0,0 +1,48 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "listeners/actionlistener.h" + +#include "utils/process.h" + +#include <string> + +#include "localconsts.h" + +struct OpenUrlListener final : public ActionListener +{ + OpenUrlListener() : + ActionListener(), + url() + { + } + + A_DELETE_COPY(OpenUrlListener) + + void action(const ActionEvent &event) override final + { + if (event.getId() == "yes") + openBrowser(url); + } + + std::string url; +}; |