Commit dfed6a9e authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

draw title on top of overview

parent c67ee5a1
......@@ -4,6 +4,38 @@
//
// ///////////////////////////////////////////////////////////////////
class dtkWidgetsWorkspaceStackBarOverview : public QLabel
{
public:
dtkWidgetsWorkspaceStackBarOverview(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent *) override;
};
dtkWidgetsWorkspaceStackBarOverview::dtkWidgetsWorkspaceStackBarOverview(QWidget *parent): QLabel(parent)
{
}
void dtkWidgetsWorkspaceStackBarOverview::paintEvent(QPaintEvent *event)
{
QLabel::paintEvent(event);
QFontMetrics metrics(qApp->font());
const int offset = 30;
const int margin = 20;
QString text = this->objectName();
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(0, 0, 0, 128));
painter.drawRect(0, this->size().height() - offset - margin, this->size().width(), margin * 7/4);
painter.setPen(Qt::white);
painter.drawText(this->size().width()/2 - metrics.width(text)/2, this->size().height() - offset, text);
}
class dtkWidgetsWorkspaceStackBarItem : public QFrame
{
Q_OBJECT
......@@ -40,8 +72,7 @@ private:
QWidget *source = nullptr;
private:
QLabel *name;
QLabel *overview;
dtkWidgetsWorkspaceStackBarOverview *overview;
private:
int index = -1;
......@@ -54,17 +85,13 @@ dtkWidgetsWorkspaceStackBarItem::dtkWidgetsWorkspaceStackBarItem(int index, QWid
{
this->index = index;
this->name = new QLabel(this);
this->name->setAlignment(Qt::AlignCenter);
this->overview = new QLabel(this);
this->overview = new dtkWidgetsWorkspaceStackBarOverview(this);
this->overview->setObjectName("overview");
this->overview->setAlignment(Qt::AlignCenter);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addStretch();
layout->addWidget(this->name);
layout->addWidget(this->overview);
layout->addStretch();
}
......@@ -78,7 +105,7 @@ void dtkWidgetsWorkspaceStackBarItem::setSource(QWidget *source)
{
this->source = source;
this->name->setText(this->source->objectName());
this->overview->setObjectName(this->source->objectName());
QTimer *timer = new QTimer(this);
timer->setInterval(250);
......@@ -126,9 +153,8 @@ dtkWidgetsWorkspaceStackBar::dtkWidgetsWorkspaceStackBar(QWidget *parent) : QFra
d->layout = new QVBoxLayout(this);
d->layout->setContentsMargins(0, 0, 1, 0);
d->layout->setSpacing(0);
d->layout->setSpacing(1);
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
}
dtkWidgetsWorkspaceStackBar::~dtkWidgetsWorkspaceStackBar(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment