1 // layeritemwidget.cpp: Layer item widget
3 // Part of the Architektonas Project
4 // (C) 2011 Underground Software
5 // See the README and GPLv3 files for licensing and warranty information
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- ------------------------------------------------------------
11 // JLH 07/13/2013 Created this file
14 #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)));
57 LayerItemWidget::~LayerItemWidget()
62 void LayerItemWidget::HandleHideToggle(bool state)
64 // printf("Eye is: %s\n", !state ? "OPEN" : "closed");
65 emit HideToggled(parent, state);
69 void LayerItemWidget::HandleLockToggle(bool state)
71 // printf("Lock is: %s\n", !state ? "OPEN" : "closed");
72 emit LockToggled(parent, state);