Align Plasma QML button content in center if it has an icon
Changes PlannedPublic

Authored by GB_2 on Tue, Dec 4, 6:47 PM.

Details

Reviewers
None
Group Reviewers
Plasma
VDG
Summary

Aligns the Plasma QML Button content in the center if it has an icon.
It makes this look better: https://phabricator.kde.org/D17323

Before:

After:

Test Plan

Run this test QML file with qmlscene:

Diff Detail

Repository
R242 Plasma Framework (Library)
Lint
Lint Skipped
Unit
Unit Tests Skipped
GB_2 created this revision.Tue, Dec 4, 6:47 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptTue, Dec 4, 6:47 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
GB_2 requested review of this revision.Tue, Dec 4, 6:47 PM
ngraham added a subscriber: ngraham.Tue, Dec 4, 7:11 PM

Cool!

Does this still work properly when the text is so long that the button expands to accommodate it?

Now that I think about this a bit, it seems like maybe the problem here is that there's a minimum button width in the first place. If we changed that so that buttons could be narrower when the icon + label is small, than we probably wouldn't need to horizontally center anything.

GB_2 updated this revision to Diff 46862.EditedTue, Dec 4, 7:27 PM

It works properly, no matter how big the button is or if it has an icon or not.
In my opinion we should leave it how it is now.

apol added a subscriber: apol.Tue, Dec 4, 11:21 PM
apol added inline comments.
src/declarativeimports/plasmastyle/ButtonStyle.qml
41

This looks wrong, a RowLayout inside another one?

Code wise:

  • Any changes to PlasmaStyle need to happen in the QQC2 (PlasmaComponents3) version too before shipping
  • Please be sure to run qmlscene tests/components/button.qml
  • Why do we have nested RowLayouts?

If we changed that so that buttons could be narrower when the icon + label is small, than we probably wouldn't need to horizontally center anything.

That's do-able from application space.

Button {

implicitWidth: minimumWidth

}

If you want that, there's no need to change this

GB_2 updated this revision to Diff 46907.Wed, Dec 5, 4:48 PM

Improved code.
How qmlscene tests/components/button.qml looks like:


For some reason "elide" doesn't work...

GB_2 marked an inline comment as done.Wed, Dec 5, 4:49 PM

On the button with menu, the triangle has moved. That seems an unwanted change.

GB_2 updated this revision to Diff 46918.EditedWed, Dec 5, 8:44 PM

I can't figure out how to make "elide" work without using Layout.fillWidth.

I can't figure out how to make "elide" work without using Layout.fillWidth.

You won't be able to. You need that.
(or setting a max width, which effectively is the same thing)

GB_2 added a comment.Wed, Dec 5, 9:09 PM

Hmm... then I give up.

GB_2 updated this revision to Diff 46920.EditedWed, Dec 5, 9:16 PM

Improved menu button.

Any changes to PlasmaStyle need to happen in the QQC2 (PlasmaComponents3) version too before shipping

src/declarativeimports/plasmastyle/ButtonStyle.qml
41

why this Item wrapper

mart added a subscriber: mart.Fri, Dec 14, 4:13 PM

in general, buttons with icons may be stacked vertically, which for me makes a general -1

mart added a comment.Fri, Dec 14, 4:14 PM
In D17355#371722, @GB_2 wrote:

Improved code.
How qmlscene tests/components/button.qml looks like:


For some reason "elide" doesn't work...

is elide working on the latest revision?

mart added a comment.Fri, Dec 14, 4:15 PM

pleaase add the changes to plasmacomponents3 as well

GB_2 planned changes to this revision.Fri, Dec 14, 6:48 PM
In D17355#376973, @mart wrote:

in general, buttons with icons may be stacked vertically, which for me makes a general -1

But it's not consistent with Qt Widgets and looks kind of weird.

In D17355#376975, @mart wrote:
In D17355#371722, @GB_2 wrote:

Improved code.
How qmlscene tests/components/button.qml looks like:


For some reason "elide" doesn't work...

is elide working on the latest revision?

No, I still didn't figure that out.

In D17355#376976, @mart wrote:

pleaase add the changes to plasmacomponents3 as well

I will do that when this is done.

This needs revision, but it's not really my priority.