-
Notifications
You must be signed in to change notification settings - Fork 255
feat(habitica): add Habitica task dashboard #799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Vasqs
wants to merge
2
commits into
noctalia-dev:main
Choose a base branch
from
Vasqs:feat/habitica-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| settings.json | ||
| cache/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| import QtQuick | ||
| import QtQuick.Layouts | ||
| import Quickshell | ||
| import qs.Commons | ||
| import qs.Services.UI | ||
| import qs.Widgets | ||
|
|
||
| NIconButton { | ||
| id: root | ||
|
|
||
| property var pluginApi: null | ||
| property ShellScreen screen | ||
| property string widgetId: "" | ||
| property string section: "" | ||
| property int sectionWidgetIndex: -1 | ||
| property int sectionWidgetsCount: 0 | ||
|
|
||
| readonly property var main: pluginApi?.mainInstance | ||
| readonly property bool configured: main?.isConfigured ?? false | ||
| readonly property bool hasError: main?.hasError ?? false | ||
| readonly property bool showNotificationBadge: pluginApi?.pluginSettings?.showNotificationBadge ?? true | ||
| readonly property bool colorizationEnabled: pluginApi?.pluginSettings?.colorizationEnabled ?? false | ||
| readonly property string colorizationIcon: pluginApi?.pluginSettings?.colorizationIcon ?? "Primary" | ||
| readonly property string colorizationBadge: pluginApi?.pluginSettings?.colorizationBadge ?? "Error" | ||
| readonly property string colorizationBadgeText: pluginApi?.pluginSettings?.colorizationBadgeText ?? "Primary" | ||
|
|
||
| function getThemeColor(key) { | ||
| switch (key) { | ||
| case "Primary": return Color.mPrimary | ||
| case "Secondary": return Color.mSecondary | ||
| case "Tertiary": return Color.mTertiary | ||
| case "Error": return Color.mError | ||
| default: return Color.mOnSurface | ||
| } | ||
| } | ||
|
|
||
| icon: "sword" | ||
| tooltipText: buildTooltip() | ||
| tooltipDirection: BarService.getTooltipDirection(screen?.name) | ||
| baseSize: Style.getCapsuleHeightForScreen(screen?.name) | ||
| applyUiScale: false | ||
| customRadius: Style.radiusL | ||
| colorBg: Style.capsuleColor | ||
| colorFg: { | ||
| if (hasError) return Color.mError | ||
| if (!configured) return Color.mOnSurfaceVariant | ||
| if (colorizationEnabled && colorizationIcon !== "None") return getThemeColor(colorizationIcon) | ||
| return Color.mOnSurface | ||
| } | ||
| colorBgHover: Color.mHover | ||
| colorFgHover: Color.mOnHover | ||
| colorBorder: "transparent" | ||
| colorBorderHover: "transparent" | ||
|
|
||
| border.color: Style.capsuleBorderColor | ||
| border.width: Style.capsuleBorderWidth | ||
|
|
||
| NPopupContextMenu { | ||
| id: contextMenu | ||
|
|
||
| model: [ | ||
| { | ||
| "label": pluginApi?.tr("menu.openPanel"), | ||
| "action": "open-panel", | ||
| "icon": "sword", | ||
| "enabled": root.configured | ||
| }, | ||
| { | ||
| "label": pluginApi?.tr("menu.refresh"), | ||
| "action": "refresh", | ||
| "icon": "refresh", | ||
| "enabled": root.configured && !(root.main?.isLoading ?? false) | ||
| }, | ||
| { | ||
| "label": pluginApi?.tr("menu.openSettings"), | ||
| "action": "open-settings", | ||
| "icon": "settings" | ||
| }, | ||
| { | ||
| "label": pluginApi?.tr("menu.openHabitica"), | ||
| "action": "open-habitica", | ||
| "icon": "external-link" | ||
| } | ||
| ] | ||
|
|
||
| onTriggered: action => { | ||
| contextMenu.close() | ||
| PanelService.closeContextMenu(screen) | ||
|
|
||
| if (action === "open-panel") { | ||
| pluginApi.openPanel(root.screen, root) | ||
| } else if (action === "refresh") { | ||
| if (root.main && root.configured) { | ||
| root.main.refresh() | ||
| ToastService.showNotice(pluginApi?.tr("toast.refreshing")) | ||
| } | ||
| } else if (action === "open-settings") { | ||
| if (pluginApi?.manifest) { | ||
| BarService.openPluginSettings(screen, pluginApi.manifest) | ||
| } | ||
| } else if (action === "open-habitica") { | ||
| Qt.openUrlExternally("https://habitica.com") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Rectangle { | ||
| id: badge | ||
| visible: root.showNotificationBadge && root.configured && (root.main?.pendingCount || 0) > 0 | ||
| anchors.right: parent.right | ||
| anchors.top: parent.top | ||
| anchors.rightMargin: 2 * Style.uiScaleRatio | ||
| anchors.topMargin: 2 * Style.uiScaleRatio | ||
| z: 2 | ||
| height: 14 * Style.uiScaleRatio | ||
| width: Math.max(height, badgeText.implicitWidth + 6 * Style.uiScaleRatio) | ||
| radius: height / 2 | ||
| color: root.colorizationEnabled && root.colorizationBadge !== "None" ? root.getThemeColor(root.colorizationBadge) : Color.mError | ||
| border.color: Color.mSurface | ||
| border.width: Style.uiScaleRatio | ||
|
|
||
| NText { | ||
| id: badgeText | ||
| anchors.centerIn: parent | ||
| text: { | ||
| var count = root.main?.pendingCount || 0 | ||
| return count > 99 ? "99+" : count.toString() | ||
| } | ||
| pointSize: Style.fontSizeXS * 0.8 | ||
| font.weight: Font.Bold | ||
| color: root.colorizationEnabled && root.colorizationBadgeText !== "None" ? root.getThemeColor(root.colorizationBadgeText) : Color.mOnError | ||
| } | ||
| } | ||
|
|
||
| onClicked: { | ||
| if (!root.configured) { | ||
| ToastService.showNotice(pluginApi?.tr("toast.configure")) | ||
| return | ||
| } | ||
| pluginApi.openPanel(root.screen, this) | ||
| } | ||
|
|
||
| onRightClicked: { | ||
| PanelService.showContextMenu(contextMenu, root, screen) | ||
| } | ||
|
|
||
| function buildTooltip() { | ||
| if (!configured) return pluginApi?.tr("tooltip.configure") | ||
| if (hasError) return pluginApi?.tr("tooltip.error") + (main?.errorMessage || pluginApi?.tr("tooltip.unknownError")) | ||
| if (main?.isLoading) return pluginApi?.tr("tooltip.loading") | ||
|
|
||
| var tooltip = "Habitica - " + (main?.displayName() || pluginApi?.tr("tooltip.player")) | ||
| tooltip += "\n" + (main?.levelText() || pluginApi?.tr("tooltip.levelFallback")) | ||
| var hpFallback = pluginApi?.tr("tooltip.hpFallback") | ||
| var xpFallback = pluginApi?.tr("tooltip.xpFallback") | ||
| var goldFallback = pluginApi?.tr("tooltip.goldFallback") | ||
| tooltip += "\n" + (main?.hpText() || hpFallback) + " - " + (main?.xpText() || xpFallback) + " - " + (main?.goldText() || goldFallback) | ||
| tooltip += "\n" + (main?.dueDailiesCount || 0) + pluginApi?.tr("tooltip.dailies") + (main?.dueTodosCount || 0) + pluginApi?.tr("tooltip.todos") | ||
|
|
||
| if (main?.lastFetchTimestamp) { | ||
| var age = Math.floor(Date.now() / 1000) - main.lastFetchTimestamp | ||
| var minutes = Math.floor(age / 60) | ||
| if (minutes < 1) tooltip += "\n" + pluginApi?.tr("tooltip.updatedNow") | ||
| else if (minutes < 60) tooltip += "\n" + pluginApi?.tr("tooltip.updatedMinutesPrefix") + minutes + pluginApi?.tr("tooltip.updatedMinutesSuffix") | ||
| else tooltip += "\n" + pluginApi?.tr("tooltip.updatedMinutesPrefix") + Math.floor(minutes / 60) + pluginApi?.tr("tooltip.updatedHoursSuffix") | ||
| } | ||
|
|
||
| tooltip += "\n\n" + pluginApi?.tr("tooltip.actionsHint") | ||
| return tooltip | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| import QtQuick | ||
| import qs.Commons | ||
|
|
||
| Item { | ||
| id: root | ||
|
|
||
| property var user: ({}) | ||
| property var stats: user?.stats || ({}) | ||
| property var layers: [] | ||
|
|
||
| readonly property string assetBaseUrl: "https://habitica-assets.s3.amazonaws.com/mobileApp/images/" | ||
| readonly property bool hasAvatarData: !!user?.preferences | ||
| readonly property string currentMount: user?.items?.currentMount || "" | ||
| readonly property string currentPet: user?.items?.currentPet || "" | ||
| readonly property bool hasCurrentMount: currentMount !== "" | ||
| readonly property bool hasCurrentPet: currentPet !== "" | ||
| readonly property real sourceWidth: 141 | ||
| readonly property real sourceHeight: 147 | ||
| readonly property real scaleRatio: Math.min(width / sourceWidth, height / sourceHeight) | ||
| readonly property real characterPaddingTop: hasCurrentMount ? 0 : 24 | ||
| readonly property real mountOffsetY: hasCurrentMount ? 18 : 0 | ||
| readonly property real avatarLayerOffsetY: hasCurrentMount && currentMount.indexOf("Kangaroo") !== -1 ? 24 : 0 | ||
| readonly property string avatarSignature: JSON.stringify({ | ||
| preferences: user?.preferences || ({}), | ||
| currentMount: currentMount, | ||
| currentPet: currentPet, | ||
| gear: user?.items?.gear || ({}) | ||
| }) | ||
|
|
||
| function pref(path, fallback) { | ||
| var current = user?.preferences || ({}) | ||
| for (var i = 0; i < path.length; i++) { | ||
| if (current === undefined || current === null || current[path[i]] === undefined) return fallback | ||
| current = current[path[i]] | ||
| } | ||
| return current | ||
| } | ||
|
|
||
| function spriteSource(sprite) { | ||
| return sprite ? assetBaseUrl + sprite + ".png" : "" | ||
| } | ||
|
|
||
| function addSprite(list, sprite) { | ||
| if (sprite && sprite !== "undefined" && sprite !== "null" && list.indexOf(sprite) === -1) list.push(sprite) | ||
| } | ||
|
|
||
| function addGearSprite(list, sprite) { | ||
| if (!sprite || sprite.match(/_base_0$/)) return | ||
| addSprite(list, sprite) | ||
| } | ||
|
|
||
| function gear(slot) { | ||
| var items = user?.items || ({}) | ||
| var allGear = items.gear || ({}) | ||
| var set = pref(["costume"], false) ? "costume" : "equipped" | ||
| var current = allGear[set] || allGear.equipped || ({}) | ||
| return current[slot] || "" | ||
| } | ||
|
|
||
| function hair(slot) { | ||
| var value = pref(["hair", slot], 0) | ||
| if (!value) return "" | ||
| return "hair_" + slot + "_" + value + "_" + pref(["hair", "color"], "brown") | ||
| } | ||
|
|
||
| function mountBody() { | ||
| return hasCurrentMount ? "Mount_Body_" + currentMount : "" | ||
| } | ||
|
|
||
| function mountHead() { | ||
| return hasCurrentMount ? "Mount_Head_" + currentMount : "" | ||
| } | ||
|
|
||
| function pet() { | ||
| return hasCurrentPet ? "Pet-" + currentPet : "" | ||
| } | ||
|
|
||
| function characterLayers() { | ||
| var list = [] | ||
| var size = pref(["size"], "slim") | ||
| var chair = pref(["chair"], "none") | ||
| var armor = gear("armor") | ||
| var flower = pref(["hair", "flower"], 0) | ||
|
|
||
| if (chair && chair !== "none") addSprite(list, "chair_" + chair) | ||
| addGearSprite(list, gear("back")) | ||
| addSprite(list, "skin_" + pref(["skin"], "ddc994") + (pref(["sleep"], false) ? "_sleep" : "")) | ||
| addSprite(list, size + "_shirt_" + pref(["shirt"], "blue")) | ||
| addSprite(list, "head_0") | ||
| if (armor) addSprite(list, size + "_" + armor) | ||
| addGearSprite(list, gear("back_collar")) | ||
| addSprite(list, hair("bangs")) | ||
| addSprite(list, hair("base")) | ||
| addSprite(list, hair("mustache")) | ||
| addSprite(list, hair("beard")) | ||
| addGearSprite(list, gear("body")) | ||
| addGearSprite(list, gear("eyewear")) | ||
| addGearSprite(list, gear("head")) | ||
| addGearSprite(list, gear("headAccessory")) | ||
| if (flower) addSprite(list, "hair_flower_" + flower) | ||
| addGearSprite(list, gear("shield")) | ||
| addGearSprite(list, gear("weapon")) | ||
| return list | ||
| } | ||
|
|
||
| Item { | ||
| id: avatarViewport | ||
| anchors.fill: parent | ||
| visible: root.hasAvatarData | ||
|
|
||
| Item { | ||
| id: avatarCanvas | ||
| width: root.sourceWidth | ||
| height: root.sourceHeight | ||
| x: (root.width - width * root.scaleRatio) / 2 | ||
| y: (root.height - height * root.scaleRatio) / 2 | ||
| scale: root.scaleRatio | ||
| transformOrigin: Item.TopLeft | ||
|
|
||
| Image { | ||
| x: 0 | ||
| y: 0 | ||
| z: 0 | ||
| width: root.sourceWidth | ||
| height: root.sourceHeight | ||
| source: root.spriteSource("background_" + root.pref(["background"], "violet")) | ||
| asynchronous: true | ||
| cache: true | ||
| smooth: false | ||
| } | ||
| } | ||
|
|
||
| Item { | ||
| id: characterSprites | ||
| parent: avatarCanvas | ||
| x: 24 | ||
| y: root.characterPaddingTop | ||
| width: 90 | ||
| height: 90 | ||
|
|
||
| Image { | ||
| x: 0 | ||
| y: root.mountOffsetY | ||
| z: 1 | ||
| source: root.spriteSource(root.mountBody()) | ||
| asynchronous: true | ||
| cache: true | ||
| smooth: false | ||
| visible: root.hasCurrentMount | ||
| } | ||
|
|
||
| Repeater { | ||
| model: root.layers | ||
|
|
||
| Image { | ||
| x: 0 | ||
| y: root.avatarLayerOffsetY | ||
| z: 2 | ||
| source: root.spriteSource(modelData) | ||
| asynchronous: true | ||
| cache: true | ||
| smooth: false | ||
| } | ||
| } | ||
|
|
||
| Image { | ||
| x: 0 | ||
| y: root.mountOffsetY | ||
| z: 3 | ||
| source: root.spriteSource(root.mountHead()) | ||
| asynchronous: true | ||
| cache: true | ||
| smooth: false | ||
| visible: root.hasCurrentMount | ||
| } | ||
|
|
||
| } | ||
|
|
||
| Image { | ||
| parent: avatarCanvas | ||
| x: 0 | ||
| y: root.sourceHeight - implicitHeight | ||
| z: 4 | ||
| source: root.spriteSource(root.pet()) | ||
| asynchronous: true | ||
| cache: true | ||
| smooth: false | ||
| visible: root.hasCurrentPet | ||
| } | ||
| } | ||
|
|
||
| onAvatarSignatureChanged: layers = characterLayers() | ||
|
|
||
| Component.onCompleted: layers = characterLayers() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 vasqs | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
settings.jsonfile is already included to get ignored in the root of this repository.