Commit c67ee5a1 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

add MenuItemFacade for WorkspaceStackBar

parent 0febe749
......@@ -278,6 +278,7 @@ public:
layout->setSpacing(0);
layout->addWidget(label);
this->setStyleSheet(m_style);
this->setObjectName("dummy workspace B");
};
~dummyWorkspaceB(void) {};
......@@ -307,6 +308,7 @@ public:
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(label);
this->setObjectName("dummy workspace C");
};
~dummyWorkspaceC(void) {};
......@@ -356,26 +358,30 @@ dummyWindow::dummyWindow(QWidget *parent) : QFrame(parent)
{
this->stack = new QStackedWidget(this);
// this->menubar = new dtkWidgetsMenuBar(this);
// this->menu_1 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 1");
// this->menu_2 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 2");
// this->menu_3 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 3");
// this->menubar->addMenu(this->menu_1);
// this->menubar->addMenu(this->menu_2);
// this->menubar->addMenu(this->menu_3);
// this->menubar->build();
this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceB"));
this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceC"));
this->stack->addWidget(dtk::widgets::workspace::pluginFactory().create("dummyWorkspaceB"));
dtkWidgetsWorkspaceStackBar *stack_bar = new dtkWidgetsWorkspaceStackBar(this);
stack_bar->setStack(this->stack);
this->menubar = new dtkWidgetsMenuBar(this);
this->menu_1 = new dtkWidgetsMenu(fa::globe, "Workspaces");
this->menu_2 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 2");
this->menu_3 = new dtkWidgetsMenu(fa::circlethin, "MainLevel 3");
dtkWidgetsMenuItemWorkspace *item = new dtkWidgetsMenuItemWorkspace("Workspaces", stack_bar);
this->menubar->addMenu(this->menu_1);
this->menubar->addMenu(this->menu_2);
this->menubar->addMenu(this->menu_3);
this->menu_1->addItem(item);
this->menubar->build();
QHBoxLayout *l = new QHBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
l->addWidget(stack_bar);
l->addWidget(this->menubar);
l->addWidget(this->stack);
this->setStyleSheet(m_style);
......@@ -385,7 +391,7 @@ void dummyWindow::resizeEvent(QResizeEvent *event)
{
QFrame::resizeEvent(event);
// this->menubar->setFixedHeight(event->size().height());
this->menubar->setFixedHeight(event->size().height());
}
......
......@@ -165,6 +165,9 @@ void dtkWidgetsMenuItemFacade::paintEvent(QPaintEvent *event)
if(menu_item->isParameter())
return;
if(menu_item->isWorkspace())
return;
dtkFontAwesome::instance()->setDefaultOption("color", ::fg_color);
QPainter painter(this);
......@@ -183,7 +186,7 @@ void dtkWidgetsMenuItemFacade::mousePressEvent(QMouseEvent *)
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItemFacade
// dtkWidgetsMenuItemParameterFacade
// ///////////////////////////////////////////////////////////////////
dtkWidgetsMenuItemParameterFacade::dtkWidgetsMenuItemParameterFacade(dtkWidgetsMenuItemParameter *source, QWidget *parent) : dtkWidgetsMenuItemFacade(source, parent)
......@@ -191,6 +194,19 @@ dtkWidgetsMenuItemParameterFacade::dtkWidgetsMenuItemParameterFacade(dtkWidgetsM
QFormLayout *layout = new QFormLayout(this);
layout->addRow(source->title(), source->widget());
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItemWorkspaceFacade
// ///////////////////////////////////////////////////////////////////
dtkWidgetsMenuItemWorkspaceFacade::dtkWidgetsMenuItemWorkspaceFacade(dtkWidgetsMenuItemWorkspace *source, QWidget *parent) : dtkWidgetsMenuItemFacade(source, parent)
{
QVBoxLayout *layout = new QVBoxLayout(this);
qDebug() << "add workspace widget in layout" << source;
layout->addWidget(source->widget());
}
// ///////////////////////////////////////////////////////////////////
......
......@@ -20,7 +20,7 @@
#include <QtWidgets>
// ///////////////////////////////////////////////////////////////////
//
//
// ///////////////////////////////////////////////////////////////////
static int item_height = 32;
......@@ -40,7 +40,7 @@ public:
public:
void setMenu(dtkWidgetsMenu *menu);
signals:
void clicked(void);
......@@ -168,7 +168,7 @@ public:
};
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItemFacade
// dtkWidgetsMenuItemParameterFacade
// ///////////////////////////////////////////////////////////////////
class dtkWidgetsMenuItemParameterFacade : public dtkWidgetsMenuItemFacade
......@@ -179,6 +179,18 @@ public:
dtkWidgetsMenuItemParameterFacade(dtkWidgetsMenuItemParameter *source, QWidget *parent = nullptr);
};
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItemWorkspaceFacade
// ///////////////////////////////////////////////////////////////////
class dtkWidgetsMenuItemWorkspaceFacade : public dtkWidgetsMenuItemFacade
{
Q_OBJECT
public:
dtkWidgetsMenuItemWorkspaceFacade(dtkWidgetsMenuItemWorkspace *source, QWidget *parent = nullptr);
};
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuFacade
// ///////////////////////////////////////////////////////////////////
......
......@@ -33,6 +33,8 @@ QWidget *build(QObject *source)
} else if(dtkWidgetsMenuItem *item = dynamic_cast<dtkWidgetsMenuItem *>(source)) {
if (item->isParameter())
return new dtkWidgetsMenuItemParameterFacade(static_cast<dtkWidgetsMenuItemParameter *>(item));
if (item->isWorkspace())
return new dtkWidgetsMenuItemWorkspaceFacade(static_cast<dtkWidgetsMenuItemWorkspace *>(item));
else if (item->isSeparator())
return new dtkWidgetsMenuItemSpacerFacade(margin, margin);
else
......
......@@ -16,6 +16,7 @@
#include "dtkWidgetsMenuItem.h"
#include "dtkWidgetsParameter.h"
#include "dtkWidgetsParameterFactory.h"
#include "dtkWidgetsWorkspaceStackBar.h"
#include <dtkCore>
......@@ -93,5 +94,32 @@ dtkWidgetsParameter *dtkWidgetsMenuItemParameter::widget(void)
return d->widget;
}
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItemWorkspacePrivate
// ///////////////////////////////////////////////////////////////////
class dtkWidgetsMenuItemWorkspacePrivate
{
public:
dtkWidgetsWorkspaceStackBar *widget = nullptr;
};
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsMenuItem
// ///////////////////////////////////////////////////////////////////
dtkWidgetsMenuItemWorkspace::dtkWidgetsMenuItemWorkspace(const QString& title, dtkWidgetsWorkspaceStackBar *bar) : dtkWidgetsMenuItem(0, title, 0)
{
d = new dtkWidgetsMenuItemWorkspacePrivate;
d->widget = bar;
}
QWidget *dtkWidgetsMenuItemWorkspace::widget(void)
{
return d->widget;
}
//
// dtkWidgetsMenuItem.cpp ends here
......@@ -31,6 +31,7 @@ class dtkCoreAbstractParameter;
// /////////////////////////////////////////////////////////////////////////////
class dtkWidgetsParameter;
class dtkWidgetsWorkspaceStackBar;
// /////////////////////////////////////////////////////////////////////////////
//
......@@ -54,6 +55,7 @@ public:
public:
virtual bool isParameter(void) const { return false; }
virtual bool isWorkspace(void) const { return false; }
protected:
class dtkWidgetsMenuItemPrivate *d;
......@@ -80,5 +82,26 @@ private:
class dtkWidgetsMenuItemParameterPrivate *d;
};
// /////////////////////////////////////////////////////////////////////////////
//
// /////////////////////////////////////////////////////////////////////////////
class DTKWIDGETS_EXPORT dtkWidgetsMenuItemWorkspace : public dtkWidgetsMenuItem
{
Q_OBJECT
public:
explicit dtkWidgetsMenuItemWorkspace(const QString& title, dtkWidgetsWorkspaceStackBar *bar);
public:
bool isWorkspace(void) const override { return true; }
public:
QWidget *widget(void);
private:
class dtkWidgetsMenuItemWorkspacePrivate *d;
};
//
// dtkWidgetsMenuItem.h ends here
......@@ -62,6 +62,7 @@ dtkWidgetsWorkspaceStackBarItem::dtkWidgetsWorkspaceStackBarItem(int index, QWid
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);
......
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