diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index e1a2d4eeb..6f5502d9b 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -8,17 +8,22 @@ */ #include "dockwidget.h" -#include "blackmisc/iconsstandard.h" +#include "blackmisc/icons.h" +#include "blackgui/stylesheetutility.h" #include +#include +#include namespace BlackGui { CDockWidget::CDockWidget(QWidget *parent) : QDockWidget(parent) { + this->ps_onStyleSheetsChanged(); this->initTitleBarWidgets(); // connect connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::ps_onTopLevelChanged); + connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CDockWidget::ps_onStyleSheetsChanged); // context menu this->setContextMenuPolicy(Qt::CustomContextMenu); @@ -85,14 +90,24 @@ namespace BlackGui { if (this->isFloating()) { - contextMenu->addAction(BlackMisc::CIconsStandard::dockTop16(), "Dock", this, SLOT(toggleFloating())); + contextMenu->addAction(BlackMisc::CIcons::dockTop16(), "Dock", this, SLOT(toggleFloating())); } else { - contextMenu->addAction(BlackMisc::CIconsStandard::floatOne16(), "Float", this, SLOT(toggleFloating())); + contextMenu->addAction(BlackMisc::CIcons::floatOne16(), "Float", this, SLOT(toggleFloating())); } } + void CDockWidget::paintEvent(QPaintEvent *event) + { + // included for style sheet compliance + // QStyleOption opt; + // opt.init(this); + // QPainter p(this); + // style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + QDockWidget::paintEvent(event); + } + void CDockWidget::ps_onTopLevelChanged(bool topLevel) { if (topLevel) @@ -126,11 +141,15 @@ namespace BlackGui void CDockWidget::ps_showContextMenu(const QPoint &pos) { - // for most widgets QPoint globalPos = this->mapToGlobal(pos); QScopedPointer contextMenu(new QMenu(this)); this->addToContextMenu(contextMenu.data()); QAction *selectedItem = contextMenu.data()->exec(globalPos); Q_UNUSED(selectedItem); } + + void CDockWidget::ps_onStyleSheetsChanged() + { + // void + } } diff --git a/src/blackgui/dockwidget.h b/src/blackgui/dockwidget.h index 9d059e7cb..3d4e3b609 100644 --- a/src/blackgui/dockwidget.h +++ b/src/blackgui/dockwidget.h @@ -79,12 +79,19 @@ namespace BlackGui //! Contribute to menu virtual void addToContextMenu(QMenu *contextMenu) const; + //! Paint event + virtual void paintEvent(QPaintEvent *event) override; + + protected slots: + //! Style sheet has changed + virtual void ps_onStyleSheetsChanged(); + private slots: //! Top level has been chaged virtual void ps_onTopLevelChanged(bool topLevel); //! Context menu - void ps_showContextMenu(const QPoint &pos); + virtual void ps_showContextMenu(const QPoint &pos); private: QWidget *m_emptyTitleBar = nullptr; //!< replacing default title bar @@ -96,7 +103,6 @@ namespace BlackGui //! Empty widget with no size void initTitleBarWidgets(); - }; } // namespace