mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-11 23:09:42 -04:00
Compare commits
55 Commits
22f384b821
...
v1.4.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db4de55338 | ||
|
|
37ecbbbbde | ||
|
|
d6a6d2a438 | ||
|
|
bf1c6eec74 | ||
|
|
0ddae80584 | ||
|
|
5c96c03bfa | ||
|
|
dfe36e47d8 | ||
|
|
63e1b75e57 | ||
|
|
29efdd8598 | ||
|
|
34d03cf11b | ||
|
|
c339389d44 | ||
|
|
af5f6eb656 | ||
|
|
a6d28e2553 | ||
|
|
6213267908 | ||
|
|
d084114149 | ||
|
|
f6d99eca0d | ||
|
|
722eb3289e | ||
|
|
b7f2bdcb2d | ||
|
|
11c20db6e6 | ||
|
|
8a4e3f8bb1 | ||
|
|
bc8fe97c13 | ||
|
|
47262155aa | ||
|
|
dd4c41a6b2 | ||
|
|
92a25fdb6a | ||
|
|
d6650be008 | ||
|
|
2646e7b19a | ||
|
|
4133f11d82 | ||
|
|
22ed740394 | ||
|
|
063299a434 | ||
|
|
44d836c975 | ||
|
|
da437e77fb | ||
|
|
34a6bbfb32 | ||
|
|
9ed53bac9e | ||
|
|
3a6752c3d2 | ||
|
|
ef19568dd7 | ||
|
|
f280cd9d3b | ||
|
|
cf4ce3c476 | ||
|
|
ae59e53c4c | ||
|
|
7e0d661f63 | ||
|
|
0b33d3f905 | ||
|
|
d62bdda56b | ||
|
|
5841b38cd9 | ||
|
|
83e2b5a7a6 | ||
|
|
2f863f64ee | ||
|
|
1a8b397cfd | ||
|
|
196c421b75 | ||
|
|
8399d64c2d | ||
|
|
c530eab303 | ||
|
|
45b6362dd3 | ||
|
|
50b77dcfc3 | ||
|
|
be8f3adf01 | ||
|
|
75a8c171ea | ||
|
|
466ff59573 | ||
|
|
053bb91927 | ||
|
|
2c9b22c016 |
6
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
6
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -45,9 +45,9 @@ body:
|
||||
- type: textarea
|
||||
id: dms_doctor
|
||||
attributes:
|
||||
label: dms doctor -v
|
||||
description: Output of `dms doctor -v` command
|
||||
placeholder: Paste the output of `dms doctor -v` here
|
||||
label: dms doctor -vC
|
||||
description: Output of `dms doctor -vC` command
|
||||
placeholder: Paste the output of `dms doctor -vC` here
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
||||
6
.github/ISSUE_TEMPLATE/support_request.yml
vendored
6
.github/ISSUE_TEMPLATE/support_request.yml
vendored
@@ -30,9 +30,9 @@ body:
|
||||
- type: textarea
|
||||
id: dms_doctor
|
||||
attributes:
|
||||
label: dms doctor -v
|
||||
description: Output of `dms doctor -v` command
|
||||
placeholder: Paste the output of `dms doctor -v` here
|
||||
label: dms doctor -vC
|
||||
description: Output of `dms doctor -vC` command
|
||||
placeholder: Paste the output of `dms doctor -vC` here
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
|
||||
@@ -19,7 +19,7 @@ Built with [Quickshell](https://quickshell.org/) and [Go](https://go.dev/)
|
||||
|
||||
</div>
|
||||
|
||||
DankMaterialShell is a complete desktop shell for [niri](https://github.com/YaLTeR/niri), [Hyprland](https://hyprland.org/), [MangoWC](https://github.com/DreamMaoMao/mangowc), [Sway](https://swaywm.org), [labwc](https://labwc.github.io/), [Scroll](https://github.com/dawsers/scroll), and other Wayland compositors. It replaces waybar, swaylock, swayidle, mako, fuzzel, polkit, and everything else you'd normally stitch together to make a desktop.
|
||||
DankMaterialShell is a complete desktop shell for [niri](https://github.com/YaLTeR/niri), [Hyprland](https://hyprland.org/), [MangoWC](https://github.com/DreamMaoMao/mangowc), [Sway](https://swaywm.org), [labwc](https://labwc.github.io/), [Scroll](https://github.com/dawsers/scroll), [Miracle WM](https://github.com/miracle-wm-org/miracle-wm), and other Wayland compositors. It replaces waybar, swaylock, swayidle, mako, fuzzel, polkit, and everything else you'd normally stitch together to make a desktop.
|
||||
|
||||
## Repository Structure
|
||||
|
||||
@@ -105,7 +105,7 @@ Extend functionality with the [plugin registry](https://plugins.danklinux.com).
|
||||
|
||||
## Supported Compositors
|
||||
|
||||
Works best with [niri](https://github.com/YaLTeR/niri), [Hyprland](https://hyprland.org/), [Sway](https://swaywm.org/), [MangoWC](https://github.com/DreamMaoMao/mangowc), [labwc](https://labwc.github.io/), and [Scroll](https://github.com/dawsers/scroll) with full workspace switching, overview integration, and monitor management. Other Wayland compositors work with reduced features.
|
||||
Works best with [niri](https://github.com/YaLTeR/niri), [Hyprland](https://hyprland.org/), [Sway](https://swaywm.org/), [MangoWC](https://github.com/DreamMaoMao/mangowc), [labwc](https://labwc.github.io/), [Scroll](https://github.com/dawsers/scroll), and [Miracle WM](https://github.com/miracle-wm-org/miracle-wm) with full workspace switching, overview integration, and monitor management. Other Wayland compositors work with reduced features.
|
||||
|
||||
[Compositor configuration guide](https://danklinux.com/docs/dankmaterialshell/compositors)
|
||||
|
||||
|
||||
@@ -649,40 +649,73 @@ func checkI2CAvailability() checkResult {
|
||||
return checkResult{catOptionalFeatures, "I2C/DDC", statusOK, fmt.Sprintf("%d monitor(s) detected", len(devices)), "External monitor brightness control", doctorDocsURL + "#optional-features"}
|
||||
}
|
||||
|
||||
func checkKImageFormats() checkResult {
|
||||
func checkImageFormatPlugins() []checkResult {
|
||||
url := doctorDocsURL + "#optional-features"
|
||||
desc := "Extra image format support (AVIF, HEIF, JXL)"
|
||||
|
||||
pluginDir := findQtPluginDir()
|
||||
if pluginDir == "" {
|
||||
return checkResult{catOptionalFeatures, "kimageformats", statusInfo, "Cannot detect (qtpaths not found)", desc, url}
|
||||
}
|
||||
|
||||
imageFormatsDir := filepath.Join(pluginDir, "imageformats")
|
||||
keyPlugins := []struct{ file, format string }{
|
||||
{"kimg_avif.so", "AVIF"},
|
||||
{"kimg_heif.so", "HEIF"},
|
||||
{"kimg_jxl.so", "JXL"},
|
||||
{"kimg_exr.so", "EXR"},
|
||||
}
|
||||
|
||||
var found []string
|
||||
for _, p := range keyPlugins {
|
||||
if _, err := os.Stat(filepath.Join(imageFormatsDir, p.file)); err == nil {
|
||||
found = append(found, p.format)
|
||||
return []checkResult{
|
||||
{catOptionalFeatures, "qt6-imageformats", statusInfo, "Cannot detect (plugin dir not found)", "WebP, TIFF, JP2 support", url},
|
||||
{catOptionalFeatures, "kimageformats", statusInfo, "Cannot detect (plugin dir not found)", "AVIF, HEIF, JXL support", url},
|
||||
}
|
||||
}
|
||||
|
||||
if len(found) == 0 {
|
||||
return checkResult{catOptionalFeatures, "kimageformats", statusWarn, "Not installed", desc, url}
|
||||
imageFormatsDir := filepath.Join(pluginDir, "imageformats")
|
||||
|
||||
type pluginCheck struct {
|
||||
name string
|
||||
desc string
|
||||
plugins []struct{ file, format string }
|
||||
}
|
||||
|
||||
details := ""
|
||||
if doctorVerbose {
|
||||
details = fmt.Sprintf("Formats: %s (%s)", strings.Join(found, ", "), imageFormatsDir)
|
||||
checks := []pluginCheck{
|
||||
{
|
||||
name: "qt6-imageformats",
|
||||
desc: "WebP, TIFF, GIF, JP2 support",
|
||||
plugins: []struct{ file, format string }{
|
||||
{"libqwebp.so", "WebP"},
|
||||
{"libqtiff.so", "TIFF"},
|
||||
{"libqgif.so", "GIF"},
|
||||
{"libqjp2.so", "JP2"},
|
||||
{"libqicns.so", "ICNS"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "kimageformats",
|
||||
desc: "AVIF, HEIF, JXL support",
|
||||
plugins: []struct{ file, format string }{
|
||||
{"kimg_avif.so", "AVIF"},
|
||||
{"kimg_heif.so", "HEIF"},
|
||||
{"kimg_jxl.so", "JXL"},
|
||||
{"kimg_exr.so", "EXR"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return checkResult{catOptionalFeatures, "kimageformats", statusOK, fmt.Sprintf("Installed (%d formats)", len(found)), details, url}
|
||||
var results []checkResult
|
||||
for _, c := range checks {
|
||||
var found []string
|
||||
for _, p := range c.plugins {
|
||||
if _, err := os.Stat(filepath.Join(imageFormatsDir, p.file)); err == nil {
|
||||
found = append(found, p.format)
|
||||
}
|
||||
}
|
||||
|
||||
var result checkResult
|
||||
switch {
|
||||
case len(found) == 0:
|
||||
result = checkResult{catOptionalFeatures, c.name, statusWarn, "Not installed", c.desc, url}
|
||||
default:
|
||||
details := ""
|
||||
if doctorVerbose {
|
||||
details = fmt.Sprintf("Formats: %s (%s)", strings.Join(found, ", "), imageFormatsDir)
|
||||
}
|
||||
result = checkResult{catOptionalFeatures, c.name, statusOK, fmt.Sprintf("Installed (%d formats)", len(found)), details, url}
|
||||
}
|
||||
results = append(results, result)
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
func findQtPluginDir() string {
|
||||
@@ -773,7 +806,7 @@ func checkOptionalDependencies() []checkResult {
|
||||
results = append(results, checkResult{catOptionalFeatures, "cups-pk-helper", cupsPkStatus, cupsPkMsg, "Printer management", optionalFeaturesURL})
|
||||
|
||||
results = append(results, checkI2CAvailability())
|
||||
results = append(results, checkKImageFormats())
|
||||
results = append(results, checkImageFormatPlugins()...)
|
||||
|
||||
terminals := []string{"ghostty", "kitty", "alacritty", "foot", "wezterm"}
|
||||
if idx := slices.IndexFunc(terminals, utils.CommandExists); idx >= 0 {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/keybinds"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/keybinds/providers"
|
||||
@@ -82,24 +83,35 @@ func init() {
|
||||
func initializeProviders() {
|
||||
registry := keybinds.GetDefaultRegistry()
|
||||
|
||||
hyprlandProvider := providers.NewHyprlandProvider("$HOME/.config/hypr")
|
||||
hyprlandProvider := providers.NewHyprlandProvider("")
|
||||
if err := registry.Register(hyprlandProvider); err != nil {
|
||||
log.Warnf("Failed to register Hyprland provider: %v", err)
|
||||
}
|
||||
|
||||
mangowcProvider := providers.NewMangoWCProvider("$HOME/.config/mango")
|
||||
mangowcProvider := providers.NewMangoWCProvider("")
|
||||
if err := registry.Register(mangowcProvider); err != nil {
|
||||
log.Warnf("Failed to register MangoWC provider: %v", err)
|
||||
}
|
||||
|
||||
scrollProvider := providers.NewSwayProvider("$HOME/.config/scroll")
|
||||
if err := registry.Register(scrollProvider); err != nil {
|
||||
log.Warnf("Failed to register Scroll provider: %v", err)
|
||||
configDir, _ := os.UserConfigDir()
|
||||
|
||||
if configDir != "" {
|
||||
scrollProvider := providers.NewSwayProvider(filepath.Join(configDir, "scroll"))
|
||||
if err := registry.Register(scrollProvider); err != nil {
|
||||
log.Warnf("Failed to register Scroll provider: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
swayProvider := providers.NewSwayProvider("$HOME/.config/sway")
|
||||
if err := registry.Register(swayProvider); err != nil {
|
||||
log.Warnf("Failed to register Sway provider: %v", err)
|
||||
miracleProvider := providers.NewMiracleProvider("")
|
||||
if err := registry.Register(miracleProvider); err != nil {
|
||||
log.Warnf("Failed to register Miracle WM provider: %v", err)
|
||||
}
|
||||
|
||||
if configDir != "" {
|
||||
swayProvider := providers.NewSwayProvider(filepath.Join(configDir, "sway"))
|
||||
if err := registry.Register(swayProvider); err != nil {
|
||||
log.Warnf("Failed to register Sway provider: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
niriProvider := providers.NewNiriProvider("")
|
||||
@@ -144,6 +156,8 @@ func makeProviderWithPath(name, path string) keybinds.Provider {
|
||||
return providers.NewSwayProvider(path)
|
||||
case "scroll":
|
||||
return providers.NewSwayProvider(path)
|
||||
case "miracle":
|
||||
return providers.NewMiracleProvider(path)
|
||||
case "niri":
|
||||
return providers.NewNiriProvider(path)
|
||||
default:
|
||||
|
||||
@@ -13,16 +13,16 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ssOutputName string
|
||||
ssIncludeCursor bool
|
||||
ssFormat string
|
||||
ssQuality int
|
||||
ssOutputDir string
|
||||
ssFilename string
|
||||
ssNoClipboard bool
|
||||
ssNoFile bool
|
||||
ssNoNotify bool
|
||||
ssStdout bool
|
||||
ssOutputName string
|
||||
ssCursor string
|
||||
ssFormat string
|
||||
ssQuality int
|
||||
ssOutputDir string
|
||||
ssFilename string
|
||||
ssNoClipboard bool
|
||||
ssNoFile bool
|
||||
ssNoNotify bool
|
||||
ssStdout bool
|
||||
)
|
||||
|
||||
var screenshotCmd = &cobra.Command{
|
||||
@@ -52,7 +52,7 @@ Examples:
|
||||
dms screenshot last # Last region (pre-selected)
|
||||
dms screenshot --no-clipboard # Save file only
|
||||
dms screenshot --no-file # Clipboard only
|
||||
dms screenshot --cursor # Include cursor
|
||||
dms screenshot --cursor=on # Include cursor
|
||||
dms screenshot -f jpg -q 85 # JPEG with quality 85`,
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ var notifyActionCmd = &cobra.Command{
|
||||
|
||||
func init() {
|
||||
screenshotCmd.PersistentFlags().StringVarP(&ssOutputName, "output", "o", "", "Output name for 'output' mode")
|
||||
screenshotCmd.PersistentFlags().BoolVar(&ssIncludeCursor, "cursor", false, "Include cursor in screenshot")
|
||||
screenshotCmd.PersistentFlags().StringVar(&ssCursor, "cursor", "off", "Include cursor in screenshot (on/off)")
|
||||
screenshotCmd.PersistentFlags().StringVarP(&ssFormat, "format", "f", "png", "Output format (png, jpg, ppm)")
|
||||
screenshotCmd.PersistentFlags().IntVarP(&ssQuality, "quality", "q", 90, "JPEG quality (1-100)")
|
||||
screenshotCmd.PersistentFlags().StringVarP(&ssOutputDir, "dir", "d", "", "Output directory")
|
||||
@@ -136,7 +136,9 @@ func getScreenshotConfig(mode screenshot.Mode) screenshot.Config {
|
||||
config := screenshot.DefaultConfig()
|
||||
config.Mode = mode
|
||||
config.OutputName = ssOutputName
|
||||
config.IncludeCursor = ssIncludeCursor
|
||||
if strings.EqualFold(ssCursor, "on") {
|
||||
config.Cursor = screenshot.CursorOn
|
||||
}
|
||||
config.Clipboard = !ssNoClipboard
|
||||
config.SaveFile = !ssNoFile
|
||||
config.Notify = !ssNoNotify
|
||||
|
||||
@@ -210,7 +210,7 @@ func runShellInteractive(session bool) {
|
||||
cmd.Env = append(cmd.Env, "QT_QPA_PLATFORMTHEME_QT6=gtk3")
|
||||
}
|
||||
if os.Getenv("QT_QPA_PLATFORM") == "" {
|
||||
cmd.Env = append(cmd.Env, "QT_QPA_PLATFORM=wayland")
|
||||
cmd.Env = append(cmd.Env, "QT_QPA_PLATFORM=wayland;xcb")
|
||||
}
|
||||
|
||||
cmd.Stdin = os.Stdin
|
||||
@@ -450,7 +450,7 @@ func runShellDaemon(session bool) {
|
||||
cmd.Env = append(cmd.Env, "QT_QPA_PLATFORMTHEME_QT6=gtk3")
|
||||
}
|
||||
if os.Getenv("QT_QPA_PLATFORM") == "" {
|
||||
cmd.Env = append(cmd.Env, "QT_QPA_PLATFORM=wayland")
|
||||
cmd.Env = append(cmd.Env, "QT_QPA_PLATFORM=wayland;xcb")
|
||||
}
|
||||
|
||||
devNull, err := os.OpenFile("/dev/null", os.O_RDWR, 0)
|
||||
|
||||
10
core/go.mod
10
core/go.mod
@@ -19,7 +19,7 @@ require (
|
||||
github.com/yuin/goldmark v1.7.16
|
||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
|
||||
go.etcd.io/bbolt v1.4.3
|
||||
golang.org/x/exp v0.0.0-20260211191109-2735e65f0518
|
||||
golang.org/x/exp v0.0.0-20260212183809-81e46e3db34a
|
||||
golang.org/x/image v0.36.0
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ require (
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/ProtonMail/go-crypto v1.3.0 // indirect
|
||||
github.com/clipperhouse/displaywidth v0.10.0 // indirect
|
||||
github.com/clipperhouse/uax29/v2 v2.6.0 // indirect
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
||||
github.com/cloudflare/circl v1.6.3 // indirect
|
||||
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.5 // indirect
|
||||
@@ -36,7 +36,7 @@ require (
|
||||
github.com/go-git/go-billy/v6 v6.0.0-20260209124918-37866f83c2d3 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.1 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
||||
github.com/kevinburke/ssh_config v1.4.0 // indirect
|
||||
github.com/kevinburke/ssh_config v1.6.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/pjbgf/sha1cd v0.5.0 // indirect
|
||||
github.com/sergi/go-diff v1.4.0 // indirect
|
||||
@@ -55,7 +55,7 @@ require (
|
||||
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
||||
github.com/go-git/go-git/v6 v6.0.0-20260210102253-e4d10f0e569a
|
||||
github.com/go-git/go-git/v6 v6.0.0-20260216160506-e6a3f881772f
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.3.0
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@@ -71,7 +71,7 @@ require (
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
golang.org/x/sys v0.41.0
|
||||
golang.org/x/text v0.34.0
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
// v0.0.1 tag is missing a LICENSE file; master has it.
|
||||
|
||||
16
core/go.sum
16
core/go.sum
@@ -40,8 +40,8 @@ github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSg
|
||||
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
||||
github.com/clipperhouse/displaywidth v0.10.0 h1:GhBG8WuerxjFQQYeuZAeVTuyxuX+UraiZGD4HJQ3Y8g=
|
||||
github.com/clipperhouse/displaywidth v0.10.0/go.mod h1:XqJajYsaiEwkxOj4bowCTMcT1SgvHo9flfF3jQasdbs=
|
||||
github.com/clipperhouse/uax29/v2 v2.6.0 h1:z0cDbUV+aPASdFb2/ndFnS9ts/WNXgTNNGFoKXuhpos=
|
||||
github.com/clipperhouse/uax29/v2 v2.6.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
|
||||
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
@@ -68,8 +68,8 @@ github.com/go-git/go-billy/v6 v6.0.0-20260209124918-37866f83c2d3 h1:UU7oARtwQ5g8
|
||||
github.com/go-git/go-billy/v6 v6.0.0-20260209124918-37866f83c2d3/go.mod h1:ZW9JC5gionMP1kv5uiaOaV23q0FFmNrVOV8VW+y/acc=
|
||||
github.com/go-git/go-git-fixtures/v5 v5.1.2-0.20260122163445-0622d7459a67 h1:3hutPZF+/FBjR/9MdsLJ7e1mlt9pwHgwxMW7CrbmWII=
|
||||
github.com/go-git/go-git-fixtures/v5 v5.1.2-0.20260122163445-0622d7459a67/go.mod h1:xKt0pNHST9tYHvbiLxSY27CQWFwgIxBJuDrOE0JvbZw=
|
||||
github.com/go-git/go-git/v6 v6.0.0-20260210102253-e4d10f0e569a h1:LLju0NuXQqR4WmGl1Dm86b9ZXsvXgLYbx/aaAjdQr6w=
|
||||
github.com/go-git/go-git/v6 v6.0.0-20260210102253-e4d10f0e569a/go.mod h1:IdXOePSwsMKGpuAbpczsm+f0Uy5fdHHjwgDPOymKA78=
|
||||
github.com/go-git/go-git/v6 v6.0.0-20260216160506-e6a3f881772f h1:TBkCJv9YwPOuXq1OG0r01bcxRrvs15Hp/DtZuPt4H6s=
|
||||
github.com/go-git/go-git/v6 v6.0.0-20260216160506-e6a3f881772f/go.mod h1:B88nWzfnhTlIikoJ4d84Nc9noKS5mJoA7SgDdkt0aPU=
|
||||
github.com/go-logfmt/logfmt v0.6.1 h1:4hvbpePJKnIzH1B+8OR/JPbTx37NktoI9LE2QZBBkvE=
|
||||
github.com/go-logfmt/logfmt v0.6.1/go.mod h1:EV2pOAQoZaT1ZXZbqDl5hrymndi4SY9ED9/z6CO0XAk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
@@ -86,8 +86,8 @@ github.com/holoplot/go-evdev v0.0.0-20250804134636-ab1d56a1fe83 h1:B+A58zGFuDrvE
|
||||
github.com/holoplot/go-evdev v0.0.0-20250804134636-ab1d56a1fe83/go.mod h1:iHAf8OIncO2gcQ8XOjS7CMJ2aPbX2Bs0wl5pZyanEqk=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/kevinburke/ssh_config v1.4.0 h1:6xxtP5bZ2E4NF5tuQulISpTO2z8XbtH8cg1PWkxoFkQ=
|
||||
github.com/kevinburke/ssh_config v1.4.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
|
||||
github.com/kevinburke/ssh_config v1.6.0 h1:J1FBfmuVosPHf5GRdltRLhPJtJpTlMdKTBjRgTaQBFY=
|
||||
github.com/kevinburke/ssh_config v1.6.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
@@ -152,8 +152,8 @@ go.etcd.io/bbolt v1.4.3/go.mod h1:tKQlpPaYCVFctUIgFKFnAlvbmB3tpy1vkTnDWohtc0E=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
|
||||
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
|
||||
golang.org/x/exp v0.0.0-20260211191109-2735e65f0518 h1:2E1CW7v5QB+Wi3N+MXllOtVR6SFmI8iJM8EdzgxrgrU=
|
||||
golang.org/x/exp v0.0.0-20260211191109-2735e65f0518/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA=
|
||||
golang.org/x/exp v0.0.0-20260212183809-81e46e3db34a h1:ovFr6Z0MNmU7nH8VaX5xqw+05ST2uO1exVfZPVqRC5o=
|
||||
golang.org/x/exp v0.0.0-20260212183809-81e46e3db34a/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA=
|
||||
golang.org/x/image v0.36.0 h1:Iknbfm1afbgtwPTmHnS2gTM/6PPZfH+z2EFuOkSbqwc=
|
||||
golang.org/x/image v0.36.0/go.mod h1:YsWD2TyyGKiIX1kZlu9QfKIsQ4nAAK9bdgdrIsE7xy4=
|
||||
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
|
||||
|
||||
@@ -644,7 +644,7 @@ func (cd *ConfigDeployer) transformHyprlandConfigForNonSystemd(config, terminalC
|
||||
if strings.HasPrefix(trimmed, "exec-once = systemctl --user start") {
|
||||
startupSectionFound = true
|
||||
result = append(result, "exec-once = dms run")
|
||||
result = append(result, "env = QT_QPA_PLATFORM,wayland")
|
||||
result = append(result, "env = QT_QPA_PLATFORM,wayland;xcb")
|
||||
result = append(result, "env = ELECTRON_OZONE_PLATFORM_HINT,auto")
|
||||
result = append(result, "env = QT_QPA_PLATFORMTHEME,gtk3")
|
||||
result = append(result, "env = QT_QPA_PLATFORMTHEME_QT6,gtk3")
|
||||
@@ -659,7 +659,7 @@ func (cd *ConfigDeployer) transformHyprlandConfigForNonSystemd(config, terminalC
|
||||
if strings.Contains(line, "STARTUP APPS") {
|
||||
insertLines := []string{
|
||||
"exec-once = dms run",
|
||||
"env = QT_QPA_PLATFORM,wayland",
|
||||
"env = QT_QPA_PLATFORM,wayland;xcb",
|
||||
"env = ELECTRON_OZONE_PLATFORM_HINT,auto",
|
||||
"env = QT_QPA_PLATFORMTHEME,gtk3",
|
||||
"env = QT_QPA_PLATFORMTHEME_QT6,gtk3",
|
||||
@@ -677,7 +677,7 @@ func (cd *ConfigDeployer) transformHyprlandConfigForNonSystemd(config, terminalC
|
||||
func (cd *ConfigDeployer) transformNiriConfigForNonSystemd(config, terminalCommand string) string {
|
||||
envVars := fmt.Sprintf(`environment {
|
||||
XDG_CURRENT_DESKTOP "niri"
|
||||
QT_QPA_PLATFORM "wayland"
|
||||
QT_QPA_PLATFORM "wayland;xcb"
|
||||
ELECTRON_OZONE_PLATFORM_HINT "auto"
|
||||
QT_QPA_PLATFORMTHEME "gtk3"
|
||||
QT_QPA_PLATFORMTHEME_QT6 "gtk3"
|
||||
|
||||
@@ -111,6 +111,7 @@ windowrule = float on, match:class ^(zoom)$
|
||||
# windowrule = float on, match:class ^(org.quickshell)$
|
||||
|
||||
layerrule = no_anim on, match:namespace ^(quickshell)$
|
||||
layerrule = no_anim on, match:namespace ^dms:.*
|
||||
|
||||
source = ./dms/colors.conf
|
||||
source = ./dms/outputs.conf
|
||||
|
||||
@@ -430,7 +430,7 @@ func (d *DebianDistribution) enableOBSRepos(ctx context.Context, obsPkgs []Packa
|
||||
}
|
||||
|
||||
// Add repository
|
||||
repoLine := fmt.Sprintf("deb [signed-by=%s, arch=%s] %s/ /", keyringPath, runtime.GOARCH, baseURL)
|
||||
repoLine := fmt.Sprintf("deb [signed-by=%s arch=%s] %s/ /", keyringPath, runtime.GOARCH, baseURL)
|
||||
|
||||
progressChan <- InstallProgressMsg{
|
||||
Phase: PhaseSystemPackages,
|
||||
|
||||
95
core/internal/keybinds/providers/miracle.go
Normal file
95
core/internal/keybinds/providers/miracle.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/keybinds"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/utils"
|
||||
)
|
||||
|
||||
type MiracleProvider struct {
|
||||
configPath string
|
||||
}
|
||||
|
||||
func NewMiracleProvider(configPath string) *MiracleProvider {
|
||||
if configPath == "" {
|
||||
configDir, err := os.UserConfigDir()
|
||||
if err == nil {
|
||||
configPath = filepath.Join(configDir, "miracle-wm")
|
||||
}
|
||||
}
|
||||
return &MiracleProvider{configPath: configPath}
|
||||
}
|
||||
|
||||
func (m *MiracleProvider) Name() string {
|
||||
return "miracle"
|
||||
}
|
||||
|
||||
func (m *MiracleProvider) GetCheatSheet() (*keybinds.CheatSheet, error) {
|
||||
config, err := ParseMiracleConfig(m.configPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse miracle-wm config: %w", err)
|
||||
}
|
||||
|
||||
bindings := MiracleConfigToBindings(config)
|
||||
categorizedBinds := make(map[string][]keybinds.Keybind)
|
||||
|
||||
for _, kb := range bindings {
|
||||
category := m.categorizeAction(kb.Action)
|
||||
bind := keybinds.Keybind{
|
||||
Key: m.formatKey(kb),
|
||||
Description: kb.Comment,
|
||||
Action: kb.Action,
|
||||
}
|
||||
categorizedBinds[category] = append(categorizedBinds[category], bind)
|
||||
}
|
||||
|
||||
return &keybinds.CheatSheet{
|
||||
Title: "Miracle WM Keybinds",
|
||||
Provider: m.Name(),
|
||||
Binds: categorizedBinds,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m *MiracleProvider) GetOverridePath() string {
|
||||
expanded, err := utils.ExpandPath(m.configPath)
|
||||
if err != nil {
|
||||
return filepath.Join(m.configPath, "config.yaml")
|
||||
}
|
||||
return filepath.Join(expanded, "config.yaml")
|
||||
}
|
||||
|
||||
func (m *MiracleProvider) formatKey(kb MiracleKeyBinding) string {
|
||||
parts := make([]string, 0, len(kb.Mods)+1)
|
||||
parts = append(parts, kb.Mods...)
|
||||
parts = append(parts, kb.Key)
|
||||
return strings.Join(parts, "+")
|
||||
}
|
||||
|
||||
func (m *MiracleProvider) categorizeAction(action string) string {
|
||||
switch {
|
||||
case strings.HasPrefix(action, "select_workspace_") || strings.HasPrefix(action, "move_to_workspace_"):
|
||||
return "Workspace"
|
||||
case strings.Contains(action, "select_") || strings.Contains(action, "move_"):
|
||||
return "Window"
|
||||
case action == "toggle_resize" || strings.HasPrefix(action, "resize_"):
|
||||
return "Window"
|
||||
case action == "fullscreen" || action == "toggle_floating" || action == "quit_active_window" || action == "toggle_pinned_to_workspace":
|
||||
return "Window"
|
||||
case action == "toggle_tabbing" || action == "toggle_stacking" || action == "request_vertical" || action == "request_horizontal":
|
||||
return "Layout"
|
||||
case action == "quit_compositor":
|
||||
return "System"
|
||||
case action == "terminal":
|
||||
return "Execute"
|
||||
case strings.HasPrefix(action, "magnifier_"):
|
||||
return "Accessibility"
|
||||
case strings.HasPrefix(action, "dms ") || strings.Contains(action, "dms ipc"):
|
||||
return "Execute"
|
||||
default:
|
||||
return "Execute"
|
||||
}
|
||||
}
|
||||
320
core/internal/keybinds/providers/miracle_parser.go
Normal file
320
core/internal/keybinds/providers/miracle_parser.go
Normal file
@@ -0,0 +1,320 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/utils"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type MiracleConfig struct {
|
||||
Terminal string `yaml:"terminal"`
|
||||
ActionKey string `yaml:"action_key"`
|
||||
DefaultActionOverrides []MiracleActionOverride `yaml:"default_action_overrides"`
|
||||
CustomActions []MiracleCustomAction `yaml:"custom_actions"`
|
||||
}
|
||||
|
||||
type MiracleActionOverride struct {
|
||||
Name string `yaml:"name"`
|
||||
Action string `yaml:"action"`
|
||||
Modifiers []string `yaml:"modifiers"`
|
||||
Key string `yaml:"key"`
|
||||
}
|
||||
|
||||
type MiracleCustomAction struct {
|
||||
Command string `yaml:"command"`
|
||||
Action string `yaml:"action"`
|
||||
Modifiers []string `yaml:"modifiers"`
|
||||
Key string `yaml:"key"`
|
||||
}
|
||||
|
||||
type MiracleKeyBinding struct {
|
||||
Mods []string
|
||||
Key string
|
||||
Action string
|
||||
Comment string
|
||||
}
|
||||
|
||||
var miracleDefaultBinds = []MiracleKeyBinding{
|
||||
{Mods: []string{"Super"}, Key: "Return", Action: "terminal", Comment: "Open terminal"},
|
||||
{Mods: []string{"Super"}, Key: "v", Action: "request_vertical", Comment: "Layout windows vertically"},
|
||||
{Mods: []string{"Super"}, Key: "h", Action: "request_horizontal", Comment: "Layout windows horizontally"},
|
||||
{Mods: []string{"Super"}, Key: "Up", Action: "select_up", Comment: "Select window above"},
|
||||
{Mods: []string{"Super"}, Key: "Down", Action: "select_down", Comment: "Select window below"},
|
||||
{Mods: []string{"Super"}, Key: "Left", Action: "select_left", Comment: "Select window left"},
|
||||
{Mods: []string{"Super"}, Key: "Right", Action: "select_right", Comment: "Select window right"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "Up", Action: "move_up", Comment: "Move window up"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "Down", Action: "move_down", Comment: "Move window down"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "Left", Action: "move_left", Comment: "Move window left"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "Right", Action: "move_right", Comment: "Move window right"},
|
||||
{Mods: []string{"Super"}, Key: "r", Action: "toggle_resize", Comment: "Toggle resize mode"},
|
||||
{Mods: []string{"Super"}, Key: "f", Action: "fullscreen", Comment: "Toggle fullscreen"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "q", Action: "quit_active_window", Comment: "Close window"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "e", Action: "quit_compositor", Comment: "Exit compositor"},
|
||||
{Mods: []string{"Super"}, Key: "Space", Action: "toggle_floating", Comment: "Toggle floating"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "p", Action: "toggle_pinned_to_workspace", Comment: "Toggle pinned to workspace"},
|
||||
{Mods: []string{"Super"}, Key: "w", Action: "toggle_tabbing", Comment: "Toggle tabbing layout"},
|
||||
{Mods: []string{"Super"}, Key: "s", Action: "toggle_stacking", Comment: "Toggle stacking layout"},
|
||||
{Mods: []string{"Super"}, Key: "1", Action: "select_workspace_0", Comment: "Workspace 1"},
|
||||
{Mods: []string{"Super"}, Key: "2", Action: "select_workspace_1", Comment: "Workspace 2"},
|
||||
{Mods: []string{"Super"}, Key: "3", Action: "select_workspace_2", Comment: "Workspace 3"},
|
||||
{Mods: []string{"Super"}, Key: "4", Action: "select_workspace_3", Comment: "Workspace 4"},
|
||||
{Mods: []string{"Super"}, Key: "5", Action: "select_workspace_4", Comment: "Workspace 5"},
|
||||
{Mods: []string{"Super"}, Key: "6", Action: "select_workspace_5", Comment: "Workspace 6"},
|
||||
{Mods: []string{"Super"}, Key: "7", Action: "select_workspace_6", Comment: "Workspace 7"},
|
||||
{Mods: []string{"Super"}, Key: "8", Action: "select_workspace_7", Comment: "Workspace 8"},
|
||||
{Mods: []string{"Super"}, Key: "9", Action: "select_workspace_8", Comment: "Workspace 9"},
|
||||
{Mods: []string{"Super"}, Key: "0", Action: "select_workspace_9", Comment: "Workspace 10"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "1", Action: "move_to_workspace_0", Comment: "Move to workspace 1"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "2", Action: "move_to_workspace_1", Comment: "Move to workspace 2"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "3", Action: "move_to_workspace_2", Comment: "Move to workspace 3"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "4", Action: "move_to_workspace_3", Comment: "Move to workspace 4"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "5", Action: "move_to_workspace_4", Comment: "Move to workspace 5"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "6", Action: "move_to_workspace_5", Comment: "Move to workspace 6"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "7", Action: "move_to_workspace_6", Comment: "Move to workspace 7"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "8", Action: "move_to_workspace_7", Comment: "Move to workspace 8"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "9", Action: "move_to_workspace_8", Comment: "Move to workspace 9"},
|
||||
{Mods: []string{"Super", "Shift"}, Key: "0", Action: "move_to_workspace_9", Comment: "Move to workspace 10"},
|
||||
}
|
||||
|
||||
func ParseMiracleConfig(configPath string) (*MiracleConfig, error) {
|
||||
expanded, err := utils.ExpandPath(configPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info, err := os.Stat(expanded)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var configFile string
|
||||
if info.IsDir() {
|
||||
configFile = filepath.Join(expanded, "config.yaml")
|
||||
} else {
|
||||
configFile = expanded
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(configFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var config MiracleConfig
|
||||
if err := yaml.Unmarshal(data, &config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if config.ActionKey == "" {
|
||||
config.ActionKey = "meta"
|
||||
}
|
||||
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
func resolveMiracleModifier(mod, actionKey string) string {
|
||||
switch mod {
|
||||
case "primary":
|
||||
return resolveActionKey(actionKey)
|
||||
case "alt", "alt_left", "alt_right":
|
||||
return "Alt"
|
||||
case "shift", "shift_left", "shift_right":
|
||||
return "Shift"
|
||||
case "ctrl", "ctrl_left", "ctrl_right":
|
||||
return "Ctrl"
|
||||
case "meta", "meta_left", "meta_right":
|
||||
return "Super"
|
||||
default:
|
||||
return mod
|
||||
}
|
||||
}
|
||||
|
||||
func resolveActionKey(actionKey string) string {
|
||||
switch actionKey {
|
||||
case "meta":
|
||||
return "Super"
|
||||
case "alt":
|
||||
return "Alt"
|
||||
case "ctrl":
|
||||
return "Ctrl"
|
||||
default:
|
||||
return "Super"
|
||||
}
|
||||
}
|
||||
|
||||
func miracleKeyCodeToName(keyCode string) string {
|
||||
name := strings.TrimPrefix(keyCode, "KEY_")
|
||||
name = strings.ToLower(name)
|
||||
|
||||
switch name {
|
||||
case "enter":
|
||||
return "Return"
|
||||
case "space":
|
||||
return "Space"
|
||||
case "up":
|
||||
return "Up"
|
||||
case "down":
|
||||
return "Down"
|
||||
case "left":
|
||||
return "Left"
|
||||
case "right":
|
||||
return "Right"
|
||||
case "tab":
|
||||
return "Tab"
|
||||
case "escape", "esc":
|
||||
return "Escape"
|
||||
case "delete":
|
||||
return "Delete"
|
||||
case "backspace":
|
||||
return "BackSpace"
|
||||
case "home":
|
||||
return "Home"
|
||||
case "end":
|
||||
return "End"
|
||||
case "pageup":
|
||||
return "Page_Up"
|
||||
case "pagedown":
|
||||
return "Page_Down"
|
||||
case "print":
|
||||
return "Print"
|
||||
case "pause":
|
||||
return "Pause"
|
||||
case "volumeup":
|
||||
return "XF86AudioRaiseVolume"
|
||||
case "volumedown":
|
||||
return "XF86AudioLowerVolume"
|
||||
case "mute":
|
||||
return "XF86AudioMute"
|
||||
case "micmute":
|
||||
return "XF86AudioMicMute"
|
||||
case "brightnessup":
|
||||
return "XF86MonBrightnessUp"
|
||||
case "brightnessdown":
|
||||
return "XF86MonBrightnessDown"
|
||||
case "kbdillumup":
|
||||
return "XF86KbdBrightnessUp"
|
||||
case "kbdillumdown":
|
||||
return "XF86KbdBrightnessDown"
|
||||
case "comma":
|
||||
return "comma"
|
||||
case "minus":
|
||||
return "minus"
|
||||
case "equal":
|
||||
return "equal"
|
||||
}
|
||||
|
||||
if len(name) == 1 {
|
||||
return name
|
||||
}
|
||||
|
||||
return name
|
||||
}
|
||||
|
||||
func MiracleConfigToBindings(config *MiracleConfig) []MiracleKeyBinding {
|
||||
overridden := make(map[string]bool)
|
||||
var bindings []MiracleKeyBinding
|
||||
|
||||
for _, override := range config.DefaultActionOverrides {
|
||||
mods := make([]string, 0, len(override.Modifiers))
|
||||
for _, mod := range override.Modifiers {
|
||||
mods = append(mods, resolveMiracleModifier(mod, config.ActionKey))
|
||||
}
|
||||
|
||||
bindings = append(bindings, MiracleKeyBinding{
|
||||
Mods: mods,
|
||||
Key: miracleKeyCodeToName(override.Key),
|
||||
Action: override.Name,
|
||||
Comment: miracleActionDescription(override.Name),
|
||||
})
|
||||
overridden[override.Name] = true
|
||||
}
|
||||
|
||||
for _, def := range miracleDefaultBinds {
|
||||
if overridden[def.Action] {
|
||||
continue
|
||||
}
|
||||
bindings = append(bindings, def)
|
||||
}
|
||||
|
||||
for _, custom := range config.CustomActions {
|
||||
mods := make([]string, 0, len(custom.Modifiers))
|
||||
for _, mod := range custom.Modifiers {
|
||||
mods = append(mods, resolveMiracleModifier(mod, config.ActionKey))
|
||||
}
|
||||
|
||||
bindings = append(bindings, MiracleKeyBinding{
|
||||
Mods: mods,
|
||||
Key: miracleKeyCodeToName(custom.Key),
|
||||
Action: custom.Command,
|
||||
Comment: custom.Command,
|
||||
})
|
||||
}
|
||||
|
||||
return bindings
|
||||
}
|
||||
|
||||
func miracleActionDescription(action string) string {
|
||||
switch action {
|
||||
case "terminal":
|
||||
return "Open terminal"
|
||||
case "request_vertical":
|
||||
return "Layout windows vertically"
|
||||
case "request_horizontal":
|
||||
return "Layout windows horizontally"
|
||||
case "select_up":
|
||||
return "Select window above"
|
||||
case "select_down":
|
||||
return "Select window below"
|
||||
case "select_left":
|
||||
return "Select window left"
|
||||
case "select_right":
|
||||
return "Select window right"
|
||||
case "move_up":
|
||||
return "Move window up"
|
||||
case "move_down":
|
||||
return "Move window down"
|
||||
case "move_left":
|
||||
return "Move window left"
|
||||
case "move_right":
|
||||
return "Move window right"
|
||||
case "toggle_resize":
|
||||
return "Toggle resize mode"
|
||||
case "fullscreen":
|
||||
return "Toggle fullscreen"
|
||||
case "quit_active_window":
|
||||
return "Close window"
|
||||
case "quit_compositor":
|
||||
return "Exit compositor"
|
||||
case "toggle_floating":
|
||||
return "Toggle floating"
|
||||
case "toggle_pinned_to_workspace":
|
||||
return "Toggle pinned to workspace"
|
||||
case "toggle_tabbing":
|
||||
return "Toggle tabbing layout"
|
||||
case "toggle_stacking":
|
||||
return "Toggle stacking layout"
|
||||
case "magnifier_on":
|
||||
return "Enable magnifier"
|
||||
case "magnifier_off":
|
||||
return "Disable magnifier"
|
||||
case "magnifier_increase_size":
|
||||
return "Increase magnifier area"
|
||||
case "magnifier_decrease_size":
|
||||
return "Decrease magnifier area"
|
||||
case "magnifier_increase_scale":
|
||||
return "Increase magnifier scale"
|
||||
case "magnifier_decrease_scale":
|
||||
return "Decrease magnifier scale"
|
||||
}
|
||||
|
||||
if num, ok := strings.CutPrefix(action, "select_workspace_"); ok {
|
||||
return "Workspace " + num
|
||||
}
|
||||
if num, ok := strings.CutPrefix(action, "move_to_workspace_"); ok {
|
||||
return "Move to workspace " + num
|
||||
}
|
||||
|
||||
return action
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package providers
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/keybinds"
|
||||
@@ -18,14 +19,21 @@ func NewSwayProvider(configPath string) *SwayProvider {
|
||||
_, scrollEnvSet := os.LookupEnv("SCROLLSOCK")
|
||||
|
||||
if configPath == "" {
|
||||
configDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
configDir = ""
|
||||
}
|
||||
if scrollEnvSet {
|
||||
configPath = "$HOME/.config/scroll"
|
||||
if configDir != "" {
|
||||
configPath = filepath.Join(configDir, "scroll")
|
||||
}
|
||||
isScroll = true
|
||||
} else {
|
||||
configPath = "$HOME/.config/sway"
|
||||
if configDir != "" {
|
||||
configPath = filepath.Join(configDir, "sway")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Determine isScroll based on the provided config path
|
||||
isScroll = strings.Contains(configPath, "scroll")
|
||||
}
|
||||
|
||||
@@ -36,16 +44,16 @@ func NewSwayProvider(configPath string) *SwayProvider {
|
||||
}
|
||||
|
||||
func (s *SwayProvider) Name() string {
|
||||
if s != nil && s.isScroll {
|
||||
return "scroll"
|
||||
}
|
||||
if s == nil {
|
||||
_, ok := os.LookupEnv("SCROLLSOCK")
|
||||
if ok {
|
||||
if os.Getenv("SCROLLSOCK") != "" {
|
||||
return "scroll"
|
||||
}
|
||||
return "sway"
|
||||
}
|
||||
|
||||
if s.isScroll {
|
||||
return "scroll"
|
||||
}
|
||||
return "sway"
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,13 @@ func TestSwayProviderName(t *testing.T) {
|
||||
|
||||
func TestSwayProviderDefaultPath(t *testing.T) {
|
||||
provider := NewSwayProvider("")
|
||||
if provider.configPath != "$HOME/.config/sway" {
|
||||
t.Errorf("configPath = %q, want %q", provider.configPath, "$HOME/.config/sway")
|
||||
configDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
t.Skip("UserConfigDir not available")
|
||||
}
|
||||
expected := filepath.Join(configDir, "sway")
|
||||
if provider.configPath != expected {
|
||||
t.Errorf("configPath = %q, want %q", provider.configPath, expected)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ const (
|
||||
TemplateKindTerminal
|
||||
TemplateKindGTK
|
||||
TemplateKindVSCode
|
||||
TemplateKindEmacs
|
||||
)
|
||||
|
||||
type TemplateDef struct {
|
||||
@@ -65,7 +66,7 @@ var templateRegistry = []TemplateDef{
|
||||
{ID: "dgop", Commands: []string{"dgop"}, ConfigFile: "dgop.toml"},
|
||||
{ID: "kcolorscheme", ConfigFile: "kcolorscheme.toml", RunUnconditionally: true},
|
||||
{ID: "vscode", Kind: TemplateKindVSCode},
|
||||
{ID: "emacs", Commands: []string{"emacs"}, ConfigFile: "emacs.toml"},
|
||||
{ID: "emacs", Commands: []string{"emacs"}, ConfigFile: "emacs.toml", Kind: TemplateKindEmacs},
|
||||
}
|
||||
|
||||
func (c *ColorMode) GTKTheme() string {
|
||||
@@ -78,7 +79,8 @@ func (c *ColorMode) GTKTheme() string {
|
||||
}
|
||||
|
||||
var (
|
||||
matugenVersionOnce sync.Once
|
||||
matugenVersionMu sync.Mutex
|
||||
matugenVersionOK bool
|
||||
matugenSupportsCOE bool
|
||||
matugenIsV4 bool
|
||||
)
|
||||
@@ -334,6 +336,10 @@ output_path = '%s'
|
||||
appendVSCodeConfig(cfgFile, "cursor", filepath.Join(homeDir, ".cursor/extensions"), opts.ShellDir)
|
||||
appendVSCodeConfig(cfgFile, "windsurf", filepath.Join(homeDir, ".windsurf/extensions"), opts.ShellDir)
|
||||
appendVSCodeConfig(cfgFile, "vscode-insiders", filepath.Join(homeDir, ".vscode-insiders/extensions"), opts.ShellDir)
|
||||
case TemplateKindEmacs:
|
||||
if utils.EmacsConfigDir() != "" {
|
||||
appendConfig(opts, cfgFile, tmpl.Commands, tmpl.Flatpaks, tmpl.ConfigFile)
|
||||
}
|
||||
default:
|
||||
appendConfig(opts, cfgFile, tmpl.Commands, tmpl.Flatpaks, tmpl.ConfigFile)
|
||||
}
|
||||
@@ -491,6 +497,9 @@ func substituteVars(content, shellDir string) string {
|
||||
result = strings.ReplaceAll(result, "'CONFIG_DIR/", "'"+utils.XDGConfigHome()+"/")
|
||||
result = strings.ReplaceAll(result, "'DATA_DIR/", "'"+utils.XDGDataHome()+"/")
|
||||
result = strings.ReplaceAll(result, "'CACHE_DIR/", "'"+utils.XDGCacheHome()+"/")
|
||||
if emacsDir := utils.EmacsConfigDir(); emacsDir != "" {
|
||||
result = strings.ReplaceAll(result, "'EMACS_DIR/", "'"+emacsDir+"/")
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -511,79 +520,160 @@ func extractTOMLSection(content, startMarker, endMarker string) string {
|
||||
return content[startIdx : startIdx+endIdx]
|
||||
}
|
||||
|
||||
func checkMatugenVersion() {
|
||||
matugenVersionOnce.Do(func() {
|
||||
cmd := exec.Command("matugen", "--version")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
versionStr := strings.TrimSpace(string(output))
|
||||
versionStr = strings.TrimPrefix(versionStr, "matugen ")
|
||||
|
||||
parts := strings.Split(versionStr, ".")
|
||||
if len(parts) < 2 {
|
||||
return
|
||||
}
|
||||
|
||||
major, err := strconv.Atoi(parts[0])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
minor, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
matugenSupportsCOE = major > 3 || (major == 3 && minor >= 1)
|
||||
matugenIsV4 = major >= 4
|
||||
if matugenSupportsCOE {
|
||||
log.Infof("Matugen %s supports --continue-on-error", versionStr)
|
||||
}
|
||||
if matugenIsV4 {
|
||||
log.Infof("Matugen %s: using v4 flags", versionStr)
|
||||
}
|
||||
})
|
||||
type matugenFlags struct {
|
||||
supportsCOE bool
|
||||
isV4 bool
|
||||
}
|
||||
|
||||
func runMatugen(args []string) error {
|
||||
checkMatugenVersion()
|
||||
func detectMatugenVersion() (matugenFlags, error) {
|
||||
matugenVersionMu.Lock()
|
||||
defer matugenVersionMu.Unlock()
|
||||
|
||||
if matugenVersionOK {
|
||||
return matugenFlags{matugenSupportsCOE, matugenIsV4}, nil
|
||||
}
|
||||
|
||||
return detectMatugenVersionLocked()
|
||||
}
|
||||
|
||||
func redetectMatugenVersion(old matugenFlags) (matugenFlags, bool) {
|
||||
matugenVersionMu.Lock()
|
||||
defer matugenVersionMu.Unlock()
|
||||
|
||||
matugenVersionOK = false
|
||||
flags, err := detectMatugenVersionLocked()
|
||||
if err != nil {
|
||||
return old, false
|
||||
}
|
||||
changed := flags.supportsCOE != old.supportsCOE || flags.isV4 != old.isV4
|
||||
return flags, changed
|
||||
}
|
||||
|
||||
func detectMatugenVersionLocked() (matugenFlags, error) {
|
||||
cmd := exec.Command("matugen", "--version")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
return matugenFlags{}, fmt.Errorf("failed to get matugen version: %w", err)
|
||||
}
|
||||
|
||||
versionStr := strings.TrimSpace(string(output))
|
||||
versionStr = strings.TrimPrefix(versionStr, "matugen ")
|
||||
|
||||
parts := strings.Split(versionStr, ".")
|
||||
if len(parts) < 2 {
|
||||
return matugenFlags{}, fmt.Errorf("unexpected matugen version format: %q", versionStr)
|
||||
}
|
||||
|
||||
major, err := strconv.Atoi(parts[0])
|
||||
if err != nil {
|
||||
return matugenFlags{}, fmt.Errorf("failed to parse matugen major version %q: %w", parts[0], err)
|
||||
}
|
||||
|
||||
minor, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
return matugenFlags{}, fmt.Errorf("failed to parse matugen minor version %q: %w", parts[1], err)
|
||||
}
|
||||
|
||||
matugenSupportsCOE = major > 3 || (major == 3 && minor >= 1)
|
||||
matugenIsV4 = major >= 4
|
||||
matugenVersionOK = true
|
||||
|
||||
if matugenSupportsCOE {
|
||||
args = append([]string{"--continue-on-error"}, args...)
|
||||
log.Infof("Matugen %s supports --continue-on-error", versionStr)
|
||||
}
|
||||
if matugenIsV4 {
|
||||
log.Infof("Matugen %s: using v4 flags", versionStr)
|
||||
}
|
||||
return matugenFlags{matugenSupportsCOE, matugenIsV4}, nil
|
||||
}
|
||||
|
||||
func buildMatugenArgs(baseArgs []string, flags matugenFlags) []string {
|
||||
args := make([]string, 0, len(baseArgs)+4)
|
||||
if flags.supportsCOE {
|
||||
args = append(args, "--continue-on-error")
|
||||
}
|
||||
args = append(args, baseArgs...)
|
||||
if flags.isV4 {
|
||||
args = append(args, "--source-color-index", "0")
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
func runMatugen(baseArgs []string) error {
|
||||
flags, err := detectMatugenVersion()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
args := buildMatugenArgs(baseArgs, flags)
|
||||
cmd := exec.Command("matugen", args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
runErr := cmd.Run()
|
||||
if runErr == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Warnf("Matugen failed (v4=%v): %v", flags.isV4, runErr)
|
||||
|
||||
newFlags, changed := redetectMatugenVersion(flags)
|
||||
if !changed {
|
||||
return runErr
|
||||
}
|
||||
|
||||
log.Warnf("Matugen version changed (v4: %v -> %v), retrying", flags.isV4, newFlags.isV4)
|
||||
args = buildMatugenArgs(baseArgs, newFlags)
|
||||
retryCmd := exec.Command("matugen", args...)
|
||||
retryCmd.Stdout = os.Stdout
|
||||
retryCmd.Stderr = os.Stderr
|
||||
return retryCmd.Run()
|
||||
}
|
||||
|
||||
func runMatugenDryRun(opts *Options) (string, error) {
|
||||
checkMatugenVersion()
|
||||
|
||||
var args []string
|
||||
switch opts.Kind {
|
||||
case "hex":
|
||||
args = []string{"color", "hex", opts.Value}
|
||||
default:
|
||||
args = []string{opts.Kind, opts.Value}
|
||||
}
|
||||
args = append(args, "-m", "dark", "-t", opts.MatugenType, "--json", "hex", "--dry-run")
|
||||
if matugenIsV4 {
|
||||
args = append(args, "--source-color-index", "0", "--old-json-output")
|
||||
}
|
||||
|
||||
cmd := exec.Command("matugen", args...)
|
||||
output, err := cmd.Output()
|
||||
flags, err := detectMatugenVersion()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
output, dryErr := execDryRun(opts, flags)
|
||||
if dryErr == nil {
|
||||
return output, nil
|
||||
}
|
||||
|
||||
log.Warnf("Matugen dry-run failed (v4=%v): %v", flags.isV4, dryErr)
|
||||
|
||||
newFlags, changed := redetectMatugenVersion(flags)
|
||||
if !changed {
|
||||
return "", dryErr
|
||||
}
|
||||
|
||||
log.Warnf("Matugen version changed (v4: %v -> %v), retrying dry-run", flags.isV4, newFlags.isV4)
|
||||
return execDryRun(opts, newFlags)
|
||||
}
|
||||
|
||||
func execDryRun(opts *Options, flags matugenFlags) (string, error) {
|
||||
var baseArgs []string
|
||||
switch opts.Kind {
|
||||
case "hex":
|
||||
baseArgs = []string{"color", "hex", opts.Value}
|
||||
default:
|
||||
baseArgs = []string{opts.Kind, opts.Value}
|
||||
}
|
||||
baseArgs = append(baseArgs, "-m", "dark", "-t", opts.MatugenType, "--json", "hex", "--dry-run")
|
||||
if flags.isV4 {
|
||||
baseArgs = append(baseArgs, "--source-color-index", "0", "--old-json-output")
|
||||
}
|
||||
|
||||
cmd := exec.Command("matugen", baseArgs...)
|
||||
var stderr strings.Builder
|
||||
cmd.Stderr = &stderr
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
if stderr.Len() > 0 {
|
||||
return "", fmt.Errorf("matugen %v failed (v4=%v): %s", baseArgs, flags.isV4, strings.TrimSpace(stderr.String()))
|
||||
}
|
||||
return "", fmt.Errorf("matugen %v failed (v4=%v): %w", baseArgs, flags.isV4, err)
|
||||
}
|
||||
return strings.ReplaceAll(string(output), "\n", ""), nil
|
||||
}
|
||||
|
||||
@@ -819,6 +909,8 @@ func CheckTemplates(checker utils.AppChecker) []TemplateCheck {
|
||||
detected = true
|
||||
case tmpl.Kind == TemplateKindVSCode:
|
||||
detected = checkVSCodeExtension(homeDir)
|
||||
case tmpl.Kind == TemplateKindEmacs:
|
||||
detected = appExists(checker, tmpl.Commands, tmpl.Flatpaks) && utils.EmacsConfigDir() != ""
|
||||
default:
|
||||
detected = appExists(checker, tmpl.Commands, tmpl.Flatpaks)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ const (
|
||||
notifyDest = "org.freedesktop.Notifications"
|
||||
notifyPath = "/org/freedesktop/Notifications"
|
||||
notifyInterface = "org.freedesktop.Notifications"
|
||||
|
||||
maxSummaryLen = 29
|
||||
maxBodyLen = 80
|
||||
)
|
||||
|
||||
type Notification struct {
|
||||
@@ -39,6 +42,13 @@ func Send(n Notification) error {
|
||||
n.Timeout = 5000
|
||||
}
|
||||
|
||||
if len(n.Summary) > maxSummaryLen {
|
||||
n.Summary = n.Summary[:maxSummaryLen-3] + "..."
|
||||
}
|
||||
if len(n.Body) > maxBodyLen {
|
||||
n.Body = n.Body[:maxBodyLen-3] + "..."
|
||||
}
|
||||
|
||||
var actions []string
|
||||
if n.FilePath != "" {
|
||||
actions = []string{
|
||||
|
||||
@@ -21,6 +21,7 @@ const (
|
||||
CompositorNiri
|
||||
CompositorDWL
|
||||
CompositorScroll
|
||||
CompositorMiracle
|
||||
)
|
||||
|
||||
var detectedCompositor Compositor = -1
|
||||
@@ -34,6 +35,7 @@ func DetectCompositor() Compositor {
|
||||
niriSocket := os.Getenv("NIRI_SOCKET")
|
||||
swaySocket := os.Getenv("SWAYSOCK")
|
||||
scrollSocket := os.Getenv("SCROLLSOCK")
|
||||
miracleSocket := os.Getenv("MIRACLESOCK")
|
||||
|
||||
switch {
|
||||
case niriSocket != "":
|
||||
@@ -46,7 +48,11 @@ func DetectCompositor() Compositor {
|
||||
detectedCompositor = CompositorScroll
|
||||
return detectedCompositor
|
||||
}
|
||||
|
||||
case miracleSocket != "":
|
||||
if _, err := os.Stat(miracleSocket); err == nil {
|
||||
detectedCompositor = CompositorMiracle
|
||||
return detectedCompositor
|
||||
}
|
||||
case swaySocket != "":
|
||||
if _, err := os.Stat(swaySocket); err == nil {
|
||||
detectedCompositor = CompositorSway
|
||||
@@ -260,6 +266,25 @@ func getScrollFocusedMonitor() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func getMiracleFocusedMonitor() string {
|
||||
output, err := exec.Command("miraclemsg", "-t", "get_workspaces").Output()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
var workspaces []swayWorkspace
|
||||
if err := json.Unmarshal(output, &workspaces); err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
for _, ws := range workspaces {
|
||||
if ws.Focused {
|
||||
return ws.Output
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type niriWorkspace struct {
|
||||
Output string `json:"output"`
|
||||
IsFocused bool `json:"is_focused"`
|
||||
@@ -407,6 +432,8 @@ func GetFocusedMonitor() string {
|
||||
return getSwayFocusedMonitor()
|
||||
case CompositorScroll:
|
||||
return getScrollFocusedMonitor()
|
||||
case CompositorMiracle:
|
||||
return getMiracleFocusedMonitor()
|
||||
case CompositorNiri:
|
||||
return getNiriFocusedMonitor()
|
||||
case CompositorDWL:
|
||||
|
||||
@@ -108,7 +108,7 @@ func NewRegionSelector(s *Screenshoter) *RegionSelector {
|
||||
screenshoter: s,
|
||||
outputs: make(map[uint32]*WaylandOutput),
|
||||
preCapture: make(map[*WaylandOutput]*PreCapture),
|
||||
showCapturedCursor: true,
|
||||
showCapturedCursor: s.config.Cursor == CursorOn,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -453,10 +453,7 @@ func (s *Screenshoter) blitBuffer(dst, src *ShmBuffer, dstX, dstY int, yInverted
|
||||
}
|
||||
|
||||
func (s *Screenshoter) captureWholeOutput(output *WaylandOutput) (*CaptureResult, error) {
|
||||
cursor := int32(0)
|
||||
if s.config.IncludeCursor {
|
||||
cursor = 1
|
||||
}
|
||||
cursor := int32(s.config.Cursor)
|
||||
|
||||
frame, err := s.screencopy.CaptureOutput(cursor, output.wlOutput)
|
||||
if err != nil {
|
||||
@@ -624,10 +621,7 @@ func (s *Screenshoter) captureRegionOnOutput(output *WaylandOutput, region Regio
|
||||
}
|
||||
}
|
||||
|
||||
cursor := int32(0)
|
||||
if s.config.IncludeCursor {
|
||||
cursor = 1
|
||||
}
|
||||
cursor := int32(s.config.Cursor)
|
||||
|
||||
frame, err := s.screencopy.CaptureOutputRegion(cursor, output.wlOutput, localX, localY, w, h)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,6 +19,13 @@ const (
|
||||
FormatPPM
|
||||
)
|
||||
|
||||
type CursorMode int
|
||||
|
||||
const (
|
||||
CursorOff CursorMode = iota
|
||||
CursorOn
|
||||
)
|
||||
|
||||
type Region struct {
|
||||
X int32 `json:"x"`
|
||||
Y int32 `json:"y"`
|
||||
@@ -42,29 +49,29 @@ type Output struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Mode Mode
|
||||
OutputName string
|
||||
IncludeCursor bool
|
||||
Format Format
|
||||
Quality int
|
||||
OutputDir string
|
||||
Filename string
|
||||
Clipboard bool
|
||||
SaveFile bool
|
||||
Notify bool
|
||||
Stdout bool
|
||||
Mode Mode
|
||||
OutputName string
|
||||
Cursor CursorMode
|
||||
Format Format
|
||||
Quality int
|
||||
OutputDir string
|
||||
Filename string
|
||||
Clipboard bool
|
||||
SaveFile bool
|
||||
Notify bool
|
||||
Stdout bool
|
||||
}
|
||||
|
||||
func DefaultConfig() Config {
|
||||
return Config{
|
||||
Mode: ModeRegion,
|
||||
IncludeCursor: false,
|
||||
Format: FormatPNG,
|
||||
Quality: 90,
|
||||
OutputDir: "",
|
||||
Filename: "",
|
||||
Clipboard: true,
|
||||
SaveFile: true,
|
||||
Notify: true,
|
||||
Mode: ModeRegion,
|
||||
Cursor: CursorOff,
|
||||
Format: FormatPNG,
|
||||
Quality: 90,
|
||||
OutputDir: "",
|
||||
Filename: "",
|
||||
Clipboard: true,
|
||||
SaveFile: true,
|
||||
Notify: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,11 +52,31 @@ func (m *Manager) initializeScreensaver() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
screensaverIface := introspect.Interface{
|
||||
Name: dbusScreensaverInterface,
|
||||
Methods: []introspect.Method{
|
||||
{
|
||||
Name: "Inhibit",
|
||||
Args: []introspect.Arg{
|
||||
{Name: "application_name", Type: "s", Direction: "in"},
|
||||
{Name: "reason_for_inhibit", Type: "s", Direction: "in"},
|
||||
{Name: "cookie", Type: "u", Direction: "out"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "UnInhibit",
|
||||
Args: []introspect.Arg{
|
||||
{Name: "cookie", Type: "u", Direction: "in"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
introNode := &introspect.Node{
|
||||
Name: dbusScreensaverPath,
|
||||
Interfaces: []introspect.Interface{
|
||||
introspect.IntrospectData,
|
||||
{Name: dbusScreensaverInterface},
|
||||
screensaverIface,
|
||||
},
|
||||
}
|
||||
if err := m.sessionConn.Export(introspect.NewIntrospectable(introNode), dbusScreensaverPath, "org.freedesktop.DBus.Introspectable"); err != nil {
|
||||
@@ -67,7 +87,7 @@ func (m *Manager) initializeScreensaver() error {
|
||||
Name: dbusScreensaverPath2,
|
||||
Interfaces: []introspect.Interface{
|
||||
introspect.IntrospectData,
|
||||
{Name: dbusScreensaverInterface},
|
||||
screensaverIface,
|
||||
},
|
||||
}
|
||||
if err := m.sessionConn.Export(introspect.NewIntrospectable(introNode2), dbusScreensaverPath2, "org.freedesktop.DBus.Introspectable"); err != nil {
|
||||
|
||||
@@ -32,8 +32,10 @@ type SecretAgent struct {
|
||||
backend *NetworkManagerBackend
|
||||
}
|
||||
|
||||
type nmVariantMap map[string]dbus.Variant
|
||||
type nmSettingMap map[string]nmVariantMap
|
||||
type (
|
||||
nmVariantMap map[string]dbus.Variant
|
||||
nmSettingMap map[string]nmVariantMap
|
||||
)
|
||||
|
||||
const introspectXML = `
|
||||
<node>
|
||||
@@ -308,6 +310,63 @@ func (a *SecretAgent) GetSecrets(
|
||||
return out, nil
|
||||
}
|
||||
a.backend.cachedVPNCredsMu.Unlock()
|
||||
|
||||
a.backend.cachedGPSamlMu.Lock()
|
||||
cachedGPSaml := a.backend.cachedGPSamlCookie
|
||||
if cachedGPSaml != nil && cachedGPSaml.ConnectionUUID == connUuid {
|
||||
a.backend.cachedGPSamlMu.Unlock()
|
||||
|
||||
log.Infof("[SecretAgent] Using cached GlobalProtect SAML cookie for %s", connUuid)
|
||||
|
||||
return buildGPSamlSecretsResponse(settingName, cachedGPSaml.Cookie, cachedGPSaml.Host, cachedGPSaml.Fingerprint), nil
|
||||
}
|
||||
a.backend.cachedGPSamlMu.Unlock()
|
||||
|
||||
if len(fields) == 1 && fields[0] == "gp-saml" {
|
||||
gateway := ""
|
||||
protocol := ""
|
||||
if vpnSettings, ok := conn["vpn"]; ok {
|
||||
if dataVariant, ok := vpnSettings["data"]; ok {
|
||||
if dataMap, ok := dataVariant.Value().(map[string]string); ok {
|
||||
if gw, ok := dataMap["gateway"]; ok {
|
||||
gateway = gw
|
||||
}
|
||||
if proto, ok := dataMap["protocol"]; ok && proto != "" {
|
||||
protocol = proto
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if protocol != "gp" {
|
||||
return nil, dbus.MakeFailedError(fmt.Errorf("gp-saml auth only supported for GlobalProtect (protocol=gp), got: %s", protocol))
|
||||
}
|
||||
|
||||
log.Infof("[SecretAgent] Starting GlobalProtect SAML authentication for gateway=%s", gateway)
|
||||
|
||||
samlCtx, samlCancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer samlCancel()
|
||||
|
||||
authResult, err := a.backend.runGlobalProtectSAMLAuth(samlCtx, gateway, protocol)
|
||||
if err != nil {
|
||||
log.Warnf("[SecretAgent] GlobalProtect SAML authentication failed: %v", err)
|
||||
return nil, dbus.MakeFailedError(fmt.Errorf("GlobalProtect SAML authentication failed: %w", err))
|
||||
}
|
||||
|
||||
log.Infof("[SecretAgent] GlobalProtect SAML authentication successful, returning cookie to NetworkManager")
|
||||
|
||||
a.backend.cachedGPSamlMu.Lock()
|
||||
a.backend.cachedGPSamlCookie = &cachedGPSamlCookie{
|
||||
ConnectionUUID: connUuid,
|
||||
Cookie: authResult.Cookie,
|
||||
Host: authResult.Host,
|
||||
User: authResult.User,
|
||||
Fingerprint: authResult.Fingerprint,
|
||||
}
|
||||
a.backend.cachedGPSamlMu.Unlock()
|
||||
|
||||
return buildGPSamlSecretsResponse(settingName, authResult.Cookie, authResult.Host, authResult.Fingerprint), nil
|
||||
}
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
@@ -659,12 +718,25 @@ func inferVPNFields(conn map[string]nmVariantMap, vpnService string) []string {
|
||||
|
||||
switch {
|
||||
case strings.Contains(vpnService, "openconnect"):
|
||||
protocol := dataMap["protocol"]
|
||||
authType := dataMap["authtype"]
|
||||
userCert := dataMap["usercert"]
|
||||
if authType == "cert" && strings.HasPrefix(userCert, "pkcs11:") {
|
||||
username := dataMap["username"]
|
||||
|
||||
if authType == "cert" && strings.HasPrefix(dataMap["usercert"], "pkcs11:") {
|
||||
return []string{"key_pass"}
|
||||
}
|
||||
if dataMap["username"] == "" {
|
||||
|
||||
if needsExternalBrowserAuth(protocol, authType, username, dataMap) {
|
||||
switch protocol {
|
||||
case "gp":
|
||||
log.Infof("[SecretAgent] GlobalProtect SAML auth detected")
|
||||
return []string{"gp-saml"}
|
||||
default:
|
||||
log.Infof("[SecretAgent] External browser auth detected for protocol '%s' but only GlobalProtect (gp) SAML is currently supported, falling back to credentials", protocol)
|
||||
}
|
||||
}
|
||||
|
||||
if username == "" {
|
||||
fields = []string{"username", "password"}
|
||||
}
|
||||
case strings.Contains(vpnService, "openvpn"):
|
||||
@@ -683,8 +755,31 @@ func inferVPNFields(conn map[string]nmVariantMap, vpnService string) []string {
|
||||
return fields
|
||||
}
|
||||
|
||||
func needsExternalBrowserAuth(protocol, authType, username string, data map[string]string) bool {
|
||||
if method, ok := data["saml-auth-method"]; ok {
|
||||
if method == "REDIRECT" || method == "POST" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if authType != "" && authType != "password" && authType != "cert" {
|
||||
return true
|
||||
}
|
||||
|
||||
switch protocol {
|
||||
case "gp":
|
||||
if authType == "" && username == "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func vpnFieldMeta(field, vpnService string) (label string, isSecret bool) {
|
||||
switch field {
|
||||
case "gp-saml":
|
||||
return "GlobalProtect SAML/SSO", false
|
||||
case "key_pass":
|
||||
return "PIN", true
|
||||
case "password":
|
||||
@@ -785,3 +880,18 @@ func reasonFromFlags(flags uint32) string {
|
||||
}
|
||||
return "required"
|
||||
}
|
||||
|
||||
func buildGPSamlSecretsResponse(settingName, cookie, host, fingerprint string) nmSettingMap {
|
||||
out := nmSettingMap{}
|
||||
vpnSec := nmVariantMap{}
|
||||
|
||||
secrets := map[string]string{
|
||||
"cookie": cookie,
|
||||
"gateway": host,
|
||||
"gwcert": fingerprint,
|
||||
}
|
||||
vpnSec["secrets"] = dbus.MakeVariant(secrets)
|
||||
|
||||
out[settingName] = vpnSec
|
||||
return out
|
||||
}
|
||||
|
||||
355
core/internal/server/network/agent_networkmanager_test.go
Normal file
355
core/internal/server/network/agent_networkmanager_test.go
Normal file
@@ -0,0 +1,355 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNeedsExternalBrowserAuth(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
protocol string
|
||||
authType string
|
||||
username string
|
||||
data map[string]string
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "GP with saml-auth-method REDIRECT",
|
||||
protocol: "gp",
|
||||
authType: "password",
|
||||
username: "user",
|
||||
data: map[string]string{"saml-auth-method": "REDIRECT"},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "GP with saml-auth-method POST",
|
||||
protocol: "gp",
|
||||
authType: "password",
|
||||
username: "user",
|
||||
data: map[string]string{"saml-auth-method": "POST"},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "GP with no authtype and no username",
|
||||
protocol: "gp",
|
||||
authType: "",
|
||||
username: "",
|
||||
data: map[string]string{},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "GP with username and password authtype",
|
||||
protocol: "gp",
|
||||
authType: "password",
|
||||
username: "john",
|
||||
data: map[string]string{},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "GP with username but no authtype",
|
||||
protocol: "gp",
|
||||
authType: "",
|
||||
username: "john",
|
||||
data: map[string]string{},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "GP with authtype but no username - should detect SAML",
|
||||
protocol: "gp",
|
||||
authType: "",
|
||||
username: "",
|
||||
data: map[string]string{},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "pulse with SAML",
|
||||
protocol: "pulse",
|
||||
authType: "",
|
||||
username: "",
|
||||
data: map[string]string{"saml-auth-method": "REDIRECT"},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "fortinet with non-password authtype",
|
||||
protocol: "fortinet",
|
||||
authType: "saml",
|
||||
username: "",
|
||||
data: map[string]string{},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "anyconnect with cert",
|
||||
protocol: "anyconnect",
|
||||
authType: "cert",
|
||||
username: "",
|
||||
data: map[string]string{},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "anyconnect with password",
|
||||
protocol: "anyconnect",
|
||||
authType: "password",
|
||||
username: "user",
|
||||
data: map[string]string{},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "empty protocol",
|
||||
protocol: "",
|
||||
authType: "",
|
||||
username: "",
|
||||
data: map[string]string{},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "GP with cert authtype",
|
||||
protocol: "gp",
|
||||
authType: "cert",
|
||||
username: "",
|
||||
data: map[string]string{},
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := needsExternalBrowserAuth(tt.protocol, tt.authType, tt.username, tt.data)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildGPSamlSecretsResponse(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
settingName string
|
||||
cookie string
|
||||
host string
|
||||
fingerprint string
|
||||
}{
|
||||
{
|
||||
name: "all fields populated",
|
||||
settingName: "vpn",
|
||||
cookie: "authcookie=abc123&portal=GATE",
|
||||
host: "vpn.example.com",
|
||||
fingerprint: "pin-sha256:ABCD1234",
|
||||
},
|
||||
{
|
||||
name: "empty fingerprint",
|
||||
settingName: "vpn",
|
||||
cookie: "authcookie=xyz",
|
||||
host: "10.0.0.1",
|
||||
fingerprint: "",
|
||||
},
|
||||
{
|
||||
name: "complex cookie with special chars",
|
||||
settingName: "vpn",
|
||||
cookie: "authcookie=077058d3bc81&portal=PANGP_GW_01-N&user=john.doe@example.com&domain=Default&preferred-ip=192.168.1.100",
|
||||
host: "connect.seclore.com",
|
||||
fingerprint: "pin-sha256:xp3scfzy3rOgQEXnfPiYKrUk7D66a8b8O+gEXaMPleE=",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := buildGPSamlSecretsResponse(tt.settingName, tt.cookie, tt.host, tt.fingerprint)
|
||||
|
||||
assert.NotNil(t, result)
|
||||
assert.Contains(t, result, tt.settingName)
|
||||
|
||||
vpnSec := result[tt.settingName]
|
||||
assert.NotNil(t, vpnSec)
|
||||
|
||||
secretsVariant, ok := vpnSec["secrets"]
|
||||
assert.True(t, ok, "secrets key should exist")
|
||||
|
||||
secrets, ok := secretsVariant.Value().(map[string]string)
|
||||
assert.True(t, ok, "secrets should be map[string]string")
|
||||
|
||||
assert.Equal(t, tt.cookie, secrets["cookie"])
|
||||
assert.Equal(t, tt.host, secrets["gateway"])
|
||||
assert.Equal(t, tt.fingerprint, secrets["gwcert"])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestVpnFieldMeta_GPSaml(t *testing.T) {
|
||||
label, isSecret := vpnFieldMeta("gp-saml", "org.freedesktop.NetworkManager.openconnect")
|
||||
|
||||
assert.Equal(t, "GlobalProtect SAML/SSO", label)
|
||||
assert.False(t, isSecret, "gp-saml should not be marked as secret")
|
||||
}
|
||||
|
||||
func TestVpnFieldMeta_StandardFields(t *testing.T) {
|
||||
tests := []struct {
|
||||
field string
|
||||
vpnService string
|
||||
expectedLabel string
|
||||
expectedSecret bool
|
||||
}{
|
||||
{
|
||||
field: "username",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
expectedLabel: "Username",
|
||||
expectedSecret: false,
|
||||
},
|
||||
{
|
||||
field: "password",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
expectedLabel: "Password",
|
||||
expectedSecret: true,
|
||||
},
|
||||
{
|
||||
field: "key_pass",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
expectedLabel: "PIN",
|
||||
expectedSecret: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.field, func(t *testing.T) {
|
||||
label, isSecret := vpnFieldMeta(tt.field, tt.vpnService)
|
||||
assert.Equal(t, tt.expectedLabel, label)
|
||||
assert.Equal(t, tt.expectedSecret, isSecret)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInferVPNFields_GPSaml(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
vpnService string
|
||||
dataMap map[string]string
|
||||
expectedLen int
|
||||
shouldHave []string
|
||||
}{
|
||||
{
|
||||
name: "GP with no authtype and no username - should require SAML",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
dataMap: map[string]string{
|
||||
"protocol": "gp",
|
||||
"gateway": "vpn.example.com",
|
||||
},
|
||||
expectedLen: 1,
|
||||
shouldHave: []string{"gp-saml"},
|
||||
},
|
||||
{
|
||||
name: "GP with saml-auth-method REDIRECT",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
dataMap: map[string]string{
|
||||
"protocol": "gp",
|
||||
"gateway": "vpn.example.com",
|
||||
"saml-auth-method": "REDIRECT",
|
||||
"username": "john",
|
||||
},
|
||||
expectedLen: 1,
|
||||
shouldHave: []string{"gp-saml"},
|
||||
},
|
||||
{
|
||||
name: "GP with saml-auth-method POST",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
dataMap: map[string]string{
|
||||
"protocol": "gp",
|
||||
"gateway": "vpn.example.com",
|
||||
"saml-auth-method": "POST",
|
||||
},
|
||||
expectedLen: 1,
|
||||
shouldHave: []string{"gp-saml"},
|
||||
},
|
||||
{
|
||||
name: "GP with username and password authtype - should use credentials",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
dataMap: map[string]string{
|
||||
"protocol": "gp",
|
||||
"gateway": "vpn.example.com",
|
||||
"authtype": "password",
|
||||
"username": "john",
|
||||
},
|
||||
expectedLen: 1,
|
||||
shouldHave: []string{"password"},
|
||||
},
|
||||
{
|
||||
name: "GP with username but no authtype - password only",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
dataMap: map[string]string{
|
||||
"protocol": "gp",
|
||||
"gateway": "vpn.example.com",
|
||||
"username": "john",
|
||||
},
|
||||
expectedLen: 1,
|
||||
shouldHave: []string{"password"},
|
||||
},
|
||||
{
|
||||
name: "GP with PKCS11 cert",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
dataMap: map[string]string{
|
||||
"protocol": "gp",
|
||||
"gateway": "vpn.example.com",
|
||||
"authtype": "cert",
|
||||
"usercert": "pkcs11:model=PKCS%2315%20emulated;manufacturer=piv_II",
|
||||
},
|
||||
expectedLen: 1,
|
||||
shouldHave: []string{"key_pass"},
|
||||
},
|
||||
{
|
||||
name: "non-GP protocol (anyconnect)",
|
||||
vpnService: "org.freedesktop.NetworkManager.openconnect",
|
||||
dataMap: map[string]string{
|
||||
"protocol": "anyconnect",
|
||||
"gateway": "vpn.example.com",
|
||||
},
|
||||
expectedLen: 2,
|
||||
shouldHave: []string{"username", "password"},
|
||||
},
|
||||
{
|
||||
name: "OpenVPN with username",
|
||||
vpnService: "org.freedesktop.NetworkManager.openvpn",
|
||||
dataMap: map[string]string{
|
||||
"connection-type": "password",
|
||||
"username": "john",
|
||||
},
|
||||
expectedLen: 1,
|
||||
shouldHave: []string{"password"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Convert dataMap to nmVariantMap
|
||||
vpnSettings := make(nmVariantMap)
|
||||
vpnSettings["data"] = dbus.MakeVariant(tt.dataMap)
|
||||
vpnSettings["service-type"] = dbus.MakeVariant(tt.vpnService)
|
||||
|
||||
conn := make(map[string]nmVariantMap)
|
||||
conn["vpn"] = vpnSettings
|
||||
|
||||
fields := inferVPNFields(conn, tt.vpnService)
|
||||
|
||||
assert.Len(t, fields, tt.expectedLen, "unexpected number of fields")
|
||||
if len(tt.shouldHave) > 0 {
|
||||
for _, expected := range tt.shouldHave {
|
||||
assert.Contains(t, fields, expected, "should contain field: %s", expected)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNmVariantMap(t *testing.T) {
|
||||
// Test that nmVariantMap and nmSettingMap work correctly
|
||||
settingMap := make(nmSettingMap)
|
||||
variantMap := make(nmVariantMap)
|
||||
|
||||
variantMap["test-key"] = dbus.MakeVariant("test-value")
|
||||
settingMap["test-setting"] = variantMap
|
||||
|
||||
assert.Contains(t, settingMap, "test-setting")
|
||||
assert.Contains(t, settingMap["test-setting"], "test-key")
|
||||
|
||||
value := settingMap["test-setting"]["test-key"].Value()
|
||||
assert.Equal(t, "test-value", value)
|
||||
}
|
||||
@@ -69,12 +69,14 @@ type NetworkManagerBackend struct {
|
||||
lastFailedTime int64
|
||||
failedMutex sync.RWMutex
|
||||
|
||||
pendingVPNSave *pendingVPNCredentials
|
||||
pendingVPNSaveMu sync.Mutex
|
||||
cachedVPNCreds *cachedVPNCredentials
|
||||
cachedVPNCredsMu sync.Mutex
|
||||
cachedPKCS11PIN *cachedPKCS11PIN
|
||||
cachedPKCS11Mu sync.Mutex
|
||||
pendingVPNSave *pendingVPNCredentials
|
||||
pendingVPNSaveMu sync.Mutex
|
||||
cachedVPNCreds *cachedVPNCredentials
|
||||
cachedVPNCredsMu sync.Mutex
|
||||
cachedPKCS11PIN *cachedPKCS11PIN
|
||||
cachedPKCS11Mu sync.Mutex
|
||||
cachedGPSamlCookie *cachedGPSamlCookie
|
||||
cachedGPSamlMu sync.Mutex
|
||||
|
||||
onStateChange func()
|
||||
}
|
||||
@@ -97,6 +99,14 @@ type cachedPKCS11PIN struct {
|
||||
PIN string
|
||||
}
|
||||
|
||||
type cachedGPSamlCookie struct {
|
||||
ConnectionUUID string
|
||||
Cookie string
|
||||
Host string
|
||||
User string
|
||||
Fingerprint string
|
||||
}
|
||||
|
||||
func NewNetworkManagerBackend(nmConn ...gonetworkmanager.NetworkManager) (*NetworkManagerBackend, error) {
|
||||
var nm gonetworkmanager.NetworkManager
|
||||
var err error
|
||||
|
||||
203
core/internal/server/network/backend_networkmanager_gp_saml.go
Normal file
203
core/internal/server/network/backend_networkmanager_gp_saml.go
Normal file
@@ -0,0 +1,203 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||
)
|
||||
|
||||
type gpSamlAuthResult struct {
|
||||
Cookie string
|
||||
Host string
|
||||
User string
|
||||
Fingerprint string
|
||||
}
|
||||
|
||||
// runGlobalProtectSAMLAuth handles GlobalProtect SAML/SSO authentication using gp-saml-gui.
|
||||
// Only supports protocol=gp. Other protocols need their own implementations.
|
||||
func (b *NetworkManagerBackend) runGlobalProtectSAMLAuth(ctx context.Context, gateway, protocol string) (*gpSamlAuthResult, error) {
|
||||
if gateway == "" {
|
||||
return nil, fmt.Errorf("GP SAML auth: gateway is empty")
|
||||
}
|
||||
if protocol != "gp" {
|
||||
return nil, fmt.Errorf("only GlobalProtect (protocol=gp) SAML is supported, got: %s", protocol)
|
||||
}
|
||||
|
||||
log.Infof("[GP-SAML] Starting GlobalProtect SAML authentication with gp-saml-gui for gateway=%s", gateway)
|
||||
|
||||
gpSamlPath, err := exec.LookPath("gp-saml-gui")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GlobalProtect SAML requires gp-saml-gui (install: pip install gp-saml-gui): %w", err)
|
||||
}
|
||||
|
||||
args := []string{
|
||||
"--gateway",
|
||||
"--allow-insecure-crypto",
|
||||
gateway,
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, gpSamlPath, args...)
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GP SAML auth: failed to create stdout pipe: %w", err)
|
||||
}
|
||||
|
||||
stderr, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GP SAML auth: failed to create stderr pipe: %w", err)
|
||||
}
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
return nil, fmt.Errorf("GP SAML auth: failed to start gp-saml-gui: %w", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(stderr)
|
||||
for scanner.Scan() {
|
||||
log.Debugf("[GP-SAML] gp-saml-gui: %s", scanner.Text())
|
||||
}
|
||||
}()
|
||||
|
||||
result := &gpSamlAuthResult{Host: gateway}
|
||||
var allOutput []string
|
||||
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
allOutput = append(allOutput, line)
|
||||
log.Infof("[GP-SAML] stdout: %s", line)
|
||||
|
||||
switch {
|
||||
case strings.HasPrefix(line, "COOKIE="):
|
||||
result.Cookie = unshellQuote(strings.TrimPrefix(line, "COOKIE="))
|
||||
case strings.HasPrefix(line, "HOST="):
|
||||
result.Host = unshellQuote(strings.TrimPrefix(line, "HOST="))
|
||||
case strings.HasPrefix(line, "USER="):
|
||||
result.User = unshellQuote(strings.TrimPrefix(line, "USER="))
|
||||
case strings.HasPrefix(line, "FINGERPRINT="):
|
||||
result.Fingerprint = unshellQuote(strings.TrimPrefix(line, "FINGERPRINT="))
|
||||
default:
|
||||
parseGPSamlFromCommandLine(line, result)
|
||||
}
|
||||
}
|
||||
|
||||
if err := cmd.Wait(); err != nil {
|
||||
if ctx.Err() != nil {
|
||||
return nil, fmt.Errorf("GP SAML auth timed out or was cancelled: %w", ctx.Err())
|
||||
}
|
||||
if result.Cookie == "" {
|
||||
return nil, fmt.Errorf("GP SAML auth failed: %w (output: %s)", err, strings.Join(allOutput, "\n"))
|
||||
}
|
||||
log.Warnf("[GP-SAML] gp-saml-gui exited with error but cookie was captured: %v", err)
|
||||
}
|
||||
|
||||
if result.Cookie == "" {
|
||||
return nil, fmt.Errorf("GP SAML auth: no cookie in gp-saml-gui output")
|
||||
}
|
||||
|
||||
log.Infof("[GP-SAML] Got prelogin-cookie from gp-saml-gui, converting to openconnect cookie via --authenticate")
|
||||
|
||||
// Convert prelogin-cookie to full openconnect cookie format
|
||||
ocResult, err := convertGPPreloginCookie(ctx, gateway, result.Cookie, result.User)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GP SAML auth: failed to convert prelogin-cookie: %w", err)
|
||||
}
|
||||
|
||||
result.Cookie = ocResult.Cookie
|
||||
result.Host = ocResult.Host
|
||||
result.Fingerprint = ocResult.Fingerprint
|
||||
|
||||
log.Infof("[GP-SAML] Authentication successful: user=%s, host=%s, cookie_len=%d, has_fingerprint=%v",
|
||||
result.User, result.Host, len(result.Cookie), result.Fingerprint != "")
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func convertGPPreloginCookie(ctx context.Context, gateway, preloginCookie, user string) (*gpSamlAuthResult, error) {
|
||||
ocPath, err := exec.LookPath("openconnect")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("openconnect not found: %w", err)
|
||||
}
|
||||
|
||||
args := []string{
|
||||
"--protocol=gp",
|
||||
"--usergroup=gateway:prelogin-cookie",
|
||||
"--user=" + user,
|
||||
"--passwd-on-stdin",
|
||||
"--allow-insecure-crypto",
|
||||
"--authenticate",
|
||||
gateway,
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(ctx, ocPath, args...)
|
||||
cmd.Stdin = strings.NewReader(preloginCookie)
|
||||
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("openconnect --authenticate failed: %w\noutput: %s", err, string(output))
|
||||
}
|
||||
|
||||
result := &gpSamlAuthResult{}
|
||||
for _, line := range strings.Split(string(output), "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
switch {
|
||||
case strings.HasPrefix(line, "COOKIE="):
|
||||
result.Cookie = unshellQuote(strings.TrimPrefix(line, "COOKIE="))
|
||||
case strings.HasPrefix(line, "HOST="):
|
||||
result.Host = unshellQuote(strings.TrimPrefix(line, "HOST="))
|
||||
case strings.HasPrefix(line, "FINGERPRINT="):
|
||||
result.Fingerprint = unshellQuote(strings.TrimPrefix(line, "FINGERPRINT="))
|
||||
case strings.HasPrefix(line, "CONNECT_URL="):
|
||||
connectURL := unshellQuote(strings.TrimPrefix(line, "CONNECT_URL="))
|
||||
if connectURL != "" && result.Host == "" {
|
||||
result.Host = connectURL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if result.Cookie == "" {
|
||||
return nil, fmt.Errorf("no COOKIE in openconnect --authenticate output: %s", string(output))
|
||||
}
|
||||
|
||||
log.Infof("[GP-SAML] openconnect --authenticate: cookie_len=%d, host=%s, fingerprint=%s",
|
||||
len(result.Cookie), result.Host, result.Fingerprint)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func unshellQuote(s string) string {
|
||||
if len(s) >= 2 {
|
||||
if (s[0] == '\'' && s[len(s)-1] == '\'') ||
|
||||
(s[0] == '"' && s[len(s)-1] == '"') {
|
||||
return s[1 : len(s)-1]
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func parseGPSamlFromCommandLine(line string, result *gpSamlAuthResult) {
|
||||
if !strings.Contains(line, "openconnect") {
|
||||
return
|
||||
}
|
||||
|
||||
for _, part := range strings.Fields(line) {
|
||||
switch {
|
||||
case strings.HasPrefix(part, "--cookie="):
|
||||
if result.Cookie == "" {
|
||||
result.Cookie = strings.TrimPrefix(part, "--cookie=")
|
||||
}
|
||||
case strings.HasPrefix(part, "--servercert="):
|
||||
if result.Fingerprint == "" {
|
||||
result.Fingerprint = strings.TrimPrefix(part, "--servercert=")
|
||||
}
|
||||
case strings.HasPrefix(part, "--user="):
|
||||
if result.User == "" {
|
||||
result.User = strings.TrimPrefix(part, "--user=")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUnshellQuote(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "single quoted",
|
||||
input: "'hello world'",
|
||||
expected: "hello world",
|
||||
},
|
||||
{
|
||||
name: "double quoted",
|
||||
input: `"hello world"`,
|
||||
expected: "hello world",
|
||||
},
|
||||
{
|
||||
name: "unquoted",
|
||||
input: "hello",
|
||||
expected: "hello",
|
||||
},
|
||||
{
|
||||
name: "empty single quotes",
|
||||
input: "''",
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
name: "empty double quotes",
|
||||
input: `""`,
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
name: "single quote only",
|
||||
input: "'",
|
||||
expected: "'",
|
||||
},
|
||||
{
|
||||
name: "mismatched quotes",
|
||||
input: "'hello\"",
|
||||
expected: "'hello\"",
|
||||
},
|
||||
{
|
||||
name: "with special chars",
|
||||
input: "'cookie=abc123&user=john'",
|
||||
expected: "cookie=abc123&user=john",
|
||||
},
|
||||
{
|
||||
name: "complex cookie",
|
||||
input: `'authcookie=077058d3bc81&portal=PANGP_GW_01-N&user=john.doe@example.com&domain=Default&preferred-ip=192.168.1.100'`,
|
||||
expected: "authcookie=077058d3bc81&portal=PANGP_GW_01-N&user=john.doe@example.com&domain=Default&preferred-ip=192.168.1.100",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := unshellQuote(tt.input)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseGPSamlFromCommandLine(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
line string
|
||||
initialResult *gpSamlAuthResult
|
||||
expectedCookie string
|
||||
expectedUser string
|
||||
expectedFP string
|
||||
}{
|
||||
{
|
||||
name: "full openconnect command",
|
||||
line: "openconnect --protocol=gp --cookie=AUTH123 --servercert=pin-sha256:ABC --user=john",
|
||||
initialResult: &gpSamlAuthResult{},
|
||||
expectedCookie: "AUTH123",
|
||||
expectedUser: "john",
|
||||
expectedFP: "pin-sha256:ABC",
|
||||
},
|
||||
{
|
||||
name: "with equals signs in cookie",
|
||||
line: "openconnect --cookie=authcookie=xyz123&portal=GATE --user=jane",
|
||||
initialResult: &gpSamlAuthResult{},
|
||||
expectedCookie: "authcookie=xyz123&portal=GATE",
|
||||
expectedUser: "jane",
|
||||
expectedFP: "",
|
||||
},
|
||||
{
|
||||
name: "non-openconnect line",
|
||||
line: "some other output",
|
||||
initialResult: &gpSamlAuthResult{},
|
||||
expectedCookie: "",
|
||||
expectedUser: "",
|
||||
expectedFP: "",
|
||||
},
|
||||
{
|
||||
name: "preserves existing values",
|
||||
line: "openconnect --user=newuser",
|
||||
initialResult: &gpSamlAuthResult{Cookie: "existing", Fingerprint: "existing-fp"},
|
||||
expectedCookie: "existing",
|
||||
expectedUser: "newuser",
|
||||
expectedFP: "existing-fp",
|
||||
},
|
||||
{
|
||||
name: "only updates empty fields",
|
||||
line: "openconnect --cookie=NEW --user=NEW",
|
||||
initialResult: &gpSamlAuthResult{Cookie: "OLD"},
|
||||
expectedCookie: "OLD",
|
||||
expectedUser: "NEW",
|
||||
expectedFP: "",
|
||||
},
|
||||
{
|
||||
name: "real gp-saml-gui output",
|
||||
line: "openconnect --protocol=gp --user=john.doe@example.com --os=linux-64 --usergroup=gateway:prelogin-cookie --passwd-on-stdin",
|
||||
initialResult: &gpSamlAuthResult{},
|
||||
expectedCookie: "",
|
||||
expectedUser: "john.doe@example.com",
|
||||
expectedFP: "",
|
||||
},
|
||||
{
|
||||
name: "with server cert flag",
|
||||
line: "openconnect --servercert=pin-sha256:xp3scfzy3rOgQEXnfPiYKrUk7D66a8b8O+gEXaMPleE= vpn.example.com",
|
||||
initialResult: &gpSamlAuthResult{},
|
||||
expectedCookie: "",
|
||||
expectedUser: "",
|
||||
expectedFP: "pin-sha256:xp3scfzy3rOgQEXnfPiYKrUk7D66a8b8O+gEXaMPleE=",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := tt.initialResult
|
||||
parseGPSamlFromCommandLine(tt.line, result)
|
||||
|
||||
assert.Equal(t, tt.expectedCookie, result.Cookie, "cookie mismatch")
|
||||
assert.Equal(t, tt.expectedUser, result.User, "user mismatch")
|
||||
assert.Equal(t, tt.expectedFP, result.Fingerprint, "fingerprint mismatch")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseGPSamlFromCommandLine_MultipleLines(t *testing.T) {
|
||||
// Simulate gp-saml-gui output with command line suggestion
|
||||
lines := []string{
|
||||
"",
|
||||
"SAML REDIRECT",
|
||||
"Got SAML Login URL",
|
||||
"POST to ACS endpoint...",
|
||||
"Got 'prelogin-cookie': 'FAKE_cookie_12345'",
|
||||
"openconnect --protocol=gp --user=john.doe@example.com --usergroup=gateway:prelogin-cookie --passwd-on-stdin vpn.example.com",
|
||||
"",
|
||||
}
|
||||
|
||||
result := &gpSamlAuthResult{}
|
||||
for _, line := range lines {
|
||||
parseGPSamlFromCommandLine(line, result)
|
||||
}
|
||||
|
||||
assert.Equal(t, "john.doe@example.com", result.User)
|
||||
assert.Empty(t, result.Cookie, "cookie should not be parsed from command line")
|
||||
assert.Empty(t, result.Fingerprint)
|
||||
}
|
||||
@@ -304,6 +304,51 @@ func (b *NetworkManagerBackend) ConnectVPN(uuidOrName string, singleActive bool)
|
||||
if err := b.handleOpenVPNUsernameAuth(targetConn, connName, targetUUID, vpnServiceType); err != nil {
|
||||
return err
|
||||
}
|
||||
case "gp_saml":
|
||||
gateway := vpnData["gateway"]
|
||||
protocol := vpnData["protocol"]
|
||||
if protocol != "gp" {
|
||||
return fmt.Errorf("GlobalProtect SAML authentication only supported for protocol=gp, got: %s", protocol)
|
||||
}
|
||||
|
||||
log.Infof("[ConnectVPN] GlobalProtect SAML/SSO authentication required for %s (gateway=%s)", connName, gateway)
|
||||
|
||||
samlCtx, samlCancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
authResult, err := b.runGlobalProtectSAMLAuth(samlCtx, gateway, protocol)
|
||||
samlCancel()
|
||||
if err != nil {
|
||||
errMsg := err.Error()
|
||||
switch {
|
||||
case strings.Contains(errMsg, "not installed"):
|
||||
return fmt.Errorf("gp-saml-gui is not installed (required for GlobalProtect SAML/SSO VPN)")
|
||||
case strings.Contains(errMsg, "timed out") || strings.Contains(errMsg, "cancelled"):
|
||||
return fmt.Errorf("GlobalProtect SAML authentication timed out — please try again")
|
||||
case strings.Contains(errMsg, "no cookie"):
|
||||
return fmt.Errorf("GlobalProtect SAML login did not complete — browser was closed before authentication finished")
|
||||
case strings.Contains(errMsg, "convert prelogin-cookie"):
|
||||
return fmt.Errorf("GlobalProtect VPN authentication succeeded but cookie exchange failed: %w", err)
|
||||
default:
|
||||
return fmt.Errorf("GlobalProtect SAML authentication failed: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
b.cachedGPSamlMu.Lock()
|
||||
b.cachedGPSamlCookie = &cachedGPSamlCookie{
|
||||
ConnectionUUID: targetUUID,
|
||||
Cookie: authResult.Cookie,
|
||||
Host: authResult.Host,
|
||||
User: authResult.User,
|
||||
Fingerprint: authResult.Fingerprint,
|
||||
}
|
||||
b.cachedGPSamlMu.Unlock()
|
||||
|
||||
if err := targetConn.ClearSecrets(); err != nil {
|
||||
log.Warnf("[ConnectVPN] ClearSecrets failed (non-fatal): %v", err)
|
||||
} else {
|
||||
log.Infof("[ConnectVPN] Cleared stale stored secrets for %s", connName)
|
||||
}
|
||||
|
||||
log.Infof("[ConnectVPN] GlobalProtect SAML cookie cached for %s, proceeding with activation", connName)
|
||||
}
|
||||
|
||||
b.stateMutex.Lock()
|
||||
@@ -339,6 +384,16 @@ func detectVPNAuthAction(serviceType string, data map[string]string) string {
|
||||
}
|
||||
|
||||
switch {
|
||||
case strings.Contains(serviceType, "openconnect"):
|
||||
protocol := data["protocol"]
|
||||
if needsExternalBrowserAuth(protocol, data["authtype"], data["username"], data) {
|
||||
switch protocol {
|
||||
case "gp":
|
||||
return "gp_saml"
|
||||
default:
|
||||
log.Infof("[VPN] External browser auth detected for protocol '%s' but only GlobalProtect (gp) is currently supported", protocol)
|
||||
}
|
||||
}
|
||||
case strings.Contains(serviceType, "openvpn"):
|
||||
connType := data["connection-type"]
|
||||
username := data["username"]
|
||||
@@ -670,10 +725,13 @@ func (b *NetworkManagerBackend) updateVPNConnectionState() {
|
||||
b.state.LastError = ""
|
||||
b.stateMutex.Unlock()
|
||||
|
||||
// Clear cached PKCS11 PIN on success
|
||||
// Clear cached PKCS11 PIN and SAML cookie on success
|
||||
b.cachedPKCS11Mu.Lock()
|
||||
b.cachedPKCS11PIN = nil
|
||||
b.cachedPKCS11Mu.Unlock()
|
||||
b.cachedGPSamlMu.Lock()
|
||||
b.cachedGPSamlCookie = nil
|
||||
b.cachedGPSamlMu.Unlock()
|
||||
|
||||
b.pendingVPNSaveMu.Lock()
|
||||
pending := b.pendingVPNSave
|
||||
@@ -692,10 +750,13 @@ func (b *NetworkManagerBackend) updateVPNConnectionState() {
|
||||
b.state.LastError = "VPN connection failed"
|
||||
b.stateMutex.Unlock()
|
||||
|
||||
// Clear cached PKCS11 PIN on failure
|
||||
// Clear cached PKCS11 PIN and SAML cookie on failure
|
||||
b.cachedPKCS11Mu.Lock()
|
||||
b.cachedPKCS11PIN = nil
|
||||
b.cachedPKCS11Mu.Unlock()
|
||||
b.cachedGPSamlMu.Lock()
|
||||
b.cachedGPSamlCookie = nil
|
||||
b.cachedGPSamlMu.Unlock()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -709,10 +770,13 @@ func (b *NetworkManagerBackend) updateVPNConnectionState() {
|
||||
b.state.LastError = "VPN connection failed"
|
||||
b.stateMutex.Unlock()
|
||||
|
||||
// Clear cached PKCS11 PIN
|
||||
// Clear cached PKCS11 PIN and SAML cookie
|
||||
b.cachedPKCS11Mu.Lock()
|
||||
b.cachedPKCS11PIN = nil
|
||||
b.cachedPKCS11Mu.Unlock()
|
||||
b.cachedGPSamlMu.Lock()
|
||||
b.cachedGPSamlCookie = nil
|
||||
b.cachedGPSamlMu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,22 @@ func XDGConfigHome() string {
|
||||
return filepath.Join(home, ".config")
|
||||
}
|
||||
|
||||
func EmacsConfigDir() string {
|
||||
home, _ := os.UserHomeDir()
|
||||
|
||||
emacsD := filepath.Join(home, ".emacs.d")
|
||||
if info, err := os.Stat(emacsD); err == nil && info.IsDir() {
|
||||
return emacsD
|
||||
}
|
||||
|
||||
xdgEmacs := filepath.Join(XDGConfigHome(), "emacs")
|
||||
if info, err := os.Stat(xdgEmacs); err == nil && info.IsDir() {
|
||||
return xdgEmacs
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func ExpandPath(path string) (string, error) {
|
||||
expanded := os.ExpandEnv(path)
|
||||
expanded = filepath.Clean(expanded)
|
||||
|
||||
@@ -73,6 +73,7 @@ in
|
||||
"labwc"
|
||||
"mango"
|
||||
"scroll"
|
||||
"miracle"
|
||||
];
|
||||
description = "Compositor to run greeter in";
|
||||
};
|
||||
|
||||
@@ -50,5 +50,6 @@ in
|
||||
|
||||
services.power-profiles-daemon.enable = lib.mkDefault true;
|
||||
services.accounts-daemon.enable = lib.mkDefault true;
|
||||
security.polkit.enable = lib.mkDefault true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
sonnet
|
||||
qtmultimedia
|
||||
qtimageformats
|
||||
kimageformats
|
||||
];
|
||||
in
|
||||
{
|
||||
@@ -79,7 +80,7 @@
|
||||
inherit version;
|
||||
pname = "dms-shell";
|
||||
src = ./core;
|
||||
vendorHash = "sha256-Ij5jlmWpZkqQU8j8HXLt6RsRDK3pKfhLBbjlRq5UZms=";
|
||||
vendorHash = "sha256-cVUJXgzYMRSM0od1xzDVkMTdxHu3OIQX2bQ8AJbGQ1Q=";
|
||||
|
||||
subPackages = [ "cmd/dms" ];
|
||||
|
||||
|
||||
@@ -123,6 +123,8 @@ Singleton {
|
||||
property string vpnLastConnected: ""
|
||||
|
||||
property var deviceMaxVolumes: ({})
|
||||
property var hiddenOutputDeviceNames: []
|
||||
property var hiddenInputDeviceNames: []
|
||||
|
||||
Component.onCompleted: {
|
||||
if (!isGreeterMode) {
|
||||
@@ -1069,6 +1071,20 @@ Singleton {
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function setHiddenOutputDeviceNames(deviceNames) {
|
||||
if (!Array.isArray(deviceNames))
|
||||
return;
|
||||
hiddenOutputDeviceNames = deviceNames;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function setHiddenInputDeviceNames(deviceNames) {
|
||||
if (!Array.isArray(deviceNames))
|
||||
return;
|
||||
hiddenInputDeviceNames = deviceNames;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function getDeviceMaxVolume(nodeName) {
|
||||
if (!nodeName)
|
||||
return 100;
|
||||
|
||||
@@ -60,6 +60,7 @@ Singleton {
|
||||
property bool _hasLoaded: false
|
||||
property bool _isReadOnly: false
|
||||
property bool _hasUnsavedChanges: false
|
||||
property bool _selfWrite: false
|
||||
property var _loadedSettingsSnapshot: null
|
||||
property var pluginSettings: ({})
|
||||
property var builtInPluginSettings: ({})
|
||||
@@ -314,7 +315,7 @@ Singleton {
|
||||
property int dankLauncherV2BorderThickness: 2
|
||||
property string dankLauncherV2BorderColor: "primary"
|
||||
property bool dankLauncherV2ShowFooter: true
|
||||
property bool dankLauncherV2UnloadOnClose: true
|
||||
property bool dankLauncherV2UnloadOnClose: false
|
||||
|
||||
property string _legacyWeatherLocation: "New York, NY"
|
||||
property string _legacyWeatherCoordinates: "40.7128,-74.0060"
|
||||
@@ -472,6 +473,8 @@ Singleton {
|
||||
property bool dockShowOverflowBadge: true
|
||||
|
||||
property bool notificationOverlayEnabled: false
|
||||
property bool notificationPopupShadowEnabled: true
|
||||
property bool notificationPopupPrivacyMode: false
|
||||
property int overviewRows: 2
|
||||
property int overviewColumns: 5
|
||||
property real overviewScale: 0.16
|
||||
@@ -501,6 +504,8 @@ Singleton {
|
||||
property int notificationTimeoutCritical: 0
|
||||
property bool notificationCompactMode: false
|
||||
property int notificationPopupPosition: SettingsData.Position.Top
|
||||
property int notificationAnimationSpeed: SettingsData.AnimationSpeed.Short
|
||||
property int notificationCustomAnimationDuration: 400
|
||||
property bool notificationHistoryEnabled: true
|
||||
property int notificationHistoryMaxCount: 50
|
||||
property int notificationHistoryMaxAgeDays: 7
|
||||
@@ -1010,6 +1015,42 @@ Singleton {
|
||||
function applyStoredIconTheme() {
|
||||
updateGtkIconTheme();
|
||||
updateQtIconTheme();
|
||||
updateCosmicIconTheme();
|
||||
}
|
||||
|
||||
function updateCosmicIconTheme() {
|
||||
let cosmicThemeName = (iconTheme === "System Default") ? systemDefaultIconTheme : iconTheme;
|
||||
if (!cosmicThemeName || cosmicThemeName === "System Default") {
|
||||
const detectScript = `if command -v gsettings >/dev/null 2>&1; then
|
||||
gsettings get org.gnome.desktop.interface icon-theme 2>/dev/null | sed "s/'//g"
|
||||
elif command -v dconf >/dev/null 2>&1; then
|
||||
dconf read /org/gnome/desktop/interface/icon-theme 2>/dev/null | sed "s/'//g"
|
||||
fi`;
|
||||
Proc.runCommand("detectCosmicIconTheme", ["sh", "-c", detectScript], (output, exitCode) => {
|
||||
if (exitCode !== 0)
|
||||
return;
|
||||
const detected = (output || "").trim();
|
||||
if (!detected || detected === "System Default")
|
||||
return;
|
||||
const detectedEscaped = detected.replace(/'/g, "'\\''");
|
||||
const writeScript = `mkdir -p ${_configDir}/cosmic/com.system76.CosmicTk/v1
|
||||
printf '"%s"\\n' '${detectedEscaped}' > ${_configDir}/cosmic/com.system76.CosmicTk/v1/icon_theme 2>/dev/null || true`;
|
||||
Quickshell.execDetached(["sh", "-lc", writeScript]);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const cosmicThemeNameEscaped = cosmicThemeName.replace(/'/g, "'\\''");
|
||||
const script = `mkdir -p ${_configDir}/cosmic/com.system76.CosmicTk/v1
|
||||
printf '"%s"\\n' '${cosmicThemeNameEscaped}' > ${_configDir}/cosmic/com.system76.CosmicTk/v1/icon_theme 2>/dev/null || true`;
|
||||
Quickshell.execDetached(["sh", "-lc", script]);
|
||||
}
|
||||
|
||||
function updateCosmicThemeMode(isLightMode) {
|
||||
const isDark = isLightMode ? "false" : "true";
|
||||
const script = `mkdir -p ${_configDir}/cosmic/com.system76.CosmicTheme.Mode/v1
|
||||
printf '%s\\n' ${isDark} > ${_configDir}/cosmic/com.system76.CosmicTheme.Mode/v1/is_dark 2>/dev/null || true`;
|
||||
Quickshell.execDetached(["sh", "-lc", script]);
|
||||
}
|
||||
|
||||
function updateGtkIconTheme() {
|
||||
@@ -1203,6 +1244,7 @@ Singleton {
|
||||
function saveSettings() {
|
||||
if (_loading || _parseError || !_hasLoaded)
|
||||
return;
|
||||
_selfWrite = true;
|
||||
settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2));
|
||||
if (_isReadOnly)
|
||||
_checkSettingsWritable();
|
||||
@@ -1816,6 +1858,7 @@ Singleton {
|
||||
iconTheme = themeName;
|
||||
updateGtkIconTheme();
|
||||
updateQtIconTheme();
|
||||
updateCosmicIconTheme();
|
||||
saveSettings();
|
||||
if (typeof Theme !== "undefined" && Theme.currentTheme === Theme.dynamic)
|
||||
Theme.generateSystemThemesFromCurrentTheme();
|
||||
@@ -2138,6 +2181,9 @@ Singleton {
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
property bool _pendingExpandNotificationRules: false
|
||||
property int _pendingNotificationRuleIndex: -1
|
||||
|
||||
function addNotificationRule() {
|
||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||
rules.push({
|
||||
@@ -2145,6 +2191,45 @@ Singleton {
|
||||
field: "appName",
|
||||
pattern: "",
|
||||
matchType: "contains",
|
||||
action: "default",
|
||||
urgency: "default"
|
||||
});
|
||||
notificationRules = rules;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function addNotificationRuleForNotification(appName, desktopEntry) {
|
||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||
var pattern = (desktopEntry && desktopEntry !== "") ? desktopEntry : (appName || "");
|
||||
var field = (desktopEntry && desktopEntry !== "") ? "desktopEntry" : "appName";
|
||||
var rule = {
|
||||
enabled: true,
|
||||
field: pattern ? field : "appName",
|
||||
pattern: pattern || "",
|
||||
matchType: pattern ? "exact" : "contains",
|
||||
action: "default",
|
||||
urgency: "default"
|
||||
};
|
||||
rules.push(rule);
|
||||
notificationRules = rules;
|
||||
saveSettings();
|
||||
var index = rules.length - 1;
|
||||
_pendingExpandNotificationRules = true;
|
||||
_pendingNotificationRuleIndex = index;
|
||||
return index;
|
||||
}
|
||||
|
||||
function addMuteRuleForApp(appName, desktopEntry) {
|
||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||
var pattern = (desktopEntry && desktopEntry !== "") ? desktopEntry : (appName || "");
|
||||
var field = (desktopEntry && desktopEntry !== "") ? "desktopEntry" : "appName";
|
||||
if (pattern === "")
|
||||
return;
|
||||
rules.push({
|
||||
enabled: true,
|
||||
field: field,
|
||||
pattern: pattern,
|
||||
matchType: "exact",
|
||||
action: "mute",
|
||||
urgency: "default"
|
||||
});
|
||||
@@ -2152,6 +2237,51 @@ Singleton {
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function isAppMuted(appName, desktopEntry) {
|
||||
const rules = notificationRules || [];
|
||||
const pat = (desktopEntry && desktopEntry !== "" ? desktopEntry : appName || "").toString().toLowerCase();
|
||||
if (!pat)
|
||||
return false;
|
||||
for (let i = 0; i < rules.length; i++) {
|
||||
const r = rules[i];
|
||||
if ((r.action || "").toString().toLowerCase() !== "mute" || r.enabled === false)
|
||||
continue;
|
||||
const field = (r.field || "appName").toString().toLowerCase();
|
||||
const rulePat = (r.pattern || "").toString().toLowerCase();
|
||||
if (!rulePat)
|
||||
continue;
|
||||
const useDesktop = field === "desktopentry";
|
||||
const matches = (useDesktop && desktopEntry) ? (desktopEntry.toString().toLowerCase() === rulePat) : (appName && appName.toString().toLowerCase() === rulePat);
|
||||
if (matches)
|
||||
return true;
|
||||
if (rulePat === pat)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeMuteRuleForApp(appName, desktopEntry) {
|
||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||
const app = (appName || "").toString().toLowerCase();
|
||||
const desktop = (desktopEntry || "").toString().toLowerCase();
|
||||
if (!app && !desktop)
|
||||
return;
|
||||
for (let i = rules.length - 1; i >= 0; i--) {
|
||||
const r = rules[i];
|
||||
if ((r.action || "").toString().toLowerCase() !== "mute")
|
||||
continue;
|
||||
const rulePat = (r.pattern || "").toString().toLowerCase();
|
||||
if (!rulePat)
|
||||
continue;
|
||||
if (rulePat === app || rulePat === desktop) {
|
||||
rules.splice(i, 1);
|
||||
notificationRules = rules;
|
||||
saveSettings();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateNotificationRule(index, ruleData) {
|
||||
var rules = JSON.parse(JSON.stringify(notificationRules || []));
|
||||
if (index < 0 || index >= rules.length)
|
||||
@@ -2446,6 +2576,13 @@ Singleton {
|
||||
|
||||
property alias settingsFile: settingsFile
|
||||
|
||||
Timer {
|
||||
id: settingsFileReloadDebounce
|
||||
interval: 50
|
||||
onTriggered: settingsFile.reload()
|
||||
repeat: false
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: settingsFile
|
||||
|
||||
@@ -2453,7 +2590,14 @@ Singleton {
|
||||
blockLoading: true
|
||||
blockWrites: true
|
||||
atomicWrites: true
|
||||
watchChanges: !isGreeterMode
|
||||
watchChanges: true
|
||||
onFileChanged: {
|
||||
if (_selfWrite) {
|
||||
_selfWrite = false;
|
||||
return;
|
||||
}
|
||||
settingsFileReloadDebounce.restart();
|
||||
}
|
||||
onLoaded: {
|
||||
if (isGreeterMode)
|
||||
return;
|
||||
|
||||
@@ -188,6 +188,8 @@ Singleton {
|
||||
|
||||
if (typeof SettingsData !== "undefined" && SettingsData.currentThemeName) {
|
||||
switchTheme(SettingsData.currentThemeName, false, false);
|
||||
const currentIsLight = (typeof SessionData !== "undefined") ? SessionData.isLightMode : false;
|
||||
SettingsData.updateCosmicThemeMode(currentIsLight);
|
||||
}
|
||||
|
||||
if (typeof SessionData !== "undefined" && SessionData.themeModeAutoEnabled) {
|
||||
@@ -776,6 +778,53 @@ Singleton {
|
||||
};
|
||||
}
|
||||
|
||||
readonly property int notificationAnimationBaseDuration: {
|
||||
if (typeof SettingsData === "undefined")
|
||||
return 200;
|
||||
if (SettingsData.notificationAnimationSpeed === SettingsData.AnimationSpeed.None)
|
||||
return 0;
|
||||
if (SettingsData.notificationAnimationSpeed === SettingsData.AnimationSpeed.Custom)
|
||||
return SettingsData.notificationCustomAnimationDuration;
|
||||
const presetMap = [0, 200, 400, 600];
|
||||
return presetMap[SettingsData.notificationAnimationSpeed] ?? 200;
|
||||
}
|
||||
|
||||
readonly property int notificationEnterDuration: {
|
||||
const base = notificationAnimationBaseDuration;
|
||||
return base === 0 ? 0 : Math.round(base * 0.875);
|
||||
}
|
||||
|
||||
readonly property int notificationExitDuration: {
|
||||
const base = notificationAnimationBaseDuration;
|
||||
return base === 0 ? 0 : Math.round(base * 0.75);
|
||||
}
|
||||
|
||||
readonly property int notificationExpandDuration: {
|
||||
const base = notificationAnimationBaseDuration;
|
||||
return base === 0 ? 0 : Math.round(base * 1.0);
|
||||
}
|
||||
|
||||
readonly property int notificationCollapseDuration: {
|
||||
const base = notificationAnimationBaseDuration;
|
||||
return base === 0 ? 0 : Math.round(base * 0.85);
|
||||
}
|
||||
|
||||
readonly property real notificationIconSizeNormal: 56
|
||||
readonly property real notificationIconSizeCompact: 48
|
||||
readonly property real notificationExpandedIconSizeNormal: 48
|
||||
readonly property real notificationExpandedIconSizeCompact: 40
|
||||
readonly property real notificationActionMinWidth: 48
|
||||
readonly property real notificationButtonCornerRadius: cornerRadius / 2
|
||||
readonly property real notificationHoverRevealMargin: spacingXL
|
||||
readonly property real notificationContentSpacing: spacingXS
|
||||
readonly property real notificationCardPadding: spacingM
|
||||
readonly property real notificationCardPaddingCompact: spacingS
|
||||
|
||||
readonly property real stateLayerHover: 0.08
|
||||
readonly property real stateLayerFocus: 0.12
|
||||
readonly property real stateLayerPressed: 0.12
|
||||
readonly property real stateLayerDrag: 0.16
|
||||
|
||||
readonly property int popoutAnimationDuration: {
|
||||
if (typeof SettingsData === "undefined")
|
||||
return 150;
|
||||
@@ -916,6 +965,9 @@ Singleton {
|
||||
if (!matugenAvailable) {
|
||||
PortalService.setLightMode(light);
|
||||
}
|
||||
if (typeof SettingsData !== "undefined") {
|
||||
SettingsData.updateCosmicThemeMode(light);
|
||||
}
|
||||
generateSystemThemesFromCurrentTheme();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,15 @@ function markdownToHtml(text) {
|
||||
return `\x00INLINECODE${inlineIndex++}\x00`;
|
||||
});
|
||||
|
||||
// Now process everything else
|
||||
// Escape HTML entities (but not in code blocks)
|
||||
// Extract plain URLs before escaping so & in query strings is preserved
|
||||
const urls = [];
|
||||
let urlIndex = 0;
|
||||
html = html.replace(/(^|[\s])((?:https?|file):\/\/[^\s]+)/gm, (match, prefix, url) => {
|
||||
urls.push(url);
|
||||
return prefix + `\x00URL${urlIndex++}\x00`;
|
||||
});
|
||||
|
||||
// Escape HTML entities (but not in code blocks or URLs)
|
||||
html = html.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
@@ -64,8 +71,12 @@ function markdownToHtml(text) {
|
||||
return '<ul>' + match + '</ul>';
|
||||
});
|
||||
|
||||
// Detect plain URLs and wrap them in anchor tags (but not inside existing <a> or markdown links)
|
||||
html = html.replace(/(^|[^"'>])((https?|file):\/\/[^\s<]+)/g, '$1<a href="$2">$2</a>');
|
||||
// Restore extracted URLs as anchor tags (preserves raw & in href)
|
||||
html = html.replace(/\x00URL(\d+)\x00/g, (_, index) => {
|
||||
const url = urls[parseInt(index)];
|
||||
const display = url.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
return `<a href="${url}">${display}</a>`;
|
||||
});
|
||||
|
||||
// Restore code blocks and inline code BEFORE line break processing
|
||||
html = html.replace(/\x00CODEBLOCK(\d+)\x00/g, (match, index) => {
|
||||
|
||||
@@ -75,7 +75,9 @@ var SPEC = {
|
||||
|
||||
vpnLastConnected: { def: "" },
|
||||
|
||||
deviceMaxVolumes: { def: {} }
|
||||
deviceMaxVolumes: { def: {} },
|
||||
hiddenOutputDeviceNames: { def: [] },
|
||||
hiddenInputDeviceNames: { def: [] }
|
||||
};
|
||||
|
||||
function getValidKeys() {
|
||||
|
||||
@@ -173,7 +173,7 @@ var SPEC = {
|
||||
dankLauncherV2BorderThickness: { def: 2 },
|
||||
dankLauncherV2BorderColor: { def: "primary" },
|
||||
dankLauncherV2ShowFooter: { def: true },
|
||||
dankLauncherV2UnloadOnClose: { def: true },
|
||||
dankLauncherV2UnloadOnClose: { def: false },
|
||||
|
||||
useAutoLocation: { def: false },
|
||||
weatherEnabled: { def: true },
|
||||
@@ -297,6 +297,8 @@ var SPEC = {
|
||||
dockShowOverflowBadge: { def: true },
|
||||
|
||||
notificationOverlayEnabled: { def: false },
|
||||
notificationPopupShadowEnabled: { def: true },
|
||||
notificationPopupPrivacyMode: { def: false },
|
||||
overviewRows: { def: 2, persist: false },
|
||||
overviewColumns: { def: 5, persist: false },
|
||||
overviewScale: { def: 0.16, persist: false },
|
||||
@@ -325,6 +327,8 @@ var SPEC = {
|
||||
notificationTimeoutCritical: { def: 0 },
|
||||
notificationCompactMode: { def: false },
|
||||
notificationPopupPosition: { def: 0 },
|
||||
notificationAnimationSpeed: { def: 1 },
|
||||
notificationCustomAnimationDuration: { def: 400 },
|
||||
notificationHistoryEnabled: { def: true },
|
||||
notificationHistoryMaxCount: { def: 50 },
|
||||
notificationHistoryMaxAgeDays: { def: 7 },
|
||||
|
||||
@@ -197,7 +197,7 @@ Item {
|
||||
if (CompositorService.isNiri && NiriService.currentOutput) {
|
||||
return NiriService.currentOutput;
|
||||
}
|
||||
if ((CompositorService.isSway || CompositorService.isScroll) && I3.workspaces?.values) {
|
||||
if ((CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) && I3.workspaces?.values) {
|
||||
const focusedWs = I3.workspaces.values.find(ws => ws.focused === true);
|
||||
return focusedWs?.monitor?.name || "";
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ Column {
|
||||
StyledText {
|
||||
id: codenameText
|
||||
anchors.centerIn: parent
|
||||
text: "Spicy Miso"
|
||||
text: "Saffron Bloom"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: Theme.primary
|
||||
@@ -74,7 +74,7 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "Desktop widgets, theme registry, native clipboard & more"
|
||||
text: "New launcher, enhanced plugin system, KDE Connect, & more"
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
@@ -108,67 +108,76 @@ Column {
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "widgets"
|
||||
title: "Desktop Widgets"
|
||||
description: "Widgets on your desktop"
|
||||
onClicked: PopoutService.openSettingsWithTab("desktop_widgets")
|
||||
iconName: "space_dashboard"
|
||||
title: "Dank Launcher V2"
|
||||
description: "New capabilities & plugins"
|
||||
onClicked: PopoutService.openDankLauncherV2()
|
||||
}
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "palette"
|
||||
title: "Theme Registry"
|
||||
description: "Community themes"
|
||||
onClicked: PopoutService.openSettingsWithTab("theme")
|
||||
iconName: "smartphone"
|
||||
title: "Phone Connect"
|
||||
description: "KDE Connect & Valent"
|
||||
onClicked: Qt.openUrlExternally("https://github.com/AvengeMedia/dms-plugins/tree/master/DankKDEConnect")
|
||||
}
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "content_paste"
|
||||
title: "Native Clipboard"
|
||||
description: "Zero-dependency history"
|
||||
onClicked: PopoutService.openSettingsWithTab("clipboard")
|
||||
iconName: "monitor_heart"
|
||||
title: "System Monitor"
|
||||
description: "Redesigned process list"
|
||||
onClicked: PopoutService.showProcessListModal()
|
||||
}
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "display_settings"
|
||||
title: "Monitor Config"
|
||||
description: "Full display setup"
|
||||
onClicked: PopoutService.openSettingsWithTab("display_config")
|
||||
iconName: "window"
|
||||
title: "Window Rules"
|
||||
description: "niri window rule manager"
|
||||
visible: CompositorService.isNiri
|
||||
onClicked: PopoutService.openSettingsWithTab("window_rules")
|
||||
}
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "notifications_active"
|
||||
title: "Notifications"
|
||||
description: "History & gestures"
|
||||
title: "Enhanced Notifications"
|
||||
description: "Configurable rules & styling"
|
||||
visible: !CompositorService.isNiri
|
||||
onClicked: PopoutService.openSettingsWithTab("notifications")
|
||||
}
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "healing"
|
||||
title: "DMS Doctor"
|
||||
description: "Diagnose issues"
|
||||
onClicked: FirstLaunchService.showDoctor()
|
||||
iconName: "dock_to_bottom"
|
||||
title: "Dock Enhancements"
|
||||
description: "Bar dock widget & more"
|
||||
onClicked: PopoutService.openSettingsWithTab("dock")
|
||||
}
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "keyboard"
|
||||
title: "Keybinds Editor"
|
||||
description: "niri, Hyprland, & MangoWC"
|
||||
visible: KeybindsService.available
|
||||
onClicked: PopoutService.openSettingsWithTab("keybinds")
|
||||
iconName: "volume_up"
|
||||
title: "Audio Aliases"
|
||||
description: "Custom device names"
|
||||
onClicked: PopoutService.openSettingsWithTab("audio")
|
||||
}
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "search"
|
||||
title: "Settings Search"
|
||||
description: "Find settings fast"
|
||||
onClicked: PopoutService.openSettings()
|
||||
iconName: "extension"
|
||||
title: "Enhanced Plugin System"
|
||||
description: "Enables new types of plugins"
|
||||
onClicked: PopoutService.openSettingsWithTab("plugins")
|
||||
}
|
||||
|
||||
ChangelogFeatureCard {
|
||||
width: (parent.width - Theme.spacingS) / 2
|
||||
iconName: "light_mode"
|
||||
title: "Auto Light/Dark"
|
||||
description: "Automatic mode switching"
|
||||
onClicked: PopoutService.openSettingsWithTab("theme")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,26 +230,21 @@ Column {
|
||||
|
||||
ChangelogUpgradeNote {
|
||||
width: parent.width
|
||||
text: "Ghostty theme path changed to ~/.config/ghostty/themes/danktheme"
|
||||
text: "Spotlight replaced by Dank Launcher V2 — check settings for new options"
|
||||
}
|
||||
|
||||
ChangelogUpgradeNote {
|
||||
width: parent.width
|
||||
text: "VS Code theme reinstall required"
|
||||
}
|
||||
|
||||
ChangelogUpgradeNote {
|
||||
width: parent.width
|
||||
text: "Clipboard history migration available from cliphist"
|
||||
text: "Plugin API updated — third-party plugins may need updates"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "See full release notes for migration steps"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
width: parent.width
|
||||
}
|
||||
// StyledText {
|
||||
// text: "See full release notes for migration steps"
|
||||
// font.pixelSize: Theme.fontSizeSmall
|
||||
// color: Theme.surfaceVariantText
|
||||
// width: parent.width
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ FloatingWindow {
|
||||
iconName: "open_in_new"
|
||||
backgroundColor: Theme.surfaceContainerHighest
|
||||
textColor: Theme.surfaceText
|
||||
onClicked: Qt.openUrlExternally("https://danklinux.com/blog/v1-2-release")
|
||||
onClicked: Qt.openUrlExternally("https://danklinux.com/blog/v1-4-release")
|
||||
}
|
||||
|
||||
DankButton {
|
||||
|
||||
@@ -246,11 +246,6 @@ Item {
|
||||
bottom: root.useSingleWindow
|
||||
}
|
||||
|
||||
BackgroundEffect.blurRegion: Region {
|
||||
item: shouldBeVisible ? modalContainer : null
|
||||
radius: root.cornerRadius
|
||||
}
|
||||
|
||||
WlrLayershell.margins {
|
||||
left: root.useSingleWindow ? 0 : Math.max(0, Theme.snap(root.alignedX - shadowBuffer, dpr))
|
||||
top: root.useSingleWindow ? 0 : Math.max(0, Theme.snap(root.alignedY - shadowBuffer, dpr))
|
||||
@@ -385,9 +380,9 @@ Item {
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: root.backgroundColor
|
||||
border.color: root.borderColor
|
||||
border.width: root.borderWidth
|
||||
radius: root.cornerRadius
|
||||
border.color: Theme.outline
|
||||
border.width: 1
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
|
||||
@@ -13,10 +13,14 @@ Item {
|
||||
property bool spotlightOpen: false
|
||||
property bool keyboardActive: false
|
||||
property bool contentVisible: false
|
||||
property alias spotlightContent: launcherContent
|
||||
property var spotlightContent: launcherContentLoader.item
|
||||
property bool openedFromOverview: false
|
||||
property bool isClosing: false
|
||||
property bool _windowEnabled: true
|
||||
property bool _pendingInitialize: false
|
||||
property string _pendingQuery: ""
|
||||
property string _pendingMode: ""
|
||||
readonly property bool unloadContentOnClose: SettingsData.dankLauncherV2UnloadOnClose
|
||||
|
||||
readonly property bool useHyprlandFocusGrab: CompositorService.useHyprlandFocusGrab
|
||||
readonly property var effectiveScreen: launcherWindow.screen
|
||||
@@ -75,7 +79,22 @@ Item {
|
||||
|
||||
signal dialogClosed
|
||||
|
||||
function _ensureContentLoadedAndInitialize(query, mode) {
|
||||
_pendingQuery = query || "";
|
||||
_pendingMode = mode || "";
|
||||
_pendingInitialize = true;
|
||||
contentVisible = true;
|
||||
launcherContentLoader.active = true;
|
||||
|
||||
if (spotlightContent) {
|
||||
_initializeAndShow(_pendingQuery, _pendingMode);
|
||||
_pendingInitialize = false;
|
||||
}
|
||||
}
|
||||
|
||||
function _initializeAndShow(query, mode) {
|
||||
if (!spotlightContent)
|
||||
return;
|
||||
contentVisible = true;
|
||||
spotlightContent.searchField.forceActiveFocus();
|
||||
|
||||
@@ -121,7 +140,7 @@ Item {
|
||||
if (useHyprlandFocusGrab)
|
||||
focusGrab.active = true;
|
||||
|
||||
_initializeAndShow("");
|
||||
_ensureContentLoadedAndInitialize("", "");
|
||||
}
|
||||
|
||||
function showWithQuery(query) {
|
||||
@@ -139,7 +158,7 @@ Item {
|
||||
if (useHyprlandFocusGrab)
|
||||
focusGrab.active = true;
|
||||
|
||||
_initializeAndShow(query);
|
||||
_ensureContentLoadedAndInitialize(query, "");
|
||||
}
|
||||
|
||||
function hide() {
|
||||
@@ -176,7 +195,7 @@ Item {
|
||||
if (useHyprlandFocusGrab)
|
||||
focusGrab.active = true;
|
||||
|
||||
_initializeAndShow("", mode);
|
||||
_ensureContentLoadedAndInitialize("", mode);
|
||||
}
|
||||
|
||||
function toggleWithMode(mode) {
|
||||
@@ -201,6 +220,8 @@ Item {
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
isClosing = false;
|
||||
if (root.unloadContentOnClose)
|
||||
launcherContentLoader.active = false;
|
||||
dialogClosed();
|
||||
}
|
||||
}
|
||||
@@ -263,7 +284,7 @@ Item {
|
||||
|
||||
PanelWindow {
|
||||
id: launcherWindow
|
||||
visible: root._windowEnabled
|
||||
visible: root._windowEnabled && (!root.unloadContentOnClose || spotlightOpen || isClosing)
|
||||
color: "transparent"
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
|
||||
@@ -291,14 +312,6 @@ Item {
|
||||
right: true
|
||||
}
|
||||
|
||||
BackgroundEffect.blurRegion: Region {
|
||||
x: contentVisible ? root.modalX : 0
|
||||
y: contentVisible ? root.modalY : 0
|
||||
width: contentVisible ? root.modalWidth : 0
|
||||
height: contentVisible ? root.modalHeight : 0
|
||||
radius: root.cornerRadius
|
||||
}
|
||||
|
||||
mask: Region {
|
||||
item: spotlightOpen ? fullScreenMask : null
|
||||
}
|
||||
@@ -367,6 +380,8 @@ Item {
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: root.backgroundColor
|
||||
border.color: root.borderColor
|
||||
border.width: root.borderWidth
|
||||
radius: root.cornerRadius
|
||||
}
|
||||
|
||||
@@ -379,12 +394,22 @@ Item {
|
||||
anchors.fill: parent
|
||||
focus: keyboardActive
|
||||
|
||||
LauncherContent {
|
||||
id: launcherContent
|
||||
Loader {
|
||||
id: launcherContentLoader
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
parentModal: root
|
||||
heavyContentActive: !SettingsData.dankLauncherV2UnloadOnClose || spotlightOpen || isClosing
|
||||
active: !root.unloadContentOnClose || root.spotlightOpen || root.isClosing || root.contentVisible || root._pendingInitialize
|
||||
asynchronous: false
|
||||
sourceComponent: LauncherContent {
|
||||
focus: true
|
||||
parentModal: root
|
||||
}
|
||||
|
||||
onLoaded: {
|
||||
if (root._pendingInitialize) {
|
||||
root._initializeAndShow(root._pendingQuery, root._pendingMode);
|
||||
root._pendingInitialize = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onEscapePressed: event => {
|
||||
@@ -392,14 +417,6 @@ Item {
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: root.cornerRadius
|
||||
color: "transparent"
|
||||
border.color: Theme.outline
|
||||
border.width: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,10 @@ FocusScope {
|
||||
LayoutMirroring.childrenInherit: true
|
||||
|
||||
property var parentModal: null
|
||||
property bool heavyContentActive: true
|
||||
property string viewModeContext: "spotlight"
|
||||
property alias searchField: searchField
|
||||
property alias controller: controller
|
||||
property var resultsList: resultsLoader.item
|
||||
property alias resultsList: resultsList
|
||||
property alias actionPanel: actionPanel
|
||||
|
||||
property bool editMode: false
|
||||
@@ -24,8 +23,7 @@ FocusScope {
|
||||
property string editAppId: ""
|
||||
|
||||
function resetScroll() {
|
||||
if (resultsList)
|
||||
resultsList.resetScroll();
|
||||
resultsList.resetScroll();
|
||||
}
|
||||
|
||||
function focusSearchField() {
|
||||
@@ -224,7 +222,7 @@ FocusScope {
|
||||
return;
|
||||
case Qt.Key_Menu:
|
||||
case Qt.Key_F10:
|
||||
if (resultsList && contextMenu.hasContextMenuActions(controller.selectedItem)) {
|
||||
if (contextMenu.hasContextMenuActions(controller.selectedItem)) {
|
||||
var scenePos = resultsList.getSelectedItemPosition();
|
||||
var localPos = root.mapFromItem(null, scenePos.x, scenePos.y);
|
||||
showContextMenu(controller.selectedItem, localPos.x, localPos.y, true);
|
||||
@@ -279,6 +277,9 @@ FocusScope {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.leftMargin: root.parentModal?.borderWidth ?? 1
|
||||
anchors.rightMargin: root.parentModal?.borderWidth ?? 1
|
||||
anchors.bottomMargin: root.parentModal?.borderWidth ?? 1
|
||||
readonly property bool showFooter: SettingsData.dankLauncherV2Size !== "micro" && SettingsData.dankLauncherV2ShowFooter
|
||||
height: showFooter ? 36 : 0
|
||||
visible: showFooter
|
||||
@@ -550,15 +551,14 @@ FocusScope {
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: resultsLoader
|
||||
Item {
|
||||
width: parent.width
|
||||
height: parent.height - searchField.height - categoryRow.height - actionPanel.height - Theme.spacingXS * (categoryRow.visible ? 3 : 2)
|
||||
active: root.heavyContentActive
|
||||
asynchronous: false
|
||||
opacity: root.parentModal?.isClosing ? 0 : 1
|
||||
|
||||
sourceComponent: ResultsList {
|
||||
ResultsList {
|
||||
id: resultsList
|
||||
anchors.fill: parent
|
||||
controller: root.controller
|
||||
|
||||
onItemRightClicked: (index, item, sceneX, sceneY) => {
|
||||
|
||||
@@ -81,6 +81,12 @@ function calculateNextIndex(flatModel, selectedFlatIndex, sectionId, viewMode, g
|
||||
return bounds.start + newPosInSection;
|
||||
}
|
||||
|
||||
var currentRow = Math.floor(posInSection / cols);
|
||||
var lastRow = Math.floor((bounds.count - 1) / cols);
|
||||
if (currentRow < lastRow) {
|
||||
return bounds.start + bounds.count - 1;
|
||||
}
|
||||
|
||||
var nextSection = findNextNonHeaderIndex(flatModel, bounds.end + 1);
|
||||
return nextSection !== -1 ? nextSection : selectedFlatIndex;
|
||||
}
|
||||
|
||||
@@ -130,24 +130,17 @@ Item {
|
||||
if (!entry || entry.isHeader)
|
||||
return;
|
||||
var rowIndex = _flatIndexToRowMap[index];
|
||||
if (rowIndex === undefined || rowIndex >= _cumulativeHeights.length)
|
||||
return;
|
||||
var row = _visualRows[rowIndex];
|
||||
if (!row)
|
||||
if (rowIndex === undefined)
|
||||
return;
|
||||
|
||||
var rowY = _cumulativeHeights[rowIndex];
|
||||
var rowHeight = row.height;
|
||||
var scrollY = mainListView.contentY - mainListView.originY;
|
||||
var viewHeight = mainListView.height;
|
||||
var headerH = stickyHeader.height;
|
||||
mainListView.positionViewAtIndex(rowIndex, ListView.Contain);
|
||||
|
||||
if (rowY < scrollY + headerH) {
|
||||
mainListView.contentY = Math.max(mainListView.originY, rowY - headerH + mainListView.originY);
|
||||
return;
|
||||
}
|
||||
if (rowY + rowHeight > scrollY + viewHeight) {
|
||||
mainListView.contentY = rowY + rowHeight - viewHeight + mainListView.originY;
|
||||
if (stickyHeader.visible && rowIndex < _cumulativeHeights.length) {
|
||||
var rowY = _cumulativeHeights[rowIndex];
|
||||
var scrollY = mainListView.contentY - mainListView.originY;
|
||||
if (rowY < scrollY + stickyHeader.height) {
|
||||
mainListView.contentY = Math.max(mainListView.originY, rowY - stickyHeader.height + mainListView.originY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import QtQml
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Hyprland
|
||||
import qs.Common
|
||||
import qs.Modals.Common
|
||||
@@ -18,7 +20,11 @@ DankModal {
|
||||
modalHeight: _maxH
|
||||
onBackgroundClicked: close()
|
||||
onOpened: {
|
||||
Qt.callLater(() => modalFocusScope.forceActiveFocus());
|
||||
Qt.callLater(() => {
|
||||
modalFocusScope.forceActiveFocus();
|
||||
if (contentLoader.item?.searchField)
|
||||
contentLoader.item.searchField.forceActiveFocus();
|
||||
});
|
||||
if (!Object.keys(KeybindsService.cheatsheet).length && KeybindsService.cheatsheetAvailable)
|
||||
KeybindsService.loadCheatsheet();
|
||||
}
|
||||
@@ -63,17 +69,39 @@ DankModal {
|
||||
content: Component {
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
property alias searchField: searchField
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingL
|
||||
spacing: Theme.spacingL
|
||||
|
||||
StyledText {
|
||||
text: KeybindsService.cheatsheet.title || "Keybinds"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Bold
|
||||
color: Theme.primary
|
||||
RowLayout {
|
||||
width: parent.width
|
||||
|
||||
StyledText {
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
text: KeybindsService.cheatsheet.title || "Keybinds"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Bold
|
||||
color: Theme.primary
|
||||
}
|
||||
|
||||
DankTextField {
|
||||
id: searchField
|
||||
Layout.alignment: Qt.AlignRight
|
||||
leftIconName: "search"
|
||||
onTextEdited: searchDebounce.restart()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: searchDebounce
|
||||
interval: 50
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
mainFlickable.categories = mainFlickable.generateCategories(searchField.text);
|
||||
}
|
||||
}
|
||||
|
||||
DankFlickable {
|
||||
@@ -87,17 +115,26 @@ DankModal {
|
||||
Component.onCompleted: root.activeFlickable = mainFlickable
|
||||
|
||||
property var rawBinds: KeybindsService.cheatsheet.binds || {}
|
||||
property var categories: {
|
||||
|
||||
function generateCategories(query) {
|
||||
const lowerQuery = query ? query.toLowerCase().trim() : "";
|
||||
const processed = {};
|
||||
|
||||
for (const cat in rawBinds) {
|
||||
const binds = rawBinds[cat];
|
||||
const catLower = cat.toLowerCase();
|
||||
const subcats = {};
|
||||
let hasSubcats = false;
|
||||
|
||||
for (let i = 0; i < binds.length; i++) {
|
||||
const bind = binds[i];
|
||||
const keyLower = bind.key.toLowerCase();
|
||||
const descLower = bind.desc.toLowerCase();
|
||||
const actionLower = bind.action.toLowerCase();
|
||||
if (!(lowerQuery.length === 0 || keyLower.includes(lowerQuery) || descLower.includes(lowerQuery) || catLower.includes(lowerQuery) || actionLower.includes(lowerQuery)))
|
||||
continue;
|
||||
if (bind.hideOnOverlay)
|
||||
continue;
|
||||
|
||||
if (bind.subcat) {
|
||||
hasSubcats = true;
|
||||
if (!subcats[bind.subcat])
|
||||
@@ -119,9 +156,11 @@ DankModal {
|
||||
subcatKeys: Object.keys(subcats)
|
||||
};
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
property var categoryKeys: Object.keys(categories)
|
||||
|
||||
property var categories: generateCategories("");
|
||||
|
||||
function estimateCategoryHeight(catName) {
|
||||
const catData = categories[catName];
|
||||
@@ -136,6 +175,8 @@ DankModal {
|
||||
return 40 + bindCount * 28;
|
||||
}
|
||||
|
||||
property var categoryKeys: Object.keys(categories);
|
||||
|
||||
function distributeCategories(cols) {
|
||||
const columns = [];
|
||||
const heights = [];
|
||||
|
||||
@@ -70,8 +70,8 @@ DankModal {
|
||||
NotificationService.dismissAllPopups();
|
||||
}
|
||||
|
||||
modalWidth: 500
|
||||
modalHeight: 700
|
||||
modalWidth: Math.min(500, screenWidth - 48)
|
||||
modalHeight: Math.min(700, screenHeight * 0.85)
|
||||
backgroundColor: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
|
||||
visible: false
|
||||
onBackgroundClicked: hide()
|
||||
|
||||
@@ -14,6 +14,7 @@ FloatingWindow {
|
||||
property int currentTab: 0
|
||||
property string searchText: ""
|
||||
property string expandedPid: ""
|
||||
property string processFilter: "all"
|
||||
property bool shouldHaveFocus: visible
|
||||
property alias shouldBeVisible: processListModal.visible
|
||||
|
||||
@@ -82,9 +83,9 @@ FloatingWindow {
|
||||
|
||||
objectName: "processListModal"
|
||||
title: I18n.tr("System Monitor", "sysmon window title")
|
||||
minimumSize: Qt.size(750, 550)
|
||||
implicitWidth: 1000
|
||||
implicitHeight: 720
|
||||
minimumSize: Qt.size(Math.min(Math.round(Theme.fontSizeMedium * 48), Screen.width), Math.min(Math.round(Theme.fontSizeMedium * 34), Screen.height))
|
||||
implicitWidth: Math.round(Theme.fontSizeMedium * 71)
|
||||
implicitHeight: Math.round(Theme.fontSizeMedium * 51)
|
||||
color: Theme.surfaceContainer
|
||||
visible: false
|
||||
|
||||
@@ -98,6 +99,8 @@ FloatingWindow {
|
||||
closingModal();
|
||||
searchText = "";
|
||||
expandedPid = "";
|
||||
processFilter = "all";
|
||||
processFilterGroup.currentIndex = 0;
|
||||
if (processesTabLoader.item)
|
||||
processesTabLoader.item.reset();
|
||||
DgopService.removeRef(["cpu", "memory", "network", "disk", "system"]);
|
||||
@@ -233,7 +236,7 @@ FloatingWindow {
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 48
|
||||
Layout.preferredHeight: Math.round(Theme.fontSizeMedium * 3.4)
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
@@ -290,10 +293,10 @@ FloatingWindow {
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 52
|
||||
Layout.preferredHeight: Math.round(Theme.fontSizeMedium * 3.7)
|
||||
Layout.leftMargin: Theme.spacingL
|
||||
Layout.rightMargin: Theme.spacingL
|
||||
spacing: Theme.spacingL
|
||||
spacing: Theme.spacingM
|
||||
|
||||
Row {
|
||||
spacing: 2
|
||||
@@ -319,14 +322,15 @@ FloatingWindow {
|
||||
]
|
||||
|
||||
Rectangle {
|
||||
width: 120
|
||||
height: 44
|
||||
width: tabRowContent.implicitWidth + Theme.spacingM * 2
|
||||
height: Math.round(Theme.fontSizeMedium * 3.1)
|
||||
radius: Theme.cornerRadius
|
||||
color: currentTab === index ? Theme.primaryPressed : (tabMouseArea.containsMouse ? Theme.primaryHoverLight : "transparent")
|
||||
border.color: currentTab === index ? Theme.primary : "transparent"
|
||||
border.width: currentTab === index ? 1 : 0
|
||||
|
||||
Row {
|
||||
id: tabRowContent
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
@@ -368,10 +372,40 @@ FloatingWindow {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
DankButtonGroup {
|
||||
id: processFilterGroup
|
||||
model: [I18n.tr("All"), I18n.tr("User"), I18n.tr("System")]
|
||||
currentIndex: 0
|
||||
checkEnabled: false
|
||||
buttonHeight: Math.round(Theme.fontSizeSmall * 2.6)
|
||||
minButtonWidth: 0
|
||||
buttonPadding: Theme.spacingS
|
||||
textSize: Theme.fontSizeSmall
|
||||
visible: currentTab === 0
|
||||
onSelectionChanged: (index, selected) => {
|
||||
if (!selected)
|
||||
return;
|
||||
currentIndex = index;
|
||||
switch (index) {
|
||||
case 0:
|
||||
processListModal.processFilter = "all";
|
||||
return;
|
||||
case 1:
|
||||
processListModal.processFilter = "user";
|
||||
return;
|
||||
case 2:
|
||||
processListModal.processFilter = "system";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankTextField {
|
||||
id: searchField
|
||||
Layout.preferredWidth: 250
|
||||
Layout.preferredHeight: 40
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: Math.round(Theme.fontSizeMedium * 18)
|
||||
Layout.minimumWidth: Theme.fontSizeMedium * 4
|
||||
Layout.preferredHeight: Math.round(Theme.fontSizeMedium * 2.8)
|
||||
placeholderText: I18n.tr("Search processes...", "process search placeholder")
|
||||
leftIconName: "search"
|
||||
showClearButton: true
|
||||
@@ -403,6 +437,7 @@ FloatingWindow {
|
||||
sourceComponent: ProcessesView {
|
||||
searchText: processListModal.searchText
|
||||
expandedPid: processListModal.expandedPid
|
||||
processFilter: processListModal.processFilter
|
||||
contextMenu: processContextMenu
|
||||
onExpandedPidChanged: processListModal.expandedPid = expandedPid
|
||||
}
|
||||
@@ -438,7 +473,7 @@ FloatingWindow {
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 32
|
||||
Layout.preferredHeight: Math.round(Theme.fontSizeSmall * 2.7)
|
||||
Layout.leftMargin: Theme.spacingL
|
||||
Layout.rightMargin: Theme.spacingL
|
||||
Layout.bottomMargin: Theme.spacingM
|
||||
|
||||
@@ -209,7 +209,7 @@ Rectangle {
|
||||
"children": [
|
||||
{
|
||||
"id": "display_config",
|
||||
"text": I18n.tr("Configuration") + " (Beta)",
|
||||
"text": I18n.tr("Configuration"),
|
||||
"icon": "display_settings",
|
||||
"tabIndex": 24
|
||||
},
|
||||
|
||||
@@ -945,22 +945,31 @@ Column {
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
Qt.callLater(() => {
|
||||
const pluginComponent = PluginService.pluginWidgetComponents[pluginId];
|
||||
if (pluginComponent) {
|
||||
const instance = pluginComponent.createObject(null, {
|
||||
"pluginId": pluginId,
|
||||
"pluginService": PluginService,
|
||||
"visible": false,
|
||||
"width": 0,
|
||||
"height": 0
|
||||
});
|
||||
if (instance) {
|
||||
pluginInstance = instance;
|
||||
}
|
||||
function tryCreatePluginInstance() {
|
||||
const pluginComponent = PluginService.pluginWidgetComponents[pluginId];
|
||||
if (!pluginComponent)
|
||||
return false;
|
||||
try {
|
||||
const instance = pluginComponent.createObject(null, {
|
||||
"pluginId": pluginId,
|
||||
"pluginService": PluginService,
|
||||
"visible": false,
|
||||
"width": 0,
|
||||
"height": 0
|
||||
});
|
||||
if (instance) {
|
||||
pluginInstance = instance;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn("DragDropGrid: stale plugin component for", pluginId, "- reloading");
|
||||
PluginService.reloadPlugin(pluginId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
Qt.callLater(() => tryCreatePluginInstance());
|
||||
}
|
||||
|
||||
Connections {
|
||||
@@ -970,6 +979,11 @@ Column {
|
||||
pluginInstance.loadPluginData();
|
||||
}
|
||||
}
|
||||
function onPluginLoaded(loadedPluginId) {
|
||||
if (loadedPluginId !== pluginId || pluginInstance)
|
||||
return;
|
||||
Qt.callLater(() => tryCreatePluginInstance());
|
||||
}
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
|
||||
@@ -13,8 +13,8 @@ Row {
|
||||
property Item popoutContent: null
|
||||
|
||||
signal addWidget(string widgetId)
|
||||
signal resetToDefault()
|
||||
signal clearAll()
|
||||
signal resetToDefault
|
||||
signal clearAll
|
||||
|
||||
height: 48
|
||||
spacing: Theme.spacingS
|
||||
@@ -28,7 +28,7 @@ Row {
|
||||
y: parent ? Math.round((parent.height - height) / 2) : 0
|
||||
width: 400
|
||||
height: 300
|
||||
modal: true
|
||||
modal: false
|
||||
focus: true
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
@@ -133,7 +133,7 @@ Row {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
root.addWidget(modelData.id)
|
||||
root.addWidget(modelData.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ DankPopout {
|
||||
id: root
|
||||
|
||||
layerNamespace: "dms:control-center"
|
||||
fullHeightSurface: true
|
||||
|
||||
property string expandedSection: ""
|
||||
property var triggerScreen: null
|
||||
|
||||
@@ -13,15 +13,12 @@ Rectangle {
|
||||
LayoutMirroring.childrenInherit: true
|
||||
|
||||
implicitHeight: {
|
||||
if (height > 0) {
|
||||
if (height > 0)
|
||||
return height;
|
||||
}
|
||||
if (NetworkService.wifiToggling) {
|
||||
if (NetworkService.wifiToggling)
|
||||
return headerRow.height + wifiToggleContent.height + Theme.spacingM;
|
||||
}
|
||||
if (NetworkService.wifiEnabled) {
|
||||
if (NetworkService.wifiEnabled)
|
||||
return headerRow.height + wifiContent.height + Theme.spacingM;
|
||||
}
|
||||
return headerRow.height + wifiOffContent.height + Theme.spacingM;
|
||||
}
|
||||
radius: Theme.cornerRadius
|
||||
@@ -40,34 +37,40 @@ Rectangle {
|
||||
property bool hasEthernetAvailable: (NetworkService.ethernetDevices?.length ?? 0) > 0
|
||||
property bool hasWifiAvailable: (NetworkService.wifiDevices?.length ?? 0) > 0
|
||||
property bool hasBothConnectionTypes: hasEthernetAvailable && hasWifiAvailable
|
||||
property int maxPinnedNetworks: 3
|
||||
|
||||
function normalizePinList(value) {
|
||||
if (Array.isArray(value))
|
||||
return value.filter(v => v);
|
||||
if (typeof value === "string" && value.length > 0)
|
||||
return [value];
|
||||
return [];
|
||||
}
|
||||
|
||||
function getPinnedNetworks() {
|
||||
const pins = SettingsData.wifiNetworkPins || {};
|
||||
return normalizePinList(pins["preferredWifi"]);
|
||||
}
|
||||
|
||||
property int currentPreferenceIndex: {
|
||||
if (DMSService.apiVersion < 5) {
|
||||
if (DMSService.apiVersion < 5)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (NetworkService.backend !== "networkmanager" || DMSService.apiVersion <= 10) {
|
||||
if (NetworkService.backend !== "networkmanager" || DMSService.apiVersion <= 10)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!hasEthernetAvailable) {
|
||||
if (!hasEthernetAvailable)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!hasWifiAvailable) {
|
||||
if (!hasWifiAvailable)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const pref = NetworkService.userPreference;
|
||||
const status = NetworkService.networkStatus;
|
||||
|
||||
if (pref === "ethernet") {
|
||||
switch (pref) {
|
||||
case "ethernet":
|
||||
return 0;
|
||||
}
|
||||
if (pref === "wifi") {
|
||||
case "wifi":
|
||||
return 1;
|
||||
default:
|
||||
return NetworkService.networkStatus === "ethernet" ? 0 : 1;
|
||||
}
|
||||
return status === "ethernet" ? 0 : 1;
|
||||
}
|
||||
|
||||
Row {
|
||||
@@ -78,7 +81,7 @@ Rectangle {
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingS
|
||||
height: 40
|
||||
height: Math.max(headerLeft.implicitHeight, rightControls.implicitHeight) + Theme.spacingS * 2
|
||||
|
||||
StyledText {
|
||||
id: headerLeft
|
||||
@@ -162,9 +165,10 @@ Rectangle {
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && NetworkService.wifiToggling
|
||||
height: visible ? 80 : 0
|
||||
height: visible ? wifiToggleColumn.implicitHeight + Theme.spacingM * 2 : 0
|
||||
|
||||
Column {
|
||||
id: wifiToggleColumn
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingM
|
||||
|
||||
@@ -201,9 +205,10 @@ Rectangle {
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && !NetworkService.wifiEnabled && !NetworkService.wifiToggling
|
||||
height: visible ? 120 : 0
|
||||
height: visible ? wifiOffColumn.implicitHeight + Theme.spacingM * 2 : 0
|
||||
|
||||
Column {
|
||||
id: wifiOffColumn
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingL
|
||||
width: parent.width
|
||||
@@ -226,14 +231,15 @@ Rectangle {
|
||||
|
||||
Rectangle {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: 120
|
||||
height: 36
|
||||
radius: 18
|
||||
width: enableWifiLabel.implicitWidth + Theme.spacingL * 2
|
||||
height: enableWifiLabel.implicitHeight + Theme.spacingM * 2
|
||||
radius: height / 2
|
||||
color: enableWifiButton.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08)
|
||||
border.width: 0
|
||||
border.color: Theme.primary
|
||||
|
||||
StyledText {
|
||||
id: enableWifiLabel
|
||||
anchors.centerIn: parent
|
||||
text: I18n.tr("Enable WiFi")
|
||||
color: Theme.primary
|
||||
@@ -252,6 +258,25 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
ScriptModel {
|
||||
id: wiredConnectionsModel
|
||||
objectProp: "uuid"
|
||||
values: {
|
||||
const networks = NetworkService.wiredConnections;
|
||||
if (!networks)
|
||||
return [];
|
||||
let sorted = [...networks];
|
||||
sorted.sort((a, b) => {
|
||||
if (a.isActive && !b.isActive)
|
||||
return -1;
|
||||
if (!a.isActive && b.isActive)
|
||||
return 1;
|
||||
return a.id.localeCompare(b.id);
|
||||
});
|
||||
return sorted;
|
||||
}
|
||||
}
|
||||
|
||||
DankFlickable {
|
||||
id: wiredContent
|
||||
anchors.top: headerRow.bottom
|
||||
@@ -270,34 +295,25 @@ Rectangle {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: {
|
||||
const currentUuid = NetworkService.ethernetConnectionUuid;
|
||||
const networks = NetworkService.wiredConnections;
|
||||
let sorted = [...networks];
|
||||
sorted.sort((a, b) => {
|
||||
if (a.isActive && !b.isActive)
|
||||
return -1;
|
||||
if (!a.isActive && b.isActive)
|
||||
return 1;
|
||||
return a.id.localeCompare(b.id);
|
||||
});
|
||||
return sorted;
|
||||
}
|
||||
}
|
||||
model: wiredConnectionsModel
|
||||
|
||||
delegate: Rectangle {
|
||||
id: wiredDelegate
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
readonly property bool isActive: modelData.isActive
|
||||
readonly property string configName: modelData.id || I18n.tr("Unknown Config")
|
||||
|
||||
width: parent.width
|
||||
height: 50
|
||||
height: wiredContentRow.implicitHeight + Theme.spacingM * 2
|
||||
radius: Theme.cornerRadius
|
||||
color: wiredNetworkMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : Theme.withAlpha(Theme.surfaceContainerHighest, Theme.popupTransparency)
|
||||
border.color: Theme.primary
|
||||
border.width: 0
|
||||
|
||||
Row {
|
||||
id: wiredContentRow
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
@@ -306,7 +322,7 @@ Rectangle {
|
||||
DankIcon {
|
||||
name: "lan"
|
||||
size: Theme.iconSize - 4
|
||||
color: modelData.isActive ? Theme.primary : Theme.surfaceText
|
||||
color: wiredDelegate.isActive ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
@@ -315,10 +331,10 @@ Rectangle {
|
||||
width: 200
|
||||
|
||||
StyledText {
|
||||
text: modelData.id || I18n.tr("Unknown Config")
|
||||
text: wiredDelegate.configName
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: modelData.isActive ? Theme.primary : Theme.surfaceText
|
||||
font.weight: modelData.isActive ? Font.Medium : Font.Normal
|
||||
color: wiredDelegate.isActive ? Theme.primary : Theme.surfaceText
|
||||
font.weight: wiredDelegate.isActive ? Font.Medium : Font.Normal
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
}
|
||||
@@ -335,12 +351,12 @@ Rectangle {
|
||||
onClicked: {
|
||||
if (wiredNetworkContextMenu.visible) {
|
||||
wiredNetworkContextMenu.close();
|
||||
} else {
|
||||
wiredNetworkContextMenu.currentID = modelData.id;
|
||||
wiredNetworkContextMenu.currentUUID = modelData.uuid;
|
||||
wiredNetworkContextMenu.currentConnected = modelData.isActive;
|
||||
wiredNetworkContextMenu.popup(wiredOptionsButton, -wiredNetworkContextMenu.width + wiredOptionsButton.width, wiredOptionsButton.height + Theme.spacingXS);
|
||||
return;
|
||||
}
|
||||
wiredNetworkContextMenu.currentID = modelData.id;
|
||||
wiredNetworkContextMenu.currentUUID = modelData.uuid;
|
||||
wiredNetworkContextMenu.currentConnected = wiredDelegate.isActive;
|
||||
wiredNetworkContextMenu.popup(wiredOptionsButton, -wiredNetworkContextMenu.width + wiredOptionsButton.width, wiredOptionsButton.height + Theme.spacingXS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,9 +373,8 @@ Rectangle {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onPressed: mouse => wiredRipple.trigger(mouse.x, mouse.y)
|
||||
onClicked: function (event) {
|
||||
if (modelData.uuid !== NetworkService.ethernetConnectionUuid) {
|
||||
if (modelData.uuid !== NetworkService.ethernetConnectionUuid)
|
||||
NetworkService.connectToSpecificWiredConfig(modelData.uuid);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
@@ -403,9 +418,8 @@ Rectangle {
|
||||
}
|
||||
|
||||
onTriggered: {
|
||||
if (!wiredNetworkContextMenu.currentConnected) {
|
||||
if (!wiredNetworkContextMenu.currentConnected)
|
||||
NetworkService.connectToSpecificWiredConfig(wiredNetworkContextMenu.currentUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,13 +465,46 @@ Rectangle {
|
||||
}
|
||||
|
||||
onTriggered: {
|
||||
let networkData = NetworkService.getWiredNetworkInfo(wiredNetworkContextMenu.currentUUID);
|
||||
networkWiredInfoModal.showNetworkInfo(wiredNetworkContextMenu.currentID, networkData);
|
||||
const networkData = NetworkService.getWiredNetworkInfo(wiredNetworkContextMenu.currentUUID);
|
||||
networkWiredInfoModalLoader.active = true;
|
||||
networkWiredInfoModalLoader.item.showNetworkInfo(wiredNetworkContextMenu.currentID, networkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankFlickable {
|
||||
ScriptModel {
|
||||
id: wifiNetworksModel
|
||||
objectProp: "ssid"
|
||||
values: wifiContent.menuOpen ? wifiContent.frozenNetworks : wifiContent.sortedNetworks
|
||||
}
|
||||
|
||||
Item {
|
||||
id: wifiScanningOverlay
|
||||
anchors.top: headerRow.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && NetworkService.wifiEnabled && !NetworkService.wifiToggling && NetworkService.wifiInterface && (NetworkService.wifiNetworks?.length ?? 0) < 1 && NetworkService.isScanning
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "refresh"
|
||||
size: 48
|
||||
color: Qt.rgba(Theme.surfaceText.r || 0.8, Theme.surfaceText.g || 0.8, Theme.surfaceText.b || 0.8, 0.3)
|
||||
|
||||
RotationAnimation on rotation {
|
||||
running: wifiScanningOverlay.visible
|
||||
loops: Animation.Infinite
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankListView {
|
||||
id: wifiContent
|
||||
anchors.top: headerRow.bottom
|
||||
anchors.left: parent.left
|
||||
@@ -465,31 +512,17 @@ Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingM
|
||||
visible: currentPreferenceIndex === 1 && NetworkService.wifiEnabled && !NetworkService.wifiToggling
|
||||
contentHeight: wifiColumn.height
|
||||
visible: currentPreferenceIndex === 1 && NetworkService.wifiEnabled && !NetworkService.wifiToggling && !wifiScanningOverlay.visible
|
||||
clip: true
|
||||
|
||||
property int maxPinnedNetworks: 3
|
||||
|
||||
function normalizePinList(value) {
|
||||
if (Array.isArray(value))
|
||||
return value.filter(v => v);
|
||||
if (typeof value === "string" && value.length > 0)
|
||||
return [value];
|
||||
return [];
|
||||
}
|
||||
|
||||
function getPinnedNetworks() {
|
||||
const pins = SettingsData.wifiNetworkPins || {};
|
||||
return normalizePinList(pins["preferredWifi"]);
|
||||
}
|
||||
spacing: Theme.spacingS
|
||||
model: wifiNetworksModel
|
||||
|
||||
property var frozenNetworks: []
|
||||
property bool menuOpen: false
|
||||
property var sortedNetworks: {
|
||||
const ssid = NetworkService.currentWifiSSID;
|
||||
const networks = NetworkService.wifiNetworks;
|
||||
const pinnedList = getPinnedNetworks();
|
||||
const pinnedList = root.getPinnedNetworks();
|
||||
|
||||
let sorted = [...networks];
|
||||
sorted.sort((a, b) => {
|
||||
@@ -519,229 +552,188 @@ Rectangle {
|
||||
frozenNetworks = sortedNetworks;
|
||||
}
|
||||
|
||||
Column {
|
||||
id: wifiColumn
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
delegate: Rectangle {
|
||||
id: wifiDelegate
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 200
|
||||
visible: NetworkService.wifiInterface && NetworkService.wifiNetworks?.length < 1 && !NetworkService.wifiToggling && NetworkService.isScanning
|
||||
readonly property bool isConnected: modelData.ssid === NetworkService.currentWifiSSID
|
||||
readonly property bool isPinned: root.getPinnedNetworks().includes(modelData.ssid)
|
||||
readonly property string networkName: modelData.ssid || I18n.tr("Unknown Network")
|
||||
readonly property int signalStrength: modelData.signal || 0
|
||||
|
||||
width: wifiContent.width
|
||||
height: wifiContentRow.implicitHeight + Theme.spacingM * 2
|
||||
radius: Theme.cornerRadius
|
||||
color: networkMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : Theme.withAlpha(Theme.surfaceContainerHighest, Theme.popupTransparency)
|
||||
border.color: wifiDelegate.isConnected ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
||||
border.width: 0
|
||||
|
||||
Row {
|
||||
id: wifiContentRow
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
spacing: Theme.spacingS
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "refresh"
|
||||
size: 48
|
||||
color: Qt.rgba(Theme.surfaceText.r || 0.8, Theme.surfaceText.g || 0.8, Theme.surfaceText.b || 0.8, 0.3)
|
||||
name: {
|
||||
if (wifiDelegate.signalStrength >= 50)
|
||||
return "wifi";
|
||||
if (wifiDelegate.signalStrength >= 25)
|
||||
return "wifi_2_bar";
|
||||
return "wifi_1_bar";
|
||||
}
|
||||
size: Theme.iconSize - 4
|
||||
color: wifiDelegate.isConnected ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
RotationAnimation on rotation {
|
||||
running: NetworkService.isScanning
|
||||
loops: Animation.Infinite
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 1000
|
||||
Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 200
|
||||
|
||||
StyledText {
|
||||
text: wifiDelegate.networkName
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceText
|
||||
font.weight: wifiDelegate.isConnected ? Font.Medium : Font.Normal
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
StyledText {
|
||||
text: wifiDelegate.isConnected ? I18n.tr("Connected") + " \u2022" : (modelData.secured ? I18n.tr("Secured") + " \u2022" : I18n.tr("Open") + " \u2022")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: modelData.saved ? I18n.tr("Saved") : ""
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primary
|
||||
visible: text.length > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: (modelData.saved ? "\u2022 " : "") + wifiDelegate.signalStrength + "%"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: ScriptModel {
|
||||
values: wifiContent.menuOpen ? wifiContent.frozenNetworks : wifiContent.sortedNetworks
|
||||
DankActionButton {
|
||||
id: optionsButton
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
iconName: "more_horiz"
|
||||
buttonSize: 28
|
||||
onClicked: {
|
||||
if (networkContextMenu.visible) {
|
||||
networkContextMenu.close();
|
||||
return;
|
||||
}
|
||||
wifiContent.menuOpen = true;
|
||||
networkContextMenu.currentSSID = modelData.ssid;
|
||||
networkContextMenu.currentSecured = modelData.secured;
|
||||
networkContextMenu.currentConnected = wifiDelegate.isConnected;
|
||||
networkContextMenu.currentSaved = modelData.saved;
|
||||
networkContextMenu.currentSignal = modelData.signal;
|
||||
networkContextMenu.currentAutoconnect = modelData.autoconnect || false;
|
||||
networkContextMenu.popup(optionsButton, -networkContextMenu.width + optionsButton.width, optionsButton.height + Theme.spacingXS);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: optionsButton.width + Theme.spacingM + Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: pinWifiRow.width + Theme.spacingS * 2
|
||||
height: pinWifiRow.implicitHeight + Theme.spacingXS * 2
|
||||
radius: height / 2
|
||||
color: wifiDelegate.isPinned ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Theme.withAlpha(Theme.surfaceText, 0.05)
|
||||
|
||||
Row {
|
||||
id: pinWifiRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
|
||||
DankIcon {
|
||||
name: "push_pin"
|
||||
size: 16
|
||||
color: wifiDelegate.isPinned ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: wifiDelegate.isPinned ? I18n.tr("Pinned") : I18n.tr("Pin")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: wifiDelegate.isPinned ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Rectangle {
|
||||
required property var modelData
|
||||
required property int index
|
||||
DankRipple {
|
||||
id: pinRipple
|
||||
cornerRadius: parent.radius
|
||||
}
|
||||
|
||||
width: parent.width
|
||||
height: 50
|
||||
radius: Theme.cornerRadius
|
||||
color: networkMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : Theme.withAlpha(Theme.surfaceContainerHighest, Theme.popupTransparency)
|
||||
border.color: modelData.ssid === NetworkService.currentWifiSSID ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
||||
border.width: 0
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onPressed: mouse => pinRipple.trigger(mouse.x, mouse.y)
|
||||
onClicked: {
|
||||
const pins = JSON.parse(JSON.stringify(SettingsData.wifiNetworkPins || {}));
|
||||
let pinnedList = root.normalizePinList(pins["preferredWifi"]);
|
||||
const pinIndex = pinnedList.indexOf(modelData.ssid);
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
spacing: Theme.spacingS
|
||||
|
||||
DankIcon {
|
||||
name: {
|
||||
let strength = modelData.signal || 0;
|
||||
if (strength >= 50)
|
||||
return "wifi";
|
||||
if (strength >= 25)
|
||||
return "wifi_2_bar";
|
||||
return "wifi_1_bar";
|
||||
}
|
||||
size: Theme.iconSize - 4
|
||||
color: modelData.ssid === NetworkService.currentWifiSSID ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
if (pinIndex !== -1) {
|
||||
pinnedList.splice(pinIndex, 1);
|
||||
} else {
|
||||
pinnedList.unshift(modelData.ssid);
|
||||
if (pinnedList.length > root.maxPinnedNetworks)
|
||||
pinnedList = pinnedList.slice(0, root.maxPinnedNetworks);
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 200
|
||||
if (pinnedList.length > 0)
|
||||
pins["preferredWifi"] = pinnedList;
|
||||
else
|
||||
delete pins["preferredWifi"];
|
||||
|
||||
StyledText {
|
||||
text: modelData.ssid || I18n.tr("Unknown Network")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceText
|
||||
font.weight: modelData.ssid === NetworkService.currentWifiSSID ? Font.Medium : Font.Normal
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
StyledText {
|
||||
text: modelData.ssid === NetworkService.currentWifiSSID ? I18n.tr("Connected") + " •" : (modelData.secured ? I18n.tr("Secured") + " •" : I18n.tr("Open") + " •")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: modelData.saved ? I18n.tr("Saved") : ""
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primary
|
||||
visible: text.length > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: (modelData.saved ? "• " : "") + modelData.signal + "%"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
}
|
||||
}
|
||||
SettingsData.set("wifiNetworkPins", pins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: optionsButton
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
iconName: "more_horiz"
|
||||
buttonSize: 28
|
||||
onClicked: {
|
||||
if (networkContextMenu.visible) {
|
||||
networkContextMenu.close();
|
||||
} else {
|
||||
wifiContent.menuOpen = true;
|
||||
networkContextMenu.currentSSID = modelData.ssid;
|
||||
networkContextMenu.currentSecured = modelData.secured;
|
||||
networkContextMenu.currentConnected = modelData.ssid === NetworkService.currentWifiSSID;
|
||||
networkContextMenu.currentSaved = modelData.saved;
|
||||
networkContextMenu.currentSignal = modelData.signal;
|
||||
networkContextMenu.currentAutoconnect = modelData.autoconnect || false;
|
||||
networkContextMenu.popup(optionsButton, -networkContextMenu.width + optionsButton.width, optionsButton.height + Theme.spacingXS);
|
||||
}
|
||||
}
|
||||
DankRipple {
|
||||
id: wifiRipple
|
||||
cornerRadius: parent.radius
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: networkMouseArea
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: optionsButton.width + Theme.spacingM + Theme.spacingS + pinWifiRow.width + Theme.spacingS * 4
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onPressed: mouse => wifiRipple.trigger(mouse.x, mouse.y)
|
||||
onClicked: function (event) {
|
||||
if (wifiDelegate.isConnected) {
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: optionsButton.width + Theme.spacingM + Theme.spacingS
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: pinWifiRow.width + Theme.spacingS * 2
|
||||
height: 28
|
||||
radius: height / 2
|
||||
color: {
|
||||
const isThisNetworkPinned = wifiContent.getPinnedNetworks().includes(modelData.ssid);
|
||||
return isThisNetworkPinned ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Theme.withAlpha(Theme.surfaceText, 0.05);
|
||||
}
|
||||
|
||||
Row {
|
||||
id: pinWifiRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
|
||||
DankIcon {
|
||||
name: "push_pin"
|
||||
size: 16
|
||||
color: {
|
||||
const isThisNetworkPinned = wifiContent.getPinnedNetworks().includes(modelData.ssid);
|
||||
return isThisNetworkPinned ? Theme.primary : Theme.surfaceText;
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
const isThisNetworkPinned = wifiContent.getPinnedNetworks().includes(modelData.ssid);
|
||||
return isThisNetworkPinned ? I18n.tr("Pinned") : I18n.tr("Pin");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: {
|
||||
const isThisNetworkPinned = wifiContent.getPinnedNetworks().includes(modelData.ssid);
|
||||
return isThisNetworkPinned ? Theme.primary : Theme.surfaceText;
|
||||
}
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
DankRipple {
|
||||
id: pinRipple
|
||||
cornerRadius: parent.radius
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onPressed: mouse => pinRipple.trigger(mouse.x, mouse.y)
|
||||
onClicked: {
|
||||
const pins = JSON.parse(JSON.stringify(SettingsData.wifiNetworkPins || {}));
|
||||
let pinnedList = wifiContent.normalizePinList(pins["preferredWifi"]);
|
||||
const pinIndex = pinnedList.indexOf(modelData.ssid);
|
||||
|
||||
if (pinIndex !== -1) {
|
||||
pinnedList.splice(pinIndex, 1);
|
||||
} else {
|
||||
pinnedList.unshift(modelData.ssid);
|
||||
if (pinnedList.length > wifiContent.maxPinnedNetworks)
|
||||
pinnedList = pinnedList.slice(0, wifiContent.maxPinnedNetworks);
|
||||
}
|
||||
|
||||
if (pinnedList.length > 0)
|
||||
pins["preferredWifi"] = pinnedList;
|
||||
else
|
||||
delete pins["preferredWifi"];
|
||||
|
||||
SettingsData.set("wifiNetworkPins", pins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankRipple {
|
||||
id: wifiRipple
|
||||
cornerRadius: parent.radius
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: networkMouseArea
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: optionsButton.width + Theme.spacingM + Theme.spacingS + pinWifiRow.width + Theme.spacingS * 4
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onPressed: mouse => wifiRipple.trigger(mouse.x, mouse.y)
|
||||
onClicked: function (event) {
|
||||
if (modelData.ssid !== NetworkService.currentWifiSSID) {
|
||||
if (modelData.secured && !modelData.saved) {
|
||||
if (DMSService.apiVersion >= 7) {
|
||||
NetworkService.connectToWifi(modelData.ssid);
|
||||
} else {
|
||||
PopoutService.showWifiPasswordModal(modelData.ssid);
|
||||
}
|
||||
} else {
|
||||
NetworkService.connectToWifi(modelData.ssid);
|
||||
}
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
if (modelData.secured && !modelData.saved && DMSService.apiVersion < 7) {
|
||||
PopoutService.showWifiPasswordModal(modelData.ssid);
|
||||
} else {
|
||||
NetworkService.connectToWifi(modelData.ssid);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -759,6 +751,8 @@ Rectangle {
|
||||
property int currentSignal: 0
|
||||
property bool currentAutoconnect: false
|
||||
|
||||
readonly property bool showSavedOptions: currentSaved || currentConnected
|
||||
|
||||
onClosed: {
|
||||
wifiContent.menuOpen = false;
|
||||
}
|
||||
@@ -790,17 +784,13 @@ Rectangle {
|
||||
onTriggered: {
|
||||
if (networkContextMenu.currentConnected) {
|
||||
NetworkService.disconnectWifi();
|
||||
} else {
|
||||
if (networkContextMenu.currentSecured && !networkContextMenu.currentSaved) {
|
||||
if (DMSService.apiVersion >= 7) {
|
||||
NetworkService.connectToWifi(networkContextMenu.currentSSID);
|
||||
} else {
|
||||
PopoutService.showWifiPasswordModal(networkContextMenu.currentSSID);
|
||||
}
|
||||
} else {
|
||||
NetworkService.connectToWifi(networkContextMenu.currentSSID);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (networkContextMenu.currentSecured && !networkContextMenu.currentSaved && DMSService.apiVersion < 7) {
|
||||
PopoutService.showWifiPasswordModal(networkContextMenu.currentSSID);
|
||||
return;
|
||||
}
|
||||
NetworkService.connectToWifi(networkContextMenu.currentSSID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -822,15 +812,16 @@ Rectangle {
|
||||
}
|
||||
|
||||
onTriggered: {
|
||||
let networkData = NetworkService.getNetworkInfo(networkContextMenu.currentSSID);
|
||||
networkInfoModal.showNetworkInfo(networkContextMenu.currentSSID, networkData);
|
||||
const networkData = NetworkService.getNetworkInfo(networkContextMenu.currentSSID);
|
||||
networkInfoModalLoader.active = true;
|
||||
networkInfoModalLoader.item.showNetworkInfo(networkContextMenu.currentSSID, networkData);
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: networkContextMenu.currentAutoconnect ? I18n.tr("Disable Autoconnect") : I18n.tr("Enable Autoconnect")
|
||||
height: (networkContextMenu.currentSaved || networkContextMenu.currentConnected) && DMSService.apiVersion > 13 ? 32 : 0
|
||||
visible: (networkContextMenu.currentSaved || networkContextMenu.currentConnected) && DMSService.apiVersion > 13
|
||||
height: networkContextMenu.showSavedOptions && DMSService.apiVersion > 13 ? 32 : 0
|
||||
visible: networkContextMenu.showSavedOptions && DMSService.apiVersion > 13
|
||||
|
||||
contentItem: StyledText {
|
||||
text: parent.text
|
||||
@@ -852,8 +843,8 @@ Rectangle {
|
||||
|
||||
MenuItem {
|
||||
text: I18n.tr("Forget Network")
|
||||
height: networkContextMenu.currentSaved || networkContextMenu.currentConnected ? 32 : 0
|
||||
visible: networkContextMenu.currentSaved || networkContextMenu.currentConnected
|
||||
height: networkContextMenu.showSavedOptions ? 32 : 0
|
||||
visible: networkContextMenu.showSavedOptions
|
||||
|
||||
contentItem: StyledText {
|
||||
text: parent.text
|
||||
@@ -874,11 +865,15 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
NetworkInfoModal {
|
||||
id: networkInfoModal
|
||||
Loader {
|
||||
id: networkInfoModalLoader
|
||||
active: false
|
||||
sourceComponent: NetworkInfoModal {}
|
||||
}
|
||||
|
||||
NetworkWiredInfoModal {
|
||||
id: networkWiredInfoModal
|
||||
Loader {
|
||||
id: networkWiredInfoModalLoader
|
||||
active: false
|
||||
sourceComponent: NetworkWiredInfoModal {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,14 +216,18 @@ QtObject {
|
||||
}
|
||||
|
||||
const pluginComponent = PluginService.pluginWidgetComponents[plugin.id];
|
||||
if (!pluginComponent || typeof pluginComponent.createObject !== 'function') {
|
||||
if (!pluginComponent)
|
||||
continue;
|
||||
}
|
||||
|
||||
const tempInstance = pluginComponent.createObject(null);
|
||||
if (!tempInstance) {
|
||||
let tempInstance;
|
||||
try {
|
||||
tempInstance = pluginComponent.createObject(null);
|
||||
} catch (e) {
|
||||
PluginService.reloadPlugin(plugin.id);
|
||||
continue;
|
||||
}
|
||||
if (!tempInstance)
|
||||
continue;
|
||||
|
||||
const hasCCWidget = tempInstance.ccWidgetIcon && tempInstance.ccWidgetIcon.length > 0;
|
||||
tempInstance.destroy();
|
||||
|
||||
@@ -96,7 +96,7 @@ Item {
|
||||
focusedScreenName = Hyprland.focusedWorkspace.monitor.name;
|
||||
} else if (CompositorService.isNiri && NiriService.currentOutput) {
|
||||
focusedScreenName = NiriService.currentOutput;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
const focusedWs = I3.workspaces?.values?.find(ws => ws.focused === true);
|
||||
focusedScreenName = focusedWs?.monitor?.name || "";
|
||||
} else if (CompositorService.isDwl && DwlService.activeOutput) {
|
||||
@@ -125,7 +125,7 @@ Item {
|
||||
focusedScreenName = Hyprland.focusedWorkspace.monitor.name;
|
||||
} else if (CompositorService.isNiri && NiriService.currentOutput) {
|
||||
focusedScreenName = NiriService.currentOutput;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
const focusedWs = I3.workspaces?.values?.find(ws => ws.focused === true);
|
||||
focusedScreenName = focusedWs?.monitor?.name || "";
|
||||
} else if (CompositorService.isDwl && DwlService.activeOutput) {
|
||||
|
||||
@@ -103,7 +103,7 @@ Item {
|
||||
}, (_, i) => i);
|
||||
}
|
||||
return DwlService.getVisibleTags(barWindow.screenName);
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
const workspaces = I3.workspaces?.values || [];
|
||||
if (workspaces.length === 0)
|
||||
return [
|
||||
@@ -145,7 +145,7 @@ Item {
|
||||
return 0;
|
||||
const activeTags = DwlService.getActiveTags(barWindow.screenName);
|
||||
return activeTags.length > 0 ? activeTags[0] : 0;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
if (!barWindow.screenName || SettingsData.workspaceFollowFocus) {
|
||||
const focusedWs = I3.workspaces?.values?.find(ws => ws.focused === true);
|
||||
return focusedWs ? focusedWs.num : 1;
|
||||
@@ -194,7 +194,7 @@ Item {
|
||||
if (nextIndex !== validIndex) {
|
||||
DwlService.switchToTag(barWindow.screenName, realWorkspaces[nextIndex]);
|
||||
}
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
const currentWs = getCurrentWorkspace();
|
||||
const currentIndex = realWorkspaces.findIndex(ws => ws.num === currentWs);
|
||||
const validIndex = currentIndex === -1 ? 0 : currentIndex;
|
||||
|
||||
@@ -96,10 +96,6 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
BackgroundEffect.blurRegion: Region {
|
||||
item: barUnitInset
|
||||
}
|
||||
|
||||
WlrLayershell.layer: dBarLayer
|
||||
WlrLayershell.namespace: "dms:bar"
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ BasePill {
|
||||
}
|
||||
|
||||
IconImage {
|
||||
visible: SettingsData.launcherLogoMode === "compositor" && (CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isLabwc)
|
||||
visible: SettingsData.launcherLogoMode === "compositor" && (CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle || CompositorService.isLabwc)
|
||||
anchors.centerIn: parent
|
||||
width: Theme.barIconSize(root.barThickness, SettingsData.launcherLogoSizeOffset, root.barConfig?.noBackground)
|
||||
height: Theme.barIconSize(root.barThickness, SettingsData.launcherLogoSizeOffset, root.barConfig?.noBackground)
|
||||
@@ -72,6 +72,8 @@ BasePill {
|
||||
return "file://" + Theme.shellDir + "/assets/sway.svg";
|
||||
} else if (CompositorService.isScroll) {
|
||||
return "file://" + Theme.shellDir + "/assets/sway.svg";
|
||||
} else if (CompositorService.isMiracle) {
|
||||
return "file://" + Theme.shellDir + "/assets/miraclewm.svg";
|
||||
} else if (CompositorService.isLabwc) {
|
||||
return "file://" + Theme.shellDir + "/assets/labwc.png";
|
||||
}
|
||||
|
||||
@@ -155,6 +155,7 @@ BasePill {
|
||||
property real touchpadThreshold: 500
|
||||
|
||||
onWheel: function (wheelEvent) {
|
||||
wheelEvent.accepted = true;
|
||||
const deltaY = wheelEvent.angleDelta.y;
|
||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0;
|
||||
|
||||
|
||||
@@ -10,6 +10,45 @@ BasePill {
|
||||
property bool isActive: false
|
||||
readonly property bool hasUpdates: SystemUpdateService.updateCount > 0
|
||||
readonly property bool isChecking: SystemUpdateService.isChecking
|
||||
readonly property bool shouldHide: SettingsData.updaterHideWidget && !hasUpdates && !isChecking && !SystemUpdateService.hasError
|
||||
|
||||
opacity: shouldHide ? 0 : 1
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "hidden_horizontal"
|
||||
when: root.shouldHide && !isVerticalOrientation
|
||||
PropertyChanges {
|
||||
target: root
|
||||
width: 0
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "hidden_vertical"
|
||||
when: root.shouldHide && isVerticalOrientation
|
||||
PropertyChanges {
|
||||
target: root
|
||||
height: 0
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
NumberAnimation {
|
||||
properties: "width,height"
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Ref {
|
||||
service: SystemUpdateService
|
||||
|
||||
@@ -37,6 +37,7 @@ Item {
|
||||
return DwlService.activeOutput || root.screenName;
|
||||
case "sway":
|
||||
case "scroll":
|
||||
case "miracle":
|
||||
const focusedWs = I3.workspaces?.values?.find(ws => ws.focused === true);
|
||||
return focusedWs?.monitor?.name || root.screenName;
|
||||
default:
|
||||
@@ -44,7 +45,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
readonly property bool useExtWorkspace: DMSService.forceExtWorkspace || (!CompositorService.isNiri && !CompositorService.isHyprland && !CompositorService.isDwl && !CompositorService.isSway && !CompositorService.isScroll && ExtWorkspaceService.extWorkspaceAvailable)
|
||||
readonly property bool useExtWorkspace: DMSService.forceExtWorkspace || (!CompositorService.isNiri && !CompositorService.isHyprland && !CompositorService.isDwl && !CompositorService.isSway && !CompositorService.isScroll && !CompositorService.isMiracle && ExtWorkspaceService.extWorkspaceAvailable)
|
||||
|
||||
Connections {
|
||||
target: DesktopEntries
|
||||
@@ -67,6 +68,7 @@ Item {
|
||||
return activeTags.length > 0 ? activeTags[0] : -1;
|
||||
case "sway":
|
||||
case "scroll":
|
||||
case "miracle":
|
||||
return getSwayActiveWorkspace();
|
||||
default:
|
||||
return 1;
|
||||
@@ -97,6 +99,7 @@ Item {
|
||||
break;
|
||||
case "sway":
|
||||
case "scroll":
|
||||
case "miracle":
|
||||
baseList = getSwayWorkspaces();
|
||||
break;
|
||||
default:
|
||||
@@ -114,12 +117,23 @@ Item {
|
||||
}
|
||||
];
|
||||
|
||||
function mapWorkspace(ws) {
|
||||
return {
|
||||
"num": ws.number,
|
||||
"name": ws.name,
|
||||
"focused": ws.focused,
|
||||
"active": ws.active,
|
||||
"urgent": ws.urgent,
|
||||
"monitor": ws.monitor
|
||||
};
|
||||
}
|
||||
|
||||
if (!root.screenName || SettingsData.workspaceFollowFocus) {
|
||||
return workspaces.slice().sort((a, b) => a.num - b.num);
|
||||
return workspaces.slice().sort((a, b) => a.num - b.num).map(mapWorkspace);
|
||||
}
|
||||
|
||||
const monitorWorkspaces = workspaces.filter(ws => ws.monitor?.name === root.screenName);
|
||||
return monitorWorkspaces.length > 0 ? monitorWorkspaces.sort((a, b) => a.num - b.num) : [
|
||||
return monitorWorkspaces.length > 0 ? monitorWorkspaces.sort((a, b) => a.num - b.num).map(mapWorkspace) : [
|
||||
{
|
||||
"num": 1
|
||||
}
|
||||
@@ -222,7 +236,7 @@ Item {
|
||||
return [];
|
||||
}
|
||||
targetWorkspaceId = ws.tag;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
targetWorkspaceId = ws.num !== undefined ? ws.num : ws;
|
||||
} else {
|
||||
return [];
|
||||
@@ -234,7 +248,7 @@ Item {
|
||||
let isActiveWs = false;
|
||||
if (CompositorService.isNiri) {
|
||||
isActiveWs = NiriService.allWorkspaces.some(ws => ws.id === targetWorkspaceId && ws.is_active);
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
const focusedWs = I3.workspaces?.values?.find(ws => ws.focused === true);
|
||||
isActiveWs = focusedWs ? (focusedWs.num === targetWorkspaceId) : false;
|
||||
} else if (CompositorService.isDwl) {
|
||||
@@ -255,7 +269,7 @@ Item {
|
||||
let winWs = null;
|
||||
if (CompositorService.isNiri) {
|
||||
winWs = w.workspace_id;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
winWs = w.workspace?.num;
|
||||
} else {
|
||||
const hyprlandToplevels = Array.from(Hyprland.toplevels?.values || []);
|
||||
@@ -322,7 +336,7 @@ Item {
|
||||
placeholder = {
|
||||
"tag": -1
|
||||
};
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
placeholder = {
|
||||
"num": -1
|
||||
};
|
||||
@@ -516,7 +530,7 @@ Item {
|
||||
return ws && ws.id !== -1;
|
||||
if (CompositorService.isDwl)
|
||||
return ws && ws.tag !== -1;
|
||||
if (CompositorService.isSway || CompositorService.isScroll)
|
||||
if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle)
|
||||
return ws && ws.num !== -1;
|
||||
return ws !== -1;
|
||||
});
|
||||
@@ -588,7 +602,7 @@ Item {
|
||||
}
|
||||
|
||||
DwlService.switchToTag(root.screenName, realWorkspaces[nextIndex].tag);
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
const realWorkspaces = getRealWorkspaces();
|
||||
if (realWorkspaces.length < 2) {
|
||||
return;
|
||||
@@ -617,7 +631,7 @@ Item {
|
||||
return modelData?.id || "";
|
||||
if (CompositorService.isDwl)
|
||||
return (modelData?.tag !== undefined) ? (modelData.tag + 1) : "";
|
||||
if (CompositorService.isSway || CompositorService.isScroll)
|
||||
if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle)
|
||||
return modelData?.num || "";
|
||||
return modelData - 1;
|
||||
}
|
||||
@@ -632,7 +646,7 @@ Item {
|
||||
isPlaceholder = modelData?.id === -1;
|
||||
} else if (CompositorService.isDwl) {
|
||||
isPlaceholder = modelData?.tag === -1;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
isPlaceholder = modelData?.num === -1;
|
||||
} else {
|
||||
isPlaceholder = modelData === -1;
|
||||
@@ -665,7 +679,7 @@ Item {
|
||||
return getWorkspaceIndexFallback(modelData, index);
|
||||
}
|
||||
|
||||
readonly property bool hasNativeWorkspaceSupport: CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll
|
||||
readonly property bool hasNativeWorkspaceSupport: CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle
|
||||
readonly property bool hasWorkspaces: getRealWorkspaces().length > 0
|
||||
readonly property bool shouldShow: hasNativeWorkspaceSupport || (useExtWorkspace && hasWorkspaces)
|
||||
|
||||
@@ -865,7 +879,7 @@ Item {
|
||||
return !!(modelData && modelData.id === root.currentWorkspace);
|
||||
if (CompositorService.isDwl)
|
||||
return !!(modelData && root.dwlActiveTags.includes(modelData.tag));
|
||||
if (CompositorService.isSway || CompositorService.isScroll)
|
||||
if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle)
|
||||
return !!(modelData && modelData.num === root.currentWorkspace);
|
||||
return modelData === root.currentWorkspace;
|
||||
}
|
||||
@@ -889,7 +903,7 @@ Item {
|
||||
return !!(modelData && modelData.id === -1);
|
||||
if (CompositorService.isDwl)
|
||||
return !!(modelData && modelData.tag === -1);
|
||||
if (CompositorService.isSway || CompositorService.isScroll)
|
||||
if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle)
|
||||
return !!(modelData && modelData.num === -1);
|
||||
return modelData === -1;
|
||||
}
|
||||
@@ -906,12 +920,17 @@ Item {
|
||||
return loadedIsUrgent;
|
||||
if (CompositorService.isDwl)
|
||||
return modelData?.state === 2;
|
||||
if (CompositorService.isSway || CompositorService.isScroll)
|
||||
if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle)
|
||||
return loadedIsUrgent;
|
||||
return false;
|
||||
}
|
||||
property var loadedIconData: null
|
||||
property bool loadedHasIcon: false
|
||||
readonly property var loadedIconData: {
|
||||
if (isPlaceholder) return null;
|
||||
const name = modelData?.name;
|
||||
if (!name) return null;
|
||||
return SettingsData.getWorkspaceNameIcon(name);
|
||||
}
|
||||
readonly property bool loadedHasIcon: loadedIconData !== null
|
||||
property var loadedIcons: []
|
||||
|
||||
readonly property int stableIconCount: {
|
||||
@@ -927,7 +946,7 @@ Item {
|
||||
targetWorkspaceId = modelData?.id;
|
||||
} else if (CompositorService.isDwl) {
|
||||
targetWorkspaceId = modelData?.tag;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
targetWorkspaceId = modelData?.num;
|
||||
}
|
||||
if (targetWorkspaceId === undefined || targetWorkspaceId === null)
|
||||
@@ -946,7 +965,7 @@ Item {
|
||||
let winWs = null;
|
||||
if (CompositorService.isNiri) {
|
||||
winWs = w.workspace_id;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
winWs = w.workspace?.num;
|
||||
} else if (CompositorService.isHyprland) {
|
||||
const hyprlandToplevels = Array.from(Hyprland.toplevels?.values || []);
|
||||
@@ -971,9 +990,9 @@ Item {
|
||||
readonly property real baseWidth: root.isVertical ? (SettingsData.showWorkspaceApps ? Math.max(widgetHeight * 0.7, root.appIconSize + Theme.spacingXS * 2) : widgetHeight * 0.5) : (isActive ? root.widgetHeight * 1.05 : root.widgetHeight * 0.7)
|
||||
readonly property real baseHeight: root.isVertical ? (isActive ? root.widgetHeight * 1.05 : root.widgetHeight * 0.7) : (SettingsData.showWorkspaceApps ? Math.max(widgetHeight * 0.7, root.appIconSize + Theme.spacingXS * 2) : widgetHeight * 0.5)
|
||||
readonly property bool hasWorkspaceName: SettingsData.showWorkspaceName && modelData?.name && modelData.name !== ""
|
||||
readonly property bool workspaceNamesEnabled: SettingsData.showWorkspaceName && CompositorService.isNiri
|
||||
readonly property real contentImplicitWidth: (hasWorkspaceName || loadedHasIcon) ? (appIconsLoader.item?.contentWidth ?? 0) : 0
|
||||
readonly property real contentImplicitHeight: (workspaceNamesEnabled || loadedHasIcon) ? (appIconsLoader.item?.contentHeight ?? 0) : 0
|
||||
readonly property bool workspaceNamesEnabled: SettingsData.showWorkspaceName && (CompositorService.isNiri || CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle)
|
||||
readonly property real contentImplicitWidth: hasWorkspaceName ? (appIconsLoader.item?.contentWidth ?? 0) : 0
|
||||
readonly property real contentImplicitHeight: workspaceNamesEnabled ? (appIconsLoader.item?.contentHeight ?? 0) : 0
|
||||
|
||||
readonly property real iconsExtraWidth: {
|
||||
if (!root.isVertical && SettingsData.showWorkspaceApps && stableIconCount > 0) {
|
||||
@@ -1123,9 +1142,7 @@ Item {
|
||||
return;
|
||||
|
||||
if (!dragHandler.dragging) {
|
||||
const distance = root.isVertical
|
||||
? Math.abs(mouse.y - dragHandler.dragStartPos.y)
|
||||
: Math.abs(mouse.x - dragHandler.dragStartPos.x);
|
||||
const distance = root.isVertical ? Math.abs(mouse.y - dragHandler.dragStartPos.y) : Math.abs(mouse.x - dragHandler.dragStartPos.x);
|
||||
if (distance > 5) {
|
||||
dragHandler.dragging = true;
|
||||
root.dragSourceIndex = index;
|
||||
@@ -1136,9 +1153,7 @@ Item {
|
||||
if (!dragHandler.dragging)
|
||||
return;
|
||||
|
||||
const rawAxisOffset = root.isVertical
|
||||
? (mouse.y - dragHandler.dragStartPos.y)
|
||||
: (mouse.x - dragHandler.dragStartPos.x);
|
||||
const rawAxisOffset = root.isVertical ? (mouse.y - dragHandler.dragStartPos.y) : (mouse.x - dragHandler.dragStartPos.x);
|
||||
|
||||
const itemSize = (root.isVertical ? delegateRoot.height : delegateRoot.width) + Theme.spacingS;
|
||||
const maxOffsetPositive = (root.workspaceList.length - 1 - index) * itemSize;
|
||||
@@ -1189,7 +1204,7 @@ Item {
|
||||
Hyprland.dispatch(`workspace ${modelData.id}`);
|
||||
} else if (CompositorService.isDwl && modelData?.tag !== undefined) {
|
||||
DwlService.switchToTag(root.screenName, modelData.tag);
|
||||
} else if ((CompositorService.isSway || CompositorService.isScroll) && modelData?.num) {
|
||||
} else if ((CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) && modelData?.num) {
|
||||
try {
|
||||
I3.dispatch(`workspace number ${modelData.num}`);
|
||||
} catch (_) {}
|
||||
@@ -1212,8 +1227,6 @@ Item {
|
||||
onTriggered: {
|
||||
if (isPlaceholder) {
|
||||
delegateRoot.loadedWorkspaceData = null;
|
||||
delegateRoot.loadedIconData = null;
|
||||
delegateRoot.loadedHasIcon = false;
|
||||
delegateRoot.loadedIcons = [];
|
||||
delegateRoot.loadedIsUrgent = false;
|
||||
return;
|
||||
@@ -1228,7 +1241,7 @@ Item {
|
||||
wsData = modelData;
|
||||
} else if (CompositorService.isDwl) {
|
||||
wsData = modelData;
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
} else if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
wsData = modelData;
|
||||
}
|
||||
delegateRoot.loadedWorkspaceData = wsData;
|
||||
@@ -1239,15 +1252,8 @@ Item {
|
||||
delegateRoot.loadedIsUrgent = wsData?.urgent ?? false;
|
||||
}
|
||||
|
||||
var icData = null;
|
||||
if (wsData?.name) {
|
||||
icData = SettingsData.getWorkspaceNameIcon(wsData.name);
|
||||
}
|
||||
delegateRoot.loadedIconData = icData;
|
||||
delegateRoot.loadedHasIcon = icData !== null;
|
||||
|
||||
if (SettingsData.showWorkspaceApps) {
|
||||
if (CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll) {
|
||||
if (CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
delegateRoot.loadedIcons = root.getWorkspaceIcons(modelData);
|
||||
} else if (CompositorService.isNiri) {
|
||||
delegateRoot.loadedIcons = root.getWorkspaceIcons(isPlaceholder ? null : modelData);
|
||||
@@ -1410,7 +1416,7 @@ Item {
|
||||
|
||||
Item {
|
||||
visible: loadedHasIcon && loadedIconData?.type === "icon"
|
||||
width: wsIcon.width + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||
width: wsIcon.width
|
||||
height: root.appIconSize
|
||||
|
||||
DankIcon {
|
||||
@@ -1425,7 +1431,7 @@ Item {
|
||||
|
||||
Item {
|
||||
visible: loadedHasIcon && loadedIconData?.type === "text"
|
||||
width: wsText.implicitWidth + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||
width: wsText.implicitWidth
|
||||
height: root.appIconSize
|
||||
|
||||
StyledText {
|
||||
@@ -1439,14 +1445,14 @@ Item {
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: (SettingsData.showWorkspaceIndex || SettingsData.showWorkspaceName) && !loadedHasIcon
|
||||
width: wsIndexText.implicitWidth + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||
visible: ((SettingsData.showWorkspaceIndex || SettingsData.showWorkspaceName) && !loadedHasIcon) || (loadedHasIcon && SettingsData.showWorkspaceName && hasWorkspaceName)
|
||||
width: wsIndexText.implicitWidth
|
||||
height: root.appIconSize
|
||||
|
||||
StyledText {
|
||||
id: wsIndexText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.getWorkspaceIndex(modelData, index)
|
||||
text: loadedHasIcon ? (modelData?.name ?? "") : root.getWorkspaceIndex(modelData, index)
|
||||
color: (isActive || isUrgent) ? Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95) : isPlaceholder ? Theme.surfaceTextAlpha : Theme.surfaceTextMedium
|
||||
font.pixelSize: Theme.barTextSize(barThickness, barConfig?.fontScale)
|
||||
font.weight: (isActive && !isPlaceholder) ? Font.DemiBold : Font.Normal
|
||||
@@ -1564,9 +1570,9 @@ Item {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
visible: (SettingsData.showWorkspaceIndex || SettingsData.showWorkspaceName) && !loadedHasIcon
|
||||
visible: ((SettingsData.showWorkspaceIndex || SettingsData.showWorkspaceName) && !loadedHasIcon) || (loadedHasIcon && SettingsData.showWorkspaceName && hasWorkspaceName)
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: root.getWorkspaceIndex(modelData, index)
|
||||
text: loadedHasIcon ? (root.isVertical ? (modelData?.name ?? "").charAt(0) : (modelData?.name ?? "")) : root.getWorkspaceIndex(modelData, index)
|
||||
color: (isActive || isUrgent) ? Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95) : isPlaceholder ? Theme.surfaceTextAlpha : Theme.surfaceTextMedium
|
||||
font.pixelSize: Theme.barTextSize(barThickness, barConfig?.fontScale)
|
||||
font.weight: (isActive && !isPlaceholder) ? Font.DemiBold : Font.Normal
|
||||
@@ -1660,55 +1666,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
// Loader for Custom Name Icon
|
||||
Loader {
|
||||
id: customIconLoader
|
||||
anchors.fill: parent
|
||||
active: !isPlaceholder && loadedHasIcon && loadedIconData.type === "icon" && !SettingsData.showWorkspaceApps
|
||||
sourceComponent: Item {
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: loadedIconData ? loadedIconData.value : "" // NULL CHECK
|
||||
size: Theme.fontSizeSmall
|
||||
color: isActive ? Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95) : Theme.surfaceTextMedium
|
||||
weight: isActive && !isPlaceholder ? 500 : 400
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loader for Custom Name Text
|
||||
Loader {
|
||||
id: customTextLoader
|
||||
anchors.fill: parent
|
||||
active: !isPlaceholder && loadedHasIcon && loadedIconData.type === "text" && !SettingsData.showWorkspaceApps
|
||||
sourceComponent: Item {
|
||||
StyledText {
|
||||
anchors.centerIn: parent
|
||||
text: loadedIconData ? loadedIconData.value : "" // NULL CHECK
|
||||
color: isActive ? Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95) : Theme.surfaceTextMedium
|
||||
font.pixelSize: Theme.barTextSize(barThickness, barConfig?.fontScale)
|
||||
font.weight: (isActive && !isPlaceholder) ? Font.DemiBold : Font.Normal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loader for Workspace Index
|
||||
Loader {
|
||||
id: indexLoader
|
||||
anchors.fill: parent
|
||||
active: (SettingsData.showWorkspaceIndex || SettingsData.showWorkspaceName) && !loadedHasIcon && !SettingsData.showWorkspaceApps
|
||||
sourceComponent: Item {
|
||||
StyledText {
|
||||
anchors.centerIn: parent
|
||||
text: {
|
||||
return root.getWorkspaceIndex(modelData, index);
|
||||
}
|
||||
color: (isActive || isUrgent) ? Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95) : isPlaceholder ? Theme.surfaceTextAlpha : Theme.surfaceTextMedium
|
||||
font.pixelSize: Theme.barTextSize(barThickness, barConfig?.fontScale)
|
||||
font.weight: (isActive && !isPlaceholder) ? Font.DemiBold : Font.Normal
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: updateAllData()
|
||||
@@ -1760,7 +1717,7 @@ Item {
|
||||
}
|
||||
Connections {
|
||||
target: I3.workspaces
|
||||
enabled: (CompositorService.isSway || CompositorService.isScroll)
|
||||
enabled: (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle)
|
||||
function onValuesChanged() {
|
||||
delegateRoot.updateAllData();
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ Card {
|
||||
return "on Sway";
|
||||
if (CompositorService.isScroll)
|
||||
return "on Scroll";
|
||||
if (CompositorService.isMiracle)
|
||||
return "on Miracle WM";
|
||||
return "";
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
|
||||
@@ -12,7 +12,7 @@ Item {
|
||||
LayoutMirroring.childrenInherit: true
|
||||
|
||||
implicitWidth: 700
|
||||
implicitHeight: root.available ? mainColumn.implicitHeight : unavailableColumn.implicitHeight + Theme.spacingXL * 2
|
||||
implicitHeight: 410
|
||||
property bool syncing: false
|
||||
property bool showHourly: false
|
||||
property bool available: WeatherService.weather.available
|
||||
@@ -848,6 +848,7 @@ Item {
|
||||
}
|
||||
|
||||
Item {
|
||||
id: chipsRow
|
||||
width: parent.width
|
||||
height: forecastChips.height
|
||||
|
||||
@@ -939,7 +940,7 @@ Item {
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: root.showHourly ? ((hourlyLoader.item?.cardHeight ?? (Theme.fontSizeLarge * 6)) + Theme.spacingXS) : ((dailyLoader.item?.cardHeight ?? (Theme.fontSizeLarge * 6)) + Theme.spacingXS)
|
||||
height: root.height - heroCard.height - skyDateRow.height - chipsRow.height - mainColumn.spacing * 3
|
||||
|
||||
Loader {
|
||||
id: dailyLoader
|
||||
@@ -981,8 +982,7 @@ Item {
|
||||
id: hourlyComponent
|
||||
ListView {
|
||||
id: hourlyList
|
||||
width: parent.width
|
||||
height: cardHeight + Theme.spacingXS
|
||||
anchors.fill: parent
|
||||
orientation: ListView.Horizontal
|
||||
spacing: Theme.spacingS
|
||||
clip: true
|
||||
@@ -990,10 +990,8 @@ Item {
|
||||
highlightRangeMode: ListView.StrictlyEnforceRange
|
||||
highlightMoveDuration: 0
|
||||
interactive: true
|
||||
contentHeight: cardHeight
|
||||
contentWidth: cardWidth
|
||||
|
||||
property var cardHeight: Theme.fontSizeLarge * 6
|
||||
property var cardHeight: height
|
||||
property var cardWidth: ((hourlyList.width + hourlyList.spacing) / hourlyList.visibleCount) - hourlyList.spacing
|
||||
property int initialIndex: (new Date()).getHours()
|
||||
property bool dense: !SessionData.weatherHourlyDetailed
|
||||
@@ -1070,8 +1068,7 @@ Item {
|
||||
id: dailyComponent
|
||||
ListView {
|
||||
id: dailyList
|
||||
width: parent.width
|
||||
height: cardHeight + Theme.spacingXS
|
||||
anchors.fill: parent
|
||||
orientation: ListView.Horizontal
|
||||
spacing: Theme.spacingS
|
||||
clip: true
|
||||
@@ -1079,10 +1076,8 @@ Item {
|
||||
highlightRangeMode: ListView.StrictlyEnforceRange
|
||||
highlightMoveDuration: 0
|
||||
interactive: true
|
||||
contentHeight: cardHeight
|
||||
contentWidth: cardWidth
|
||||
|
||||
property var cardHeight: Theme.fontSizeLarge * 6
|
||||
property var cardHeight: height
|
||||
property var cardWidth: ((dailyList.width + dailyList.spacing) / dailyList.visibleCount) - dailyList.spacing
|
||||
property int initialIndex: 0
|
||||
property bool dense: false
|
||||
|
||||
@@ -500,10 +500,10 @@ Item {
|
||||
anchors.top: SettingsData.dockPosition === SettingsData.Position.Top ? parent.top : undefined
|
||||
anchors.left: SettingsData.dockPosition === SettingsData.Position.Left ? parent.left : undefined
|
||||
anchors.right: SettingsData.dockPosition === SettingsData.Position.Right ? parent.right : undefined
|
||||
anchors.bottomMargin: SettingsData.dockPosition === SettingsData.Position.Bottom ? -(SettingsData.dockSpacing / 2) : 0
|
||||
anchors.topMargin: SettingsData.dockPosition === SettingsData.Position.Top ? -(SettingsData.dockSpacing / 2) : 0
|
||||
anchors.leftMargin: SettingsData.dockPosition === SettingsData.Position.Left ? -(SettingsData.dockSpacing / 2) : 0
|
||||
anchors.rightMargin: SettingsData.dockPosition === SettingsData.Position.Right ? -(SettingsData.dockSpacing / 2) : 0
|
||||
anchors.bottomMargin: SettingsData.dockPosition === SettingsData.Position.Bottom ? -(SettingsData.dockSpacing / 2 + 1.4) : 0
|
||||
anchors.topMargin: SettingsData.dockPosition === SettingsData.Position.Top ? -(SettingsData.dockSpacing / 2 + 1.4) : 0
|
||||
anchors.leftMargin: SettingsData.dockPosition === SettingsData.Position.Left ? -(SettingsData.dockSpacing / 2 + 1.4) : 0
|
||||
anchors.rightMargin: SettingsData.dockPosition === SettingsData.Position.Right ? -(SettingsData.dockSpacing / 2 + 1.4) : 0
|
||||
|
||||
sourceComponent: SettingsData.dockPosition === SettingsData.Position.Left || SettingsData.dockPosition === SettingsData.Position.Right ? columnIndicator : rowIndicator
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ Item {
|
||||
}
|
||||
|
||||
IconImage {
|
||||
visible: SettingsData.dockLauncherLogoMode === "compositor" && (CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isLabwc)
|
||||
visible: SettingsData.dockLauncherLogoMode === "compositor" && (CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle || CompositorService.isLabwc)
|
||||
anchors.centerIn: parent
|
||||
width: actualIconSize + SettingsData.dockLauncherLogoSizeOffset
|
||||
height: actualIconSize + SettingsData.dockLauncherLogoSizeOffset
|
||||
@@ -253,6 +253,8 @@ Item {
|
||||
return "file://" + Theme.shellDir + "/assets/sway.svg";
|
||||
} else if (CompositorService.isScroll) {
|
||||
return "file://" + Theme.shellDir + "/assets/sway.svg";
|
||||
} else if (CompositorService.isMiracle) {
|
||||
return "file://" + Theme.shellDir + "/assets/miraclewm.svg";
|
||||
} else if (CompositorService.isLabwc) {
|
||||
return "file://" + Theme.shellDir + "/assets/labwc.png";
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ dms-greeter - DankMaterialShell greeter launcher
|
||||
Usage: dms-greeter --command COMPOSITOR [OPTIONS]
|
||||
|
||||
Required:
|
||||
--command COMPOSITOR Compositor to use (niri, hyprland, sway, scroll, mango, or labwc)
|
||||
--command COMPOSITOR Compositor to use (niri, hyprland, sway, scroll, miracle, mango, or labwc)
|
||||
|
||||
Options:
|
||||
-C, --config PATH Custom compositor config file
|
||||
@@ -244,6 +244,24 @@ SCROLL_EOF
|
||||
exec scroll -c "$COMPOSITOR_CONFIG"
|
||||
;;
|
||||
|
||||
miracle|miracle-wm)
|
||||
if [[ -z "$COMPOSITOR_CONFIG" ]]; then
|
||||
TEMP_CONFIG=$(mktemp)
|
||||
cat > "$TEMP_CONFIG" << MIRACLE_EOF
|
||||
exec "$QS_CMD; miraclemsg exit"
|
||||
MIRACLE_EOF
|
||||
COMPOSITOR_CONFIG="$TEMP_CONFIG"
|
||||
else
|
||||
TEMP_CONFIG=$(mktemp)
|
||||
cat "$COMPOSITOR_CONFIG" > "$TEMP_CONFIG"
|
||||
cat >> "$TEMP_CONFIG" << MIRACLE_EOF
|
||||
|
||||
exec "$QS_CMD; miraclemsg exit"
|
||||
MIRACLE_EOF
|
||||
COMPOSITOR_CONFIG="$TEMP_CONFIG"
|
||||
fi
|
||||
exec miracle-wm -c "$COMPOSITOR_CONFIG"
|
||||
;;
|
||||
|
||||
labwc)
|
||||
if [[ -n "$COMPOSITOR_CONFIG" ]]; then
|
||||
@@ -263,7 +281,7 @@ SCROLL_EOF
|
||||
|
||||
*)
|
||||
echo "Error: Unsupported compositor: $COMPOSITOR" >&2
|
||||
echo "Supported compositors: niri, hyprland, sway, scroll, mango, labwc" >&2
|
||||
echo "Supported compositors: niri, hyprland, sway, scroll, miracle, mango, labwc" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -21,8 +21,8 @@ Rectangle {
|
||||
}
|
||||
|
||||
readonly property bool compactMode: SettingsData.notificationCompactMode
|
||||
readonly property real cardPadding: compactMode ? Theme.spacingS : Theme.spacingM
|
||||
readonly property real iconSize: compactMode ? 48 : 63
|
||||
readonly property real cardPadding: compactMode ? Theme.notificationCardPaddingCompact : Theme.notificationCardPadding
|
||||
readonly property real iconSize: compactMode ? Theme.notificationIconSizeCompact : Theme.notificationIconSizeNormal
|
||||
readonly property real contentSpacing: compactMode ? Theme.spacingXS : Theme.spacingS
|
||||
readonly property real collapsedContentHeight: iconSize + cardPadding
|
||||
readonly property real baseCardHeight: cardPadding * 2 + collapsedContentHeight
|
||||
@@ -93,7 +93,7 @@ Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: cardPadding
|
||||
anchors.leftMargin: Theme.spacingL
|
||||
anchors.rightMargin: Theme.spacingL + (compactMode ? 32 : 40)
|
||||
anchors.rightMargin: Theme.spacingL + Theme.notificationHoverRevealMargin
|
||||
height: collapsedContentHeight + extraHeight
|
||||
|
||||
DankCircularImage {
|
||||
@@ -165,32 +165,47 @@ Rectangle {
|
||||
Column {
|
||||
width: parent.width
|
||||
anchors.top: parent.top
|
||||
spacing: compactMode ? 1 : 2
|
||||
spacing: Theme.notificationContentSpacing
|
||||
|
||||
StyledText {
|
||||
Row {
|
||||
width: parent.width
|
||||
text: {
|
||||
const timeStr = NotificationService.formatHistoryTime(historyItem.timestamp);
|
||||
const appName = historyItem.appName || "";
|
||||
return timeStr.length > 0 ? `${appName} • ${timeStr}` : appName;
|
||||
spacing: Theme.spacingXS
|
||||
readonly property real reservedTrailingWidth: historySeparator.implicitWidth + Math.max(historyTimeText.implicitWidth, 72) + spacing
|
||||
|
||||
StyledText {
|
||||
id: historyTitleText
|
||||
width: Math.min(implicitWidth, Math.max(0, parent.width - parent.reservedTrailingWidth))
|
||||
text: {
|
||||
let title = historyItem.summary || "";
|
||||
const appName = historyItem.appName || "";
|
||||
const prefix = appName + " • ";
|
||||
if (appName && title.toLowerCase().startsWith(prefix.toLowerCase())) {
|
||||
title = title.substring(prefix.length);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
color: Theme.surfaceText
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
}
|
||||
StyledText {
|
||||
id: historySeparator
|
||||
text: (historyTitleText.text.length > 0 && historyTimeText.text.length > 0) ? " • " : ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
}
|
||||
StyledText {
|
||||
id: historyTimeText
|
||||
text: NotificationService.formatHistoryTime(historyItem.timestamp)
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
visible: text.length > 0
|
||||
}
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: historyItem.summary || ""
|
||||
color: Theme.surfaceText
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
|
||||
@@ -278,7 +278,7 @@ Item {
|
||||
Behavior on x {
|
||||
enabled: !swipeDragHandler.active && delegateRoot.__delegateInitialized
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
duration: Theme.notificationExitDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
@@ -286,7 +286,7 @@ Item {
|
||||
Behavior on opacity {
|
||||
enabled: delegateRoot.__delegateInitialized
|
||||
NumberAnimation {
|
||||
duration: delegateRoot.__delegateInitialized ? Theme.shortDuration : 0
|
||||
duration: delegateRoot.__delegateInitialized ? Theme.notificationExitDuration : 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,15 +11,63 @@ DankListView {
|
||||
property bool autoScrollDisabled: false
|
||||
property bool isAnimatingExpansion: false
|
||||
property alias listContentHeight: listView.contentHeight
|
||||
property real stableContentHeight: 0
|
||||
property bool cardAnimateExpansion: true
|
||||
property bool listInitialized: false
|
||||
property int swipingCardIndex: -1
|
||||
property real swipingCardOffset: 0
|
||||
property real __pendingStableHeight: 0
|
||||
property real __heightUpdateThreshold: 20
|
||||
|
||||
Component.onCompleted: {
|
||||
Qt.callLater(() => {
|
||||
listInitialized = true;
|
||||
if (listView) {
|
||||
listView.listInitialized = true;
|
||||
listView.stableContentHeight = listView.contentHeight;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: heightUpdateDebounce
|
||||
interval: Theme.mediumDuration + 20
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
if (!listView.isAnimatingExpansion && Math.abs(listView.__pendingStableHeight - listView.stableContentHeight) > listView.__heightUpdateThreshold) {
|
||||
listView.stableContentHeight = listView.__pendingStableHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onContentHeightChanged: {
|
||||
if (!isAnimatingExpansion) {
|
||||
__pendingStableHeight = contentHeight;
|
||||
if (Math.abs(contentHeight - stableContentHeight) > __heightUpdateThreshold) {
|
||||
heightUpdateDebounce.restart();
|
||||
} else {
|
||||
stableContentHeight = contentHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onIsAnimatingExpansionChanged: {
|
||||
if (isAnimatingExpansion) {
|
||||
heightUpdateDebounce.stop();
|
||||
let delta = 0;
|
||||
for (let i = 0; i < count; i++) {
|
||||
const item = itemAtIndex(i);
|
||||
if (item && item.children[0] && item.children[0].isAnimating)
|
||||
delta += item.children[0].targetHeight - item.height;
|
||||
}
|
||||
const targetHeight = contentHeight + delta;
|
||||
// During expansion, always update immediately without threshold check
|
||||
stableContentHeight = targetHeight;
|
||||
} else {
|
||||
__pendingStableHeight = contentHeight;
|
||||
heightUpdateDebounce.restart();
|
||||
}
|
||||
}
|
||||
|
||||
clip: true
|
||||
model: NotificationService.groupedNotifications
|
||||
spacing: Theme.spacingL
|
||||
@@ -86,29 +134,47 @@ DankListView {
|
||||
readonly property real dismissThreshold: width * 0.35
|
||||
property bool __delegateInitialized: false
|
||||
|
||||
readonly property bool isAdjacentToSwipe: listView.count >= 2 && listView.swipingCardIndex !== -1 &&
|
||||
(index === listView.swipingCardIndex - 1 || index === listView.swipingCardIndex + 1)
|
||||
readonly property real adjacentSwipeInfluence: isAdjacentToSwipe ? listView.swipingCardOffset * 0.10 : 0
|
||||
readonly property real adjacentScaleInfluence: isAdjacentToSwipe ? 1.0 - Math.abs(listView.swipingCardOffset) / width * 0.02 : 1.0
|
||||
readonly property real swipeFadeStartOffset: width * 0.75
|
||||
readonly property real swipeFadeDistance: Math.max(1, width - swipeFadeStartOffset)
|
||||
|
||||
Component.onCompleted: {
|
||||
Qt.callLater(() => {
|
||||
__delegateInitialized = true;
|
||||
if (delegateRoot)
|
||||
delegateRoot.__delegateInitialized = true;
|
||||
});
|
||||
}
|
||||
|
||||
width: ListView.view.width
|
||||
height: isDismissing ? 0 : notificationCard.targetHeight
|
||||
clip: isDismissing || notificationCard.isAnimating
|
||||
height: notificationCard.height
|
||||
clip: notificationCard.isAnimating
|
||||
|
||||
NotificationCard {
|
||||
id: notificationCard
|
||||
width: parent.width
|
||||
x: delegateRoot.swipeOffset
|
||||
x: delegateRoot.swipeOffset + delegateRoot.adjacentSwipeInfluence
|
||||
listLevelAdjacentScaleInfluence: delegateRoot.adjacentScaleInfluence
|
||||
listLevelScaleAnimationsEnabled: listView.swipingCardIndex === -1 || !delegateRoot.isAdjacentToSwipe
|
||||
notificationGroup: modelData
|
||||
keyboardNavigationActive: listView.keyboardActive
|
||||
animateExpansion: listView.cardAnimateExpansion && listView.listInitialized
|
||||
opacity: 1 - Math.abs(delegateRoot.swipeOffset) / (delegateRoot.width * 0.5)
|
||||
opacity: {
|
||||
const swipeAmount = Math.abs(delegateRoot.swipeOffset);
|
||||
if (swipeAmount <= delegateRoot.swipeFadeStartOffset)
|
||||
return 1;
|
||||
const fadeProgress = (swipeAmount - delegateRoot.swipeFadeStartOffset) / delegateRoot.swipeFadeDistance;
|
||||
return Math.max(0, 1 - fadeProgress);
|
||||
}
|
||||
onIsAnimatingChanged: {
|
||||
if (isAnimating) {
|
||||
listView.isAnimatingExpansion = true;
|
||||
} else {
|
||||
Qt.callLater(() => {
|
||||
if (!notificationCard || !listView)
|
||||
return;
|
||||
let anyAnimating = false;
|
||||
for (let i = 0; i < listView.count; i++) {
|
||||
const item = listView.itemAtIndex(i);
|
||||
@@ -139,7 +205,7 @@ DankListView {
|
||||
}
|
||||
|
||||
Behavior on x {
|
||||
enabled: !swipeDragHandler.active && listView.listInitialized
|
||||
enabled: !swipeDragHandler.active && !delegateRoot.isDismissing && (listView.swipingCardIndex === -1 || !delegateRoot.isAdjacentToSwipe) && listView.listInitialized
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
@@ -161,12 +227,18 @@ DankListView {
|
||||
xAxis.enabled: true
|
||||
|
||||
onActiveChanged: {
|
||||
if (active || delegateRoot.isDismissing)
|
||||
if (active) {
|
||||
listView.swipingCardIndex = index;
|
||||
return;
|
||||
}
|
||||
listView.swipingCardIndex = -1;
|
||||
listView.swipingCardOffset = 0;
|
||||
if (delegateRoot.isDismissing)
|
||||
return;
|
||||
if (Math.abs(delegateRoot.swipeOffset) > delegateRoot.dismissThreshold) {
|
||||
delegateRoot.isDismissing = true;
|
||||
delegateRoot.swipeOffset = delegateRoot.swipeOffset > 0 ? delegateRoot.width : -delegateRoot.width;
|
||||
dismissTimer.start();
|
||||
swipeDismissAnim.to = delegateRoot.swipeOffset > 0 ? delegateRoot.width : -delegateRoot.width;
|
||||
swipeDismissAnim.start();
|
||||
} else {
|
||||
delegateRoot.swipeOffset = 0;
|
||||
}
|
||||
@@ -176,13 +248,18 @@ DankListView {
|
||||
if (delegateRoot.isDismissing)
|
||||
return;
|
||||
delegateRoot.swipeOffset = translation.x;
|
||||
listView.swipingCardOffset = translation.x;
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: dismissTimer
|
||||
interval: Theme.shortDuration
|
||||
onTriggered: NotificationService.dismissGroup(delegateRoot.modelData?.key || "")
|
||||
NumberAnimation {
|
||||
id: swipeDismissAnim
|
||||
target: delegateRoot
|
||||
property: "swipeOffset"
|
||||
to: 0
|
||||
duration: Theme.notificationExitDuration
|
||||
easing.type: Easing.OutCubic
|
||||
onStopped: NotificationService.dismissGroup(delegateRoot.modelData?.key || "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import Quickshell.Services.Notifications
|
||||
import qs.Common
|
||||
@@ -18,28 +19,43 @@ Rectangle {
|
||||
property bool isGroupSelected: false
|
||||
property int selectedNotificationIndex: -1
|
||||
property bool keyboardNavigationActive: false
|
||||
property int swipingNotificationIndex: -1
|
||||
property real swipingNotificationOffset: 0
|
||||
property real listLevelAdjacentScaleInfluence: 1.0
|
||||
property bool listLevelScaleAnimationsEnabled: true
|
||||
|
||||
readonly property bool compactMode: SettingsData.notificationCompactMode
|
||||
readonly property real cardPadding: compactMode ? Theme.spacingS : Theme.spacingM
|
||||
readonly property real iconSize: compactMode ? 48 : 63
|
||||
readonly property real cardPadding: compactMode ? Theme.notificationCardPaddingCompact : Theme.notificationCardPadding
|
||||
readonly property real iconSize: compactMode ? Theme.notificationIconSizeCompact : Theme.notificationIconSizeNormal
|
||||
readonly property real contentSpacing: compactMode ? Theme.spacingXS : Theme.spacingS
|
||||
readonly property real collapsedDismissOffset: 5
|
||||
readonly property real badgeSize: compactMode ? 16 : 18
|
||||
readonly property real actionButtonHeight: compactMode ? 20 : 24
|
||||
readonly property real collapsedContentHeight: iconSize
|
||||
readonly property real collapsedContentHeight: Math.max(iconSize, Theme.fontSizeSmall * 1.2 + Theme.fontSizeMedium * 1.2 + Theme.fontSizeSmall * 1.2 * (compactMode ? 1 : 2))
|
||||
readonly property real baseCardHeight: cardPadding * 2 + collapsedContentHeight + actionButtonHeight + contentSpacing
|
||||
|
||||
width: parent ? parent.width : 400
|
||||
height: expanded ? (expandedContent.height + cardPadding * 2) : (baseCardHeight + collapsedContent.extraHeight)
|
||||
readonly property real targetHeight: expanded ? (expandedContent.height + cardPadding * 2) : (baseCardHeight + collapsedContent.extraHeight)
|
||||
radius: Theme.cornerRadius
|
||||
scale: (cardHoverHandler.hovered ? 1.01 : 1.0) * listLevelAdjacentScaleInfluence
|
||||
property bool __initialized: false
|
||||
|
||||
Component.onCompleted: {
|
||||
Qt.callLater(() => {
|
||||
__initialized = true;
|
||||
if (root)
|
||||
root.__initialized = true;
|
||||
});
|
||||
}
|
||||
|
||||
Behavior on scale {
|
||||
enabled: listLevelScaleAnimationsEnabled
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on border.color {
|
||||
enabled: root.__initialized
|
||||
ColorAnimation {
|
||||
@@ -83,6 +99,10 @@ Rectangle {
|
||||
}
|
||||
clip: true
|
||||
|
||||
HoverHandler {
|
||||
id: cardHoverHandler
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: parent.radius
|
||||
@@ -109,15 +129,16 @@ Rectangle {
|
||||
id: collapsedContent
|
||||
|
||||
readonly property real expandedTextHeight: descriptionText.contentHeight
|
||||
readonly property real twoLineHeight: descriptionText.font.pixelSize * 1.2 * 2
|
||||
readonly property real extraHeight: (descriptionExpanded && expandedTextHeight > twoLineHeight + 2) ? (expandedTextHeight - twoLineHeight) : 0
|
||||
readonly property real collapsedLineCount: compactMode ? 1 : 2
|
||||
readonly property real collapsedLineHeight: Theme.fontSizeSmall * 1.2 * collapsedLineCount
|
||||
readonly property real extraHeight: (descriptionExpanded && expandedTextHeight > collapsedLineHeight + 2) ? (expandedTextHeight - collapsedLineHeight) : 0
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: cardPadding
|
||||
anchors.leftMargin: Theme.spacingL
|
||||
anchors.rightMargin: Theme.spacingL + (compactMode ? 32 : 40)
|
||||
anchors.rightMargin: Theme.spacingL + Theme.notificationHoverRevealMargin
|
||||
height: collapsedContentHeight + extraHeight
|
||||
visible: !expanded
|
||||
|
||||
@@ -139,6 +160,7 @@ Rectangle {
|
||||
height: iconSize
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: descriptionExpanded ? Math.max(0, Theme.fontSizeSmall * 1.2 + (Theme.fontSizeMedium * 1.2 + Theme.fontSizeSmall * 1.2 * (compactMode ? 1 : 2)) / 2 - iconSize / 2) : Math.max(0, Theme.fontSizeSmall * 1.2 + (textContainer.height - Theme.fontSizeSmall * 1.2) / 2 - iconSize / 2)
|
||||
|
||||
imageSource: {
|
||||
if (hasNotificationImage)
|
||||
@@ -212,29 +234,49 @@ Rectangle {
|
||||
Column {
|
||||
width: parent.width
|
||||
anchors.top: parent.top
|
||||
spacing: compactMode ? 1 : 2
|
||||
spacing: Theme.notificationContentSpacing
|
||||
|
||||
StyledText {
|
||||
Row {
|
||||
id: collapsedHeaderRow
|
||||
width: parent.width
|
||||
text: {
|
||||
const timeStr = (notificationGroup && notificationGroup.latestNotification && notificationGroup.latestNotification.timeStr) || "";
|
||||
const appName = (notificationGroup && notificationGroup.appName) || "";
|
||||
return timeStr.length > 0 ? `${appName} • ${timeStr}` : appName;
|
||||
spacing: Theme.spacingXS
|
||||
visible: (collapsedHeaderAppNameText.text.length > 0 || collapsedHeaderTimeText.text.length > 0)
|
||||
|
||||
StyledText {
|
||||
id: collapsedHeaderAppNameText
|
||||
text: notificationGroup?.appName || ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
width: Math.min(implicitWidth, parent.width - collapsedHeaderSeparator.implicitWidth - collapsedHeaderTimeText.implicitWidth - parent.spacing * 2)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: collapsedHeaderSeparator
|
||||
text: (collapsedHeaderAppNameText.text.length > 0 && collapsedHeaderTimeText.text.length > 0) ? " • " : ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: collapsedHeaderTimeText
|
||||
text: notificationGroup?.latestNotification?.timeStr || ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
}
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: (notificationGroup && notificationGroup.latestNotification && notificationGroup.latestNotification.summary) || ""
|
||||
id: collapsedTitleText
|
||||
width: parent.width
|
||||
text: notificationGroup?.latestNotification?.summary || ""
|
||||
color: Theme.surfaceText
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
@@ -301,7 +343,7 @@ Rectangle {
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingL + (compactMode ? 32 : 40)
|
||||
anchors.rightMargin: Theme.spacingL + Theme.notificationHoverRevealMargin
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingS
|
||||
|
||||
@@ -343,214 +385,331 @@ Rectangle {
|
||||
objectName: "notificationRepeater"
|
||||
model: notificationGroup?.notifications?.slice(0, 10) || []
|
||||
|
||||
delegate: Rectangle {
|
||||
delegate: Item {
|
||||
id: expandedDelegateWrapper
|
||||
required property var modelData
|
||||
required property int index
|
||||
readonly property bool messageExpanded: NotificationService.expandedMessages[modelData?.notification?.id] || false
|
||||
readonly property bool isSelected: root.selectedNotificationIndex === index
|
||||
readonly property real expandedIconSize: compactMode ? 40 : 48
|
||||
readonly property bool actionsVisible: true
|
||||
readonly property real expandedIconSize: compactMode ? Theme.notificationExpandedIconSizeCompact : Theme.notificationExpandedIconSizeNormal
|
||||
|
||||
HoverHandler {
|
||||
id: expandedDelegateHoverHandler
|
||||
}
|
||||
readonly property real expandedItemPadding: compactMode ? Theme.spacingS : Theme.spacingM
|
||||
readonly property real expandedBaseHeight: expandedItemPadding * 2 + expandedIconSize + actionButtonHeight + contentSpacing * 2
|
||||
readonly property real expandedBaseHeight: expandedItemPadding * 2 + Math.max(expandedIconSize, Theme.fontSizeSmall * 1.2 + Theme.fontSizeMedium * 1.2 + Theme.fontSizeSmall * 1.2 * 2) + actionButtonHeight + contentSpacing * 2
|
||||
property bool __delegateInitialized: false
|
||||
property real swipeOffset: 0
|
||||
property bool isDismissing: false
|
||||
readonly property real dismissThreshold: width * 0.35
|
||||
|
||||
Component.onCompleted: {
|
||||
Qt.callLater(() => {
|
||||
__delegateInitialized = true;
|
||||
if (expandedDelegateWrapper)
|
||||
expandedDelegateWrapper.__delegateInitialized = true;
|
||||
});
|
||||
}
|
||||
|
||||
width: parent.width
|
||||
height: {
|
||||
if (!messageExpanded)
|
||||
return expandedBaseHeight;
|
||||
const twoLineHeight = bodyText.font.pixelSize * 1.2 * 2;
|
||||
if (bodyText.implicitHeight > twoLineHeight + 2)
|
||||
return expandedBaseHeight + bodyText.implicitHeight - twoLineHeight;
|
||||
return expandedBaseHeight;
|
||||
}
|
||||
radius: Theme.cornerRadius
|
||||
color: isSelected ? Theme.primaryPressed : Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
|
||||
border.color: isSelected ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
|
||||
border.width: 1
|
||||
height: delegateRect.height
|
||||
clip: true
|
||||
|
||||
Behavior on border.color {
|
||||
enabled: __delegateInitialized
|
||||
ColorAnimation {
|
||||
duration: __delegateInitialized ? Theme.shortDuration : 0
|
||||
easing.type: Theme.standardEasing
|
||||
Rectangle {
|
||||
id: delegateRect
|
||||
width: parent.width
|
||||
|
||||
readonly property bool isAdjacentToSwipe: root.swipingNotificationIndex !== -1 &&
|
||||
(expandedDelegateWrapper.index === root.swipingNotificationIndex - 1 ||
|
||||
expandedDelegateWrapper.index === root.swipingNotificationIndex + 1)
|
||||
readonly property real adjacentSwipeInfluence: isAdjacentToSwipe ? root.swipingNotificationOffset * 0.10 : 0
|
||||
readonly property real adjacentScaleInfluence: isAdjacentToSwipe ? 1.0 - Math.abs(root.swipingNotificationOffset) / width * 0.02 : 1.0
|
||||
|
||||
x: expandedDelegateWrapper.swipeOffset + adjacentSwipeInfluence
|
||||
scale: adjacentScaleInfluence
|
||||
transformOrigin: Item.Center
|
||||
|
||||
Behavior on x {
|
||||
enabled: !expandedSwipeHandler.active && !expandedDelegateWrapper.isDismissing
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on height {
|
||||
enabled: false
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.margins: compactMode ? Theme.spacingS : Theme.spacingM
|
||||
anchors.bottomMargin: contentSpacing
|
||||
|
||||
DankCircularImage {
|
||||
id: messageIcon
|
||||
|
||||
readonly property string rawImage: modelData?.image || ""
|
||||
readonly property string iconFromImage: {
|
||||
if (rawImage.startsWith("image://icon/"))
|
||||
return rawImage.substring(13);
|
||||
return "";
|
||||
Behavior on scale {
|
||||
enabled: !expandedSwipeHandler.active
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
readonly property bool imageHasSpecialPrefix: {
|
||||
const icon = iconFromImage;
|
||||
return icon.startsWith("material:") || icon.startsWith("svg:") || icon.startsWith("unicode:") || icon.startsWith("image:");
|
||||
}
|
||||
readonly property bool hasNotificationImage: rawImage !== "" && !rawImage.startsWith("image://icon/")
|
||||
}
|
||||
|
||||
width: expandedIconSize
|
||||
height: expandedIconSize
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: compactMode ? Theme.spacingM : Theme.spacingXL
|
||||
height: {
|
||||
if (!messageExpanded)
|
||||
return expandedBaseHeight;
|
||||
const twoLineHeight = bodyText.font.pixelSize * 1.2 * 2;
|
||||
if (bodyText.implicitHeight > twoLineHeight + 2)
|
||||
return expandedBaseHeight + bodyText.implicitHeight - twoLineHeight;
|
||||
return expandedBaseHeight;
|
||||
}
|
||||
radius: Theme.cornerRadius
|
||||
color: isSelected ? Theme.primaryPressed : Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
|
||||
border.color: isSelected ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.05)
|
||||
border.width: 1
|
||||
|
||||
imageSource: {
|
||||
if (hasNotificationImage)
|
||||
return modelData.cleanImage;
|
||||
if (imageHasSpecialPrefix)
|
||||
return "";
|
||||
const appIcon = modelData?.appIcon;
|
||||
if (!appIcon)
|
||||
return iconFromImage ? "image://icon/" + iconFromImage : "";
|
||||
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://") || appIcon.includes("/"))
|
||||
return appIcon;
|
||||
if (appIcon.startsWith("material:") || appIcon.startsWith("svg:") || appIcon.startsWith("unicode:") || appIcon.startsWith("image:"))
|
||||
return "";
|
||||
return Quickshell.iconPath(appIcon, true);
|
||||
Behavior on border.color {
|
||||
enabled: __delegateInitialized
|
||||
ColorAnimation {
|
||||
duration: __delegateInitialized ? Theme.shortDuration : 0
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
fallbackIcon: {
|
||||
if (imageHasSpecialPrefix)
|
||||
return iconFromImage;
|
||||
return modelData?.appIcon || iconFromImage || "";
|
||||
}
|
||||
|
||||
fallbackText: {
|
||||
const appName = modelData?.appName || "?";
|
||||
return appName.charAt(0).toUpperCase();
|
||||
}
|
||||
Behavior on height {
|
||||
enabled: false
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.left: messageIcon.right
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.fill: parent
|
||||
anchors.margins: compactMode ? Theme.spacingS : Theme.spacingM
|
||||
anchors.bottomMargin: contentSpacing
|
||||
|
||||
Column {
|
||||
DankCircularImage {
|
||||
id: messageIcon
|
||||
|
||||
readonly property string rawImage: modelData?.image || ""
|
||||
readonly property string iconFromImage: {
|
||||
if (rawImage.startsWith("image://icon/"))
|
||||
return rawImage.substring(13);
|
||||
return "";
|
||||
}
|
||||
readonly property bool imageHasSpecialPrefix: {
|
||||
const icon = iconFromImage;
|
||||
return icon.startsWith("material:") || icon.startsWith("svg:") || icon.startsWith("unicode:") || icon.startsWith("image:");
|
||||
}
|
||||
readonly property bool hasNotificationImage: rawImage !== "" && !rawImage.startsWith("image://icon/")
|
||||
|
||||
width: expandedIconSize
|
||||
height: expandedIconSize
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: buttonArea.top
|
||||
anchors.bottomMargin: contentSpacing
|
||||
spacing: compactMode ? 1 : 2
|
||||
anchors.topMargin: Theme.fontSizeSmall * 1.2 + (compactMode ? Theme.spacingXS : Theme.spacingS)
|
||||
|
||||
StyledText {
|
||||
width: parent.width
|
||||
text: modelData?.timeStr || ""
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
imageSource: {
|
||||
if (hasNotificationImage)
|
||||
return modelData.cleanImage;
|
||||
if (imageHasSpecialPrefix)
|
||||
return "";
|
||||
const appIcon = modelData?.appIcon;
|
||||
if (!appIcon)
|
||||
return iconFromImage ? "image://icon/" + iconFromImage : "";
|
||||
if (appIcon.startsWith("file://") || appIcon.startsWith("http://") || appIcon.startsWith("https://") || appIcon.includes("/"))
|
||||
return appIcon;
|
||||
if (appIcon.startsWith("material:") || appIcon.startsWith("svg:") || appIcon.startsWith("unicode:") || appIcon.startsWith("image:"))
|
||||
return "";
|
||||
return Quickshell.iconPath(appIcon, true);
|
||||
}
|
||||
|
||||
StyledText {
|
||||
width: parent.width
|
||||
text: modelData?.summary || ""
|
||||
color: Theme.surfaceText
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
fallbackIcon: {
|
||||
if (imageHasSpecialPrefix)
|
||||
return iconFromImage;
|
||||
return modelData?.appIcon || iconFromImage || "";
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: bodyText
|
||||
property bool hasMoreText: truncated
|
||||
|
||||
text: modelData?.htmlBody || ""
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
width: parent.width
|
||||
elide: messageExpanded ? Text.ElideNone : Text.ElideRight
|
||||
maximumLineCount: messageExpanded ? -1 : 2
|
||||
wrapMode: Text.WordWrap
|
||||
visible: text.length > 0
|
||||
linkColor: Theme.primary
|
||||
onLinkActivated: link => Qt.openUrlExternally(link)
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : (bodyText.hasMoreText || messageExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
|
||||
onClicked: mouse => {
|
||||
if (!parent.hoveredLink && (bodyText.hasMoreText || messageExpanded)) {
|
||||
NotificationService.toggleMessageExpansion(modelData?.notification?.id || "");
|
||||
}
|
||||
}
|
||||
|
||||
propagateComposedEvents: true
|
||||
onPressed: mouse => {
|
||||
if (parent.hoveredLink) {
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
onReleased: mouse => {
|
||||
if (parent.hoveredLink) {
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
fallbackText: {
|
||||
const appName = modelData?.appName || "?";
|
||||
return appName.charAt(0).toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: buttonArea
|
||||
anchors.left: parent.left
|
||||
anchors.left: messageIcon.right
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
height: actionButtonHeight + contentSpacing
|
||||
|
||||
Row {
|
||||
Column {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: buttonArea.top
|
||||
anchors.bottomMargin: contentSpacing
|
||||
spacing: Theme.notificationContentSpacing
|
||||
|
||||
Row {
|
||||
id: expandedDelegateHeaderRow
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXS
|
||||
visible: (expandedDelegateHeaderAppNameText.text.length > 0 || expandedDelegateHeaderTimeText.text.length > 0)
|
||||
|
||||
StyledText {
|
||||
id: expandedDelegateHeaderAppNameText
|
||||
text: modelData?.appName || ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
width: Math.min(implicitWidth, parent.width - expandedDelegateHeaderSeparator.implicitWidth - expandedDelegateHeaderTimeText.implicitWidth - parent.spacing * 2)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: expandedDelegateHeaderSeparator
|
||||
text: (expandedDelegateHeaderAppNameText.text.length > 0 && expandedDelegateHeaderTimeText.text.length > 0) ? " • " : ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: expandedDelegateHeaderTimeText
|
||||
text: modelData?.timeStr || ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: expandedDelegateTitleText
|
||||
width: parent.width
|
||||
text: modelData?.summary || ""
|
||||
color: Theme.surfaceText
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: bodyText
|
||||
property bool hasMoreText: truncated
|
||||
|
||||
text: modelData?.htmlBody || ""
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
width: parent.width
|
||||
elide: messageExpanded ? Text.ElideNone : Text.ElideRight
|
||||
maximumLineCount: messageExpanded ? -1 : 2
|
||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||
visible: text.length > 0
|
||||
linkColor: Theme.primary
|
||||
onLinkActivated: link => Qt.openUrlExternally(link)
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : (bodyText.hasMoreText || messageExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
|
||||
onClicked: mouse => {
|
||||
if (!parent.hoveredLink && (bodyText.hasMoreText || messageExpanded)) {
|
||||
NotificationService.toggleMessageExpansion(modelData?.notification?.id || "");
|
||||
}
|
||||
}
|
||||
|
||||
propagateComposedEvents: true
|
||||
onPressed: mouse => {
|
||||
if (parent.hoveredLink) {
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
onReleased: mouse => {
|
||||
if (parent.hoveredLink) {
|
||||
mouse.accepted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: buttonArea
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
spacing: contentSpacing
|
||||
height: actionButtonHeight + contentSpacing
|
||||
|
||||
Repeater {
|
||||
model: modelData?.actions || []
|
||||
Row {
|
||||
visible: expandedDelegateWrapper.actionsVisible
|
||||
opacity: visible ? 1 : 0
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
spacing: contentSpacing
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: modelData?.actions || []
|
||||
|
||||
Rectangle {
|
||||
property bool isHovered: false
|
||||
|
||||
width: Math.max(expandedActionText.implicitWidth + Theme.spacingM, Theme.notificationActionMinWidth)
|
||||
height: actionButtonHeight
|
||||
radius: Theme.notificationButtonCornerRadius
|
||||
color: isHovered ? Theme.withAlpha(Theme.primary, Theme.stateLayerHover) : "transparent"
|
||||
|
||||
StyledText {
|
||||
id: expandedActionText
|
||||
text: {
|
||||
const baseText = modelData.text || "Open";
|
||||
if (keyboardNavigationActive && (isGroupSelected || selectedNotificationIndex >= 0))
|
||||
return `${baseText} (${index + 1})`;
|
||||
return baseText;
|
||||
}
|
||||
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
anchors.centerIn: parent
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onEntered: parent.isHovered = true
|
||||
onExited: parent.isHovered = false
|
||||
onClicked: {
|
||||
if (modelData && modelData.invoke)
|
||||
modelData.invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: expandedDelegateDismissBtn
|
||||
property bool isHovered: false
|
||||
|
||||
width: Math.max(expandedActionText.implicitWidth + Theme.spacingM, compactMode ? 40 : 50)
|
||||
visible: expandedDelegateWrapper.actionsVisible
|
||||
opacity: visible ? 1 : 0
|
||||
width: Math.max(expandedClearText.implicitWidth + Theme.spacingM, Theme.notificationActionMinWidth)
|
||||
height: actionButtonHeight
|
||||
radius: Theme.spacingXS
|
||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
||||
radius: Theme.notificationButtonCornerRadius
|
||||
color: isHovered ? Theme.withAlpha(Theme.primary, Theme.stateLayerHover) : "transparent"
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: expandedActionText
|
||||
text: {
|
||||
const baseText = modelData.text || "View";
|
||||
if (keyboardNavigationActive && (isGroupSelected || selectedNotificationIndex >= 0))
|
||||
return `${baseText} (${index + 1})`;
|
||||
return baseText;
|
||||
}
|
||||
id: expandedClearText
|
||||
text: I18n.tr("Dismiss")
|
||||
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
anchors.centerIn: parent
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -559,44 +718,56 @@ Rectangle {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onEntered: parent.isHovered = true
|
||||
onExited: parent.isHovered = false
|
||||
onClicked: {
|
||||
if (modelData && modelData.invoke)
|
||||
modelData.invoke();
|
||||
}
|
||||
onClicked: NotificationService.dismissNotification(modelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
property bool isHovered: false
|
||||
|
||||
width: Math.max(expandedClearText.implicitWidth + Theme.spacingM, compactMode ? 40 : 50)
|
||||
height: actionButtonHeight
|
||||
radius: Theme.spacingXS
|
||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
||||
|
||||
StyledText {
|
||||
id: expandedClearText
|
||||
text: I18n.tr("Dismiss")
|
||||
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onEntered: parent.isHovered = true
|
||||
onExited: parent.isHovered = false
|
||||
onClicked: NotificationService.dismissNotification(modelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DragHandler {
|
||||
id: expandedSwipeHandler
|
||||
target: null
|
||||
xAxis.enabled: true
|
||||
yAxis.enabled: false
|
||||
grabPermissions: PointerHandler.CanTakeOverFromItems | PointerHandler.CanTakeOverFromHandlersOfDifferentType
|
||||
|
||||
onActiveChanged: {
|
||||
if (active) {
|
||||
root.swipingNotificationIndex = expandedDelegateWrapper.index;
|
||||
} else {
|
||||
root.swipingNotificationIndex = -1;
|
||||
root.swipingNotificationOffset = 0;
|
||||
}
|
||||
if (active || expandedDelegateWrapper.isDismissing)
|
||||
return;
|
||||
if (Math.abs(expandedDelegateWrapper.swipeOffset) > expandedDelegateWrapper.dismissThreshold) {
|
||||
expandedDelegateWrapper.isDismissing = true;
|
||||
expandedSwipeDismissAnim.start();
|
||||
} else {
|
||||
expandedDelegateWrapper.swipeOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
onTranslationChanged: {
|
||||
if (expandedDelegateWrapper.isDismissing)
|
||||
return;
|
||||
expandedDelegateWrapper.swipeOffset = translation.x;
|
||||
root.swipingNotificationOffset = translation.x;
|
||||
}
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: expandedSwipeDismissAnim
|
||||
target: expandedDelegateWrapper
|
||||
property: "swipeOffset"
|
||||
to: expandedDelegateWrapper.swipeOffset > 0 ? expandedDelegateWrapper.width : -expandedDelegateWrapper.width
|
||||
duration: Theme.notificationExitDuration
|
||||
easing.type: Easing.OutCubic
|
||||
onStopped: NotificationService.dismissNotification(modelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -607,7 +778,7 @@ Rectangle {
|
||||
anchors.right: clearButton.visible ? clearButton.left : parent.right
|
||||
anchors.rightMargin: clearButton.visible ? contentSpacing : Theme.spacingL
|
||||
anchors.top: collapsedContent.bottom
|
||||
anchors.topMargin: contentSpacing
|
||||
anchors.topMargin: contentSpacing + collapsedDismissOffset
|
||||
spacing: contentSpacing
|
||||
|
||||
Repeater {
|
||||
@@ -616,15 +787,15 @@ Rectangle {
|
||||
Rectangle {
|
||||
property bool isHovered: false
|
||||
|
||||
width: Math.max(collapsedActionText.implicitWidth + Theme.spacingM, compactMode ? 40 : 50)
|
||||
width: Math.max(collapsedActionText.implicitWidth + Theme.spacingM, Theme.notificationActionMinWidth)
|
||||
height: actionButtonHeight
|
||||
radius: Theme.spacingXS
|
||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
||||
radius: Theme.notificationButtonCornerRadius
|
||||
color: isHovered ? Theme.withAlpha(Theme.primary, Theme.stateLayerHover) : "transparent"
|
||||
|
||||
StyledText {
|
||||
id: collapsedActionText
|
||||
text: {
|
||||
const baseText = modelData.text || "View";
|
||||
const baseText = modelData.text || "Open";
|
||||
if (keyboardNavigationActive && isGroupSelected) {
|
||||
return `${baseText} (${index + 1})`;
|
||||
}
|
||||
@@ -663,11 +834,11 @@ Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingL
|
||||
anchors.top: collapsedContent.bottom
|
||||
anchors.topMargin: contentSpacing
|
||||
width: Math.max(collapsedClearText.implicitWidth + Theme.spacingM, compactMode ? 40 : 50)
|
||||
anchors.topMargin: contentSpacing + collapsedDismissOffset
|
||||
width: Math.max(collapsedClearText.implicitWidth + Theme.spacingM, Theme.notificationActionMinWidth)
|
||||
height: actionButtonHeight
|
||||
radius: Theme.spacingXS
|
||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
||||
radius: Theme.notificationButtonCornerRadius
|
||||
color: isHovered ? Theme.withAlpha(Theme.primary, Theme.stateLayerHover) : "transparent"
|
||||
|
||||
StyledText {
|
||||
id: collapsedClearText
|
||||
@@ -691,6 +862,7 @@ Rectangle {
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
visible: !expanded && (notificationGroup?.count || 0) > 1 && !descriptionExpanded
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
root.userInitiatedExpansion = true;
|
||||
NotificationService.toggleGroupExpansion(notificationGroup?.key || "");
|
||||
@@ -731,11 +903,11 @@ Rectangle {
|
||||
}
|
||||
|
||||
Behavior on height {
|
||||
enabled: root.userInitiatedExpansion && root.animateExpansion
|
||||
enabled: root.__initialized && root.userInitiatedExpansion && root.animateExpansion
|
||||
NumberAnimation {
|
||||
duration: Theme.expressiveDurations.normal
|
||||
duration: root.expanded ? Theme.notificationExpandDuration : Theme.notificationCollapseDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.standard
|
||||
easing.bezierCurve: Theme.expressiveCurves.emphasized
|
||||
onRunningChanged: {
|
||||
if (running) {
|
||||
root.isAnimating = true;
|
||||
@@ -746,4 +918,102 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: notificationCardContextMenu
|
||||
width: 220
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
background: Rectangle {
|
||||
color: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
|
||||
radius: Theme.cornerRadius
|
||||
border.width: 0
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
id: setNotificationRulesItem
|
||||
text: I18n.tr("Set notification rules")
|
||||
|
||||
contentItem: StyledText {
|
||||
text: parent.text
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
leftPadding: Theme.spacingS
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||
radius: Theme.cornerRadius / 2
|
||||
}
|
||||
|
||||
onTriggered: {
|
||||
const appName = notificationGroup?.appName || "";
|
||||
const desktopEntry = notificationGroup?.latestNotification?.desktopEntry || "";
|
||||
SettingsData.addNotificationRuleForNotification(appName, desktopEntry);
|
||||
PopoutService.openSettingsWithTab("notifications");
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
id: muteUnmuteItem
|
||||
readonly property bool isMuted: SettingsData.isAppMuted(notificationGroup?.appName || "", notificationGroup?.latestNotification?.desktopEntry || "")
|
||||
text: isMuted ? I18n.tr("Unmute popups for %1").arg(notificationGroup?.appName || I18n.tr("this app")) : I18n.tr("Mute popups for %1").arg(notificationGroup?.appName || I18n.tr("this app"))
|
||||
|
||||
contentItem: StyledText {
|
||||
text: parent.text
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
leftPadding: Theme.spacingS
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||
radius: Theme.cornerRadius / 2
|
||||
}
|
||||
|
||||
onTriggered: {
|
||||
const appName = notificationGroup?.appName || "";
|
||||
const desktopEntry = notificationGroup?.latestNotification?.desktopEntry || "";
|
||||
if (isMuted) {
|
||||
SettingsData.removeMuteRuleForApp(appName, desktopEntry);
|
||||
} else {
|
||||
SettingsData.addMuteRuleForApp(appName, desktopEntry);
|
||||
NotificationService.dismissGroup(notificationGroup?.key || "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: I18n.tr("Dismiss")
|
||||
|
||||
contentItem: StyledText {
|
||||
text: parent.text
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
leftPadding: Theme.spacingS
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||
radius: Theme.cornerRadius / 2
|
||||
}
|
||||
|
||||
onTriggered: NotificationService.dismissGroup(notificationGroup?.key || "")
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
z: -2
|
||||
onClicked: mouse => {
|
||||
if (mouse.button === Qt.RightButton && notificationGroup) {
|
||||
notificationCardContextMenu.popup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,21 @@ DankPopout {
|
||||
id: root
|
||||
|
||||
layerNamespace: "dms:notification-center-popout"
|
||||
fullHeightSurface: true
|
||||
|
||||
property bool notificationHistoryVisible: false
|
||||
property var triggerScreen: null
|
||||
property real stablePopupHeight: 400
|
||||
property real _lastAlignedContentHeight: -1
|
||||
|
||||
function updateStablePopupHeight() {
|
||||
const item = contentLoader.item;
|
||||
const target = item ? Theme.px(item.implicitHeight, dpr) : 400;
|
||||
if (Math.abs(target - _lastAlignedContentHeight) < 0.5)
|
||||
return;
|
||||
_lastAlignedContentHeight = target;
|
||||
stablePopupHeight = target;
|
||||
}
|
||||
|
||||
NotificationKeyboardController {
|
||||
id: keyboardController
|
||||
@@ -20,11 +32,12 @@ DankPopout {
|
||||
}
|
||||
}
|
||||
|
||||
popupWidth: 400
|
||||
popupHeight: contentLoader.item ? contentLoader.item.implicitHeight : 400
|
||||
popupWidth: triggerScreen ? Math.min(500, Math.max(380, triggerScreen.width - 48)) : 400
|
||||
popupHeight: stablePopupHeight
|
||||
positioning: ""
|
||||
animationScaleCollapsed: 1.0
|
||||
animationScaleCollapsed: 0.94
|
||||
animationOffset: 0
|
||||
suspendShadowWhileResizing: false
|
||||
|
||||
screen: triggerScreen
|
||||
shouldBeVisible: notificationHistoryVisible
|
||||
@@ -68,19 +81,32 @@ DankPopout {
|
||||
Connections {
|
||||
target: contentLoader
|
||||
function onLoaded() {
|
||||
root.updateStablePopupHeight();
|
||||
if (root.shouldBeVisible)
|
||||
Qt.callLater(root.setupKeyboardNavigation);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: contentLoader.item
|
||||
function onImplicitHeightChanged() {
|
||||
root.updateStablePopupHeight();
|
||||
}
|
||||
}
|
||||
|
||||
onDprChanged: updateStablePopupHeight()
|
||||
|
||||
onShouldBeVisibleChanged: {
|
||||
if (shouldBeVisible) {
|
||||
NotificationService.onOverlayOpen();
|
||||
updateStablePopupHeight();
|
||||
if (contentLoader.item)
|
||||
Qt.callLater(setupKeyboardNavigation);
|
||||
} else {
|
||||
NotificationService.onOverlayClose();
|
||||
keyboardController.keyboardNavigationActive = false;
|
||||
NotificationService.expandedGroups = {};
|
||||
NotificationService.expandedMessages = {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +139,7 @@ DankPopout {
|
||||
baseHeight += Theme.spacingM * 2;
|
||||
|
||||
const settingsHeight = notificationSettings.expanded ? notificationSettings.contentHeight : 0;
|
||||
let listHeight = notificationHeader.currentTab === 0 ? notificationList.listContentHeight : Math.max(200, NotificationService.historyList.length * 80);
|
||||
let listHeight = notificationHeader.currentTab === 0 ? notificationList.stableContentHeight : Math.max(200, NotificationService.historyList.length * 80);
|
||||
if (notificationHeader.currentTab === 0 && NotificationService.groupedNotifications.length === 0) {
|
||||
listHeight = 200;
|
||||
}
|
||||
|
||||
@@ -262,6 +262,50 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: Math.max(privacyRow.implicitHeight, privacyToggle.implicitHeight) + Theme.spacingS
|
||||
|
||||
Row {
|
||||
id: privacyRow
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingM
|
||||
|
||||
DankIcon {
|
||||
name: "privacy_tip"
|
||||
size: Theme.iconSizeSmall
|
||||
color: SettingsData.notificationPopupPrivacyMode ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Column {
|
||||
spacing: 2
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Privacy Mode")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Hide notification content until expanded")
|
||||
font.pixelSize: Theme.fontSizeSmall - 1
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
id: privacyToggle
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
checked: SettingsData.notificationPopupPrivacyMode
|
||||
onToggled: toggled => SettingsData.set("notificationPopupPrivacyMode", toggled)
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
|
||||
@@ -13,35 +13,46 @@ PanelWindow {
|
||||
|
||||
WlrLayershell.namespace: "dms:notification-popup"
|
||||
|
||||
BackgroundEffect.blurRegion: Region {
|
||||
x: content.x + bgShadowLayer.x
|
||||
y: content.y + bgShadowLayer.y
|
||||
width: bgShadowLayer.width
|
||||
height: bgShadowLayer.height
|
||||
radius: !win._finalized && !win.exiting ? Theme.cornerRadius : 0
|
||||
}
|
||||
|
||||
required property var notificationData
|
||||
required property string notificationId
|
||||
readonly property bool hasValidData: notificationData && notificationData.notification
|
||||
readonly property alias hovered: cardHoverHandler.hovered
|
||||
property int screenY: 0
|
||||
property bool exiting: false
|
||||
property bool _isDestroying: false
|
||||
property bool _finalized: false
|
||||
property real _lastReportedAlignedHeight: -1
|
||||
property real _storedTopMargin: 0
|
||||
property real _storedBottomMargin: 0
|
||||
readonly property string clearText: I18n.tr("Dismiss")
|
||||
property bool descriptionExpanded: false
|
||||
readonly property bool hasExpandableBody: (notificationData?.htmlBody || "").replace(/<[^>]*>/g, "").trim().length > 0
|
||||
onDescriptionExpandedChanged: {
|
||||
popupHeightChanged();
|
||||
}
|
||||
onImplicitHeightChanged: {
|
||||
const aligned = Theme.px(implicitHeight, dpr);
|
||||
if (Math.abs(aligned - _lastReportedAlignedHeight) < 0.5)
|
||||
return;
|
||||
_lastReportedAlignedHeight = aligned;
|
||||
popupHeightChanged();
|
||||
}
|
||||
|
||||
readonly property bool compactMode: SettingsData.notificationCompactMode
|
||||
readonly property real cardPadding: compactMode ? Theme.spacingS : Theme.spacingM
|
||||
readonly property real popupIconSize: compactMode ? 48 : 63
|
||||
readonly property real cardPadding: compactMode ? Theme.notificationCardPaddingCompact : Theme.notificationCardPadding
|
||||
readonly property real popupIconSize: compactMode ? Theme.notificationIconSizeCompact : Theme.notificationIconSizeNormal
|
||||
readonly property real contentSpacing: compactMode ? Theme.spacingXS : Theme.spacingS
|
||||
readonly property real contentBottomClearance: 8
|
||||
readonly property real actionButtonHeight: compactMode ? 20 : 24
|
||||
readonly property real collapsedContentHeight: popupIconSize
|
||||
readonly property real basePopupHeight: cardPadding * 2 + collapsedContentHeight + actionButtonHeight + Theme.spacingS
|
||||
readonly property real collapsedContentHeight: Math.max(popupIconSize, Theme.fontSizeSmall * 1.2 + Theme.fontSizeMedium * 1.2 + Theme.fontSizeSmall * 1.2 * (compactMode ? 1 : 2)) + contentBottomClearance
|
||||
readonly property real privacyCollapsedContentHeight: Math.max(popupIconSize, Theme.fontSizeSmall * 1.2 + Theme.fontSizeMedium * 1.2) + contentBottomClearance
|
||||
readonly property real basePopupHeight: cardPadding * 2 + collapsedContentHeight + actionButtonHeight + contentSpacing
|
||||
readonly property real basePopupHeightPrivacy: cardPadding * 2 + privacyCollapsedContentHeight + actionButtonHeight + contentSpacing
|
||||
|
||||
signal entered
|
||||
signal exitStarted
|
||||
signal exitFinished
|
||||
signal popupHeightChanged
|
||||
|
||||
function startExit() {
|
||||
if (exiting || _isDestroying) {
|
||||
@@ -107,22 +118,40 @@ PanelWindow {
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
color: "transparent"
|
||||
implicitWidth: 400
|
||||
implicitWidth: screen ? Math.min(400, Math.max(320, screen.width * 0.23)) : 380
|
||||
implicitHeight: {
|
||||
if (SettingsData.notificationPopupPrivacyMode && !descriptionExpanded)
|
||||
return basePopupHeightPrivacy;
|
||||
if (!descriptionExpanded)
|
||||
return basePopupHeight;
|
||||
const bodyTextHeight = bodyText.contentHeight || 0;
|
||||
const twoLineHeight = Theme.fontSizeSmall * 1.2 * 2;
|
||||
if (bodyTextHeight > twoLineHeight + 2)
|
||||
return basePopupHeight + bodyTextHeight - twoLineHeight;
|
||||
const collapsedBodyHeight = Theme.fontSizeSmall * 1.2 * (compactMode ? 1 : 2);
|
||||
if (bodyTextHeight > collapsedBodyHeight + 2)
|
||||
return basePopupHeight + bodyTextHeight - collapsedBodyHeight;
|
||||
return basePopupHeight;
|
||||
}
|
||||
|
||||
Behavior on implicitHeight {
|
||||
enabled: !exiting && !_isDestroying
|
||||
NumberAnimation {
|
||||
id: implicitHeightAnim
|
||||
duration: descriptionExpanded ? Theme.notificationExpandDuration : Theme.notificationCollapseDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.emphasized
|
||||
}
|
||||
}
|
||||
|
||||
onHasValidDataChanged: {
|
||||
if (!hasValidData && !exiting && !_isDestroying) {
|
||||
forceExit();
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
_lastReportedAlignedHeight = Theme.px(implicitHeight, dpr);
|
||||
_storedTopMargin = getTopMargin();
|
||||
_storedBottomMargin = getBottomMargin();
|
||||
if (SettingsData.notificationPopupPrivacyMode)
|
||||
descriptionExpanded = false;
|
||||
if (hasValidData) {
|
||||
Qt.callLater(() => enterX.restart());
|
||||
} else {
|
||||
@@ -131,6 +160,8 @@ PanelWindow {
|
||||
}
|
||||
onNotificationDataChanged: {
|
||||
if (!_isDestroying) {
|
||||
if (SettingsData.notificationPopupPrivacyMode)
|
||||
descriptionExpanded = false;
|
||||
wrapperConn.target = win.notificationData || null;
|
||||
notificationConn.target = (win.notificationData && win.notificationData.notification && win.notificationData.notification.Retainable) || null;
|
||||
}
|
||||
@@ -149,15 +180,33 @@ PanelWindow {
|
||||
}
|
||||
|
||||
property bool isTopCenter: SettingsData.notificationPopupPosition === -1
|
||||
property bool isBottomCenter: SettingsData.notificationPopupPosition === SettingsData.Position.BottomCenter
|
||||
property bool isCenterPosition: isTopCenter || isBottomCenter
|
||||
|
||||
anchors.top: isTopCenter || SettingsData.notificationPopupPosition === SettingsData.Position.Top || SettingsData.notificationPopupPosition === SettingsData.Position.Left
|
||||
anchors.bottom: SettingsData.notificationPopupPosition === SettingsData.Position.Bottom || SettingsData.notificationPopupPosition === SettingsData.Position.Right
|
||||
anchors.top: true
|
||||
anchors.bottom: true
|
||||
anchors.left: SettingsData.notificationPopupPosition === SettingsData.Position.Left || SettingsData.notificationPopupPosition === SettingsData.Position.Bottom
|
||||
anchors.right: SettingsData.notificationPopupPosition === SettingsData.Position.Top || SettingsData.notificationPopupPosition === SettingsData.Position.Right
|
||||
|
||||
mask: contentInputMask
|
||||
|
||||
Region {
|
||||
id: contentInputMask
|
||||
item: contentMaskRect
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentMaskRect
|
||||
visible: false
|
||||
x: content.x
|
||||
y: content.y
|
||||
width: alignedWidth
|
||||
height: alignedHeight
|
||||
}
|
||||
|
||||
margins {
|
||||
top: getTopMargin()
|
||||
bottom: getBottomMargin()
|
||||
top: _storedTopMargin
|
||||
bottom: _storedBottomMargin
|
||||
left: getLeftMargin()
|
||||
right: getRightMargin()
|
||||
}
|
||||
@@ -190,7 +239,7 @@ PanelWindow {
|
||||
|
||||
function getBottomMargin() {
|
||||
const popupPos = SettingsData.notificationPopupPosition;
|
||||
const isBottom = popupPos === SettingsData.Position.Bottom || popupPos === SettingsData.Position.Right;
|
||||
const isBottom = isBottomCenter || popupPos === SettingsData.Position.Bottom || popupPos === SettingsData.Position.Right;
|
||||
if (!isBottom)
|
||||
return 0;
|
||||
|
||||
@@ -200,7 +249,7 @@ PanelWindow {
|
||||
}
|
||||
|
||||
function getLeftMargin() {
|
||||
if (isTopCenter)
|
||||
if (isCenterPosition)
|
||||
return screen ? (screen.width - implicitWidth) / 2 : 0;
|
||||
|
||||
const popupPos = SettingsData.notificationPopupPosition;
|
||||
@@ -213,7 +262,7 @@ PanelWindow {
|
||||
}
|
||||
|
||||
function getRightMargin() {
|
||||
if (isTopCenter)
|
||||
if (isCenterPosition)
|
||||
return 0;
|
||||
|
||||
const popupPos = SettingsData.notificationPopupPosition;
|
||||
@@ -234,22 +283,57 @@ PanelWindow {
|
||||
id: content
|
||||
|
||||
x: Theme.snap((win.width - alignedWidth) / 2, dpr)
|
||||
y: Theme.snap((win.height - alignedHeight) / 2, dpr)
|
||||
y: {
|
||||
const isTop = isTopCenter || SettingsData.notificationPopupPosition === SettingsData.Position.Top || SettingsData.notificationPopupPosition === SettingsData.Position.Left;
|
||||
if (isTop) {
|
||||
return Theme.snap(screenY, dpr);
|
||||
} else {
|
||||
return Theme.snap(win.height - alignedHeight - screenY, dpr);
|
||||
}
|
||||
}
|
||||
width: alignedWidth
|
||||
height: alignedHeight
|
||||
visible: !win._finalized
|
||||
scale: cardHoverHandler.hovered ? 1.01 : 1.0
|
||||
transformOrigin: Item.Center
|
||||
|
||||
Behavior on scale {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
property real swipeOffset: 0
|
||||
readonly property real dismissThreshold: isTopCenter ? height * 0.4 : width * 0.35
|
||||
readonly property real dismissThreshold: isCenterPosition ? height * 0.4 : width * 0.35
|
||||
readonly property real swipeFadeStartRatio: 0.75
|
||||
readonly property real swipeTravelDistance: isCenterPosition ? height : width
|
||||
readonly property real swipeFadeStartOffset: swipeTravelDistance * swipeFadeStartRatio
|
||||
readonly property real swipeFadeDistance: Math.max(1, swipeTravelDistance - swipeFadeStartOffset)
|
||||
readonly property bool swipeActive: swipeDragHandler.active
|
||||
property bool swipeDismissing: false
|
||||
|
||||
property real shadowBlurPx: 10
|
||||
property real shadowSpreadPx: 0
|
||||
property real shadowBaseAlpha: 0.60
|
||||
readonly property real radiusForShadow: Theme.cornerRadius
|
||||
property real shadowBlurPx: SettingsData.notificationPopupShadowEnabled ? ((2 + radiusForShadow * 0.2) * (cardHoverHandler.hovered ? 1.2 : 1)) : 0
|
||||
property real shadowSpreadPx: SettingsData.notificationPopupShadowEnabled ? (radiusForShadow * (cardHoverHandler.hovered ? 0.06 : 0)) : 0
|
||||
property real shadowBaseAlpha: 0.35
|
||||
readonly property real popupSurfaceAlpha: SettingsData.popupTransparency
|
||||
readonly property real effectiveShadowAlpha: Math.max(0, Math.min(1, shadowBaseAlpha * popupSurfaceAlpha))
|
||||
|
||||
Behavior on shadowBlurPx {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on shadowSpreadPx {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: bgShadowLayer
|
||||
anchors.fill: parent
|
||||
@@ -264,7 +348,7 @@ PanelWindow {
|
||||
layer.effect: MultiEffect {
|
||||
id: shadowFx
|
||||
autoPaddingEnabled: true
|
||||
shadowEnabled: true
|
||||
shadowEnabled: SettingsData.notificationPopupShadowEnabled
|
||||
blurEnabled: false
|
||||
maskEnabled: false
|
||||
shadowBlur: Math.max(0, Math.min(1, content.shadowBlurPx / bgShadowLayer.blurMax))
|
||||
@@ -276,15 +360,7 @@ PanelWindow {
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: Theme.cornerRadius
|
||||
color: "transparent"
|
||||
border.color: Theme.outline
|
||||
border.width: 1
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: backgroundShape
|
||||
id: shadowShapeSource
|
||||
anchors.fill: parent
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
|
||||
@@ -294,7 +370,7 @@ PanelWindow {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: backgroundShape.radius
|
||||
radius: shadowShapeSource.radius
|
||||
visible: notificationData && notificationData.urgency === NotificationUrgency.Critical
|
||||
opacity: 1
|
||||
clip: true
|
||||
@@ -326,6 +402,24 @@ PanelWindow {
|
||||
anchors.margins: Theme.snap(4, win.dpr)
|
||||
clip: true
|
||||
|
||||
HoverHandler {
|
||||
id: cardHoverHandler
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: cardHoverHandler
|
||||
function onHoveredChanged() {
|
||||
if (!notificationData || win.exiting || win._isDestroying)
|
||||
return;
|
||||
if (cardHoverHandler.hovered) {
|
||||
if (notificationData.timer)
|
||||
notificationData.timer.stop();
|
||||
} else if (notificationData.popup && notificationData.timer) {
|
||||
notificationData.timer.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LayoutMirroring.enabled: I18n.isRtl
|
||||
LayoutMirroring.childrenInherit: true
|
||||
|
||||
@@ -333,16 +427,18 @@ PanelWindow {
|
||||
id: notificationContent
|
||||
|
||||
readonly property real expandedTextHeight: bodyText.contentHeight || 0
|
||||
readonly property real twoLineHeight: Theme.fontSizeSmall * 1.2 * 2
|
||||
readonly property real extraHeight: (descriptionExpanded && expandedTextHeight > twoLineHeight + 2) ? (expandedTextHeight - twoLineHeight) : 0
|
||||
readonly property real collapsedBodyHeight: Theme.fontSizeSmall * 1.2 * (compactMode ? 1 : 2)
|
||||
readonly property real effectiveCollapsedHeight: (SettingsData.notificationPopupPrivacyMode && !descriptionExpanded) ? win.privacyCollapsedContentHeight : win.collapsedContentHeight
|
||||
readonly property real extraHeight: (descriptionExpanded && expandedTextHeight > collapsedBodyHeight + 2) ? (expandedTextHeight - collapsedBodyHeight) : 0
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: cardPadding
|
||||
anchors.leftMargin: Theme.spacingL
|
||||
anchors.rightMargin: Theme.spacingL + (compactMode ? 32 : 40)
|
||||
height: collapsedContentHeight + extraHeight
|
||||
anchors.rightMargin: Theme.spacingL + Theme.notificationHoverRevealMargin
|
||||
height: effectiveCollapsedHeight + extraHeight
|
||||
clip: SettingsData.notificationPopupPrivacyMode && !descriptionExpanded
|
||||
|
||||
DankCircularImage {
|
||||
id: iconContainer
|
||||
@@ -364,6 +460,15 @@ PanelWindow {
|
||||
height: popupIconSize
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: {
|
||||
if (SettingsData.notificationPopupPrivacyMode && !descriptionExpanded) {
|
||||
const headerSummary = Theme.fontSizeSmall * 1.2 + Theme.fontSizeMedium * 1.2;
|
||||
return Math.max(0, headerSummary / 2 - popupIconSize / 2);
|
||||
}
|
||||
if (descriptionExpanded)
|
||||
return Math.max(0, Theme.fontSizeSmall * 1.2 + (Theme.fontSizeMedium * 1.2 + Theme.fontSizeSmall * 1.2 * (compactMode ? 1 : 2)) / 2 - popupIconSize / 2);
|
||||
return Math.max(0, Theme.fontSizeSmall * 1.2 + (textContainer.height - Theme.fontSizeSmall * 1.2) / 2 - popupIconSize / 2);
|
||||
}
|
||||
|
||||
imageSource: {
|
||||
if (!notificationData)
|
||||
@@ -417,24 +522,40 @@ PanelWindow {
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
spacing: compactMode ? 1 : 2
|
||||
spacing: Theme.notificationContentSpacing
|
||||
|
||||
StyledText {
|
||||
Row {
|
||||
id: headerRow
|
||||
width: parent.width
|
||||
text: {
|
||||
if (!notificationData)
|
||||
return "";
|
||||
const appName = notificationData.appName || "";
|
||||
const timeStr = notificationData.timeStr || "";
|
||||
return timeStr.length > 0 ? appName + " • " + timeStr : appName;
|
||||
spacing: Theme.spacingXS
|
||||
visible: headerAppNameText.text.length > 0 || headerTimeText.text.length > 0
|
||||
|
||||
StyledText {
|
||||
id: headerAppNameText
|
||||
text: notificationData ? (notificationData.appName || "") : ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 1
|
||||
width: Math.min(implicitWidth, parent.width - headerSeparator.implicitWidth - headerTimeText.implicitWidth - parent.spacing * 2)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: headerSeparator
|
||||
text: (headerAppNameText.text.length > 0 && headerTimeText.text.length > 0) ? " • " : ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: headerTimeText
|
||||
text: notificationData ? (notificationData.timeStr || "") : ""
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Normal
|
||||
}
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
elide: Text.ElideRight
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
maximumLineCount: 1
|
||||
visible: text.length > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
@@ -460,8 +581,9 @@ PanelWindow {
|
||||
elide: descriptionExpanded ? Text.ElideNone : Text.ElideRight
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
maximumLineCount: descriptionExpanded ? -1 : (compactMode ? 1 : 2)
|
||||
wrapMode: Text.WordWrap
|
||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||
visible: text.length > 0
|
||||
opacity: (SettingsData.notificationPopupPrivacyMode && !descriptionExpanded) ? 0 : 1
|
||||
linkColor: Theme.primary
|
||||
onLinkActivated: link => Qt.openUrlExternally(link)
|
||||
|
||||
@@ -485,6 +607,14 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Message Content", "notification privacy mode placeholder")
|
||||
color: Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
width: parent.width
|
||||
visible: SettingsData.notificationPopupPrivacyMode && !descriptionExpanded && win.hasExpandableBody
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,16 +626,38 @@ PanelWindow {
|
||||
anchors.topMargin: cardPadding
|
||||
anchors.rightMargin: Theme.spacingL
|
||||
iconName: "close"
|
||||
iconSize: compactMode ? 16 : 18
|
||||
buttonSize: compactMode ? 24 : 28
|
||||
iconSize: compactMode ? 14 : 16
|
||||
buttonSize: compactMode ? 20 : 24
|
||||
z: 15
|
||||
|
||||
onClicked: {
|
||||
if (notificationData && !win.exiting)
|
||||
notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: expandButton
|
||||
|
||||
anchors.right: closeButton.left
|
||||
anchors.rightMargin: Theme.spacingXS
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: cardPadding
|
||||
iconName: descriptionExpanded ? "expand_less" : "expand_more"
|
||||
iconSize: compactMode ? 14 : 16
|
||||
buttonSize: compactMode ? 20 : 24
|
||||
z: 15
|
||||
visible: SettingsData.notificationPopupPrivacyMode && win.hasExpandableBody
|
||||
|
||||
onClicked: {
|
||||
if (win.hasExpandableBody)
|
||||
win.descriptionExpanded = !win.descriptionExpanded;
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
visible: cardHoverHandler.hovered
|
||||
opacity: visible ? 1 : 0
|
||||
anchors.right: clearButton.visible ? clearButton.left : parent.right
|
||||
anchors.rightMargin: clearButton.visible ? contentSpacing : Theme.spacingL
|
||||
anchors.top: notificationContent.bottom
|
||||
@@ -513,21 +665,28 @@ PanelWindow {
|
||||
spacing: contentSpacing
|
||||
z: 20
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: notificationData ? (notificationData.actions || []) : []
|
||||
|
||||
Rectangle {
|
||||
property bool isHovered: false
|
||||
|
||||
width: Math.max(actionText.implicitWidth + Theme.spacingM, compactMode ? 40 : 50)
|
||||
width: Math.max(actionText.implicitWidth + Theme.spacingM, Theme.notificationActionMinWidth)
|
||||
height: actionButtonHeight
|
||||
radius: Theme.spacingXS
|
||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
||||
radius: Theme.notificationButtonCornerRadius
|
||||
color: isHovered ? Theme.withAlpha(Theme.primary, Theme.stateLayerHover) : "transparent"
|
||||
|
||||
StyledText {
|
||||
id: actionText
|
||||
|
||||
text: modelData.text || "View"
|
||||
text: modelData.text || "Open"
|
||||
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
@@ -559,15 +718,22 @@ PanelWindow {
|
||||
property bool isHovered: false
|
||||
readonly property int actionCount: notificationData ? (notificationData.actions || []).length : 0
|
||||
|
||||
visible: actionCount < 3
|
||||
visible: actionCount < 3 && cardHoverHandler.hovered
|
||||
opacity: visible ? 1 : 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingL
|
||||
anchors.top: notificationContent.bottom
|
||||
anchors.topMargin: contentSpacing
|
||||
width: Math.max(clearTextLabel.implicitWidth + Theme.spacingM, compactMode ? 40 : 50)
|
||||
width: Math.max(clearTextLabel.implicitWidth + Theme.spacingM, Theme.notificationActionMinWidth)
|
||||
height: actionButtonHeight
|
||||
radius: Theme.spacingXS
|
||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
||||
radius: Theme.notificationButtonCornerRadius
|
||||
color: isHovered ? Theme.withAlpha(Theme.primary, Theme.stateLayerHover) : "transparent"
|
||||
z: 20
|
||||
|
||||
StyledText {
|
||||
@@ -600,23 +766,19 @@ PanelWindow {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
propagateComposedEvents: true
|
||||
z: -1
|
||||
onEntered: {
|
||||
if (notificationData && notificationData.timer)
|
||||
notificationData.timer.stop();
|
||||
}
|
||||
onExited: {
|
||||
if (notificationData && notificationData.popup && notificationData.timer)
|
||||
notificationData.timer.restart();
|
||||
}
|
||||
onClicked: mouse => {
|
||||
if (!notificationData || win.exiting)
|
||||
return;
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
NotificationService.dismissNotification(notificationData);
|
||||
popupContextMenu.popup();
|
||||
} else if (mouse.button === Qt.LeftButton) {
|
||||
if (notificationData.actions && notificationData.actions.length > 0) {
|
||||
const canExpand = bodyText.hasMoreText || win.descriptionExpanded || (SettingsData.notificationPopupPrivacyMode && win.hasExpandableBody);
|
||||
if (canExpand) {
|
||||
win.descriptionExpanded = !win.descriptionExpanded;
|
||||
} else if (notificationData.actions && notificationData.actions.length > 0) {
|
||||
notificationData.actions[0].invoke();
|
||||
NotificationService.dismissNotification(notificationData);
|
||||
} else {
|
||||
@@ -630,8 +792,8 @@ PanelWindow {
|
||||
DragHandler {
|
||||
id: swipeDragHandler
|
||||
target: null
|
||||
xAxis.enabled: !isTopCenter
|
||||
yAxis.enabled: isTopCenter
|
||||
xAxis.enabled: !isCenterPosition
|
||||
yAxis.enabled: isCenterPosition
|
||||
|
||||
onActiveChanged: {
|
||||
if (active || win.exiting || content.swipeDismissing)
|
||||
@@ -649,9 +811,11 @@ PanelWindow {
|
||||
if (win.exiting)
|
||||
return;
|
||||
|
||||
const raw = isTopCenter ? translation.y : translation.x;
|
||||
const raw = isCenterPosition ? translation.y : translation.x;
|
||||
if (isTopCenter) {
|
||||
content.swipeOffset = Math.min(0, raw);
|
||||
} else if (isBottomCenter) {
|
||||
content.swipeOffset = Math.max(0, raw);
|
||||
} else {
|
||||
const isLeft = SettingsData.notificationPopupPosition === SettingsData.Position.Left || SettingsData.notificationPopupPosition === SettingsData.Position.Bottom;
|
||||
content.swipeOffset = isLeft ? Math.min(0, raw) : Math.max(0, raw);
|
||||
@@ -659,7 +823,13 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
opacity: 1 - Math.abs(content.swipeOffset) / (isTopCenter ? content.height : content.width * 0.6)
|
||||
opacity: {
|
||||
const swipeAmount = Math.abs(content.swipeOffset);
|
||||
if (swipeAmount <= content.swipeFadeStartOffset)
|
||||
return 1;
|
||||
const fadeProgress = (swipeAmount - content.swipeFadeStartOffset) / content.swipeFadeDistance;
|
||||
return Math.max(0, 1 - fadeProgress);
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
enabled: !content.swipeActive
|
||||
@@ -671,7 +841,7 @@ PanelWindow {
|
||||
Behavior on swipeOffset {
|
||||
enabled: !content.swipeActive && !content.swipeDismissing
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
duration: Theme.notificationExitDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
@@ -680,8 +850,8 @@ PanelWindow {
|
||||
id: swipeDismissAnim
|
||||
target: content
|
||||
property: "swipeOffset"
|
||||
to: isTopCenter ? -content.height : (SettingsData.notificationPopupPosition === SettingsData.Position.Left || SettingsData.notificationPopupPosition === SettingsData.Position.Bottom ? -content.width : content.width)
|
||||
duration: Theme.shortDuration
|
||||
to: isTopCenter ? -content.height : isBottomCenter ? content.height : (SettingsData.notificationPopupPosition === SettingsData.Position.Left || SettingsData.notificationPopupPosition === SettingsData.Position.Bottom ? -content.width : content.width)
|
||||
duration: Theme.notificationExitDuration
|
||||
easing.type: Easing.OutCubic
|
||||
onStopped: {
|
||||
NotificationService.dismissNotification(notificationData);
|
||||
@@ -692,18 +862,18 @@ PanelWindow {
|
||||
transform: [
|
||||
Translate {
|
||||
id: swipeTx
|
||||
x: isTopCenter ? 0 : content.swipeOffset
|
||||
y: isTopCenter ? content.swipeOffset : 0
|
||||
x: isCenterPosition ? 0 : content.swipeOffset
|
||||
y: isCenterPosition ? content.swipeOffset : 0
|
||||
},
|
||||
Translate {
|
||||
id: tx
|
||||
x: {
|
||||
if (isTopCenter)
|
||||
if (isCenterPosition)
|
||||
return 0;
|
||||
const isLeft = SettingsData.notificationPopupPosition === SettingsData.Position.Left || SettingsData.notificationPopupPosition === SettingsData.Position.Bottom;
|
||||
return isLeft ? -Anims.slidePx : Anims.slidePx;
|
||||
}
|
||||
y: isTopCenter ? -Anims.slidePx : 0
|
||||
y: isTopCenter ? -Anims.slidePx : isBottomCenter ? Anims.slidePx : 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -712,20 +882,22 @@ PanelWindow {
|
||||
id: enterX
|
||||
|
||||
target: tx
|
||||
property: isTopCenter ? "y" : "x"
|
||||
property: isCenterPosition ? "y" : "x"
|
||||
from: {
|
||||
if (isTopCenter)
|
||||
return -Anims.slidePx;
|
||||
if (isBottomCenter)
|
||||
return Anims.slidePx;
|
||||
const isLeft = SettingsData.notificationPopupPosition === SettingsData.Position.Left || SettingsData.notificationPopupPosition === SettingsData.Position.Bottom;
|
||||
return isLeft ? -Anims.slidePx : Anims.slidePx;
|
||||
}
|
||||
to: 0
|
||||
duration: Theme.mediumDuration
|
||||
duration: Theme.notificationEnterDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: isTopCenter ? Theme.expressiveCurves.standardDecel : Theme.expressiveCurves.emphasizedDecel
|
||||
easing.bezierCurve: isCenterPosition ? Theme.expressiveCurves.standardDecel : Theme.expressiveCurves.emphasizedDecel
|
||||
onStopped: {
|
||||
if (!win.exiting && !win._isDestroying) {
|
||||
if (isTopCenter) {
|
||||
if (isCenterPosition) {
|
||||
if (Math.abs(tx.y) < 0.5)
|
||||
win.entered();
|
||||
} else {
|
||||
@@ -743,15 +915,17 @@ PanelWindow {
|
||||
|
||||
PropertyAnimation {
|
||||
target: tx
|
||||
property: isTopCenter ? "y" : "x"
|
||||
property: isCenterPosition ? "y" : "x"
|
||||
from: 0
|
||||
to: {
|
||||
if (isTopCenter)
|
||||
return -Anims.slidePx;
|
||||
if (isBottomCenter)
|
||||
return Anims.slidePx;
|
||||
const isLeft = SettingsData.notificationPopupPosition === SettingsData.Position.Left || SettingsData.notificationPopupPosition === SettingsData.Position.Bottom;
|
||||
return isLeft ? -Anims.slidePx : Anims.slidePx;
|
||||
}
|
||||
duration: Theme.shortDuration
|
||||
duration: Theme.notificationExitDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.emphasizedAccel
|
||||
}
|
||||
@@ -761,7 +935,7 @@ PanelWindow {
|
||||
property: "opacity"
|
||||
from: 1
|
||||
to: 0
|
||||
duration: Theme.shortDuration
|
||||
duration: Theme.notificationExitDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.standardAccel
|
||||
}
|
||||
@@ -771,7 +945,7 @@ PanelWindow {
|
||||
property: "scale"
|
||||
from: 1
|
||||
to: 0.98
|
||||
duration: Theme.shortDuration
|
||||
duration: Theme.notificationExitDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Theme.expressiveCurves.emphasizedAccel
|
||||
}
|
||||
@@ -835,4 +1009,98 @@ PanelWindow {
|
||||
easing.bezierCurve: Theme.expressiveCurves.standardDecel
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: popupContextMenu
|
||||
width: 220
|
||||
contentHeight: 130
|
||||
margins: -1
|
||||
popupType: Popup.Window
|
||||
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
||||
|
||||
background: Rectangle {
|
||||
color: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
|
||||
radius: Theme.cornerRadius
|
||||
border.width: 0
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.12)
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
id: setNotificationRulesItem
|
||||
text: I18n.tr("Set notification rules")
|
||||
|
||||
contentItem: StyledText {
|
||||
text: parent.text
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
leftPadding: Theme.spacingS
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||
radius: Theme.cornerRadius / 2
|
||||
}
|
||||
|
||||
onTriggered: {
|
||||
const appName = notificationData?.appName || "";
|
||||
const desktopEntry = notificationData?.desktopEntry || "";
|
||||
SettingsData.addNotificationRuleForNotification(appName, desktopEntry);
|
||||
PopoutService.openSettingsWithTab("notifications");
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
id: muteUnmuteItem
|
||||
readonly property bool isMuted: SettingsData.isAppMuted(notificationData?.appName || "", notificationData?.desktopEntry || "")
|
||||
text: isMuted ? I18n.tr("Unmute popups for %1").arg(notificationData?.appName || I18n.tr("this app")) : I18n.tr("Mute popups for %1").arg(notificationData?.appName || I18n.tr("this app"))
|
||||
|
||||
contentItem: StyledText {
|
||||
text: parent.text
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
leftPadding: Theme.spacingS
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||
radius: Theme.cornerRadius / 2
|
||||
}
|
||||
|
||||
onTriggered: {
|
||||
const appName = notificationData?.appName || "";
|
||||
const desktopEntry = notificationData?.desktopEntry || "";
|
||||
if (isMuted) {
|
||||
SettingsData.removeMuteRuleForApp(appName, desktopEntry);
|
||||
} else {
|
||||
SettingsData.addMuteRuleForApp(appName, desktopEntry);
|
||||
if (notificationData && !exiting)
|
||||
NotificationService.dismissNotification(notificationData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: I18n.tr("Dismiss")
|
||||
|
||||
contentItem: StyledText {
|
||||
text: parent.text
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
leftPadding: Theme.spacingS
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: parent.hovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||
radius: Theme.cornerRadius / 2
|
||||
}
|
||||
|
||||
onTriggered: {
|
||||
if (notificationData && !exiting)
|
||||
NotificationService.dismissNotification(notificationData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,26 +8,23 @@ QtObject {
|
||||
property var modelData
|
||||
property int topMargin: 0
|
||||
readonly property bool compactMode: SettingsData.notificationCompactMode
|
||||
readonly property real cardPadding: compactMode ? Theme.spacingS : Theme.spacingM
|
||||
readonly property real popupIconSize: compactMode ? 48 : 63
|
||||
readonly property real cardPadding: compactMode ? Theme.notificationCardPaddingCompact : Theme.notificationCardPadding
|
||||
readonly property real popupIconSize: compactMode ? Theme.notificationIconSizeCompact : Theme.notificationIconSizeNormal
|
||||
readonly property real actionButtonHeight: compactMode ? 20 : 24
|
||||
readonly property real popupSpacing: 4
|
||||
readonly property int baseNotificationHeight: cardPadding * 2 + popupIconSize + actionButtonHeight + Theme.spacingS + popupSpacing
|
||||
property int maxTargetNotifications: 4
|
||||
property var popupWindows: [] // strong refs to windows (live until exitFinished)
|
||||
readonly property real contentSpacing: compactMode ? Theme.spacingXS : Theme.spacingS
|
||||
readonly property real popupSpacing: compactMode ? 0 : Theme.spacingXS
|
||||
readonly property real collapsedContentHeight: Math.max(popupIconSize, Theme.fontSizeSmall * 1.2 + Theme.fontSizeMedium * 1.2 + Theme.fontSizeSmall * 1.2 * (compactMode ? 1 : 2))
|
||||
readonly property int baseNotificationHeight: cardPadding * 2 + collapsedContentHeight + actionButtonHeight + contentSpacing + popupSpacing
|
||||
property var popupWindows: []
|
||||
property var destroyingWindows: new Set()
|
||||
property var pendingDestroys: []
|
||||
property int destroyDelayMs: 100
|
||||
property var pendingCreates: []
|
||||
property int createDelayMs: 50
|
||||
property bool createBusy: false
|
||||
property Component popupComponent
|
||||
|
||||
popupComponent: Component {
|
||||
NotificationPopup {
|
||||
onEntered: manager._onPopupEntered(this)
|
||||
onExitStarted: manager._onPopupExitStarted(this)
|
||||
onExitFinished: manager._onPopupExitFinished(this)
|
||||
onPopupHeightChanged: manager._onPopupHeightChanged(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,36 +68,6 @@ QtObject {
|
||||
destroyTimer.restart();
|
||||
}
|
||||
|
||||
property Timer createTimer: Timer {
|
||||
interval: createDelayMs
|
||||
running: false
|
||||
repeat: false
|
||||
onTriggered: manager._processCreateQueue()
|
||||
}
|
||||
|
||||
function _processCreateQueue() {
|
||||
createBusy = false;
|
||||
if (pendingCreates.length === 0)
|
||||
return;
|
||||
const wrapper = pendingCreates.shift();
|
||||
if (wrapper)
|
||||
_doInsertNewestAtTop(wrapper);
|
||||
if (pendingCreates.length > 0) {
|
||||
createBusy = true;
|
||||
createTimer.restart();
|
||||
}
|
||||
}
|
||||
|
||||
function _scheduleCreate(wrapper) {
|
||||
if (!wrapper)
|
||||
return;
|
||||
pendingCreates.push(wrapper);
|
||||
if (!createBusy) {
|
||||
createBusy = true;
|
||||
createTimer.restart();
|
||||
}
|
||||
}
|
||||
|
||||
sweeper: Timer {
|
||||
interval: 500
|
||||
running: false
|
||||
@@ -126,14 +93,10 @@ QtObject {
|
||||
}
|
||||
if (toRemove.length) {
|
||||
popupWindows = popupWindows.filter(p => toRemove.indexOf(p) === -1);
|
||||
const survivors = _active().sort((a, b) => a.screenY - b.screenY);
|
||||
for (let k = 0; k < survivors.length; ++k) {
|
||||
survivors[k].screenY = topMargin + k * baseNotificationHeight;
|
||||
}
|
||||
_repositionAll();
|
||||
}
|
||||
if (popupWindows.length === 0) {
|
||||
if (popupWindows.length === 0)
|
||||
sweeper.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,105 +108,29 @@ QtObject {
|
||||
return p && p.status !== Component.Null && !p._isDestroying && p.hasValidData;
|
||||
}
|
||||
|
||||
function _canMakeRoomFor(wrapper) {
|
||||
const activeWindows = _active();
|
||||
if (activeWindows.length < maxTargetNotifications) {
|
||||
return true;
|
||||
}
|
||||
if (!wrapper || !wrapper.notification) {
|
||||
return false;
|
||||
}
|
||||
const incomingUrgency = wrapper.urgency || 0;
|
||||
for (const p of activeWindows) {
|
||||
if (!p.notificationData || !p.notificationData.notification) {
|
||||
continue;
|
||||
}
|
||||
const existingUrgency = p.notificationData.urgency || 0;
|
||||
if (existingUrgency < incomingUrgency) {
|
||||
return true;
|
||||
}
|
||||
if (existingUrgency === incomingUrgency) {
|
||||
const timer = p.notificationData.timer;
|
||||
if (timer && !timer.running) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function _makeRoomForNew(wrapper) {
|
||||
const activeWindows = _active();
|
||||
if (activeWindows.length < maxTargetNotifications) {
|
||||
return;
|
||||
}
|
||||
const toRemove = _selectPopupToRemove(activeWindows, wrapper);
|
||||
if (toRemove && !toRemove.exiting) {
|
||||
toRemove.notificationData.removedByLimit = true;
|
||||
toRemove.notificationData.popup = false;
|
||||
if (toRemove.notificationData.timer) {
|
||||
toRemove.notificationData.timer.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _selectPopupToRemove(activeWindows, incomingWrapper) {
|
||||
const sortedWindows = activeWindows.slice().sort((a, b) => {
|
||||
const aUrgency = (a.notificationData) ? a.notificationData.urgency || 0 : 0;
|
||||
const bUrgency = (b.notificationData) ? b.notificationData.urgency || 0 : 0;
|
||||
if (aUrgency !== bUrgency) {
|
||||
return aUrgency - bUrgency;
|
||||
}
|
||||
const aTimer = a.notificationData && a.notificationData.timer;
|
||||
const bTimer = b.notificationData && b.notificationData.timer;
|
||||
const aRunning = aTimer && aTimer.running;
|
||||
const bRunning = bTimer && bTimer.running;
|
||||
if (aRunning !== bRunning) {
|
||||
return aRunning ? 1 : -1;
|
||||
}
|
||||
return b.screenY - a.screenY;
|
||||
});
|
||||
return sortedWindows[0];
|
||||
}
|
||||
|
||||
function _sync(newWrappers) {
|
||||
for (const w of newWrappers) {
|
||||
if (w && !_hasWindowFor(w)) {
|
||||
insertNewestAtTop(w);
|
||||
}
|
||||
}
|
||||
for (const p of popupWindows.slice()) {
|
||||
if (!_isValidWindow(p)) {
|
||||
if (!_isValidWindow(p) || p.exiting)
|
||||
continue;
|
||||
}
|
||||
if (p.notificationData && newWrappers.indexOf(p.notificationData) === -1 && !p.exiting) {
|
||||
if (p.notificationData && newWrappers.indexOf(p.notificationData) === -1) {
|
||||
p.notificationData.removedByLimit = true;
|
||||
p.notificationData.popup = false;
|
||||
}
|
||||
}
|
||||
for (const w of newWrappers) {
|
||||
if (w && !_hasWindowFor(w))
|
||||
_insertAtTop(w);
|
||||
}
|
||||
}
|
||||
|
||||
function insertNewestAtTop(wrapper) {
|
||||
if (!wrapper)
|
||||
return;
|
||||
if (createBusy || pendingCreates.length > 0) {
|
||||
_scheduleCreate(wrapper);
|
||||
return;
|
||||
}
|
||||
_doInsertNewestAtTop(wrapper);
|
||||
function _popupHeight(p) {
|
||||
return (p.alignedHeight || p.implicitHeight || (baseNotificationHeight - popupSpacing)) + popupSpacing;
|
||||
}
|
||||
|
||||
function _doInsertNewestAtTop(wrapper) {
|
||||
function _insertAtTop(wrapper) {
|
||||
if (!wrapper)
|
||||
return;
|
||||
for (const p of popupWindows) {
|
||||
if (!_isValidWindow(p))
|
||||
continue;
|
||||
if (p.exiting)
|
||||
continue;
|
||||
p.screenY = p.screenY + baseNotificationHeight;
|
||||
}
|
||||
const notificationId = wrapper && wrapper.notification ? wrapper.notification.id : "";
|
||||
const notificationId = wrapper?.notification ? wrapper.notification.id : "";
|
||||
const win = popupComponent.createObject(null, {
|
||||
"notificationData": wrapper,
|
||||
"notificationId": notificationId,
|
||||
@@ -256,72 +143,70 @@ QtObject {
|
||||
win.destroy();
|
||||
return;
|
||||
}
|
||||
popupWindows.push(win);
|
||||
createBusy = true;
|
||||
createTimer.restart();
|
||||
popupWindows.unshift(win);
|
||||
_repositionAll();
|
||||
if (!sweeper.running)
|
||||
sweeper.start();
|
||||
}
|
||||
|
||||
function _active() {
|
||||
return popupWindows.filter(p => _isValidWindow(p) && p.notificationData && p.notificationData.popup && !p.exiting);
|
||||
}
|
||||
function _repositionAll() {
|
||||
const active = popupWindows.filter(p => _isValidWindow(p) && p.notificationData?.popup && !p.exiting);
|
||||
|
||||
function _bottom() {
|
||||
let b = null;
|
||||
let maxY = -1;
|
||||
for (const p of _active()) {
|
||||
if (p.screenY > maxY) {
|
||||
maxY = p.screenY;
|
||||
b = p;
|
||||
}
|
||||
const pinnedSlots = [];
|
||||
for (const p of active) {
|
||||
if (!p.hovered)
|
||||
continue;
|
||||
pinnedSlots.push({
|
||||
y: p.screenY,
|
||||
end: p.screenY + _popupHeight(p)
|
||||
});
|
||||
}
|
||||
pinnedSlots.sort((a, b) => a.y - b.y);
|
||||
|
||||
let currentY = topMargin;
|
||||
for (const win of active) {
|
||||
if (win.hovered)
|
||||
continue;
|
||||
for (const slot of pinnedSlots) {
|
||||
if (currentY >= slot.y - 1 && currentY < slot.end)
|
||||
currentY = slot.end;
|
||||
}
|
||||
win.screenY = currentY;
|
||||
currentY += _popupHeight(win);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
function _onPopupEntered(p) {
|
||||
}
|
||||
|
||||
function _onPopupExitStarted(p) {
|
||||
if (!p)
|
||||
function _onPopupHeightChanged(p) {
|
||||
if (!p || p.exiting || p._isDestroying)
|
||||
return;
|
||||
const survivors = _active().sort((a, b) => a.screenY - b.screenY);
|
||||
for (let k = 0; k < survivors.length; ++k)
|
||||
survivors[k].screenY = topMargin + k * baseNotificationHeight;
|
||||
if (popupWindows.indexOf(p) === -1)
|
||||
return;
|
||||
_repositionAll();
|
||||
}
|
||||
|
||||
function _onPopupExitFinished(p) {
|
||||
if (!p) {
|
||||
if (!p)
|
||||
return;
|
||||
}
|
||||
const windowId = p.toString();
|
||||
if (destroyingWindows.has(windowId)) {
|
||||
if (destroyingWindows.has(windowId))
|
||||
return;
|
||||
}
|
||||
destroyingWindows.add(windowId);
|
||||
const i = popupWindows.indexOf(p);
|
||||
if (i !== -1) {
|
||||
popupWindows.splice(i, 1);
|
||||
popupWindows = popupWindows.slice();
|
||||
}
|
||||
if (NotificationService.releaseWrapper && p.notificationData) {
|
||||
if (NotificationService.releaseWrapper && p.notificationData)
|
||||
NotificationService.releaseWrapper(p.notificationData);
|
||||
}
|
||||
_scheduleDestroy(p);
|
||||
Qt.callLater(() => destroyingWindows.delete(windowId));
|
||||
const survivors = _active().sort((a, b) => a.screenY - b.screenY);
|
||||
for (let k = 0; k < survivors.length; ++k) {
|
||||
survivors[k].screenY = topMargin + k * baseNotificationHeight;
|
||||
}
|
||||
_repositionAll();
|
||||
}
|
||||
|
||||
function cleanupAllWindows() {
|
||||
sweeper.stop();
|
||||
destroyTimer.stop();
|
||||
createTimer.stop();
|
||||
pendingDestroys = [];
|
||||
pendingCreates = [];
|
||||
createBusy = false;
|
||||
for (const p of popupWindows.slice()) {
|
||||
if (p) {
|
||||
try {
|
||||
|
||||
@@ -7,9 +7,10 @@ DankOSD {
|
||||
id: root
|
||||
|
||||
readonly property bool useVertical: isVerticalLayout
|
||||
property int targetBrightness: {
|
||||
DisplayService.brightnessVersion;
|
||||
return DisplayService.brightnessLevel;
|
||||
property int _displayBrightness: 0
|
||||
|
||||
function _syncBrightness() {
|
||||
_displayBrightness = DisplayService.brightnessLevel;
|
||||
}
|
||||
|
||||
osdWidth: useVertical ? (40 + Theme.spacingS * 2) : Math.min(260, Screen.width - Theme.spacingM * 2)
|
||||
@@ -20,9 +21,9 @@ DankOSD {
|
||||
Connections {
|
||||
target: DisplayService
|
||||
function onBrightnessChanged(showOsd) {
|
||||
if (showOsd && SettingsData.osdBrightnessEnabled) {
|
||||
root._syncBrightness();
|
||||
if (showOsd && SettingsData.osdBrightnessEnabled)
|
||||
root.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +54,11 @@ DankOSD {
|
||||
anchors.centerIn: parent
|
||||
name: {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||
if (!deviceInfo || deviceInfo.class === "backlight" || deviceInfo.class === "ddc") {
|
||||
if (!deviceInfo || deviceInfo.class === "backlight" || deviceInfo.class === "ddc")
|
||||
return "brightness_medium";
|
||||
} else if (deviceInfo.name.includes("kbd")) {
|
||||
if (deviceInfo.name.includes("kbd"))
|
||||
return "keyboard";
|
||||
} else {
|
||||
return "lightbulb";
|
||||
}
|
||||
return "lightbulb";
|
||||
}
|
||||
size: Theme.iconSize
|
||||
color: Theme.primary
|
||||
@@ -77,20 +76,16 @@ DankOSD {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||
if (!deviceInfo)
|
||||
return 1;
|
||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
||||
if (isExponential) {
|
||||
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||
return 1;
|
||||
}
|
||||
return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0;
|
||||
}
|
||||
maximum: {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||
if (!deviceInfo)
|
||||
return 100;
|
||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
||||
if (isExponential) {
|
||||
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||
return 100;
|
||||
}
|
||||
return deviceInfo.displayMax || 100;
|
||||
}
|
||||
enabled: DisplayService.brightnessAvailable
|
||||
@@ -99,28 +94,24 @@ DankOSD {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||
if (!deviceInfo)
|
||||
return "%";
|
||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
||||
if (isExponential) {
|
||||
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||
return "%";
|
||||
}
|
||||
return deviceInfo.class === "ddc" ? "" : "%";
|
||||
}
|
||||
thumbOutlineColor: Theme.surfaceContainer
|
||||
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
||||
|
||||
onSliderValueChanged: newValue => {
|
||||
if (DisplayService.brightnessAvailable) {
|
||||
DisplayService.setBrightness(newValue, DisplayService.lastIpcDevice, true);
|
||||
resetHideTimer();
|
||||
}
|
||||
if (!DisplayService.brightnessAvailable)
|
||||
return;
|
||||
DisplayService.setBrightness(newValue, DisplayService.lastIpcDevice, true);
|
||||
resetHideTimer();
|
||||
}
|
||||
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse);
|
||||
}
|
||||
onContainsMouseChanged: setChildHovered(containsMouse)
|
||||
|
||||
Binding on value {
|
||||
value: root.targetBrightness
|
||||
value: root._displayBrightness
|
||||
when: !brightnessSlider.isDragging
|
||||
}
|
||||
}
|
||||
@@ -146,13 +137,11 @@ DankOSD {
|
||||
anchors.centerIn: parent
|
||||
name: {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||
if (!deviceInfo || deviceInfo.class === "backlight" || deviceInfo.class === "ddc") {
|
||||
if (!deviceInfo || deviceInfo.class === "backlight" || deviceInfo.class === "ddc")
|
||||
return "brightness_medium";
|
||||
} else if (deviceInfo.name.includes("kbd")) {
|
||||
if (deviceInfo.name.includes("kbd"))
|
||||
return "keyboard";
|
||||
} else {
|
||||
return "lightbulb";
|
||||
}
|
||||
return "lightbulb";
|
||||
}
|
||||
size: Theme.iconSize
|
||||
color: Theme.primary
|
||||
@@ -170,7 +159,7 @@ DankOSD {
|
||||
property int value: 50
|
||||
|
||||
Binding on value {
|
||||
value: root.targetBrightness
|
||||
value: root._displayBrightness
|
||||
when: !vertSlider.dragging
|
||||
}
|
||||
|
||||
@@ -178,8 +167,7 @@ DankOSD {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||
if (!deviceInfo)
|
||||
return 1;
|
||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
||||
if (isExponential)
|
||||
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||
return 1;
|
||||
return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0;
|
||||
}
|
||||
@@ -188,8 +176,7 @@ DankOSD {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||
if (!deviceInfo)
|
||||
return 100;
|
||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
||||
if (isExponential)
|
||||
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||
return 100;
|
||||
return deviceInfo.displayMax || 100;
|
||||
}
|
||||
@@ -240,33 +227,25 @@ DankOSD {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse);
|
||||
}
|
||||
onContainsMouseChanged: setChildHovered(containsMouse)
|
||||
|
||||
onPressed: mouse => {
|
||||
vertSlider.dragging = true;
|
||||
updateBrightness(mouse);
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
vertSlider.dragging = false;
|
||||
}
|
||||
onReleased: vertSlider.dragging = false
|
||||
|
||||
onPositionChanged: mouse => {
|
||||
if (pressed) {
|
||||
if (pressed)
|
||||
updateBrightness(mouse);
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: mouse => {
|
||||
updateBrightness(mouse);
|
||||
}
|
||||
onClicked: mouse => updateBrightness(mouse)
|
||||
|
||||
function updateBrightness(mouse) {
|
||||
if (!DisplayService.brightnessAvailable) {
|
||||
if (!DisplayService.brightnessAvailable)
|
||||
return;
|
||||
}
|
||||
const ratio = 1.0 - (mouse.y / height);
|
||||
const newValue = Math.round(vertSlider.minimum + ratio * (vertSlider.maximum - vertSlider.minimum));
|
||||
vertSlider.value = newValue;
|
||||
|
||||
@@ -8,13 +8,20 @@ DankOSD {
|
||||
|
||||
readonly property bool useVertical: isVerticalLayout
|
||||
readonly property var player: MprisController.activePlayer
|
||||
readonly property int currentVolume: player ? Math.min(100, Math.round(player.volume * 100)) : 0
|
||||
readonly property bool volumeSupported: player?.volumeSupported ?? false
|
||||
property bool _suppressNewPlayer: false
|
||||
property int _displayVolume: 0
|
||||
|
||||
function _syncVolume() {
|
||||
if (!player)
|
||||
return;
|
||||
_displayVolume = Math.min(100, Math.round(player.volume * 100));
|
||||
}
|
||||
|
||||
onPlayerChanged: {
|
||||
_suppressNewPlayer = true;
|
||||
_suppressTimer.restart();
|
||||
_syncVolume();
|
||||
}
|
||||
|
||||
Timer {
|
||||
@@ -37,25 +44,25 @@ DankOSD {
|
||||
}
|
||||
|
||||
function toggleMute() {
|
||||
if (player) {
|
||||
player.volume = player.volume > 0 ? 0 : 1;
|
||||
}
|
||||
if (!player)
|
||||
return;
|
||||
player.volume = player.volume > 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
function setVolume(volumePercent) {
|
||||
if (player) {
|
||||
player.volume = volumePercent / 100;
|
||||
resetHideTimer();
|
||||
}
|
||||
if (!player)
|
||||
return;
|
||||
player.volume = volumePercent / 100;
|
||||
resetHideTimer();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: player
|
||||
|
||||
function onVolumeChanged() {
|
||||
if (SettingsData.osdMediaVolumeEnabled && volumeSupported && !_suppressNewPlayer) {
|
||||
root._syncVolume();
|
||||
if (SettingsData.osdMediaVolumeEnabled && volumeSupported && !_suppressNewPlayer)
|
||||
root.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +103,7 @@ DankOSD {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: toggleMute()
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse || volumeSlider.containsMouse);
|
||||
}
|
||||
onContainsMouseChanged: setChildHovered(containsMouse || volumeSlider.containsMouse)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,29 +120,21 @@ DankOSD {
|
||||
showValue: true
|
||||
unit: "%"
|
||||
thumbOutlineColor: Theme.surfaceContainer
|
||||
valueOverride: currentVolume
|
||||
valueOverride: root._displayVolume
|
||||
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
||||
|
||||
Component.onCompleted: {
|
||||
value = currentVolume;
|
||||
root._syncVolume();
|
||||
value = root._displayVolume;
|
||||
}
|
||||
|
||||
onSliderValueChanged: newValue => {
|
||||
setVolume(newValue);
|
||||
}
|
||||
onSliderValueChanged: newValue => setVolume(newValue)
|
||||
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse || muteButton.containsMouse);
|
||||
}
|
||||
onContainsMouseChanged: setChildHovered(containsMouse || muteButton.containsMouse)
|
||||
|
||||
Connections {
|
||||
target: player
|
||||
|
||||
function onVolumeChanged() {
|
||||
if (volumeSlider && !volumeSlider.pressed) {
|
||||
volumeSlider.value = currentVolume;
|
||||
}
|
||||
}
|
||||
Binding on value {
|
||||
value: root._displayVolume
|
||||
when: !volumeSlider.pressed
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,9 +169,7 @@ DankOSD {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: toggleMute()
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse || vertSliderArea.containsMouse);
|
||||
}
|
||||
onContainsMouseChanged: setChildHovered(containsMouse || vertSliderArea.containsMouse)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +181,7 @@ DankOSD {
|
||||
y: gap * 2 + Theme.iconSize
|
||||
|
||||
property bool dragging: false
|
||||
property int value: currentVolume
|
||||
property int value: root._displayVolume
|
||||
|
||||
Rectangle {
|
||||
id: vertTrack
|
||||
@@ -231,28 +226,21 @@ DankOSD {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse || muteButtonVert.containsMouse);
|
||||
}
|
||||
onContainsMouseChanged: setChildHovered(containsMouse || muteButtonVert.containsMouse)
|
||||
|
||||
onPressed: mouse => {
|
||||
vertSlider.dragging = true;
|
||||
updateVolume(mouse);
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
vertSlider.dragging = false;
|
||||
}
|
||||
onReleased: vertSlider.dragging = false
|
||||
|
||||
onPositionChanged: mouse => {
|
||||
if (pressed) {
|
||||
if (pressed)
|
||||
updateVolume(mouse);
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: mouse => {
|
||||
updateVolume(mouse);
|
||||
}
|
||||
onClicked: mouse => updateVolume(mouse)
|
||||
|
||||
function updateVolume(mouse) {
|
||||
const ratio = 1.0 - (mouse.y / height);
|
||||
@@ -260,16 +248,6 @@ DankOSD {
|
||||
setVolume(volume);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: player
|
||||
|
||||
function onVolumeChanged() {
|
||||
if (!vertSlider.dragging) {
|
||||
vertSlider.value = currentVolume;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
@@ -283,15 +261,4 @@ DankOSD {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onOsdShown: {
|
||||
if (player && contentLoader.item && contentLoader.item.item) {
|
||||
if (!useVertical) {
|
||||
const slider = contentLoader.item.item.children[0].children[1];
|
||||
if (slider && slider.value !== undefined) {
|
||||
slider.value = currentVolume;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,13 @@ DankOSD {
|
||||
id: root
|
||||
|
||||
readonly property bool useVertical: isVerticalLayout
|
||||
property int _displayVolume: 0
|
||||
|
||||
function _syncVolume() {
|
||||
if (!AudioService.sink?.audio)
|
||||
return;
|
||||
_displayVolume = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
||||
}
|
||||
|
||||
osdWidth: useVertical ? (40 + Theme.spacingS * 2) : Math.min(260, Screen.width - Theme.spacingM * 2)
|
||||
osdHeight: useVertical ? Math.min(260, Screen.height - Theme.spacingM * 2) : (40 + Theme.spacingS * 2)
|
||||
@@ -14,18 +21,17 @@ DankOSD {
|
||||
enableMouseInteraction: true
|
||||
|
||||
Connections {
|
||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
||||
target: AudioService.sink?.audio ?? null
|
||||
|
||||
function onVolumeChanged() {
|
||||
if (SettingsData.osdVolumeEnabled) {
|
||||
root._syncVolume();
|
||||
if (SettingsData.osdVolumeEnabled)
|
||||
root.show();
|
||||
}
|
||||
}
|
||||
|
||||
function onMutedChanged() {
|
||||
if (SettingsData.osdVolumeEnabled) {
|
||||
if (SettingsData.osdVolumeEnabled)
|
||||
root.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +39,9 @@ DankOSD {
|
||||
target: AudioService
|
||||
|
||||
function onSinkChanged() {
|
||||
if (root.shouldBeVisible && SettingsData.osdVolumeEnabled) {
|
||||
root._syncVolume();
|
||||
if (root.shouldBeVisible && SettingsData.osdVolumeEnabled)
|
||||
root.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +70,7 @@ DankOSD {
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: AudioService.sink && AudioService.sink.audio && AudioService.sink.audio.muted ? "volume_off" : "volume_up"
|
||||
name: AudioService.sink?.audio?.muted ? "volume_off" : "volume_up"
|
||||
size: Theme.iconSize
|
||||
color: muteButton.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
@@ -75,60 +81,45 @@ DankOSD {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
AudioService.toggleMute();
|
||||
}
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse || volumeSlider.containsMouse);
|
||||
}
|
||||
onClicked: AudioService.toggleMute()
|
||||
onContainsMouseChanged: setChildHovered(containsMouse || volumeSlider.containsMouse)
|
||||
}
|
||||
}
|
||||
|
||||
DankSlider {
|
||||
id: volumeSlider
|
||||
|
||||
readonly property real actualVolumePercent: AudioService.sink && AudioService.sink.audio ? Math.round(AudioService.sink.audio.volume * 100) : 0
|
||||
readonly property real displayPercent: actualVolumePercent
|
||||
|
||||
width: parent.width - Theme.iconSize - parent.gap * 3
|
||||
height: 40
|
||||
x: parent.gap * 2 + Theme.iconSize
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
minimum: 0
|
||||
maximum: AudioService.sinkMaxVolume
|
||||
enabled: AudioService.sink && AudioService.sink.audio
|
||||
enabled: AudioService.sink?.audio
|
||||
showValue: true
|
||||
unit: "%"
|
||||
thumbOutlineColor: Theme.surfaceContainer
|
||||
valueOverride: displayPercent
|
||||
valueOverride: root._displayVolume
|
||||
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
||||
|
||||
Component.onCompleted: {
|
||||
if (AudioService.sink && AudioService.sink.audio) {
|
||||
value = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
||||
}
|
||||
root._syncVolume();
|
||||
value = root._displayVolume;
|
||||
}
|
||||
|
||||
onSliderValueChanged: newValue => {
|
||||
if (AudioService.sink && AudioService.sink.audio) {
|
||||
SessionData.suppressOSDTemporarily();
|
||||
AudioService.sink.audio.volume = newValue / 100;
|
||||
resetHideTimer();
|
||||
}
|
||||
if (!AudioService.sink?.audio)
|
||||
return;
|
||||
SessionData.suppressOSDTemporarily();
|
||||
AudioService.sink.audio.volume = newValue / 100;
|
||||
resetHideTimer();
|
||||
}
|
||||
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse || muteButton.containsMouse);
|
||||
}
|
||||
onContainsMouseChanged: setChildHovered(containsMouse || muteButton.containsMouse)
|
||||
|
||||
Connections {
|
||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
||||
|
||||
function onVolumeChanged() {
|
||||
if (volumeSlider && !volumeSlider.pressed) {
|
||||
volumeSlider.value = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
||||
}
|
||||
}
|
||||
Binding on value {
|
||||
value: root._displayVolume
|
||||
when: !volumeSlider.pressed
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +142,7 @@ DankOSD {
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: AudioService.sink && AudioService.sink.audio && AudioService.sink.audio.muted ? "volume_off" : "volume_up"
|
||||
name: AudioService.sink?.audio?.muted ? "volume_off" : "volume_up"
|
||||
size: Theme.iconSize
|
||||
color: muteButtonVert.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
@@ -162,12 +153,8 @@ DankOSD {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
AudioService.toggleMute();
|
||||
}
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse || vertSliderArea.containsMouse);
|
||||
}
|
||||
onClicked: AudioService.toggleMute()
|
||||
onContainsMouseChanged: setChildHovered(containsMouse || vertSliderArea.containsMouse)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +166,7 @@ DankOSD {
|
||||
y: gap * 2 + Theme.iconSize
|
||||
|
||||
property bool dragging: false
|
||||
property int value: AudioService.sink && AudioService.sink.audio ? Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100)) : 0
|
||||
property int value: root._displayVolume
|
||||
|
||||
Rectangle {
|
||||
id: vertTrack
|
||||
@@ -220,50 +207,35 @@ DankOSD {
|
||||
id: vertSliderArea
|
||||
anchors.fill: parent
|
||||
anchors.margins: -12
|
||||
enabled: AudioService.sink && AudioService.sink.audio
|
||||
enabled: AudioService.sink?.audio
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onContainsMouseChanged: {
|
||||
setChildHovered(containsMouse || muteButtonVert.containsMouse);
|
||||
}
|
||||
onContainsMouseChanged: setChildHovered(containsMouse || muteButtonVert.containsMouse)
|
||||
|
||||
onPressed: mouse => {
|
||||
vertSlider.dragging = true;
|
||||
updateVolume(mouse);
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
vertSlider.dragging = false;
|
||||
}
|
||||
onReleased: vertSlider.dragging = false
|
||||
|
||||
onPositionChanged: mouse => {
|
||||
if (pressed) {
|
||||
if (pressed)
|
||||
updateVolume(mouse);
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: mouse => {
|
||||
updateVolume(mouse);
|
||||
}
|
||||
onClicked: mouse => updateVolume(mouse)
|
||||
|
||||
function updateVolume(mouse) {
|
||||
if (AudioService.sink && AudioService.sink.audio) {
|
||||
const maxVol = AudioService.sinkMaxVolume;
|
||||
const ratio = 1.0 - (mouse.y / height);
|
||||
const volume = Math.max(0, Math.min(maxVol, Math.round(ratio * maxVol)));
|
||||
SessionData.suppressOSDTemporarily();
|
||||
AudioService.sink.audio.volume = volume / 100;
|
||||
resetHideTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
||||
|
||||
function onVolumeChanged() {
|
||||
vertSlider.value = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
||||
if (!AudioService.sink?.audio)
|
||||
return;
|
||||
const maxVol = AudioService.sinkMaxVolume;
|
||||
const ratio = 1.0 - (mouse.y / height);
|
||||
const volume = Math.max(0, Math.min(maxVol, Math.round(ratio * maxVol)));
|
||||
SessionData.suppressOSDTemporarily();
|
||||
AudioService.sink.audio.volume = volume / 100;
|
||||
resetHideTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,15 +251,4 @@ DankOSD {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onOsdShown: {
|
||||
if (AudioService.sink && AudioService.sink.audio && contentLoader.item && contentLoader.item.item) {
|
||||
if (!useVertical) {
|
||||
const slider = contentLoader.item.item.children[0].children[1];
|
||||
if (slider && slider.value !== undefined) {
|
||||
slider.value = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,36 +18,41 @@ Column {
|
||||
property bool isInitialized: false
|
||||
|
||||
function loadValue() {
|
||||
const settings = findSettings()
|
||||
const settings = findSettings();
|
||||
if (settings && settings.pluginService) {
|
||||
const loadedValue = settings.loadValue(settingKey, defaultValue)
|
||||
value = loadedValue
|
||||
textField.text = loadedValue
|
||||
isInitialized = true
|
||||
const loadedValue = settings.loadValue(settingKey, defaultValue);
|
||||
if (textField.activeFocus && isInitialized)
|
||||
return;
|
||||
value = loadedValue;
|
||||
textField.text = loadedValue;
|
||||
isInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
Qt.callLater(loadValue)
|
||||
Qt.callLater(loadValue);
|
||||
}
|
||||
|
||||
onValueChanged: {
|
||||
if (!isInitialized) return
|
||||
const settings = findSettings()
|
||||
if (settings) {
|
||||
settings.saveValue(settingKey, value)
|
||||
}
|
||||
function commit() {
|
||||
if (!isInitialized)
|
||||
return;
|
||||
if (textField.text === value)
|
||||
return;
|
||||
value = textField.text;
|
||||
const settings = findSettings();
|
||||
if (settings)
|
||||
settings.saveValue(settingKey, value);
|
||||
}
|
||||
|
||||
function findSettings() {
|
||||
let item = parent
|
||||
let item = parent;
|
||||
while (item) {
|
||||
if (item.saveValue !== undefined && item.loadValue !== undefined) {
|
||||
return item
|
||||
return item;
|
||||
}
|
||||
item = item.parent
|
||||
item = item.parent;
|
||||
}
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
StyledText {
|
||||
@@ -70,16 +75,10 @@ Column {
|
||||
id: textField
|
||||
width: parent.width
|
||||
placeholderText: root.placeholder
|
||||
onTextEdited: {
|
||||
root.value = text
|
||||
}
|
||||
onEditingFinished: {
|
||||
root.value = text
|
||||
}
|
||||
onEditingFinished: root.commit()
|
||||
onActiveFocusChanged: {
|
||||
if (!activeFocus) {
|
||||
root.value = text
|
||||
}
|
||||
if (!activeFocus)
|
||||
root.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ DankPopout {
|
||||
property var triggerScreen: null
|
||||
property string searchText: ""
|
||||
property string expandedPid: ""
|
||||
property string processFilter: "all"
|
||||
|
||||
function hide() {
|
||||
close();
|
||||
@@ -25,8 +26,8 @@ DankPopout {
|
||||
open();
|
||||
}
|
||||
|
||||
popupWidth: 650
|
||||
popupHeight: 550
|
||||
popupWidth: Math.round(Theme.fontSizeMedium * 46)
|
||||
popupHeight: Math.round(Theme.fontSizeMedium * 39)
|
||||
triggerWidth: 55
|
||||
positioning: ""
|
||||
screen: triggerScreen
|
||||
@@ -42,6 +43,7 @@ DankPopout {
|
||||
if (!shouldBeVisible) {
|
||||
searchText = "";
|
||||
expandedPid = "";
|
||||
processFilter = "all";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +112,7 @@ DankPopout {
|
||||
Qt.callLater(() => searchField.forceActiveFocus());
|
||||
} else {
|
||||
processesView.reset();
|
||||
processFilterGroup.currentIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,9 +149,38 @@ DankPopout {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
DankButtonGroup {
|
||||
id: processFilterGroup
|
||||
Layout.minimumWidth: implicitWidth
|
||||
model: [I18n.tr("All"), I18n.tr("User"), I18n.tr("System")]
|
||||
currentIndex: 0
|
||||
checkEnabled: false
|
||||
buttonHeight: Math.round(Theme.fontSizeSmall * 2.4)
|
||||
minButtonWidth: 0
|
||||
buttonPadding: Theme.spacingM
|
||||
textSize: Theme.fontSizeSmall
|
||||
onSelectionChanged: (index, selected) => {
|
||||
if (!selected)
|
||||
return;
|
||||
currentIndex = index;
|
||||
switch (index) {
|
||||
case 0:
|
||||
processListPopout.processFilter = "all";
|
||||
return;
|
||||
case 1:
|
||||
processListPopout.processFilter = "user";
|
||||
return;
|
||||
case 2:
|
||||
processListPopout.processFilter = "system";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankTextField {
|
||||
id: searchField
|
||||
Layout.preferredWidth: Theme.fontSizeMedium * 14
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumWidth: Theme.fontSizeMedium * 8
|
||||
Layout.preferredHeight: Theme.fontSizeMedium * 2.5
|
||||
placeholderText: I18n.tr("Search...")
|
||||
leftIconName: "search"
|
||||
@@ -334,6 +366,7 @@ DankPopout {
|
||||
anchors.margins: Theme.spacingS
|
||||
searchText: processListPopout.searchText
|
||||
expandedPid: processListPopout.expandedPid
|
||||
processFilter: processListPopout.processFilter
|
||||
contextMenu: processContextMenu
|
||||
onExpandedPidChanged: processListPopout.expandedPid = expandedPid
|
||||
}
|
||||
@@ -354,7 +387,7 @@ DankPopout {
|
||||
|
||||
readonly property real thickness: Math.max(4, Math.min(width, height) / 15)
|
||||
readonly property real glowExtra: thickness * 1.4
|
||||
readonly property real arcPadding: thickness / 1.3
|
||||
readonly property real arcPadding: (thickness + glowExtra) / 2
|
||||
|
||||
readonly property real innerDiameter: width - (arcPadding + thickness + glowExtra) * 2
|
||||
readonly property real maxTextWidth: innerDiameter * 0.9
|
||||
|
||||
@@ -11,6 +11,7 @@ Item {
|
||||
property string searchText: ""
|
||||
property string expandedPid: ""
|
||||
property var contextMenu: null
|
||||
property string processFilter: "all" // "all", "user", "system"
|
||||
|
||||
property int selectedIndex: -1
|
||||
property bool keyboardNavigationActive: false
|
||||
@@ -41,6 +42,12 @@ Item {
|
||||
|
||||
let procs = DgopService.allProcesses.slice();
|
||||
|
||||
if (processFilter === "user") {
|
||||
procs = procs.filter(p => p.username === UserInfoService.username);
|
||||
} else if (processFilter === "system") {
|
||||
procs = procs.filter(p => p.username !== UserInfoService.username);
|
||||
}
|
||||
|
||||
if (searchText.length > 0) {
|
||||
const search = searchText.toLowerCase();
|
||||
procs = procs.filter(p => {
|
||||
|
||||
@@ -14,6 +14,7 @@ Item {
|
||||
property bool isNiri: CompositorService.isNiri
|
||||
property bool isSway: CompositorService.isSway
|
||||
property bool isScroll: CompositorService.isScroll
|
||||
property bool isMiracle: CompositorService.isMiracle
|
||||
property bool isDwl: CompositorService.isDwl
|
||||
property bool isLabwc: CompositorService.isLabwc
|
||||
|
||||
@@ -24,6 +25,8 @@ Item {
|
||||
return "sway";
|
||||
if (isScroll)
|
||||
return "scroll";
|
||||
if (isMiracle)
|
||||
return "miracle";
|
||||
if (isDwl)
|
||||
return "mangowc";
|
||||
if (isLabwc)
|
||||
@@ -38,6 +41,8 @@ Item {
|
||||
return "/assets/sway.svg";
|
||||
if (isScroll)
|
||||
return "/assets/sway.svg";
|
||||
if (isMiracle)
|
||||
return "/assets/miraclewm.svg";
|
||||
if (isDwl)
|
||||
return "/assets/mango.png";
|
||||
if (isLabwc)
|
||||
@@ -52,6 +57,8 @@ Item {
|
||||
return "https://swaywm.org";
|
||||
if (isScroll)
|
||||
return "https://github.com/dawsers/scroll";
|
||||
if (isMiracle)
|
||||
return "https://github.com/miracle-wm-org/miracle-wm";
|
||||
if (isDwl)
|
||||
return "https://github.com/DreamMaoMao/mangowc";
|
||||
if (isLabwc)
|
||||
@@ -66,6 +73,8 @@ Item {
|
||||
return "Sway Website";
|
||||
if (isScroll)
|
||||
return "Scroll Github";
|
||||
if (isMiracle)
|
||||
return "Miracle WM GitHub";
|
||||
if (isDwl)
|
||||
return "mangowc GitHub";
|
||||
if (isLabwc)
|
||||
@@ -98,9 +107,9 @@ Item {
|
||||
property string ircUrl: "https://web.libera.chat/gamja/?channels=#labwc"
|
||||
property string ircTooltip: "LabWC IRC Channel"
|
||||
|
||||
property bool showMatrix: isNiri && !isHyprland && !isSway && !isScroll && !isDwl && !isLabwc
|
||||
property bool showMatrix: isNiri && !isHyprland && !isSway && !isScroll && !isMiracle && !isDwl && !isLabwc
|
||||
property bool showCompositorDiscord: isHyprland || isDwl
|
||||
property bool showReddit: isNiri && !isHyprland && !isSway && !isScroll && !isDwl && !isLabwc
|
||||
property bool showReddit: isNiri && !isHyprland && !isSway && !isScroll && !isMiracle && !isDwl && !isLabwc
|
||||
property bool showIrc: isLabwc
|
||||
|
||||
DankFlickable {
|
||||
|
||||
@@ -18,6 +18,22 @@ Item {
|
||||
property string editingDeviceType: ""
|
||||
property string newDeviceName: ""
|
||||
property bool isReloadingAudio: false
|
||||
property var hiddenOutputDeviceNames: SessionData.hiddenOutputDeviceNames ?? []
|
||||
property var hiddenInputDeviceNames: SessionData.hiddenInputDeviceNames ?? []
|
||||
property bool showHiddenOutputDevices: false
|
||||
property bool showHiddenInputDevices: false
|
||||
|
||||
function persistHiddenOutputDeviceNames(deviceNames) {
|
||||
const uniqueNames = [...new Set(deviceNames)];
|
||||
hiddenOutputDeviceNames = uniqueNames;
|
||||
SessionData.setHiddenOutputDeviceNames(uniqueNames);
|
||||
}
|
||||
|
||||
function persistHiddenInputDeviceNames(deviceNames) {
|
||||
const uniqueNames = [...new Set(deviceNames)];
|
||||
hiddenInputDeviceNames = uniqueNames;
|
||||
SessionData.setHiddenInputDeviceNames(uniqueNames);
|
||||
}
|
||||
|
||||
function updateDeviceList() {
|
||||
const allNodes = Pipewire.nodes.values;
|
||||
@@ -56,6 +72,8 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
hiddenOutputDeviceNames = SessionData.hiddenOutputDeviceNames ?? [];
|
||||
hiddenInputDeviceNames = SessionData.hiddenInputDeviceNames ?? [];
|
||||
updateDeviceList();
|
||||
}
|
||||
|
||||
@@ -132,7 +150,7 @@ Item {
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: root.outputDevices
|
||||
model: root.outputDevices.filter(d => !root.hiddenOutputDeviceNames.includes(d.name))
|
||||
|
||||
delegate: Column {
|
||||
required property var modelData
|
||||
@@ -142,6 +160,7 @@ Item {
|
||||
DeviceAliasRow {
|
||||
deviceNode: modelData
|
||||
deviceType: "output"
|
||||
showHideButton: true
|
||||
|
||||
onEditRequested: device => {
|
||||
root.editingDevice = device;
|
||||
@@ -153,6 +172,10 @@ Item {
|
||||
onResetRequested: device => {
|
||||
AudioService.removeDeviceAlias(device.name);
|
||||
}
|
||||
|
||||
onHideRequested: device => {
|
||||
root.persistHiddenOutputDeviceNames([...root.hiddenOutputDeviceNames, device.name]);
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -161,7 +184,7 @@ Item {
|
||||
|
||||
StyledText {
|
||||
id: maxVolLabel
|
||||
text: I18n.tr("Max Volume", "Audio settings: maximum volume limit per device")
|
||||
text: I18n.tr("Max Volume", "Audio settings: maximum volume limit per device") + " · " + maxVolSlider.value + "%"
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.spacingM + Theme.iconSize + Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -182,6 +205,8 @@ Item {
|
||||
maximum: 200
|
||||
step: 5
|
||||
showValue: true
|
||||
wheelEnabled: false
|
||||
centerMinimum: true
|
||||
unit: "%"
|
||||
onSliderValueChanged: newValue => {
|
||||
SessionData.setDeviceMaxVolume(modelData.name, newValue);
|
||||
@@ -204,9 +229,87 @@ Item {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
visible: root.outputDevices.length === 0
|
||||
visible: root.outputDevices.filter(d => !root.hiddenOutputDeviceNames.includes(d.name)).length === 0 && root.hiddenOutputDeviceNames.length === 0
|
||||
topPadding: Theme.spacingM
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 0
|
||||
visible: root.hiddenOutputDeviceNames.length > 0
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.15
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 36
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingS
|
||||
|
||||
DankIcon {
|
||||
name: "visibility_off"
|
||||
size: Theme.iconSize - 4
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Hidden (%1)", "count of hidden audio devices").arg(root.hiddenOutputDeviceNames.length)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
name: root.showHiddenOutputDevices ? "expand_less" : "expand_more"
|
||||
size: Theme.iconSize - 4
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.showHiddenOutputDevices = !root.showHiddenOutputDevices
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 0
|
||||
visible: root.showHiddenOutputDevices
|
||||
|
||||
Repeater {
|
||||
model: root.outputDevices.filter(d => root.hiddenOutputDeviceNames.includes(d.name))
|
||||
|
||||
delegate: DeviceAliasRow {
|
||||
required property var modelData
|
||||
deviceNode: modelData
|
||||
deviceType: "output"
|
||||
isHidden: true
|
||||
showHideButton: true
|
||||
|
||||
onHideRequested: device => {
|
||||
root.persistHiddenOutputDeviceNames(root.hiddenOutputDeviceNames.filter(n => n !== device.name));
|
||||
}
|
||||
|
||||
onResetRequested: device => {
|
||||
AudioService.removeDeviceAlias(device.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,13 +341,14 @@ Item {
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: root.inputDevices
|
||||
model: root.inputDevices.filter(d => !root.hiddenInputDeviceNames.includes(d.name))
|
||||
|
||||
delegate: DeviceAliasRow {
|
||||
required property var modelData
|
||||
|
||||
deviceNode: modelData
|
||||
deviceType: "input"
|
||||
showHideButton: true
|
||||
|
||||
onEditRequested: device => {
|
||||
root.editingDevice = device;
|
||||
@@ -256,6 +360,10 @@ Item {
|
||||
onResetRequested: device => {
|
||||
AudioService.removeDeviceAlias(device.name);
|
||||
}
|
||||
|
||||
onHideRequested: device => {
|
||||
root.persistHiddenInputDeviceNames([...root.hiddenInputDeviceNames, device.name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,9 +373,87 @@ Item {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
visible: root.inputDevices.length === 0
|
||||
visible: root.inputDevices.filter(d => !root.hiddenInputDeviceNames.includes(d.name)).length === 0 && root.hiddenInputDeviceNames.length === 0
|
||||
topPadding: Theme.spacingM
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 0
|
||||
visible: root.hiddenInputDeviceNames.length > 0
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.15
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 36
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingS
|
||||
|
||||
DankIcon {
|
||||
name: "visibility_off"
|
||||
size: Theme.iconSize - 4
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Hidden (%1)", "count of hidden audio devices").arg(root.hiddenInputDeviceNames.length)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
name: root.showHiddenInputDevices ? "expand_less" : "expand_more"
|
||||
size: Theme.iconSize - 4
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.showHiddenInputDevices = !root.showHiddenInputDevices
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 0
|
||||
visible: root.showHiddenInputDevices
|
||||
|
||||
Repeater {
|
||||
model: root.inputDevices.filter(d => root.hiddenInputDeviceNames.includes(d.name))
|
||||
|
||||
delegate: DeviceAliasRow {
|
||||
required property var modelData
|
||||
deviceNode: modelData
|
||||
deviceType: "input"
|
||||
isHidden: true
|
||||
showHideButton: true
|
||||
|
||||
onHideRequested: device => {
|
||||
root.persistHiddenInputDeviceNames(root.hiddenInputDeviceNames.filter(n => n !== device.name));
|
||||
}
|
||||
|
||||
onResetRequested: device => {
|
||||
AudioService.removeDeviceAlias(device.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1493,6 +1493,10 @@ Singleton {
|
||||
}
|
||||
|
||||
const original = originalOutputs ? JSON.parse(JSON.stringify(originalOutputs)) : buildOutputsWithPendingChanges();
|
||||
for (const name in savedOutputs) {
|
||||
if (!original[name])
|
||||
original[name] = JSON.parse(JSON.stringify(savedOutputs[name]));
|
||||
}
|
||||
backendWriteOutputsConfig(original);
|
||||
clearPendingChanges();
|
||||
if (originalOutputs)
|
||||
|
||||
@@ -21,8 +21,9 @@ Rectangle {
|
||||
continue;
|
||||
const x = output.logical.x;
|
||||
const y = output.logical.y;
|
||||
const w = output.logical.width || 1920;
|
||||
const h = output.logical.height || 1080;
|
||||
const size = DisplayConfigState.getLogicalSize(output);
|
||||
const w = size.w || 1920;
|
||||
const h = size.h || 1080;
|
||||
minX = Math.min(minX, x);
|
||||
minY = Math.min(minY, y);
|
||||
maxX = Math.max(maxX, x + w);
|
||||
|
||||
@@ -264,6 +264,8 @@ Item {
|
||||
modes.push("Sway");
|
||||
} else if (CompositorService.isScroll) {
|
||||
modes.push("Scroll");
|
||||
} else if (CompositorService.isMiracle) {
|
||||
modes.push("Miracle");
|
||||
} else {
|
||||
modes.push(I18n.tr("Compositor"));
|
||||
}
|
||||
@@ -507,6 +509,7 @@ Item {
|
||||
value: SettingsData.dockIconSize
|
||||
minimum: 24
|
||||
maximum: 96
|
||||
unit: "px"
|
||||
defaultValue: 48
|
||||
onSliderValueChanged: newValue => SettingsData.set("dockIconSize", newValue)
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ Item {
|
||||
modes.push("Sway");
|
||||
} else if (CompositorService.isScroll) {
|
||||
modes.push("Scroll");
|
||||
} else if (CompositorService.isMiracle) {
|
||||
modes.push("Miracle");
|
||||
} else {
|
||||
modes.push(I18n.tr("Compositor"));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,25 @@ import qs.Modules.Settings.Widgets
|
||||
Item {
|
||||
id: root
|
||||
|
||||
Component.onCompleted: {
|
||||
if (SettingsData._pendingExpandNotificationRules) {
|
||||
SettingsData._pendingExpandNotificationRules = false;
|
||||
notificationRulesCard.userToggledCollapse = true;
|
||||
notificationRulesCard.expanded = true;
|
||||
SettingsData._pendingNotificationRuleIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var mutedRules: {
|
||||
var rules = SettingsData.notificationRules || [];
|
||||
var out = [];
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
if ((rules[i].action || "").toString().toLowerCase() === "mute")
|
||||
out.push({ rule: rules[i], index: i });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
readonly property var timeoutOptions: [
|
||||
{
|
||||
text: I18n.tr("Never"),
|
||||
@@ -201,22 +220,33 @@ Item {
|
||||
return I18n.tr("Top Left", "screen position option");
|
||||
case SettingsData.Position.Right:
|
||||
return I18n.tr("Bottom Right", "screen position option");
|
||||
case SettingsData.Position.BottomCenter:
|
||||
return I18n.tr("Bottom Center", "screen position option");
|
||||
default:
|
||||
return I18n.tr("Top Right", "screen position option");
|
||||
}
|
||||
}
|
||||
options: [I18n.tr("Top Right", "screen position option"), I18n.tr("Top Left", "screen position option"), I18n.tr("Top Center", "screen position option"), I18n.tr("Bottom Right", "screen position option"), I18n.tr("Bottom Left", "screen position option")]
|
||||
options: [I18n.tr("Top Right", "screen position option"), I18n.tr("Top Left", "screen position option"), I18n.tr("Top Center", "screen position option"), I18n.tr("Bottom Center", "screen position option"), I18n.tr("Bottom Right", "screen position option"), I18n.tr("Bottom Left", "screen position option")]
|
||||
onValueChanged: value => {
|
||||
if (value === I18n.tr("Top Right", "screen position option")) {
|
||||
switch (value) {
|
||||
case I18n.tr("Top Right", "screen position option"):
|
||||
SettingsData.set("notificationPopupPosition", SettingsData.Position.Top);
|
||||
} else if (value === I18n.tr("Top Left", "screen position option")) {
|
||||
break;
|
||||
case I18n.tr("Top Left", "screen position option"):
|
||||
SettingsData.set("notificationPopupPosition", SettingsData.Position.Left);
|
||||
} else if (value === I18n.tr("Top Center", "screen position option")) {
|
||||
break;
|
||||
case I18n.tr("Top Center", "screen position option"):
|
||||
SettingsData.set("notificationPopupPosition", -1);
|
||||
} else if (value === I18n.tr("Bottom Right", "screen position option")) {
|
||||
break;
|
||||
case I18n.tr("Bottom Center", "screen position option"):
|
||||
SettingsData.set("notificationPopupPosition", SettingsData.Position.BottomCenter);
|
||||
break;
|
||||
case I18n.tr("Bottom Right", "screen position option"):
|
||||
SettingsData.set("notificationPopupPosition", SettingsData.Position.Right);
|
||||
} else if (value === I18n.tr("Bottom Left", "screen position option")) {
|
||||
break;
|
||||
case I18n.tr("Bottom Left", "screen position option"):
|
||||
SettingsData.set("notificationPopupPosition", SettingsData.Position.Bottom);
|
||||
break;
|
||||
}
|
||||
SettingsData.sendTestNotifications();
|
||||
}
|
||||
@@ -239,6 +269,95 @@ Item {
|
||||
checked: SettingsData.notificationCompactMode
|
||||
onToggled: checked => SettingsData.set("notificationCompactMode", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "notificationPopupShadowEnabled"
|
||||
tags: ["notification", "popup", "shadow", "radius", "rounded"]
|
||||
text: I18n.tr("Popup Shadow")
|
||||
description: I18n.tr("Show drop shadow on notification popups")
|
||||
checked: SettingsData.notificationPopupShadowEnabled
|
||||
onToggled: checked => SettingsData.set("notificationPopupShadowEnabled", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "notificationPopupPrivacyMode"
|
||||
tags: ["notification", "popup", "privacy", "body", "content", "hide"]
|
||||
text: I18n.tr("Privacy Mode")
|
||||
description: I18n.tr("Hide notification content until expanded; popups show collapsed by default")
|
||||
checked: SettingsData.notificationPopupPrivacyMode
|
||||
onToggled: checked => SettingsData.set("notificationPopupPrivacyMode", checked)
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: notificationAnimationColumn.implicitHeight + Theme.spacingM * 2
|
||||
|
||||
Column {
|
||||
id: notificationAnimationColumn
|
||||
width: parent.width - Theme.spacingM * 2
|
||||
x: Theme.spacingM
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Theme.spacingM
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Animation Speed")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Control animation duration for notification popups and history")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
wrapMode: Text.WordWrap
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
DankButtonGroup {
|
||||
id: notificationSpeedGroup
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
buttonPadding: parent.width < 480 ? Theme.spacingS : Theme.spacingM
|
||||
minButtonWidth: parent.width < 480 ? 44 : 56
|
||||
textSize: parent.width < 480 ? Theme.fontSizeSmall : Theme.fontSizeMedium
|
||||
model: [I18n.tr("None"), I18n.tr("Short"), I18n.tr("Medium"), I18n.tr("Long"), I18n.tr("Custom")]
|
||||
selectionMode: "single"
|
||||
currentIndex: SettingsData.notificationAnimationSpeed
|
||||
onSelectionChanged: (index, selected) => {
|
||||
if (!selected)
|
||||
return;
|
||||
SettingsData.set("notificationAnimationSpeed", index);
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SettingsData
|
||||
function onNotificationAnimationSpeedChanged() {
|
||||
notificationSpeedGroup.currentIndex = SettingsData.notificationAnimationSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsSliderRow {
|
||||
settingKey: "notificationCustomAnimationDuration"
|
||||
tags: ["notification", "animation", "duration", "custom", "speed"]
|
||||
text: I18n.tr("Duration")
|
||||
description: I18n.tr("Base duration for animations (drag to use Custom)")
|
||||
minimum: 100
|
||||
maximum: 800
|
||||
value: Theme.notificationAnimationBaseDuration
|
||||
unit: "ms"
|
||||
defaultValue: 400
|
||||
onSliderValueChanged: newValue => {
|
||||
if (SettingsData.notificationAnimationSpeed !== SettingsData.AnimationSpeed.Custom) {
|
||||
SettingsData.set("notificationAnimationSpeed", SettingsData.AnimationSpeed.Custom);
|
||||
}
|
||||
SettingsData.set("notificationCustomAnimationDuration", newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
@@ -258,6 +377,7 @@ Item {
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
id: notificationRulesCard
|
||||
width: parent.width
|
||||
iconName: "rule_settings"
|
||||
title: I18n.tr("Notification Rules")
|
||||
@@ -282,7 +402,11 @@ Item {
|
||||
iconSize: 20
|
||||
backgroundColor: Theme.surfaceContainer
|
||||
iconColor: Theme.primary
|
||||
onClicked: SettingsData.addNotificationRule()
|
||||
onClicked: {
|
||||
SettingsData.addNotificationRule();
|
||||
notificationRulesCard.userToggledCollapse = true;
|
||||
notificationRulesCard.expanded = true;
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -291,7 +415,7 @@ Item {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Create rules to mute, ignore, hide from history, or override notification priority.")
|
||||
text: I18n.tr("Create rules to mute, ignore, hide from history, or override notification priority. Default only overrides priority; notifications still show normally.")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
wrapMode: Text.WordWrap
|
||||
@@ -407,6 +531,7 @@ Item {
|
||||
width: parent.width
|
||||
compactMode: true
|
||||
dropdownWidth: parent.width
|
||||
popupWidth: 165
|
||||
currentValue: root.getRuleOptionLabel(root.notificationRuleFieldOptions, modelData.field, root.notificationRuleFieldOptions[0].label)
|
||||
options: root.notificationRuleFieldOptions.map(o => o.label)
|
||||
onValueChanged: value => SettingsData.updateNotificationRuleField(index, "field", root.getRuleOptionValue(root.notificationRuleFieldOptions, value, "appName"))
|
||||
@@ -447,6 +572,7 @@ Item {
|
||||
width: parent.width
|
||||
compactMode: true
|
||||
dropdownWidth: parent.width
|
||||
popupWidth: 170
|
||||
currentValue: root.getRuleOptionLabel(root.notificationRuleActionOptions, modelData.action, root.notificationRuleActionOptions[0].label)
|
||||
options: root.notificationRuleActionOptions.map(o => o.label)
|
||||
onValueChanged: value => SettingsData.updateNotificationRuleField(index, "action", root.getRuleOptionValue(root.notificationRuleActionOptions, value, "default"))
|
||||
@@ -467,6 +593,7 @@ Item {
|
||||
width: parent.width
|
||||
compactMode: true
|
||||
dropdownWidth: parent.width
|
||||
popupWidth: 165
|
||||
currentValue: root.getRuleOptionLabel(root.notificationRuleUrgencyOptions, modelData.urgency, root.notificationRuleUrgencyOptions[0].label)
|
||||
options: root.notificationRuleUrgencyOptions.map(o => o.label)
|
||||
onValueChanged: value => SettingsData.updateNotificationRuleField(index, "urgency", root.getRuleOptionValue(root.notificationRuleUrgencyOptions, value, "default"))
|
||||
@@ -479,6 +606,95 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
width: parent.width
|
||||
iconName: "volume_off"
|
||||
title: I18n.tr("Muted Apps")
|
||||
settingKey: "mutedApps"
|
||||
tags: ["notification", "mute", "unmute", "popup"]
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: mutedRules.length > 0 ? I18n.tr("Apps with notification popups muted. Unmute or delete to remove.") : I18n.tr("No apps muted. Right-click a notification and choose \"Mute popups\" to add one here.")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
wrapMode: Text.WordWrap
|
||||
width: parent.width
|
||||
bottomPadding: Theme.spacingS
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: mutedRules
|
||||
|
||||
delegate: Rectangle {
|
||||
width: parent.width
|
||||
height: mutedRow.implicitHeight + Theme.spacingS * 2
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.withAlpha(Theme.surfaceContainer, 0.5)
|
||||
|
||||
Row {
|
||||
id: mutedRow
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingS
|
||||
spacing: Theme.spacingM
|
||||
|
||||
StyledText {
|
||||
id: mutedAppLabel
|
||||
text: (modelData.rule && modelData.rule.pattern) ? modelData.rule.pattern : I18n.tr("Unknown")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Item {
|
||||
width: Math.max(0, parent.width - parent.spacing - mutedAppLabel.width - unmuteBtn.width - deleteBtn.width - Theme.spacingS * 5)
|
||||
height: 1
|
||||
}
|
||||
|
||||
DankButton {
|
||||
id: unmuteBtn
|
||||
text: I18n.tr("Unmute")
|
||||
backgroundColor: Theme.surfaceContainer
|
||||
textColor: Theme.primary
|
||||
onClicked: SettingsData.removeNotificationRule(modelData.index)
|
||||
}
|
||||
|
||||
Item {
|
||||
id: deleteBtn
|
||||
width: 28
|
||||
height: 28
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: Theme.cornerRadius
|
||||
color: deleteArea.containsMouse ? Theme.withAlpha(Theme.error, 0.2) : "transparent"
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "delete"
|
||||
size: 18
|
||||
color: deleteArea.containsMouse ? Theme.error : Theme.surfaceVariantText
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: deleteArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: SettingsData.removeNotificationRule(modelData.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
width: parent.width
|
||||
iconName: "lock"
|
||||
|
||||
@@ -375,8 +375,20 @@ FocusScope {
|
||||
if (!plugin || !PluginService.isPluginLoaded(pluginId))
|
||||
return;
|
||||
var isLauncher = plugin.type === "launcher" || (plugin.capabilities && plugin.capabilities.includes("launcher"));
|
||||
if (isLauncher)
|
||||
PluginService.reloadPlugin(pluginId);
|
||||
if (isLauncher) {
|
||||
pluginReloadTimer.pendingPluginId = pluginId;
|
||||
pluginReloadTimer.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: pluginReloadTimer
|
||||
property string pendingPluginId: ""
|
||||
interval: 500
|
||||
onTriggered: {
|
||||
if (pendingPluginId)
|
||||
PluginService.reloadPlugin(pendingPluginId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Item {
|
||||
property var cachedCursorThemes: SettingsData.availableCursorThemes
|
||||
property var cachedMatugenSchemes: Theme.availableMatugenSchemes.map(option => option.label)
|
||||
property var installedRegistryThemes: []
|
||||
property var templateDetection: ({})
|
||||
property var templateDetection: []
|
||||
|
||||
property var cursorIncludeStatus: ({
|
||||
"exists": false,
|
||||
@@ -106,9 +106,10 @@ Item {
|
||||
}
|
||||
|
||||
function isTemplateDetected(templateId) {
|
||||
if (!templateDetection || Object.keys(templateDetection).length === 0)
|
||||
if (!templateDetection || templateDetection.length === 0)
|
||||
return true;
|
||||
return templateDetection[templateId] !== false;
|
||||
var item = templateDetection.find(i => i.id === templateId);
|
||||
return !item || item.detected !== false;
|
||||
}
|
||||
|
||||
function getTemplateDescription(templateId, baseDescription) {
|
||||
@@ -145,30 +146,17 @@ Item {
|
||||
DMSService.listInstalledThemes();
|
||||
if (PopoutService.pendingThemeInstall)
|
||||
Qt.callLater(() => showThemeBrowser());
|
||||
templateCheckProcess.running = true;
|
||||
Proc.runCommand("template-check", ["dms", "matugen", "check"], (output, exitCode) => {
|
||||
if (exitCode !== 0)
|
||||
return;
|
||||
try {
|
||||
themeColorsTab.templateDetection = JSON.parse(output.trim());
|
||||
} catch (e) {}
|
||||
});
|
||||
if (CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl)
|
||||
checkCursorIncludeStatus();
|
||||
}
|
||||
|
||||
Process {
|
||||
id: templateCheckProcess
|
||||
command: ["dms", "matugen", "check"]
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
try {
|
||||
const results = JSON.parse(text);
|
||||
const detection = {};
|
||||
for (const item of results) {
|
||||
detection[item.id] = item.detected;
|
||||
}
|
||||
themeColorsTab.templateDetection = detection;
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: DMSService
|
||||
function onInstalledThemesReceived(themes) {
|
||||
|
||||
@@ -14,8 +14,12 @@ Rectangle {
|
||||
required property var deviceNode
|
||||
property string deviceType: "output"
|
||||
|
||||
property bool showHideButton: false
|
||||
property bool isHidden: false
|
||||
|
||||
signal editRequested(var deviceNode)
|
||||
signal resetRequested(var deviceNode)
|
||||
signal hideRequested(var deviceNode)
|
||||
|
||||
width: parent?.width ?? 0
|
||||
height: deviceRowContent.height + Theme.spacingM * 2
|
||||
@@ -127,6 +131,21 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: hideButton
|
||||
visible: root.showHideButton
|
||||
buttonSize: 36
|
||||
iconName: root.isHidden ? "visibility" : "visibility_off"
|
||||
iconSize: 20
|
||||
backgroundColor: Theme.surfaceContainerHigh
|
||||
iconColor: root.isHidden ? Theme.primary : Theme.surfaceVariantText
|
||||
tooltipText: root.isHidden ? I18n.tr("Show device") : I18n.tr("Hide device")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: {
|
||||
root.hideRequested(root.deviceNode);
|
||||
}
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: editButton
|
||||
buttonSize: 36
|
||||
@@ -136,6 +155,7 @@ Rectangle {
|
||||
iconColor: Theme.buttonText
|
||||
tooltipText: I18n.tr("Set custom name")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: !root.isHidden
|
||||
onClicked: {
|
||||
root.editRequested(root.deviceNode);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ Item {
|
||||
text: I18n.tr("Follow Monitor Focus")
|
||||
description: I18n.tr("Show workspaces of the currently focused monitor")
|
||||
checked: SettingsData.workspaceFollowFocus
|
||||
visible: CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll
|
||||
visible: CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle
|
||||
onToggled: checked => SettingsData.set("workspaceFollowFocus", checked)
|
||||
}
|
||||
|
||||
@@ -296,12 +296,12 @@ Item {
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.15
|
||||
visible: CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll
|
||||
visible: CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle
|
||||
}
|
||||
|
||||
SettingsButtonGroupRow {
|
||||
text: I18n.tr("Urgent Color")
|
||||
visible: CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll
|
||||
visible: CompositorService.isNiri || CompositorService.isHyprland || CompositorService.isDwl || CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle
|
||||
model: ["err", "pri", "sec", "s", "sc"]
|
||||
buttonHeight: 22
|
||||
minButtonWidth: 36
|
||||
|
||||
@@ -66,7 +66,7 @@ Singleton {
|
||||
return Hyprland.focusedWorkspace.monitor.name;
|
||||
if (CompositorService.isNiri && NiriService.currentOutput)
|
||||
return NiriService.currentOutput;
|
||||
if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
const focusedWs = I3.workspaces?.values?.find(ws => ws.focused === true);
|
||||
return focusedWs?.monitor?.name || "";
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import qs.Common
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property string currentVersion: "1.2"
|
||||
readonly property bool changelogEnabled: false
|
||||
readonly property string currentVersion: "1.4"
|
||||
readonly property bool changelogEnabled: true
|
||||
|
||||
readonly property string configDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation)) + "/DankMaterialShell"
|
||||
readonly property string changelogMarkerPath: configDir + "/.changelog-" + currentVersion
|
||||
|
||||
@@ -16,6 +16,7 @@ Singleton {
|
||||
property bool isDwl: false
|
||||
property bool isSway: false
|
||||
property bool isScroll: false
|
||||
property bool isMiracle: false
|
||||
property bool isLabwc: false
|
||||
property string compositor: "unknown"
|
||||
readonly property bool useHyprlandFocusGrab: isHyprland && Quickshell.env("DMS_HYPRLAND_EXCLUSIVE_FOCUS") !== "1"
|
||||
@@ -24,6 +25,7 @@ Singleton {
|
||||
readonly property string niriSocket: Quickshell.env("NIRI_SOCKET")
|
||||
readonly property string swaySocket: Quickshell.env("SWAYSOCK")
|
||||
readonly property string scrollSocket: Quickshell.env("SWAYSOCK")
|
||||
readonly property string miracleSocket: Quickshell.env("MIRACLESOCK")
|
||||
readonly property string labwcPid: Quickshell.env("LABWC_PID")
|
||||
property bool useNiriSorting: isNiri && NiriService
|
||||
|
||||
@@ -74,7 +76,7 @@ Singleton {
|
||||
screenName = Hyprland.focusedWorkspace.monitor.name;
|
||||
else if (isNiri && NiriService.currentOutput)
|
||||
screenName = NiriService.currentOutput;
|
||||
else if (isSway || isScroll) {
|
||||
else if (isSway || isScroll || isMiracle) {
|
||||
const focusedWs = I3.workspaces?.values?.find(ws => ws.focused === true);
|
||||
screenName = focusedWs?.monitor?.name || "";
|
||||
} else if (isDwl && DwlService.activeOutput)
|
||||
@@ -443,12 +445,13 @@ Singleton {
|
||||
}
|
||||
|
||||
function detectCompositor() {
|
||||
if (hyprlandSignature && hyprlandSignature.length > 0 && !niriSocket && !swaySocket && !scrollSocket && !labwcPid) {
|
||||
if (hyprlandSignature && hyprlandSignature.length > 0 && !niriSocket && !swaySocket && !scrollSocket && !miracleSocket && !labwcPid) {
|
||||
isHyprland = true;
|
||||
isNiri = false;
|
||||
isDwl = false;
|
||||
isSway = false;
|
||||
isScroll = false;
|
||||
isMiracle = false;
|
||||
isLabwc = false;
|
||||
compositor = "hyprland";
|
||||
console.info("CompositorService: Detected Hyprland");
|
||||
@@ -463,6 +466,7 @@ Singleton {
|
||||
isDwl = false;
|
||||
isSway = false;
|
||||
isScroll = false;
|
||||
isMiracle = false;
|
||||
isLabwc = false;
|
||||
compositor = "niri";
|
||||
console.info("CompositorService: Detected Niri with socket:", niriSocket);
|
||||
@@ -472,7 +476,7 @@ Singleton {
|
||||
return;
|
||||
}
|
||||
|
||||
if (swaySocket && swaySocket.length > 0 && !scrollSocket && scrollSocket.length == 0) {
|
||||
if (swaySocket && swaySocket.length > 0 && !scrollSocket && scrollSocket.length == 0 && !miracleSocket) {
|
||||
Proc.runCommand("swaySocketCheck", ["test", "-S", swaySocket], (output, exitCode) => {
|
||||
if (exitCode === 0) {
|
||||
isNiri = false;
|
||||
@@ -480,6 +484,7 @@ Singleton {
|
||||
isDwl = false;
|
||||
isSway = true;
|
||||
isScroll = false;
|
||||
isMiracle = false;
|
||||
isLabwc = false;
|
||||
compositor = "sway";
|
||||
console.info("CompositorService: Detected Sway with socket:", swaySocket);
|
||||
@@ -488,7 +493,24 @@ Singleton {
|
||||
return;
|
||||
}
|
||||
|
||||
if (scrollSocket && scrollSocket.length > 0) {
|
||||
if (miracleSocket && miracleSocket.length > 0) {
|
||||
Proc.runCommand("miracleSocketCheck", ["test", "-S", miracleSocket], (output, exitCode) => {
|
||||
if (exitCode === 0) {
|
||||
isNiri = false;
|
||||
isHyprland = false;
|
||||
isDwl = false;
|
||||
isSway = false;
|
||||
isScroll = false;
|
||||
isMiracle = true;
|
||||
isLabwc = false;
|
||||
compositor = "miracle";
|
||||
console.info("CompositorService: Detected Miracle WM with socket:", miracleSocket);
|
||||
}
|
||||
}, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (scrollSocket && scrollSocket.length > 0 && !miracleSocket) {
|
||||
Proc.runCommand("scrollSocketCheck", ["test", "-S", scrollSocket], (output, exitCode) => {
|
||||
if (exitCode === 0) {
|
||||
isNiri = false;
|
||||
@@ -496,6 +518,7 @@ Singleton {
|
||||
isDwl = false;
|
||||
isSway = false;
|
||||
isScroll = true;
|
||||
isMiracle = false;
|
||||
isLabwc = false;
|
||||
compositor = "scroll";
|
||||
console.info("CompositorService: Detected Scroll with socket:", scrollSocket);
|
||||
@@ -510,6 +533,7 @@ Singleton {
|
||||
isDwl = false;
|
||||
isSway = false;
|
||||
isScroll = false;
|
||||
isMiracle = false;
|
||||
isLabwc = true;
|
||||
compositor = "labwc";
|
||||
console.info("CompositorService: Detected LabWC with PID:", labwcPid);
|
||||
@@ -524,6 +548,7 @@ Singleton {
|
||||
isDwl = false;
|
||||
isSway = false;
|
||||
isScroll = false;
|
||||
isMiracle = false;
|
||||
isLabwc = false;
|
||||
compositor = "unknown";
|
||||
console.warn("CompositorService: No compositor detected");
|
||||
@@ -546,6 +571,7 @@ Singleton {
|
||||
isDwl = true;
|
||||
isSway = false;
|
||||
isScroll = false;
|
||||
isMiracle = false;
|
||||
isLabwc = false;
|
||||
compositor = "dwl";
|
||||
console.info("CompositorService: Detected DWL via DMS capability");
|
||||
@@ -559,7 +585,7 @@ Singleton {
|
||||
return Hyprland.dispatch("dpms off");
|
||||
if (isDwl)
|
||||
return _dwlPowerOffMonitors();
|
||||
if (isSway || isScroll) {
|
||||
if (isSway || isScroll || isMiracle) {
|
||||
try {
|
||||
I3.dispatch("output * dpms off");
|
||||
} catch (_) {}
|
||||
@@ -578,7 +604,7 @@ Singleton {
|
||||
return Hyprland.dispatch("dpms on");
|
||||
if (isDwl)
|
||||
return _dwlPowerOnMonitors();
|
||||
if (isSway || isScroll) {
|
||||
if (isSway || isScroll || isMiracle) {
|
||||
try {
|
||||
I3.dispatch("output * dpms on");
|
||||
} catch (_) {}
|
||||
|
||||
@@ -395,6 +395,7 @@ Singleton {
|
||||
"memoryKB": proc.memoryKB || proc.pssKB || 0,
|
||||
"command": proc.command || "",
|
||||
"fullCommand": proc.fullCommand || "",
|
||||
"username": proc.username || "",
|
||||
"displayName": (proc.command && proc.command.length > 15) ? proc.command.substring(0, 15) + "..." : (proc.command || "")
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,83 +11,83 @@ Singleton {
|
||||
property var groups: []
|
||||
property var _cachedWorkspaces: ({})
|
||||
|
||||
signal stateChanged()
|
||||
signal stateChanged
|
||||
|
||||
Connections {
|
||||
target: DMSService
|
||||
function onCapabilitiesReceived() {
|
||||
checkCapabilities()
|
||||
checkCapabilities();
|
||||
}
|
||||
function onConnectionStateChanged() {
|
||||
if (DMSService.isConnected) {
|
||||
checkCapabilities()
|
||||
checkCapabilities();
|
||||
} else {
|
||||
extWorkspaceAvailable = false
|
||||
extWorkspaceAvailable = false;
|
||||
}
|
||||
}
|
||||
function onExtWorkspaceStateUpdate(data) {
|
||||
if (extWorkspaceAvailable) {
|
||||
handleStateUpdate(data)
|
||||
handleStateUpdate(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (DMSService.dmsAvailable) {
|
||||
checkCapabilities()
|
||||
checkCapabilities();
|
||||
}
|
||||
}
|
||||
|
||||
function checkCapabilities() {
|
||||
if (!DMSService.capabilities || !Array.isArray(DMSService.capabilities)) {
|
||||
extWorkspaceAvailable = false
|
||||
return
|
||||
extWorkspaceAvailable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const hasExtWorkspace = DMSService.capabilities.includes("extworkspace")
|
||||
const hasExtWorkspace = DMSService.capabilities.includes("extworkspace");
|
||||
if (hasExtWorkspace && !extWorkspaceAvailable) {
|
||||
if (typeof CompositorService !== "undefined") {
|
||||
const useExtWorkspace = DMSService.forceExtWorkspace || (!CompositorService.isNiri && !CompositorService.isHyprland && !CompositorService.isDwl && !CompositorService.isSway && !CompositorService.isScroll)
|
||||
const useExtWorkspace = DMSService.forceExtWorkspace || (!CompositorService.isNiri && !CompositorService.isHyprland && !CompositorService.isDwl && !CompositorService.isSway && !CompositorService.isScroll && !CompositorService.isMiracle);
|
||||
if (!useExtWorkspace) {
|
||||
console.info("ExtWorkspaceService: ext-workspace available but compositor has native support")
|
||||
extWorkspaceAvailable = false
|
||||
return
|
||||
console.info("ExtWorkspaceService: ext-workspace available but compositor has native support");
|
||||
extWorkspaceAvailable = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
extWorkspaceAvailable = true
|
||||
console.info("ExtWorkspaceService: ext-workspace capability detected")
|
||||
DMSService.addSubscription("extworkspace")
|
||||
requestState()
|
||||
extWorkspaceAvailable = true;
|
||||
console.info("ExtWorkspaceService: ext-workspace capability detected");
|
||||
DMSService.addSubscription("extworkspace");
|
||||
requestState();
|
||||
} else if (!hasExtWorkspace) {
|
||||
extWorkspaceAvailable = false
|
||||
extWorkspaceAvailable = false;
|
||||
}
|
||||
}
|
||||
|
||||
function requestState() {
|
||||
if (!DMSService.isConnected || !extWorkspaceAvailable) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
DMSService.sendRequest("extworkspace.getState", null, response => {
|
||||
if (response.result) {
|
||||
handleStateUpdate(response.result)
|
||||
handleStateUpdate(response.result);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function handleStateUpdate(state) {
|
||||
groups = state.groups || []
|
||||
groups = state.groups || [];
|
||||
if (groups.length === 0) {
|
||||
console.warn("ExtWorkspaceService: Received empty workspace groups from backend")
|
||||
console.warn("ExtWorkspaceService: Received empty workspace groups from backend");
|
||||
} else {
|
||||
console.log("ExtWorkspaceService: Updated with", groups.length, "workspace groups")
|
||||
console.log("ExtWorkspaceService: Updated with", groups.length, "workspace groups");
|
||||
}
|
||||
stateChanged()
|
||||
stateChanged();
|
||||
}
|
||||
|
||||
function activateWorkspace(workspaceID, groupID = "") {
|
||||
if (!DMSService.isConnected || !extWorkspaceAvailable) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
DMSService.sendRequest("extworkspace.activateWorkspace", {
|
||||
@@ -95,14 +95,14 @@ Singleton {
|
||||
"groupID": groupID
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("ExtWorkspaceService: activateWorkspace error:", response.error)
|
||||
console.warn("ExtWorkspaceService: activateWorkspace error:", response.error);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function deactivateWorkspace(workspaceID, groupID = "") {
|
||||
if (!DMSService.isConnected || !extWorkspaceAvailable) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
DMSService.sendRequest("extworkspace.deactivateWorkspace", {
|
||||
@@ -110,14 +110,14 @@ Singleton {
|
||||
"groupID": groupID
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("ExtWorkspaceService: deactivateWorkspace error:", response.error)
|
||||
console.warn("ExtWorkspaceService: deactivateWorkspace error:", response.error);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function removeWorkspace(workspaceID, groupID = "") {
|
||||
if (!DMSService.isConnected || !extWorkspaceAvailable) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
DMSService.sendRequest("extworkspace.removeWorkspace", {
|
||||
@@ -125,14 +125,14 @@ Singleton {
|
||||
"groupID": groupID
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("ExtWorkspaceService: removeWorkspace error:", response.error)
|
||||
console.warn("ExtWorkspaceService: removeWorkspace error:", response.error);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function createWorkspace(groupID, name) {
|
||||
if (!DMSService.isConnected || !extWorkspaceAvailable) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
DMSService.sendRequest("extworkspace.createWorkspace", {
|
||||
@@ -140,134 +140,138 @@ Singleton {
|
||||
"name": name
|
||||
}, response => {
|
||||
if (response.error) {
|
||||
console.warn("ExtWorkspaceService: createWorkspace error:", response.error)
|
||||
console.warn("ExtWorkspaceService: createWorkspace error:", response.error);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function getGroupForOutput(outputName) {
|
||||
for (const group of groups) {
|
||||
if (group.outputs && group.outputs.includes(outputName)) {
|
||||
return group
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
function getWorkspacesForOutput(outputName) {
|
||||
const group = getGroupForOutput(outputName)
|
||||
return group ? (group.workspaces || []) : []
|
||||
const group = getGroupForOutput(outputName);
|
||||
return group ? (group.workspaces || []) : [];
|
||||
}
|
||||
|
||||
function getActiveWorkspaces() {
|
||||
const active = []
|
||||
const active = [];
|
||||
for (const group of groups) {
|
||||
if (!group.workspaces) continue
|
||||
if (!group.workspaces)
|
||||
continue;
|
||||
for (const ws of group.workspaces) {
|
||||
if (ws.active) {
|
||||
active.push({
|
||||
workspace: ws,
|
||||
group: group,
|
||||
outputs: group.outputs || []
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return active
|
||||
return active;
|
||||
}
|
||||
|
||||
function getActiveWorkspaceForOutput(outputName) {
|
||||
const group = getGroupForOutput(outputName)
|
||||
if (!group || !group.workspaces) return null
|
||||
const group = getGroupForOutput(outputName);
|
||||
if (!group || !group.workspaces)
|
||||
return null;
|
||||
|
||||
for (const ws of group.workspaces) {
|
||||
if (ws.active) {
|
||||
return ws
|
||||
return ws;
|
||||
}
|
||||
}
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
function getVisibleWorkspaces(outputName) {
|
||||
const workspaces = getWorkspacesForOutput(outputName)
|
||||
let visible = workspaces.filter(ws => !ws.hidden)
|
||||
const workspaces = getWorkspacesForOutput(outputName);
|
||||
let visible = workspaces.filter(ws => !ws.hidden);
|
||||
|
||||
const hasValidCoordinates = visible.some(ws => ws.coordinates && ws.coordinates.length > 0)
|
||||
const hasValidCoordinates = visible.some(ws => ws.coordinates && ws.coordinates.length > 0);
|
||||
if (hasValidCoordinates) {
|
||||
visible = visible.sort((a, b) => {
|
||||
const coordsA = a.coordinates || [0, 0]
|
||||
const coordsB = b.coordinates || [0, 0]
|
||||
if (coordsA[0] !== coordsB[0]) return coordsA[0] - coordsB[0]
|
||||
return coordsA[1] - coordsB[1]
|
||||
})
|
||||
const coordsA = a.coordinates || [0, 0];
|
||||
const coordsB = b.coordinates || [0, 0];
|
||||
if (coordsA[0] !== coordsB[0])
|
||||
return coordsA[0] - coordsB[0];
|
||||
return coordsA[1] - coordsB[1];
|
||||
});
|
||||
}
|
||||
|
||||
const cacheKey = outputName
|
||||
const cacheKey = outputName;
|
||||
if (!_cachedWorkspaces[cacheKey]) {
|
||||
_cachedWorkspaces[cacheKey] = {
|
||||
workspaces: [],
|
||||
lastNames: []
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const cache = _cachedWorkspaces[cacheKey]
|
||||
const currentNames = visible.map(ws => ws.name || ws.id)
|
||||
const namesChanged = JSON.stringify(cache.lastNames) !== JSON.stringify(currentNames)
|
||||
const cache = _cachedWorkspaces[cacheKey];
|
||||
const currentNames = visible.map(ws => ws.name || ws.id);
|
||||
const namesChanged = JSON.stringify(cache.lastNames) !== JSON.stringify(currentNames);
|
||||
|
||||
if (namesChanged || cache.workspaces.length !== visible.length) {
|
||||
cache.workspaces = visible.map(ws => ({
|
||||
id: ws.id,
|
||||
name: ws.name,
|
||||
coordinates: ws.coordinates,
|
||||
state: ws.state,
|
||||
active: ws.active,
|
||||
urgent: ws.urgent,
|
||||
hidden: ws.hidden
|
||||
}))
|
||||
cache.lastNames = currentNames
|
||||
return cache.workspaces
|
||||
id: ws.id,
|
||||
name: ws.name,
|
||||
coordinates: ws.coordinates,
|
||||
state: ws.state,
|
||||
active: ws.active,
|
||||
urgent: ws.urgent,
|
||||
hidden: ws.hidden
|
||||
}));
|
||||
cache.lastNames = currentNames;
|
||||
return cache.workspaces;
|
||||
}
|
||||
|
||||
for (let i = 0; i < visible.length; i++) {
|
||||
const src = visible[i]
|
||||
const dst = cache.workspaces[i]
|
||||
dst.id = src.id
|
||||
dst.name = src.name
|
||||
dst.coordinates = src.coordinates
|
||||
dst.state = src.state
|
||||
dst.active = src.active
|
||||
dst.urgent = src.urgent
|
||||
dst.hidden = src.hidden
|
||||
const src = visible[i];
|
||||
const dst = cache.workspaces[i];
|
||||
dst.id = src.id;
|
||||
dst.name = src.name;
|
||||
dst.coordinates = src.coordinates;
|
||||
dst.state = src.state;
|
||||
dst.active = src.active;
|
||||
dst.urgent = src.urgent;
|
||||
dst.hidden = src.hidden;
|
||||
}
|
||||
|
||||
return cache.workspaces
|
||||
return cache.workspaces;
|
||||
}
|
||||
|
||||
function getUrgentWorkspaces() {
|
||||
const urgent = []
|
||||
const urgent = [];
|
||||
for (const group of groups) {
|
||||
if (!group.workspaces) continue
|
||||
if (!group.workspaces)
|
||||
continue;
|
||||
for (const ws of group.workspaces) {
|
||||
if (ws.urgent) {
|
||||
urgent.push({
|
||||
workspace: ws,
|
||||
group: group,
|
||||
outputs: group.outputs || []
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return urgent
|
||||
return urgent;
|
||||
}
|
||||
|
||||
function switchToWorkspace(outputName, workspaceName) {
|
||||
const workspaces = getWorkspacesForOutput(outputName)
|
||||
const workspaces = getWorkspacesForOutput(outputName);
|
||||
for (const ws of workspaces) {
|
||||
if (ws.name === workspaceName || ws.id === workspaceName) {
|
||||
activateWorkspace(ws.name || ws.id)
|
||||
return
|
||||
activateWorkspace(ws.name || ws.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.warn("ExtWorkspaceService: workspace not found:", workspaceName)
|
||||
console.warn("ExtWorkspaceService: workspace not found:", workspaceName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ Singleton {
|
||||
|
||||
property list<NotifWrapper> notificationQueue: []
|
||||
property list<NotifWrapper> visibleNotifications: []
|
||||
property int maxVisibleNotifications: 3
|
||||
property int maxVisibleNotifications: 4
|
||||
property bool addGateBusy: false
|
||||
property int enterAnimMs: 400
|
||||
property int seqCounter: 0
|
||||
@@ -158,10 +158,7 @@ Singleton {
|
||||
continue;
|
||||
const urg = typeof item.urgency === "number" ? item.urgency : 1;
|
||||
const body = item.body || "";
|
||||
let htmlBody = item.htmlBody || "";
|
||||
if (!htmlBody && body) {
|
||||
htmlBody = (body.includes('<') && body.includes('>')) ? body : Markdown2Html.markdownToHtml(body);
|
||||
}
|
||||
const htmlBody = item.htmlBody || _resolveHtmlBody(body);
|
||||
loaded.push({
|
||||
id: item.id || "",
|
||||
summary: item.summary || "",
|
||||
@@ -251,9 +248,15 @@ Singleton {
|
||||
const timeStr = SettingsData.use24HourClock ? date.toLocaleTimeString(Qt.locale(), "HH:mm") : date.toLocaleTimeString(Qt.locale(), "h:mm AP");
|
||||
if (daysDiff === 0)
|
||||
return timeStr;
|
||||
if (daysDiff === 1)
|
||||
return I18n.tr("yesterday") + ", " + timeStr;
|
||||
return I18n.tr("%1 days ago").arg(daysDiff);
|
||||
try {
|
||||
const localeName = (typeof Qt !== "undefined" && Qt.locale) ? Qt.locale().name : "en-US";
|
||||
const weekday = date.toLocaleDateString(localeName, {
|
||||
weekday: "long"
|
||||
});
|
||||
return weekday + ", " + timeStr;
|
||||
} catch (e) {
|
||||
return timeStr;
|
||||
}
|
||||
}
|
||||
|
||||
function _nowSec() {
|
||||
@@ -484,7 +487,7 @@ Singleton {
|
||||
|
||||
Timer {
|
||||
id: addGate
|
||||
interval: enterAnimMs + 50
|
||||
interval: 80
|
||||
running: false
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
@@ -688,11 +691,15 @@ Singleton {
|
||||
return formatTime(time);
|
||||
}
|
||||
|
||||
if (daysDiff === 1) {
|
||||
return `yesterday, ${formatTime(time)}`;
|
||||
try {
|
||||
const localeName = (typeof Qt !== "undefined" && Qt.locale) ? Qt.locale().name : "en-US";
|
||||
const weekday = time.toLocaleDateString(localeName, {
|
||||
weekday: "long"
|
||||
});
|
||||
return `${weekday}, ${formatTime(time)}`;
|
||||
} catch (e) {
|
||||
return formatTime(time);
|
||||
}
|
||||
|
||||
return `${daysDiff} days ago`;
|
||||
}
|
||||
|
||||
function formatTime(date) {
|
||||
@@ -715,13 +722,7 @@ Singleton {
|
||||
required property Notification notification
|
||||
readonly property string summary: notification?.summary ?? ""
|
||||
readonly property string body: notification?.body ?? ""
|
||||
readonly property string htmlBody: {
|
||||
if (!body)
|
||||
return "";
|
||||
if (body.includes('<') && body.includes('>'))
|
||||
return body;
|
||||
return Markdown2Html.markdownToHtml(body);
|
||||
}
|
||||
readonly property string htmlBody: root._resolveHtmlBody(body)
|
||||
readonly property string appIcon: notification?.appIcon ?? ""
|
||||
readonly property string appName: {
|
||||
if (!notification)
|
||||
@@ -837,39 +838,54 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function processQueue() {
|
||||
if (addGateBusy) {
|
||||
return;
|
||||
}
|
||||
if (popupsDisabled) {
|
||||
return;
|
||||
}
|
||||
if (SessionData.doNotDisturb) {
|
||||
return;
|
||||
}
|
||||
if (notificationQueue.length === 0) {
|
||||
return;
|
||||
}
|
||||
property bool _processingQueue: false
|
||||
|
||||
const activePopupCount = visibleNotifications.filter(n => n && n.popup).length;
|
||||
if (activePopupCount >= 4) {
|
||||
function processQueue() {
|
||||
if (addGateBusy || _processingQueue)
|
||||
return;
|
||||
}
|
||||
if (popupsDisabled)
|
||||
return;
|
||||
if (SessionData.doNotDisturb)
|
||||
return;
|
||||
if (notificationQueue.length === 0)
|
||||
return;
|
||||
|
||||
_processingQueue = true;
|
||||
|
||||
const next = notificationQueue.shift();
|
||||
if (!next)
|
||||
if (!next) {
|
||||
_processingQueue = false;
|
||||
return;
|
||||
}
|
||||
|
||||
next.seq = ++seqCounter;
|
||||
visibleNotifications = [...visibleNotifications, next];
|
||||
|
||||
const activePopups = visibleNotifications.filter(n => n && n.popup);
|
||||
let evicted = null;
|
||||
if (activePopups.length >= maxVisibleNotifications) {
|
||||
const unhovered = activePopups.filter(n => n.timer?.running);
|
||||
const pool = unhovered.length > 0 ? unhovered : activePopups;
|
||||
evicted = pool.reduce((min, n) => (n.seq < min.seq) ? n : min, pool[0]);
|
||||
if (evicted)
|
||||
evicted.removedByLimit = true;
|
||||
}
|
||||
|
||||
if (evicted) {
|
||||
visibleNotifications = [...visibleNotifications.filter(n => n !== evicted), next];
|
||||
} else {
|
||||
visibleNotifications = [...visibleNotifications, next];
|
||||
}
|
||||
|
||||
if (evicted)
|
||||
evicted.popup = false;
|
||||
next.popup = true;
|
||||
|
||||
if (next.timer.interval > 0) {
|
||||
if (next.timer.interval > 0)
|
||||
next.timer.start();
|
||||
}
|
||||
|
||||
addGateBusy = true;
|
||||
addGate.restart();
|
||||
_processingQueue = false;
|
||||
}
|
||||
|
||||
function removeFromVisibleNotifications(wrapper) {
|
||||
@@ -890,6 +906,96 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function _decodeEntities(s) {
|
||||
s = s.replace(/&#(\d+);/g, (_, n) => String.fromCodePoint(parseInt(n, 10)));
|
||||
s = s.replace(/&#x([0-9a-fA-F]+);/g, (_, n) => String.fromCodePoint(parseInt(n, 16)));
|
||||
return s.replace(/&([a-zA-Z][a-zA-Z0-9]*);/g, (match, name) => {
|
||||
switch (name) {
|
||||
case "amp":
|
||||
return "&";
|
||||
case "lt":
|
||||
return "<";
|
||||
case "gt":
|
||||
return ">";
|
||||
case "quot":
|
||||
return "\"";
|
||||
case "apos":
|
||||
return "'";
|
||||
case "nbsp":
|
||||
return "\u00A0";
|
||||
case "ndash":
|
||||
return "\u2013";
|
||||
case "mdash":
|
||||
return "\u2014";
|
||||
case "lsquo":
|
||||
return "\u2018";
|
||||
case "rsquo":
|
||||
return "\u2019";
|
||||
case "ldquo":
|
||||
return "\u201C";
|
||||
case "rdquo":
|
||||
return "\u201D";
|
||||
case "bull":
|
||||
return "\u2022";
|
||||
case "hellip":
|
||||
return "\u2026";
|
||||
case "trade":
|
||||
return "\u2122";
|
||||
case "copy":
|
||||
return "\u00A9";
|
||||
case "reg":
|
||||
return "\u00AE";
|
||||
case "deg":
|
||||
return "\u00B0";
|
||||
case "plusmn":
|
||||
return "\u00B1";
|
||||
case "times":
|
||||
return "\u00D7";
|
||||
case "divide":
|
||||
return "\u00F7";
|
||||
case "micro":
|
||||
return "\u00B5";
|
||||
case "middot":
|
||||
return "\u00B7";
|
||||
case "laquo":
|
||||
return "\u00AB";
|
||||
case "raquo":
|
||||
return "\u00BB";
|
||||
case "larr":
|
||||
return "\u2190";
|
||||
case "rarr":
|
||||
return "\u2192";
|
||||
case "uarr":
|
||||
return "\u2191";
|
||||
case "darr":
|
||||
return "\u2193";
|
||||
default:
|
||||
return match;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function _resolveHtmlBody(body) {
|
||||
if (!body)
|
||||
return "";
|
||||
if (/<\/?[a-z][\s\S]*>/i.test(body))
|
||||
return body;
|
||||
|
||||
// Decode percent-encoded URLs (e.g. https%3A%2F%2F → https://)
|
||||
body = body.replace(/\bhttps?%3A%2F%2F[^\s]+/gi, match => {
|
||||
try { return decodeURIComponent(match); }
|
||||
catch (e) { return match; }
|
||||
});
|
||||
|
||||
if (/&(#\d+|#x[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]+);/.test(body)) {
|
||||
const decoded = _decodeEntities(body);
|
||||
if (/<\/?[a-z][\s\S]*>/i.test(decoded))
|
||||
return decoded;
|
||||
return Markdown2Html.markdownToHtml(decoded);
|
||||
}
|
||||
return Markdown2Html.markdownToHtml(body);
|
||||
}
|
||||
|
||||
function getGroupKey(wrapper) {
|
||||
if (wrapper.desktopEntry && wrapper.desktopEntry !== "") {
|
||||
return wrapper.desktopEntry.toLowerCase();
|
||||
|
||||
@@ -314,7 +314,7 @@ Singleton {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CompositorService.isSway || CompositorService.isScroll) {
|
||||
if (CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) {
|
||||
try {
|
||||
I3.dispatch("exit");
|
||||
} catch (_) {}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user