Added Config::setDisabledPaintEvents()
Makes our internal widgets not override QWidget::paintEvent(), which gives full power to the user to stylesheets. Was already possible, but required the user to override the internal widgets via the widget factory For issue #146
This commit is contained in:
@@ -56,6 +56,7 @@ public:
|
||||
FrameworkWidgetFactory *m_frameworkWidgetFactory = nullptr;
|
||||
Flags m_flags = Flag_Default;
|
||||
InternalFlags m_internalFlags = InternalFlag_None;
|
||||
CustomizableWidgets m_disabledPaintEvents = CustomizableWidget_None;
|
||||
qreal m_draggedWindowOpacity = Q_QNAN;
|
||||
};
|
||||
|
||||
@@ -292,4 +293,14 @@ void Config::Private::fixFlags()
|
||||
}
|
||||
}
|
||||
|
||||
void Config::setDisabledPaintEvents(CustomizableWidgets widgets)
|
||||
{
|
||||
d->m_disabledPaintEvents = widgets;
|
||||
}
|
||||
|
||||
Config::CustomizableWidgets Config::disabledPaintEvents() const
|
||||
{
|
||||
return d->m_disabledPaintEvents;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -220,6 +220,13 @@ public:
|
||||
void setAbsoluteWidgetMaxSize(QSize size);
|
||||
QSize absoluteWidgetMaxSize() const;
|
||||
|
||||
///@brief Disables our internal widget's paint events
|
||||
/// By default, KDDockWidget's internal widgets reimplement paintEvent(). Disabling them
|
||||
/// (which makes the base-class, QWidget::paintEvent() be called instead) can be useful if you want to style
|
||||
// via CSS stylesheets.
|
||||
void setDisabledPaintEvents(CustomizableWidgets);
|
||||
Config::CustomizableWidgets disabledPaintEvents() const;
|
||||
|
||||
///@internal
|
||||
///@brief returns the internal flags.
|
||||
///@warning Not for public consumption, support will be limited.
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "Separator_qwidget.h"
|
||||
#include "Widget_qwidget.h"
|
||||
#include "Logging_p.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
@@ -28,8 +29,13 @@ SeparatorWidget::SeparatorWidget(Layouting::Widget *parent)
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
void SeparatorWidget::paintEvent(QPaintEvent *)
|
||||
void SeparatorWidget::paintEvent(QPaintEvent *ev)
|
||||
{
|
||||
if (KDDockWidgets::Config::self().disabledPaintEvents() & KDDockWidgets::Config::CustomizableWidget_Separator) {
|
||||
QWidget::paintEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
|
||||
QStyleOption opt;
|
||||
|
||||
@@ -36,8 +36,13 @@ FloatingWindowWidget::FloatingWindowWidget(Frame *frame, MainWindowBase *parent)
|
||||
init();
|
||||
}
|
||||
|
||||
void FloatingWindowWidget::paintEvent(QPaintEvent *)
|
||||
void FloatingWindowWidget::paintEvent(QPaintEvent *ev)
|
||||
{
|
||||
if (Config::self().disabledPaintEvents() & Config::CustomizableWidget_FloatingWindow) {
|
||||
QWidget::paintEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
QPen pen(0x666666);
|
||||
pen.setWidth(1);
|
||||
|
||||
Reference in New Issue
Block a user