OpenWalnut
1.5.0dev
src
qtgui
WSettingMenu.h
1
//---------------------------------------------------------------------------
2
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
7
//
8
// This file is part of OpenWalnut.
9
//
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
14
//
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22
//
23
//---------------------------------------------------------------------------
24
25
#ifndef WSETTINGMENU_H
26
#define WSETTINGMENU_H
27
28
#include <string>
29
30
#include <QMenu>
31
32
/**
33
* Similar to WSettingAction, this can handle a multi-option setting as QMenu.
34
*/
35
class
WSettingMenu
:
public
QMenu
36
{
37
Q_OBJECT
38
public
:
39
/**
40
* Constructs a menu with the specified options and automatically handles updates.
41
*
42
* \param parent the parent widget owning this menu
43
* \param settingName the name of the setting tohandle
44
* \param menuName the menu's name
45
* \param tooltip the tooltip for the menu
46
* \param defaultValue a initial default item
47
* \param options a list of exclusive options
48
* \param showRestartInfo if true, show an info dialog that changes get applied on next start.
49
*/
50
WSettingMenu
( QWidget* parent, std::string settingName, std::string menuName, std::string tooltip,
unsigned
int
defaultValue,
51
const
QList< QString >
& options,
bool
showRestartInfo =
false
);
52
53
/**
54
* Destructor.
55
*/
56
virtual
~WSettingMenu
();
57
58
/**
59
* Returns the current setting.
60
*
61
* \return current setting
62
*/
63
unsigned
int
get
()
const
;
64
65
signals:
66
67
/**
68
* Signal getting emitted if the selected option changes.
69
*
70
* \param index the new index.
71
*/
72
void
change
(
unsigned
int
index );
73
74
protected
:
75
private
:
76
/**
77
* The name of the setting handled here.
78
*/
79
QString
m_settingName
;
80
81
/**
82
* If true, a change of the setting causes an restart notification dialog.
83
*/
84
bool
m_showRestartInfo
;
85
86
/**
87
* Tracks the currently selected option.
88
*/
89
unsigned
int
m_currentItem
;
90
91
private
slots:
92
93
/**
94
* Handles updates in the option.
95
*
96
* \param action the triggered action.
97
*/
98
void
handleUpdate
(
QAction
* action );
99
};
100
101
#endif
// WSETTINGMENU_H
102
QAction
QList
QMenu
WSettingMenu
Similar to WSettingAction, this can handle a multi-option setting as QMenu.
Definition:
WSettingMenu.h:36
WSettingMenu::WSettingMenu
WSettingMenu(QWidget *parent, std::string settingName, std::string menuName, std::string tooltip, unsigned int defaultValue, const QList< QString > &options, bool showRestartInfo=false)
Constructs a menu with the specified options and automatically handles updates.
Definition:
WSettingMenu.cpp:33
WSettingMenu::get
unsigned int get() const
Returns the current setting.
Definition:
WSettingMenu.cpp:88
WSettingMenu::m_currentItem
unsigned int m_currentItem
Tracks the currently selected option.
Definition:
WSettingMenu.h:89
WSettingMenu::change
void change(unsigned int index)
Signal getting emitted if the selected option changes.
WSettingMenu::handleUpdate
void handleUpdate(QAction *action)
Handles updates in the option.
Definition:
WSettingMenu.cpp:73
WSettingMenu::~WSettingMenu
virtual ~WSettingMenu()
Destructor.
Definition:
WSettingMenu.cpp:69
WSettingMenu::m_showRestartInfo
bool m_showRestartInfo
If true, a change of the setting causes an restart notification dialog.
Definition:
WSettingMenu.h:84
WSettingMenu::m_settingName
QString m_settingName
The name of the setting handled here.
Definition:
WSettingMenu.h:79
Generated by
1.9.1