Commit 4db4eab5 authored by Nate Graham's avatar Nate Graham
Browse files

[applets/systemtray] Improve size options

Currently in git master there are three options for Tray icon sizing/arrangement:
1. Scale to fit + automatic number of rows/columns
2. One auto-scaling row/column
3. Two auto-scaling rows/columns

After consultation with VDG folks and many discussions, we discovered that the
latter two settings are kind of useless and are unlikely to satisfy anyone.
Instead, what some people will actually want is a way to return to the pre-Plasma
5.20 style, with one or two rows/columns of small-ish, fixed size icons.

This commit changes those two options to provide exactly that, allowing people who
don't like auto-scaling icons to return to the way their System Tray looked before
Plasma 5.20, and can also be used for global themes which are trying to emulate
Windows or Cinnamon, which have tray icons like this.
parent 1cfd9e88
......@@ -30,7 +30,7 @@
<default>true</default>
</entry>
<entry name="rowsOrColumns" type="Int">
<label>Number of rows or columns to show in the panel view (depending on whether the panel is horizontal or vertical, respectively) when not using automatic row/column determination.</label>
<label>Number of rows or columns of small icons to show in the panel view (depending on whether the panel is horizontal or vertical, respectively) when not using automatic row/column determination.</label>
<default>1</default>
</entry>
<entry name="pin" type="Bool">
......
......@@ -20,30 +20,51 @@
***************************************************************************/
import QtQuick 2.14
import QtQuick.Controls 2.14 as QQC2
import QtQuick.Layouts 1.13
import org.kde.plasma.core 2.1 as PlasmaCore
import org.kde.kirigami 2.13 as Kirigami
Kirigami.FormLayout {
ColumnLayout {
property alias cfg_automaticRowsOrColumns: automaticRadioButton.checked
property int cfg_rowsOrColumns
QQC2.RadioButton {
id: automaticRadioButton
Kirigami.FormData.label: i18nc("The arrangement of system tray icons in the Panel", "Panel icon arrangement:")
text: plasmoid.formFactor === PlasmaCore.Types.Horizontal ?
i18n("Adapt to Panel height") : i18n("Adapt to Panel width")
Component.onCompleted: {
console.warn("Plasmoid width is " + plasmoid.width)
console.warn("Plasmoid height is " + plasmoid.height)
}
QQC2.RadioButton {
text: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? i18n("One row") : i18n("One column")
checked: !automaticRadioButton.checked && cfg_rowsOrColumns === 1
onClicked: cfg_rowsOrColumns = 1
Kirigami.InlineMessage {
readonly property int minimumSize: units.iconSizes.small * 2
Layout.fillWidth: true
visible: twoRowsOrColumnsRadioButton.checked && (plasmoid.width <= minimumSize || plasmoid.height <= minimumSize)
type: Kirigami.MessageType.Warning
text: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? i18n("This layout may look odd with a short panel.") : i18n("This layout may look odd with a narrow panel.")
}
QQC2.RadioButton {
text: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? i18n("Two rows") : i18n("Two columns")
checked: !automaticRadioButton.checked && cfg_rowsOrColumns === 2
onClicked: cfg_rowsOrColumns = 2
Kirigami.FormLayout {
Layout.fillHeight: true
QQC2.RadioButton {
id: automaticRadioButton
Kirigami.FormData.label: i18nc("The arrangement of system tray icons in the Panel", "Panel icon arrangement:")
text: plasmoid.formFactor === PlasmaCore.Types.Horizontal ?
i18n("Adapt to Panel height") : i18n("Adapt to Panel width")
}
QQC2.RadioButton {
text: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? i18n("One row of small icons") : i18n("One column of small icons")
checked: !automaticRadioButton.checked && cfg_rowsOrColumns === 1
onClicked: cfg_rowsOrColumns = 1
}
QQC2.RadioButton {
id: twoRowsOrColumnsRadioButton
text: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? i18n("Two rows of small icons") : i18n("Two columns of small icons")
checked: !automaticRadioButton.checked && cfg_rowsOrColumns === 2
onClicked: cfg_rowsOrColumns = 2
}
}
}
......@@ -38,11 +38,16 @@ MouseArea {
LayoutMirroring.enabled: !vertical && Qt.application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
// The icon size to display when not using the default auto-scaling setting
readonly property int smallIconSize: units.iconSizes.smallMedium
readonly property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
readonly property bool autoSize: plasmoid.configuration.automaticRowsOrColumns
// Used only by AbstractItem, but it's easiest to keep it here since it
// uses dimensions from this item to calculate the final value
readonly property int itemSize: units.roundToIconSize(Math.min(Math.min(width, height), units.iconSizes.enormous));
readonly property int itemSize: autoSize ? units.roundToIconSize(Math.min(Math.min(width, height), units.iconSizes.enormous)) : smallIconSize
property alias expanded: dialog.visible
property Item activeApplet
......@@ -144,9 +149,8 @@ MouseArea {
id: tasksGrid
readonly property int thickness: root.vertical ? root.width : root.height
readonly property bool autoSize: plasmoid.configuration.automaticRowsOrColumns
readonly property int rowsOrColumns: {
if (autoSize) {
if (root.autoSize) {
if (thickness <= units.iconSizes.smallMedium * 2) {
return 1
} else {
......@@ -156,8 +160,9 @@ MouseArea {
return plasmoid.configuration.rowsOrColumns
}
}
readonly property int cellLength: thickness / rowsOrColumns
readonly property int totalLength: cellLength * Math.round(count / rowsOrColumns)
readonly property int autoSizeCellLength: thickness / rowsOrColumns
readonly property int totalLength: root.vertical ? cellHeight * Math.round(count / rowsOrColumns)
: cellWidth * Math.round(count / rowsOrColumns)
Layout.alignment: Qt.AlignCenter
......@@ -167,8 +172,8 @@ MouseArea {
implicitHeight: root.vertical ? totalLength : root.height
implicitWidth: !root.vertical ? totalLength : root.width
cellHeight: cellLength
cellWidth: cellLength
cellHeight: root.vertical && !root.autoSize ? root.smallIconSize + units.smallSpacing : autoSizeCellLength
cellWidth: !root.vertical && !root.autoSize ? root.smallIconSize + units.smallSpacing : autoSizeCellLength
model: PlasmaCore.SortFilterModel {
sourceModel: plasmoid.nativeInterface.systemTrayModel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment