KTitleWidget and the native Mac style

René J.V. Bertin rjvbertin at gmail.com
Tue Jul 4 17:40:22 UTC 2017


Hi,

How about this?

In KWidgetAddons (out-commented code shows "stock" 5.35.0):

KTitleWidget::KTitleWidget(QWidget *parent)
    : QWidget(parent),
      d(new Private(this))
{
    QFrame *titleFrame = new QFrame(this);
//     titleFrame->setAutoFillBackground(true);
//     titleFrame->setFrameShape(QFrame::StyledPanel);
    titleFrame->setFrameShadow(QFrame::Plain);
//     titleFrame->setBackgroundRole(QPalette::Base);

In breeze/kstyle/breezestyle.cpp (Style::polish(QWidget*)):

        } else if( qobject_cast<QFrame*>( widget ) && widget->parent() && widget->parent()->inherits( "KTitleWidget" ) ) {

//             widget->setAutoFillBackground( false );
//             if( !StyleConfigData::titleWidgetDrawFrame() )
//             { widget->setBackgroundRole( QPalette::Window ); }
            QFrame *frame = qobject_cast<QFrame*>( widget );
            if( StyleConfigData::titleWidgetDrawFrame() ) {
                frame->setAutoFillBackground( true );
                frame->setFrameShape( QFrame::StyledPanel );
                frame->setBackgroundRole( QPalette::Base );
            } else {
                frame->setAutoFillBackground( false );
                frame->setFrameShape( QFrame::NoFrame );
                frame->setBackgroundRole( QPalette::Window );
            }

        }

That moves the entire choice of the title frame rendering style to the style plugin and the end result looks the same (I didn't to a pixel analysis yet).

R.



More information about the Kde-frameworks-devel mailing list