forked from donaloconnor/automon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menuitem.cpp
61 lines (49 loc) · 2.57 KB
/
menuitem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
==================================================================================================
| menuitem.cpp |
| Part of the Automon application. |
| |
| Final Year Project - "An Embedded Automotive Monitoring Device" |
| |
| By Donal O' Connor for completion of B.Sc (Hons) Software Development and Computer Networking |
| Email: [email protected] |
| Website/Blog: http://automon.killarneyonline.eu |
| |
| Cork Institute of Technology, Cork, Ireland - http://www.cit.ie/ |
| |
| Copyright © 2009 Donal O'Connor <[email protected]> |
==================================================================================================
Implementation of the Menu Item Pushbutton
*/
#include "menuitem.h"
MenuItem::MenuItem(const QIcon & icon, const QString & name, const QSize & size, QWidget *parent)
: QPushButton(icon, "", parent), m_name(name)
{
/* This is a reference value to the stacked widget index in the main GUI */
m_stackedWidgetIndex = -1;
/* Connect the clicked event of this push button to a custom slot so we can override the clicked event */
connect(this, SIGNAL(clicked()), this, SLOT(changePanel()));
/* Set the size of the button and icon to the defined one in constructor */
setFixedSize(size);
setIconSize(size);
/* Set no background */
setStyleSheet("background:none;");
}
MenuItem::~MenuItem()
{
}
QString MenuItem::getName()
{
/* Return name of menu item. */
return m_name;
}
void MenuItem::setPanelIndex(int index)
{
/* Set the index of the stacked widget that this button will load */
m_stackedWidgetIndex = index;
}
void MenuItem::changePanel()
{
/* Basically over riding the clicked signal. So we just emit another signal to change the panel to this index */
emit displayPanel(m_stackedWidgetIndex);
}