Commit 0ec13197 authored by KLOCZKO Thibaud's avatar KLOCZKO Thibaud

Use dtkTheme for menu.

parent 66dd4607
......@@ -132,6 +132,8 @@ void setup(dtkApplication *application)
menubar_generator_1.populate(application->window()->menubar());
menubar_generator_2.populate(application->window()->menubar());
application->window()->populate();
application->window()->menubar()->touch();
}
......
......@@ -96,7 +96,7 @@ dtkWidgetsMenu *dtkWidgetsMainWindow::populateThemesMenu(void)
d->menu_themes = d->menubar->addMenu(fa::paintbrush, "Themes");
for (const QString theme : dtkThemesEngine::instance()->themes()) {
connect(static_cast<dtkWidgetsMenuItemCustom *>(d->menu_themes->addItem(new dtkWidgetsMenuItemTheme(theme))), &dtkWidgetsMenuItemCustom::clicked, [=] (void) -> void {
connect(static_cast<dtkWidgetsMenuItem *>(d->menu_themes->addItem(new dtkWidgetsMenuItemTheme(theme))), &dtkWidgetsMenuItem::clicked, [=] (void) -> void {
dtkThemesEngine::instance()->apply(theme);
});
}
......@@ -109,8 +109,8 @@ dtkWidgetsMenu *dtkWidgetsMainWindow::populateAboutMenu(void)
{
if(!d->menu_about) {
d->menu_about = d->menubar->addMenu(fa::question, "About");
d->menu_about->addMenu(fa::question, "dtk");
d->menu_about->addMenu(fa::question, "dtk environment (conda)");
d->menu_about->addMenu(fa::question, "dtk")->addItem(0, "prout");
d->menu_about->addMenu(fa::question, "dtk environment (conda)")->addItem(0, "Pour Come");
}
return d->menu_about;
......
......@@ -17,6 +17,7 @@
#include "dtkWidgetsParameter.h"
#include <dtkFonts>
#include <dtkThemes>
// ///////////////////////////////////////////////////////////////////
// TODO: Substitute *inplace* with dtkThemesEngine
......@@ -97,17 +98,17 @@ void dtkWidgetsMenuNavigationFacade::paintEvent(QPaintEvent *event)
{
QFrame::paintEvent(event);
dtkFontAwesome::instance()->setDefaultOption("color", ::fg_color);
dtkFontAwesome::instance()->setDefaultOption("color", dtkThemesEngine::instance()->color("@bgalt"));
QRect rect(5, 10, 28, 32);
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush((bg_color));
painter.setBrush(dtkThemesEngine::instance()->color("@base6"));
painter.drawRoundedRect(rect, 5, 5);
painter.drawPixmap(10, 20, 16, 16, dtkFontAwesome::instance()->icon(fa::chevronleft).pixmap(16, 16));
painter.setPen(fg_color);
painter.setPen(dtkThemesEngine::instance()->color("@base8"));
if(this->menu)
painter.drawText(::margin*4, ::margin * 2 + 2 + 10, this->menu->title());
else
......@@ -134,11 +135,11 @@ void dtkWidgetsMenuHeaderFacade::paintEvent(QPaintEvent *event)
{
QFrame::paintEvent(event);
dtkFontAwesome::instance()->setDefaultOption("color", ::fg_color);
dtkFontAwesome::instance()->setDefaultOption("color", dtkThemesEngine::instance()->color("@fg"));
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing);
painter.setPen(fg_color);
painter.setPen(dtkThemesEngine::instance()->color("@fg"));
painter.drawPixmap(::margin, ::margin, dtkFontAwesome::instance()->icon(this->menu->icon()).pixmap(16, 16));
painter.drawText(::margin + 16 + ::margin, ::margin * 2 + 2, this->menu->title());
}
......@@ -163,14 +164,11 @@ void dtkWidgetsMenuInnerFacade::paintEvent(QPaintEvent *event)
{
QFrame::paintEvent(event);
dtkFontAwesome::instance()->setDefaultOption("color", ::fg_color);
dtkFontAwesome::instance()->setDefaultOption("color", dtkThemesEngine::instance()->color("@base8"));
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
// painter.setPen(::bg_color);
// painter.setBrush(::bg_color);
// painter.drawRoundedRect(event->rect(), 5, 5);
painter.setPen(::fg_color);
painter.setPen(dtkThemesEngine::instance()->color("@base8"));
painter.drawPixmap(10, 10, 16, 16, dtkFontAwesome::instance()->icon(this->menu->icon()).pixmap(16, 16));
painter.drawText(::margin + 16 + ::margin, ::margin * 2 + 2, this->menu->title());
painter.drawPixmap(this->width() - ::margin - 16, 10, 16, 16, dtkFontAwesome::instance()->icon(fa::chevronright).pixmap(16, 16));
......@@ -216,16 +214,13 @@ void dtkWidgetsMenuItemFacade::paintEvent(QPaintEvent *event)
// painter.setPen(::bg_color);
// painter.setBrush(::bg_color);
// painter.drawRoundedRect(event->rect(), 5, 5);
painter.setPen(::fg_color);
painter.setPen(dtkThemesEngine::instance()->color("@fg"));
painter.drawPixmap(10, 10, 16, 16, dtkFontAwesome::instance()->icon(this->menu_item->icon()).pixmap(16, 16));
painter.drawText(::margin + 16 + ::margin, ::margin * 2 + 2, this->menu_item->title());
}
void dtkWidgetsMenuItemFacade::mousePressEvent(QMouseEvent *)
{
if( menu_item->isCustom())
return;
emit clicked();
}
......
......@@ -44,18 +44,18 @@ void handle(const QList<QWidget *>& items, dtkWidgetsMenuBarContainer *c, dtkWid
{
auto setup = [=] (QWidget *facade, int i) {
if (items.count() == 1 || (i > 1 && i < items.count() - 1 && dynamic_cast<dtkWidgetsMenuItemSpacerFacade *>(items.at(i - 1)) && dynamic_cast<dtkWidgetsMenuItemSpacerFacade *>(items.at(i + 1)))) {
facade->setProperty("state", "prout");
facade->setProperty("state", "alone");
} else if (facade == items.last()) {
facade->setProperty("state", "last");
if(items.count() > 1 && dynamic_cast<dtkWidgetsMenuItemSpacerFacade *>(items.at(i - 1))) {
facade->setProperty("state", "prout");
facade->setProperty("state", "alone");
}
} else if (i < items.count() - 1 && dynamic_cast<dtkWidgetsMenuItemSpacerFacade *>(items.at(i + 1))) {
facade->setProperty("state", "last");
} else if (i == 0) {
facade->setProperty("state", "first");
if(items.count() > 1 && dynamic_cast<dtkWidgetsMenuItemSpacerFacade *>(items.at(i + 1))) {
facade->setProperty("state", "prout");
facade->setProperty("state", "alone");
}
} else if (i > 1 && dynamic_cast<dtkWidgetsMenuItemSpacerFacade *>(items.at(i - 1))) {
facade->setProperty("state", "first");
......@@ -73,6 +73,7 @@ void handle(const QList<QWidget *>& items, dtkWidgetsMenuBarContainer *c, dtkWid
QObject::connect(facade, &dtkWidgetsMenuItemFacade::clicked, [=] (void) -> void
{
facade->menu_item->emit triggered();
facade->menu_item->emit clicked();
});
} else if (dtkWidgetsMenuInnerFacade *facade = dynamic_cast<dtkWidgetsMenuInnerFacade *>(item)) {
......
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