]> Shamusworld >> Repos - architektonas/blob - src/layeritemwidget.cpp
Whitespace changes. :-P
[architektonas] / src / layeritemwidget.cpp
1 //
2 // layeritemwidget.cpp: Layer item widget
3 //
4 // Part of the Architektonas Project
5 // (C) 2011 Underground Software
6 // See the README and GPLv3 files for licensing and warranty information
7 //
8 // JLH = James Hammons <jlhamm@acm.org>
9 //
10 // WHO  WHEN        WHAT
11 // ---  ----------  ------------------------------------------------------------
12 // JLH  07/13/2013  Created this file
13 //
14
15 #include "layeritemwidget.h"
16
17 LayerItemWidget::LayerItemWidget(QString s, bool i/*=false*/, bool l/*=false*/, QListWidgetItem * p/*=null*/):
18         QWidget(),
19         name(new QLabel(s)),
20         invisible(new QPushButton),
21         locked(new QPushButton),
22         parent(p)
23 {
24         QIcon visibleIcon(":/res/eye-open.png");
25         visibleIcon.addFile(":/res/eye-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On);
26         QIcon lockedIcon(":/res/lock-open.png");
27         lockedIcon.addFile(":/res/lock-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On);
28         QSize buttonSize(20, 20);
29
30         QHBoxLayout * mainLayout = new QHBoxLayout;
31         // This is required, otherwise the layout engine puts too much space around
32         // this widget. :-/
33         mainLayout->setContentsMargins(0, 0, 0, 0);
34
35         invisible->setFlat(true);
36         invisible->setIcon(visibleIcon);
37         invisible->setCheckable(true);
38         invisible->setMaximumSize(buttonSize);
39         invisible->setChecked(i);
40
41         locked->setFlat(true);
42         locked->setIcon(lockedIcon);
43         locked->setCheckable(true);
44         locked->setMaximumSize(buttonSize);
45         locked->setChecked(l);
46
47         mainLayout->addWidget(invisible);
48         mainLayout->addWidget(locked);
49         mainLayout->addWidget(name);
50         setLayout(mainLayout);
51
52         connect(invisible, SIGNAL(clicked(bool)), this, SLOT(HandleHideToggle(bool)));
53         connect(locked, SIGNAL(clicked(bool)), this, SLOT(HandleLockToggle(bool)));
54 }
55
56 LayerItemWidget::~LayerItemWidget()
57 {
58 }
59
60 void LayerItemWidget::HandleHideToggle(bool state)
61 {
62 //      printf("Eye is: %s\n", !state ? "OPEN" : "closed");
63         emit HideToggled(parent, state);
64 }
65
66 void LayerItemWidget::HandleLockToggle(bool state)
67 {
68 //      printf("Lock is: %s\n", !state ? "OPEN" : "closed");
69         emit LockToggled(parent, state);
70 }