Commit a9d941b3 authored by Konrad Materka's avatar Konrad Materka

[applets/systemtray] Simplify icon size logic

Summary: This change simplifies icon size logic - now it is controled only in one place: AbstractItem. This gives additional benefits, like icons perfectly centered.

Test Plan: Highlights should always be centered

Reviewers: #plasma_workspaces, #plasma, ngraham, broulik, davidedmundson, apol

Reviewed By: #plasma_workspaces, #plasma, ngraham, broulik

Subscribers: mart, davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28109
parent ecac6a60
......@@ -28,7 +28,7 @@ PlasmaCore.ToolTipArea {
property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
implicitWidth: units.iconSizes.smallMedium
implicitHeight: implicitWidth
visible: root.hiddenLayout.contentItem.children.length > 0
visible: root.hiddenLayout.count > 0
subText: root.expanded ? i18n("Close popup") : i18n("Show hidden icons")
......
......@@ -74,8 +74,9 @@ MouseArea {
}
CurrentItemHighLight {
parent: hiddenTasksColumn.contentItem
target: root.activeApplet && root.activeApplet.parent && root.activeApplet.parent.inHiddenLayout ? root.activeApplet.parent.parent : null
location: PlasmaCore.Types.LeftEdge
readonly property bool hiddenAppletActivated: root.activeApplet && root.activeApplet.parent && root.activeApplet.parent.inHiddenLayout
parent: hiddenAppletActivated ? root.activeApplet.parent : hiddenTasksColumn.contentItem
target: hiddenAppletActivated ? root.activeApplet.parent : null
location: LayoutMirroring.enabled ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.LeftEdge
}
}
......@@ -32,7 +32,7 @@ PlasmaCore.ToolTipArea {
property string itemId
property alias text: label.text
property Item iconItem
property alias iconContainer: iconContainer
property int /*PlasmaCore.Types.ItemStatus*/ status: model.status || PlasmaCore.Types.UnknownStatus
property int /*PlasmaCore.Types.ItemStatus*/ effectiveStatus: model.effectiveStatus || PlasmaCore.Types.UnknownStatus
readonly property bool inHiddenLayout: effectiveStatus === PlasmaCore.Types.PassiveStatus
......@@ -72,7 +72,7 @@ PlasmaCore.ToolTipArea {
//END CONNECTIONS
PulseAnimation {
targetItem: iconItem
targetItem: iconContainer
running: (abstractItem.status === PlasmaCore.Types.NeedsAttentionStatus ||
abstractItem.status === PlasmaCore.Types.RequiresAttentionStatus ) &&
units.longDuration > 0
......@@ -87,7 +87,7 @@ PlasmaCore.ToolTipArea {
loops: 1
ScaleAnimator {
target: iconItem
target: iconContainer
from: 1
to: 0.5
duration: units.shortDuration
......@@ -95,7 +95,7 @@ PlasmaCore.ToolTipArea {
}
ScaleAnimator {
target: iconItem
target: iconContainer
from: 0.5
to: 1
duration: units.shortDuration
......@@ -124,19 +124,27 @@ PlasmaCore.ToolTipArea {
}
}
PlasmaComponents.Label {
id: label
anchors {
left: parent.left
leftMargin: iconItem ? iconItem.width + units.smallSpacing : 0
verticalCenter: parent.verticalCenter
Row {
spacing: units.smallSpacing
anchors.horizontalCenter: inVisibleLayout ? parent.horizontalCenter : undefined
Item {
id: iconContainer
anchors.verticalCenter: parent.verticalCenter
width: Math.min(abstractItem.width, abstractItem.height)
height: width
property alias inHiddenLayout: abstractItem.inHiddenLayout
property alias inVisibleLayout: abstractItem.inVisibleLayout
}
opacity: visible ? 1 : 0
visible: abstractItem.inHiddenLayout && !root.activeApplet
Behavior on opacity {
NumberAnimation {
duration: units.longDuration
easing.type: Easing.InOutQuad
PlasmaComponents.Label {
id: label
anchors.verticalCenter: parent.verticalCenter
visible: abstractItem.inHiddenLayout && !root.activeApplet
opacity: visible ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
}
}
......
......@@ -24,7 +24,6 @@ AbstractItem {
id: plasmoidContainer
property Item applet: model.applet || null
iconItem: applet
text: applet ? applet.title : ""
itemId: applet ? applet.pluginName : ""
......@@ -51,19 +50,6 @@ AbstractItem {
}
}
onHeightChanged: {
if (applet) {
applet.width = Math.min(plasmoidContainer.width, plasmoidContainer.height)
applet.height = applet.width
}
}
onWidthChanged: {
if (applet) {
applet.width = Math.min(plasmoidContainer.width, plasmoidContainer.height)
applet.height = applet.width
}
}
//This is to make preloading effective, minimizes the scene changes
function preloadFullRepresentationItem(fullRepresentationItem) {
if (fullRepresentationItem && fullRepresentationItem.parent === null) {
......@@ -75,11 +61,8 @@ AbstractItem {
onAppletChanged: {
if (applet) {
applet.parent = plasmoidContainer
applet.anchors.left = plasmoidContainer.left
applet.anchors.verticalCenter = plasmoidContainer.verticalCenter
applet.width = Math.min(plasmoidContainer.width, plasmoidContainer.height)
applet.height = applet.width
applet.parent = plasmoidContainer.iconContainer
applet.anchors.fill = applet.parent
applet.visible = true
preloadFullRepresentationItem(applet.fullRepresentationItem)
......
......@@ -30,10 +30,11 @@ AbstractItem {
icon: model.ToolTipIcon !== "" ? model.ToolTipIcon : model.Icon ? model.Icon : model.IconName
textFormat: Text.AutoText
iconItem: iconItem
PlasmaCore.IconItem {
id: iconItem
parent: taskIcon.iconContainer
anchors.fill: iconItem.parent
source: {
if (model.status === PlasmaCore.Types.NeedsAttentionStatus) {
if (model.AttentionIcon) {
......@@ -45,15 +46,7 @@ AbstractItem {
}
return model.Icon ? model.Icon : model.IconName
}
width: Math.min(parent.width, parent.height)
height: width
active: taskIcon.containsMouse
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
}
}
onContextMenu: {
......
......@@ -92,8 +92,9 @@ MouseArea {
}
CurrentItemHighLight {
visualParent: tasksGrid
target: root.activeApplet && root.activeApplet.parent && root.activeApplet.parent.inVisibleLayout ? root.activeApplet.parent.parent : root
readonly property bool visibleAppletActivated: root.activeApplet && root.activeApplet.parent && root.activeApplet.parent.inVisibleLayout
parent: visibleAppletActivated ? root.activeApplet.parent : root
target: visibleAppletActivated ? root.activeApplet.parent : root
location: plasmoid.location
}
......
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