2 // layeritemwidget.cpp: Layer item widget
4 // Part of the Architektonas Project
5 // (C) 2011 Underground Software
6 // See the README and GPLv3 files for licensing and warranty information
8 // JLH = James Hammons <jlhamm@acm.org>
11 // --- ---------- ------------------------------------------------------------
12 // JLH 07/13/2013 Created this file
15 #include "layeritemwidget.h"
17 LayerItemWidget::LayerItemWidget(QString s, bool i/*=false*/, bool l/*=false*/, QListWidgetItem * p/*=null*/):
20 invisible(new QPushButton),
21 locked(new QPushButton),
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);
30 QHBoxLayout * mainLayout = new QHBoxLayout;
31 // This is required, otherwise the layout engine puts too much space around
33 mainLayout->setContentsMargins(0, 0, 0, 0);
35 invisible->setFlat(true);
36 invisible->setIcon(visibleIcon);
37 invisible->setCheckable(true);
38 invisible->setMaximumSize(buttonSize);
39 invisible->setChecked(i);
41 locked->setFlat(true);
42 locked->setIcon(lockedIcon);
43 locked->setCheckable(true);
44 locked->setMaximumSize(buttonSize);
45 locked->setChecked(l);
47 mainLayout->addWidget(invisible);
48 mainLayout->addWidget(locked);
49 mainLayout->addWidget(name);
50 setLayout(mainLayout);
52 connect(invisible, SIGNAL(clicked(bool)), this, SLOT(HandleHideToggle(bool)));
53 connect(locked, SIGNAL(clicked(bool)), this, SLOT(HandleLockToggle(bool)));
56 LayerItemWidget::~LayerItemWidget()
60 void LayerItemWidget::HandleHideToggle(bool state)
62 // printf("Eye is: %s\n", !state ? "OPEN" : "closed");
63 emit HideToggled(parent, state);
66 void LayerItemWidget::HandleLockToggle(bool state)
68 // printf("Lock is: %s\n", !state ? "OPEN" : "closed");
69 emit LockToggled(parent, state);