wbar: add updates indicator

This commit is contained in:
end-4
2025-11-15 21:30:28 +01:00
parent 6ee7212bdc
commit fdc38d69f7
13 changed files with 194 additions and 20 deletions
@@ -11,8 +11,10 @@ BarPopup {
id: root
default property var menuData
property var model: [
{iconName: "start-here", text: "Start", action: () => {print("hello")}}
{ iconName: "start-here", text: "Start", action: () => {print("hello")} },
{ type : "separator" },
]
readonly property bool hasIcons: model.some(item => item.iconName !== undefined && item.iconName !== "")
padding: 2
contentItem: ColumnLayout {
@@ -21,18 +23,35 @@ BarPopup {
Repeater {
model: root.model
delegate: WButton {
id: btn
Layout.fillWidth: true
delegate: DelegateChooser {
role: "type"
DelegateChoice {
roleValue: "separator"
Rectangle {
Layout.topMargin: 2
Layout.bottomMargin: 2
Layout.fillWidth: true
implicitHeight: 1
color: Looks.colors.bg0Border
}
}
DelegateChoice {
roleValue: undefined
WButton {
id: btn
Layout.fillWidth: true
required property var modelData
icon.name: modelData.iconName ? modelData.iconName : ""
monochromeIcon: modelData.monochromeIcon ?? true
text: modelData.text ? modelData.text : ""
required property var modelData
forceShowIcon: root.hasIcons
icon.name: modelData.iconName ? modelData.iconName : ""
monochromeIcon: modelData.monochromeIcon ?? true
text: modelData.text ? modelData.text : ""
onClicked: {
if (modelData.action) modelData.action();
root.close();
onClicked: {
if (modelData.action) modelData.action();
root.close();
}
}
}
}
}
@@ -91,7 +91,7 @@ Loader {
fill: realContent
margins: -border.width
}
border.color: ColorUtils.transparentize(Looks.colors.bg0Border, Looks.shadowTransparency)
border.color: ColorUtils.transparentize(Looks.colors.ambientShadow, Looks.shadowTransparency)
border.width: root.ambientShadowWidth
color: "transparent"
radius: realContent.radius + border.width
@@ -0,0 +1,41 @@
import QtQuick
import qs
import qs.services
import qs.modules.common
import qs.modules.waffle.looks
BarButton {
id: root
visible: Updates.available && Updates.updateAdvised
padding: 4
contentItem: Item {
anchors.centerIn: parent
implicitWidth: iconContent.implicitWidth
implicitHeight: iconContent.implicitHeight
FluentIcon {
id: iconContent
anchors.centerIn: parent
icon: "arrow-sync"
Rectangle {
anchors {
right: parent.right
bottom: parent.bottom
margins: 1
}
implicitWidth: 8
implicitHeight: implicitWidth
radius: height / 2
color: Updates.updateStronglyAdvised ? Looks.colors.warning : Looks.colors.accent
}
}
}
BarToolTip {
extraVisibleCondition: root.shouldShowTooltip
text: Translation.tr("Get the latest features and security improvements with\nthe newest feature update.\n\n%1 packages").arg(Updates.count)
}
}
@@ -68,6 +68,7 @@ Rectangle {
shown: Config.options.waffles.bar.leftAlignApps
sourceComponent: WidgetsButton {}
}
UpdatesButton {}
SystemButton {}
TimeButton {}
}
@@ -87,6 +87,13 @@ AppButton {
id: contextMenu
model: [
...((root.desktopEntry?.actions.length > 0) ? root.desktopEntry.actions.map(action =>({
iconName: action.icon,
text: action.name,
action: () => {
action.execute()
}
})).concat({ type: "separator" }) : []),
{
iconName: root.iconName,
text: root.desktopEntry ? root.desktopEntry.name : StringUtils.toTitleCase(appEntry.appId),
@@ -70,7 +70,7 @@ PopupWindow {
fill: contentItem
margins: -border.width
}
border.color: ColorUtils.transparentize(Looks.colors.bg0Border, Looks.shadowTransparency)
border.color: ColorUtils.transparentize(Looks.colors.ambientShadow, Looks.shadowTransparency)
border.width: 1
color: "transparent"
radius: Looks.radius.large + border.width