]> Shamusworld >> Repos - architektonas/blob - src/layeritemwidget.cpp
Layer handling code mostly done; still need to handle layer locking.
[architektonas] / src / layeritemwidget.cpp
1 // layeritemwidget.cpp: Layer item widget
2 //
3 // Part of the Architektonas Project
4 // (C) 2011 Underground Software
5 // See the README and GPLv3 files for licensing and warranty information
6 //
7 // JLH = James Hammons <jlhamm@acm.org>
8 //
9 // WHO  WHEN        WHAT
10 // ---  ----------  ------------------------------------------------------------
11 // JLH  07/13/2013  Created this file
12 //
13
14 #include "layeritemwidget.h"
15
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
57 LayerItemWidget::~LayerItemWidget()
58 {
59 }
60
61
62 void LayerItemWidget::HandleHideToggle(bool state)
63 {
64 //      printf("Eye is: %s\n", !state ? "OPEN" : "closed");
65         emit(HideToggled(parent, state));
66 }
67
68
69 void LayerItemWidget::HandleLockToggle(bool state)
70 {
71 //      printf("Lock is: %s\n", !state ? "OPEN" : "closed");
72         emit(LockToggled(parent, state));
73 }
74