KTitleWidget and the native Mac style
René J.V. Bertin
rjvbertin at gmail.com
Wed Jul 5 08:30:54 UTC 2017
On Wednesday July 05 2017 09:55:27 Hugo Pereira Da Costa wrote:
(CC'ing the plasma-devel ML and thus keeping Hugo's full reply as context.)
>On 07/04/2017 11:13 PM, René J.V. Bertin wrote:
>> On Tuesday July 04 2017 20:16:55 Sebastian Kügler wrote:
>>
>> @Kevin: should we continue to CC you?
>>
>>> The frame in my understanding is old weight, and can go (do check with the VDG
>>> though!)
>> Thing is that you cannot simply get rid of the QFrame, it would at least have to be replaced with something invisible that can take over its other role.
>>
>> What works (mostly) is something like this:
>>
>> 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);
>>
>> // default image / text part start
>> d->headerLayout = new QGridLayout(titleFrame);
>> d->headerLayout->setColumnStretch(0, 1);
>> // d->headerLayout->setMargin(6);
>> d->headerLayout->setContentsMargins(0, 0, 0, 0);
>> //...
>> }
>>
>> and replace `d->textLabel->setStyleSheet(d->textStyleSheet())` with
>>
>> d->textLabel->setFont(QFontDatabase::systemFont(QFontDatabase::TitleFont));
>>
>> (that will use the window titlebar font, but also when no platform theme plugin -aka plasma-integration- is installed).
>>
>> in Breeze we can then do
>>
>> } else if( qobject_cast<QFrame*>( widget ) && widget->parent() && widget->parent()->inherits( "KTitleWidget" ) ) {
>>
>> QFrame *frame = qobject_cast<QFrame*>( widget );
>> if( StyleConfigData::titleWidgetDrawFrame() ) {
>> frame->setAutoFillBackground( true );
>> frame->setFrameShape( QFrame::StyledPanel );
>> frame->setBackgroundRole( QPalette::Base );
>> // make the title frame a bit less luxuriously big, and centre the text vertically
>> frame->layout()->setContentsMargins(3, 3, 3, 0);
>> } else {
>> frame->setAutoFillBackground( false );
>> frame->setFrameShape( QFrame::NoFrame );
>> frame->setBackgroundRole( QPalette::Window );
>> // don't take extra space for a frame we're not showing at all
>> frame->layout()->setContentsMargins(0, 0, 0, 0);
>> }
>>
>> }
>Concerning the change in breeze:
>1/ I would gladly get rid of the option to draw the frame at all (not
>sure anyone uses this anyway)
Given that it's the default I have a hunch many people actually do (if you can call that "using" ;)). What you can do is start by not drawing the frame by default, possibly disable the option to enable drawing it in breeze-settings5 and see what kind of feedback you get on that.
Do you have any idea why moving the QFrame shape and background role configuration from the KTitleWidget ctor to Style::polish() has this subtle effect, or why the frame outline is NOT drawn with rounded corners in the current code?
>2/ however, the default layout should not change with respect to what we
>have now, unless blessed by the vdg and plasma team.
>That implies:
>- keep the current font size increment
>- don't change the margins.
Was the font increment blessed by either when Sebas introduced it, or maybe just the general idea of using a larger font?
I've CC'ed the plasma-devel ML, maybe you (Hugo) can loop in (someone from) the vdg team?
This also implies that appropriate display of the KTitleWidget on Mac (and MS Windows?) will require testing for the style in use in KWidgetsAddons.
R.
More information about the Plasma-devel
mailing list