Permalink
Browse files

Changed layer style widget.

Layer style widget (popup) now contains checkbox for toggling
visibility.
  • Loading branch information...
1 parent 12a5bbc commit 204b99492e582b224746e1a413db19db502be0bb Calle Laakkonen committed Nov 6, 2010
Showing with 43 additions and 13 deletions.
  1. +2 −0 .gitignore
  2. +3 −2 src/client/layerlistdelegate.cpp
  3. +27 −8 src/client/layerwidget.cpp
  4. +11 −3 src/client/layerwidget.h
View
@@ -10,3 +10,5 @@ Makefile.*
/lib/
*.so
+
+*.swp
@@ -120,9 +120,10 @@ bool LayerListDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
emit layerToggleHidden(layer->id());
} else if(me->x() < btnwidth*2) {
// Opacity button
- widgets::LayerEditor *lw = new widgets::LayerEditor(layer);
- lw->move(me->globalPos());
+ widgets::LayerStyleEditor *lw = new widgets::LayerStyleEditor(layer);
+ lw->move(me->globalPos() - QPoint(15, 15));
lw->connect(lw, SIGNAL(opacityChanged(int,int)), this, SIGNAL(changeOpacity(int,int)));
+ lw->connect(lw, SIGNAL(toggleHidden(int)), this, SIGNAL(layerToggleHidden(int)));
lw->show();
} else if(me->x() >= option.rect.width() - btnwidth) {
@@ -20,38 +20,52 @@
#include <QDebug>
#include <QSlider>
+#include <QCheckBox>
#include <QEvent>
-#include <QVBoxLayout>
+#include <QLabel>
+#include <QGridLayout>
#include "layerwidget.h"
#include "core/layer.h"
namespace widgets {
-LayerEditor::LayerEditor(const dpcore::Layer *layer, QWidget *parent)
+LayerStyleEditor::LayerStyleEditor(const dpcore::Layer *layer, QWidget *parent)
: QFrame(parent, Qt::FramelessWindowHint), id_(layer->id())
{
setAttribute(Qt::WA_DeleteOnClose);
setFrameStyle(Panel);
setFrameShadow(Raised);
- QVBoxLayout *layout = new QVBoxLayout();
- opacity_ = new QSlider(Qt::Vertical, this);
+ QGridLayout *layout = new QGridLayout();
+
+ hide_ = new QCheckBox(this);
+ hide_->setChecked(layer->hidden());
+ hide_->setText(tr("Hide"));
+ layout->addWidget(hide_, 0, 0);
+
+ QLabel *lbl = new QLabel(this);
+ lbl->setText(tr("Opacity") + ":");
+ layout->addWidget(lbl, 1, 0);
+
+ opacity_ = new QSlider(Qt::Horizontal, this);
opacity_->setRange(0, 255);
opacity_->setValue(layer->opacity());
- layout->addWidget(opacity_);
+ layout->addWidget(opacity_, 1, 1);
setLayout(layout);
connect(opacity_, SIGNAL(valueChanged(int)),
this, SLOT(updateOpacity(int)));
+ connect(hide_, SIGNAL(toggled(bool)),
+ this, SLOT(toggleHide()));
}
-LayerEditor::~LayerEditor()
+LayerStyleEditor::~LayerStyleEditor()
{
}
-void LayerEditor::changeEvent(QEvent *e)
+void LayerStyleEditor::changeEvent(QEvent *e)
{
if(e->type() == QEvent::ActivationChange && !isActiveWindow()) {
// Close the editor when focus is lost
@@ -61,9 +75,14 @@ void LayerEditor::changeEvent(QEvent *e)
QWidget::changeEvent(e);
}
-void LayerEditor::updateOpacity(int o)
+void LayerStyleEditor::updateOpacity(int o)
{
emit opacityChanged(id_, o);
}
+void LayerStyleEditor::toggleHide()
+{
+ emit toggleHidden(id_);
+}
+
}
@@ -23,31 +23,39 @@
#include <QFrame>
class QSlider;
+class QCheckBox;
namespace dpcore {
class Layer;
}
namespace widgets {
-class LayerEditor : public QFrame
+/**
+ * A widget for adjusting the visual attributes of a layer.
+ * This pops up when the user clicks on the layer details icon.
+ */
+class LayerStyleEditor : public QFrame
{
Q_OBJECT
public:
- LayerEditor(const dpcore::Layer *layer, QWidget *parent=0);
- ~LayerEditor();
+ LayerStyleEditor(const dpcore::Layer *layer, QWidget *parent=0);
+ ~LayerStyleEditor();
signals:
void opacityChanged(int id, int newopacity);
+ void toggleHidden(int id);
protected:
void changeEvent(QEvent*);
private slots:
void updateOpacity(int o);
+ void toggleHide();
private:
QSlider *opacity_;
+ QCheckBox *hide_;
int id_;
};

0 comments on commit 204b994

Please sign in to comment.