]> Shamusworld >> Repos - architektonas/blob - src/layeritemwidget.cpp
57631388737686cf08085b5a9e18b8a6869009e7
[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 invisible/*=false*/, bool locked/*=false*/):
18         QWidget(),
19         name(new QLabel(s)),
20         visibility(new QPushButton),
21         editibility(new QPushButton)
22 {
23         QIcon visibleIcon(":/res/eye-open.png");
24         visibleIcon.addFile(":/res/eye-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On);
25         QIcon lockedIcon(":/res/lock-open.png");
26         lockedIcon.addFile(":/res/lock-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On);
27         QSize buttonSize(20, 20);
28
29         QHBoxLayout * mainLayout = new QHBoxLayout;
30         mainLayout->setContentsMargins(0, 0, 0, 0); // This is required, otherwise the layout engine puts too much space around this widget. :-/
31
32         visibility->setFlat(true);
33         visibility->setIcon(visibleIcon);
34         visibility->setCheckable(true);
35         visibility->setMaximumSize(buttonSize);
36         visibility->setChecked(invisible);
37
38         editibility->setFlat(true);
39         editibility->setIcon(lockedIcon);
40         editibility->setCheckable(true);
41         editibility->setMaximumSize(buttonSize);
42         editibility->setChecked(locked);
43
44         mainLayout->addWidget(visibility);
45         mainLayout->addWidget(editibility);
46         mainLayout->addWidget(name);
47         setLayout(mainLayout);
48
49 }
50
51
52 LayerItemWidget::~LayerItemWidget()
53 {
54 }
55