Commit 927ff338 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

add option to disable/enable dynamic workspace bar

parent 4b0b24eb
......@@ -411,9 +411,17 @@ dummyWindowBar::dummyWindowBar(QWidget *parent) : QFrame(parent)
dtkWidgetsWorkspaceBar *bar = new dtkWidgetsWorkspaceBar;
bar->setStack(this->stack);
bar->addWorkspaceInMenu("My Dummy Workspace A", fa::sitemap, "dummyWorkspaceA" );
bar->addWorkspaceInMenu("My Dummy Workspace B", fa::image, "dummyWorkspaceB" );
bar->addWorkspaceInMenu("dtk", fa::image, "dummyWorkspaceC" );
// For a dynamic bar with a botton that pops a menu to create new workspace:
// bar->addWorkspaceInMenu("My Dummy Workspace A", fa::sitemap, "dummyWorkspaceA" );
// bar->addWorkspaceInMenu("My Dummy Workspace B", fa::image, "dummyWorkspaceB" );
// bar->addWorkspaceInMenu("dtk", fa::image, "dummyWorkspaceC" );
// here we use a static workspace bar
bar->setDynamic(false);
bar->createWorkspace("My Dummy Workspace A", "dummyWorkspaceA", false );
bar->createWorkspace("My Dummy Workspace B", "dummyWorkspaceB", false );
QVBoxLayout *l = new QVBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0);
......
......@@ -28,7 +28,7 @@ public:
dtkWidgetsWorkspaceBarButton::dtkWidgetsWorkspaceBarButton(QWidget *parent): QLabel(parent)
{
dtkFontAwesome::instance()->setDefaultOption("color", QColor("#ff0000"));
dtkFontAwesome::instance()->setDefaultOption("color", QColor("#ffffff"));
this->setAlignment(Qt::AlignCenter);
this->setPixmap(dtkFontAwesome::instance()->icon(fa::plussquare).pixmap(32, 32));
......@@ -37,7 +37,6 @@ dtkWidgetsWorkspaceBarButton::dtkWidgetsWorkspaceBarButton(QWidget *parent): QLa
this->menu = new QMenu(this);
this->menu->setStyleSheet("QMenu::item {padding: 2px 20px 2px 30px; border: 1px solid transparent; spacing: 10px; height: 50px; width: 300px; font-size: 16pt;} QMenu::icon {width: 50px; height:50px;}");
}
void dtkWidgetsWorkspaceBarButton::create(QAction *action)
......@@ -194,16 +193,16 @@ signals:
void indexDeleted(int);
public:
void createWorkspace(const QColor &, const QString &);
void createWorkspace(const QColor &, const QString &, bool display_destroy);
public:
QList<QColor> colors;
QStringList workspaces;
};
void dtkWidgetsWorkspaceBarPrivate::createWorkspace(const QColor & color, const QString& name)
void dtkWidgetsWorkspaceBarPrivate::createWorkspace(const QColor & color, const QString& name, bool display_destroy)
{
dtkWidgetsWorkspaceBarItem *item = new dtkWidgetsWorkspaceBarItem(color, name, q);
dtkWidgetsWorkspaceBarItem *item = new dtkWidgetsWorkspaceBarItem(color, name, q, display_destroy);
if (this->items.count() > 0) {
dtkWidgetsWorkspaceBarSeparator *separator = new dtkWidgetsWorkspaceBarSeparator(q);
......@@ -296,6 +295,12 @@ void dtkWidgetsWorkspaceBar::setStack(QStackedWidget *stack)
d->stack = stack;
}
void dtkWidgetsWorkspaceBar::setDynamic(bool value)
{
d->button->setVisible(value);
}
void dtkWidgetsWorkspaceBar::addWorkspaceInMenu(const QString& workspace_name, int icon, const QString & type)
{
d->workspaces << workspace_name;
......@@ -306,11 +311,11 @@ void dtkWidgetsWorkspaceBar::addWorkspaceInMenu(const QString& workspace_name, i
});
}
void dtkWidgetsWorkspaceBar::createWorkspace(const QString &name, const QString& type)
void dtkWidgetsWorkspaceBar::createWorkspace(const QString &name, const QString& type, bool display_destroy)
{
QColor color = d->colors.at(d->workspaces.indexOf(name,0) % d->colors.count()) ;
d->createWorkspace(color, name);
d->createWorkspace(color, name, display_destroy);
dtkWidgetsWorkspace *workspace = dtk::widgets::workspace::pluginFactory().create(type);
if (!workspace) {
qWarning() << "can't create workspace of type" << type << dtk::widgets::workspace::pluginFactory().keys();
......
......@@ -25,7 +25,7 @@ public slots:
void addWorkspaceInMenu(const QString& workspace_name, int icon, const QString& type);
public slots:
void createWorkspace(const QString &name, const QString& type);
void createWorkspace(const QString &name, const QString& type, bool display_destroy = true);
protected:
void enterEvent(QEvent *);
......@@ -33,6 +33,7 @@ protected:
public:
void setCurrentIndex(int);
void setDynamic(bool);
public:
QSize sizeHint(void) const;
......
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