import QtQuick
import QtQuick.Layouts
import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents3
import org.kde.kirigami as Kirigami
import "Vigil.js" as Vigil
// The Vigil eye, badged with the unresolved count, then one circle per
// watched project (or one for the whole organization). The eye opens
// every watched project's issues; a circle opens just its own.
Item {
id: strip
required property var store
readonly property bool vertical: Plasmoid.formFactor === PlasmaCore.Types.Vertical
readonly property real cell: Math.max(Kirigami.Units.iconSizes.small,
Math.min(vertical ? width : height, Kirigami.Units.iconSizes.medium))
// Circles are smaller than the eye, so a row of them stays compact.
readonly property real dot: Math.round(cell * 0.6)
readonly property int circleCount: circles.count
Layout.minimumWidth: vertical ? Kirigami.Units.iconSizes.small : cell + circleCount * dot
Layout.preferredWidth: Layout.minimumWidth
Layout.minimumHeight: vertical ? cell + circleCount * dot : Kirigami.Units.iconSizes.small
Layout.preferredHeight: Layout.minimumHeight
Flow {
id: flow
anchors.fill: parent
flow: strip.vertical ? Flow.TopToBottom : Flow.LeftToRight
spacing: 0
// ── the eye: every watched project ──────────────────────────────
Item {
width: strip.vertical ? strip.width : strip.cell
height: strip.vertical ? strip.cell : strip.height
Rectangle {
anchors.fill: parent
radius: Kirigami.Units.cornerRadius
color: Kirigami.Theme.highlightColor
opacity: logoMouse.containsMouse ? 0.2 : 0
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration } }
}
Kirigami.Icon {
id: logo
anchors.centerIn: parent
width: strip.cell * 0.84
height: width
source: strip.store.logoSource
isMask: true
color: !strip.store.hasValidConfig || strip.store.authError !== ""
|| (strip.store.offline && !strip.store.issuesLoaded)
? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
}
// The same badge shape the task manager uses for unread counts.
Rectangle {
visible: strip.store.badgeText !== ""
anchors.right: logo.right
anchors.bottom: logo.bottom
anchors.rightMargin: -Math.round(width * 0.25)
height: Math.max(Kirigami.Units.iconSizes.small * 0.7, Math.round(strip.cell * 0.45))
width: Math.max(height, badgeLabel.implicitWidth + Kirigami.Units.smallSpacing * 2)
radius: height / 2
color: Kirigami.Theme.highlightColor
border.color: Kirigami.Theme.backgroundColor
border.width: 1
PlasmaComponents3.Label {
id: badgeLabel
anchors.centerIn: parent
text: strip.store.badgeText
color: Kirigami.Theme.highlightedTextColor
font.pixelSize: Math.max(7, Math.round(parent.height * 0.68))
font.bold: true
}
}
PlasmaCore.ToolTipArea {
anchors.fill: parent
mainText: strip.store.org && strip.store.orgs.length > 1
? i18n("Vigil · %1", strip.store.org.name || strip.store.org.slug) : i18n("Vigil")
subText: strip.store.logoTooltip
}
MouseArea {
id: logoMouse
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onClicked: function(mouse) {
if (!strip.store.hasValidConfig || strip.store.authError !== "") {
Plasmoid.internalAction("configure").trigger()
} else if (mouse.button === Qt.MiddleButton) {
strip.store.openWeb()
} else if (strip.store.expanded && Plasmoid.configuration.projectFilter === "") {
strip.store.expanded = false
} else {
strip.store.openCircle("")
}
}
}
}
// ── one circle per watched project, or the org's ────────────────
Repeater {
id: circles
model: strip.store.circles
delegate: Item {
id: circleItem
required property var modelData
width: strip.vertical ? strip.width : strip.dot
height: strip.vertical ? strip.dot : strip.height
StatusCircle {
anchors.centerIn: parent
width: strip.dot * 0.8
height: width
health: circleItem.modelData.health
dimmed: strip.store.offline
highlighted: mouse.containsMouse
|| (strip.store.expanded && Plasmoid.configuration.projectFilter === circleItem.modelData.slug
&& circleItem.modelData.slug !== "")
}
PlasmaCore.ToolTipArea {
anchors.fill: parent
mainText: circleItem.modelData.label
subText: circleItem.modelData.tooltip
}
MouseArea {
id: mouse
anchors.fill: parent
hoverEnabled: true
onClicked: {
var slug = circleItem.modelData.slug
if (strip.store.expanded && Plasmoid.configuration.projectFilter === slug) strip.store.expanded = false
else strip.store.openCircle(slug)
}
}
}
}
}
}
neiam
/vigil-plasmoid
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
6.2 KiB · text
History
905ae26