forked from Shinonome/dots-hyprland
wbar: add updates indicator
This commit is contained in:
@@ -536,6 +536,12 @@ Singleton {
|
||||
}
|
||||
property bool secondPrecision: false
|
||||
}
|
||||
|
||||
property JsonObject updates: JsonObject {
|
||||
property int checkInterval: 120 // minutes
|
||||
property int adviseUpdateThreshold: 75 // packages
|
||||
property int stronglyAdviseUpdateThreshold: 200 // packages
|
||||
}
|
||||
|
||||
property JsonObject wallpaperSelector: JsonObject {
|
||||
property bool useSystemFileDialog: false
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,6 +20,7 @@ Singleton {
|
||||
property real shadowTransparency: 0.6
|
||||
colors: QtObject {
|
||||
id: colors
|
||||
property color ambientShadow: ColorUtils.transparentize("#000000", 0.4)
|
||||
property color bg0: root.dark ? "#1C1C1C" : "#EEEEEE"
|
||||
property color bg0Border: root.dark ? "#404040" : "#BEBEBE"
|
||||
property color bg1: root.dark ? "#2C2C2C" : "#F7F7F7"
|
||||
@@ -34,6 +35,7 @@ Singleton {
|
||||
property color fg1: root.dark ? "#D1D1D1" : "#626262"
|
||||
property color danger: "#C42B1C"
|
||||
property color dangerActive: "#B62D1F"
|
||||
property color warning: "#FF9900"
|
||||
// property color accent: root.dark ? "#A5C6D8" : "#5377A3"
|
||||
property color accent: Appearance.m3colors.m3primary
|
||||
property color accentUnfocused: root.dark ? "#989898" : "#848484"
|
||||
|
||||
@@ -14,6 +14,7 @@ Button {
|
||||
property color colBackground: ColorUtils.transparentize(Looks.colors.bg1)
|
||||
|
||||
property alias monochromeIcon: buttonIcon.monochrome
|
||||
property bool forceShowIcon: false
|
||||
|
||||
property var altAction: () => {}
|
||||
property var middleClickAction: () => {}
|
||||
@@ -71,12 +72,12 @@ Button {
|
||||
spacing: 12
|
||||
FluentIcon {
|
||||
id: buttonIcon
|
||||
visible: root.icon.name !== "" || root.forceShowIcon
|
||||
monochrome: true
|
||||
implicitSize: 16
|
||||
Layout.leftMargin: 6
|
||||
Layout.fillWidth: false
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
visible: root.icon.name !== ""
|
||||
icon: root.icon.name
|
||||
}
|
||||
WText {
|
||||
|
||||
@@ -10,14 +10,14 @@ import qs.modules.waffle.looks
|
||||
PopupToolTip {
|
||||
id: root
|
||||
|
||||
property real padding: 2
|
||||
verticalPadding: padding
|
||||
horizontalPadding: padding
|
||||
property real visualMargin: 11
|
||||
verticalPadding: visualMargin
|
||||
horizontalPadding: visualMargin
|
||||
|
||||
contentItem: Item {
|
||||
anchors.centerIn: parent
|
||||
implicitWidth: realContent.implicitWidth + root.verticalPadding * 2
|
||||
implicitHeight: realContent.implicitHeight + root.horizontalPadding * 2
|
||||
implicitWidth: realContent.implicitWidth + 2 * 2
|
||||
implicitHeight: realContent.implicitHeight + 2 * 2
|
||||
|
||||
Rectangle {
|
||||
id: ambientShadow
|
||||
@@ -26,7 +26,7 @@ PopupToolTip {
|
||||
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: 1
|
||||
color: "transparent"
|
||||
radius: realContent.radius + border.width
|
||||
|
||||
Reference in New Issue
Block a user