1 // layerwidget.cpp: Layer add/remove/use 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/11/2013 Created this file
14 #include "layerwidget.h"
15 #include "layeritemwidget.h"
18 LayerWidget::LayerWidget(void): QWidget(),
21 LayerItemWidget * liw = new LayerItemWidget("Background");
22 QListWidgetItem * qlwi = new QListWidgetItem(list);
23 list->setItemWidget(qlwi, liw);
26 QPushButton * pb1 = new QPushButton("+");
27 QPushButton * pb2 = new QPushButton("-");
28 QPushButton * pb3 = new QPushButton("Edit");
29 QPushButton * pb4 = new QPushButton("^");
30 QPushButton * pb5 = new QPushButton("v");
32 QToolButton * pb1 = new QToolButton;
33 QToolButton * pb2 = new QToolButton;
34 QToolButton * pb3 = new QToolButton;
35 QToolButton * pb4 = new QToolButton;
36 QToolButton * pb5 = new QToolButton;
38 pb1->setIcon(QIcon(":/res/layer-add.png"));
39 pb2->setIcon(QIcon(":/res/layer-delete.png"));
40 pb3->setIcon(QIcon(":/res/layer-edit.png"));
41 pb4->setIcon(QIcon(":/res/layer-up.png"));
42 pb5->setIcon(QIcon(":/res/layer-down.png"));
44 pb1->setToolTip(tr("Add layer"));
45 pb2->setToolTip(tr("Remove layer"));
46 pb3->setToolTip(tr("Edit layer"));
47 pb4->setToolTip(tr("Move layer up"));
48 pb5->setToolTip(tr("Move layer down"));
51 QHBoxLayout * hbox1 = new QHBoxLayout;
52 hbox1->addWidget(pb1);
53 hbox1->addWidget(pb2);
54 hbox1->addWidget(pb3);
55 hbox1->addWidget(pb4);
56 hbox1->addWidget(pb5);
59 QVBoxLayout * mainLayout = new QVBoxLayout;
60 mainLayout->addWidget(list);
61 mainLayout->addLayout(hbox1);
63 setLayout(mainLayout);
65 connect(list, SIGNAL(currentRowChanged(int)), this, SLOT(HandleLayerSelected(int)));
66 list->setCurrentRow(4);
67 connect(pb1, SIGNAL(clicked()), this, SLOT(AddLayer()));
68 connect(pb2, SIGNAL(clicked()), this, SLOT(DeleteLayer()));
69 connect(pb3, SIGNAL(clicked()), this, SLOT(EditLayer()));
70 connect(pb4, SIGNAL(clicked()), this, SLOT(MoveLayerUp()));
71 connect(pb5, SIGNAL(clicked()), this, SLOT(MoveLayerDown()));
75 LayerWidget::~LayerWidget()
80 void LayerWidget::HandleLayerSelected(int currentRow)
82 //printf("LayerWidget::HandleLayerSelected(): currentRow = %i\n", currentRow);
83 emit(LayerSelected(currentRow));
87 void LayerWidget::AddLayer(void)
89 int count = list->count();
90 QString text = QString("Layer #%1").arg(count);
91 LayerItemWidget * liw = new LayerItemWidget(text);
92 QListWidgetItem * qlwi = new QListWidgetItem();
93 list->insertItem(0, qlwi);
94 list->setItemWidget(qlwi, liw);
98 void LayerWidget::DeleteLayer(void)
103 void LayerWidget::EditLayer(void)
108 void LayerWidget::MoveLayerUp(void)
113 void LayerWidget::MoveLayerDown(void)