]> Shamusworld >> Repos - architektonas/blobdiff - src/layeritemwidget.cpp
Layer handling code mostly done; still need to handle layer locking.
[architektonas] / src / layeritemwidget.cpp
index 57631388737686cf08085b5a9e18b8a6869009e7..40c8b01b5d141c0bd7c2fe5603ad852add5eed5d 100644 (file)
 #include "layeritemwidget.h"
 
 
-LayerItemWidget::LayerItemWidget(QString s, bool invisible/*=false*/, bool locked/*=false*/):
+LayerItemWidget::LayerItemWidget(QString s, bool i/*=false*/, bool l/*=false*/, QListWidgetItem * p/*=null*/):
        QWidget(),
        name(new QLabel(s)),
-       visibility(new QPushButton),
-       editibility(new QPushButton)
+       invisible(new QPushButton),
+       locked(new QPushButton),
+       parent(p)
 {
        QIcon visibleIcon(":/res/eye-open.png");
        visibleIcon.addFile(":/res/eye-closed.png", QSize(16, 16), QIcon::Normal, QIcon::On);
@@ -27,25 +28,29 @@ LayerItemWidget::LayerItemWidget(QString s, bool invisible/*=false*/, bool locke
        QSize buttonSize(20, 20);
 
        QHBoxLayout * mainLayout = new QHBoxLayout;
-       mainLayout->setContentsMargins(0, 0, 0, 0); // This is required, otherwise the layout engine puts too much space around this widget. :-/
-
-       visibility->setFlat(true);
-       visibility->setIcon(visibleIcon);
-       visibility->setCheckable(true);
-       visibility->setMaximumSize(buttonSize);
-       visibility->setChecked(invisible);
-
-       editibility->setFlat(true);
-       editibility->setIcon(lockedIcon);
-       editibility->setCheckable(true);
-       editibility->setMaximumSize(buttonSize);
-       editibility->setChecked(locked);
-
-       mainLayout->addWidget(visibility);
-       mainLayout->addWidget(editibility);
+       // This is required, otherwise the layout engine puts too much space around
+       // this widget. :-/
+       mainLayout->setContentsMargins(0, 0, 0, 0);
+       
+       invisible->setFlat(true);
+       invisible->setIcon(visibleIcon);
+       invisible->setCheckable(true);
+       invisible->setMaximumSize(buttonSize);
+       invisible->setChecked(i);
+
+       locked->setFlat(true);
+       locked->setIcon(lockedIcon);
+       locked->setCheckable(true);
+       locked->setMaximumSize(buttonSize);
+       locked->setChecked(l);
+
+       mainLayout->addWidget(invisible);
+       mainLayout->addWidget(locked);
        mainLayout->addWidget(name);
        setLayout(mainLayout);
 
+       connect(invisible, SIGNAL(clicked(bool)), this, SLOT(HandleHideToggle(bool)));
+       connect(locked, SIGNAL(clicked(bool)), this, SLOT(HandleLockToggle(bool)));
 }
 
 
@@ -53,3 +58,17 @@ LayerItemWidget::~LayerItemWidget()
 {
 }
 
+
+void LayerItemWidget::HandleHideToggle(bool state)
+{
+//     printf("Eye is: %s\n", !state ? "OPEN" : "closed");
+       emit(HideToggled(parent, state));
+}
+
+
+void LayerItemWidget::HandleLockToggle(bool state)
+{
+//     printf("Lock is: %s\n", !state ? "OPEN" : "closed");
+       emit(LockToggled(parent, state));
+}
+