snark
Action.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
20 
21 #ifndef SNARK_GRAPHICS_APPLICATIONS_LABELPOINTS_ACTION_H_
22 #define SNARK_GRAPHICS_APPLICATIONS_LABELPOINTS_ACTION_H_
23 
24 #include <boost/function.hpp>
25 #include <qaction.h>
26 #include <qactiongroup.h>
27 #include <qicon.h>
28 
29 namespace snark { namespace graphics { namespace View {
30 
31 class Action : public QAction // quick and dirty
32 {
33  Q_OBJECT
34 
35  public:
36  Action( const std::string& name, boost::function< void() > f );
37 
38  public slots:
39  void action();
40 
41  private:
42  boost::function< void() > m_action;
43 };
44 
45 class ToggleAction : public QAction
46 {
47  Q_OBJECT
48 
49  public:
50  ToggleAction( const std::string& name
51  , boost::function< void( bool ) > f
52  , const std::string& key = "" );
53 
54  ToggleAction( const QIcon& icon
55  , const std::string& name
56  , boost::function< void( bool ) > f
57  , const std::string& key = "" );
58 
59  public slots:
60  void action( bool checked );
61 
62  private:
63  boost::function< void( bool ) > m_functor;
64 };
65 
66 } } } // namespace snark { namespace graphics { namespace View {
67 
68 #endif // SNARK_GRAPHICS_APPLICATIONS_LABELPOINTS_ACTION_H_