mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-03 03:59:11 -04:00
Compare commits
129 Commits
v1.5.3
..
qml-common
| Author | SHA1 | Date | |
|---|---|---|---|
| 990d86d481 | |||
| 526cb157fd | |||
| 92ba96d9f9 | |||
| 5dfd875b9e | |||
| 00b22df802 | |||
| b22b1bef9b | |||
| 5cae48a85d | |||
| 4200270b55 | |||
| c2c180d304 | |||
| 3938e60ce4 | |||
| 2986e354e8 | |||
| bf12665adb | |||
| f8fe16738e | |||
| 3c688cfbd3 | |||
| 92ba2bb57d | |||
| 504c132f78 | |||
| bdaa6bcc9d | |||
| a50bb2cab3 | |||
| b17a90a412 | |||
| 0ffec5011b | |||
| adbbd9b112 | |||
| 95e1d6b72e | |||
| 4cb09dcc1b | |||
| ed44d02202 | |||
| 4352f49ae3 | |||
| 9ddea82063 | |||
| 3c0f2cbc48 | |||
| 6c45413d7a | |||
| 149e1e64b1 | |||
| 5589cfb783 | |||
| ff71502083 | |||
| 1ef5371c3b | |||
| 3951cd6b18 | |||
| 9686f29246 | |||
| 6d206c9521 | |||
| 48e36ae146 | |||
| 7c24e85c19 | |||
| fe1a783ec2 | |||
| 358496134c | |||
| dc924618fb | |||
| fb2dbced08 | |||
| cdaedad969 | |||
| bf408f8d00 | |||
| b169fe0d77 | |||
| 9b67cedaa1 | |||
| 2edf70a144 | |||
| 72a71cacba | |||
| 0440e40a82 | |||
| ec27d4643c | |||
| f18d36f6c2 | |||
| 3254cc6a1e | |||
| 4af3225f21 | |||
| 3c5245914f | |||
| 89814a2c65 | |||
| 5d2093e54a | |||
| 3cd52ca327 | |||
| 5b41d699fa | |||
| 544599bf1c | |||
| 296b3a3d7e | |||
| 729a990fa7 | |||
| c3fa7b2e1d | |||
| 2c5a1a2804 | |||
| 1973526c4e | |||
| bba5502960 | |||
| 52740290b2 | |||
| 27703575bc | |||
| e6504add7b | |||
| f1e9121295 | |||
| 9ff751b82a | |||
| 21eaaef056 | |||
| bb0be2b215 | |||
| 25847c3f03 | |||
| 7b5c25c50f | |||
| 7535b70fa6 | |||
| e3034e4e94 | |||
| 3da19e5c15 | |||
| ca89e12963 | |||
| 4fb6995796 | |||
| 3f5a54aa88 | |||
| d379d251b9 | |||
| 7ab0e01573 | |||
| 2cb48aaf6b | |||
| e4657aa5f9 | |||
| 197d17ac4e | |||
| 31ea83584b | |||
| ea66b136ba | |||
| 06c0ea2afb | |||
| f4f47c0bc5 | |||
| 8a0ed8a50f | |||
| 63eea01243 | |||
| f590a2965a | |||
| 4ab03deded | |||
| 846d07d86a | |||
| 55d88d8dfb | |||
| a803f96f41 | |||
| da7cc5648b | |||
| 75443758f9 | |||
| eaecff93a4 | |||
| 6e7c20c59c | |||
| 406dcfe110 | |||
| e2b3a2e3ca | |||
| 71ab752e1b | |||
| 204ecd0461 | |||
| 0fdfac366e | |||
| 52123458c7 | |||
| 26b2955cf3 | |||
| d82d86df5c | |||
| c445597f83 | |||
| 6a58adfb29 | |||
| 05feb211ba | |||
| a3b2167e58 | |||
| 0b69feaa1a | |||
| 494144a7c7 | |||
| 2a2c1ca9e6 | |||
| 56b7ecb008 | |||
| 867102b82c | |||
| 4bdb7d17b2 | |||
| c44ffae751 | |||
| ce1595d62d | |||
| 45f6232e32 | |||
| 9cf2ca7196 | |||
| c0eeed4e89 | |||
| d0a4c1c56e | |||
| cb0dc9c68d | |||
| 0439d017b9 | |||
| 8008238ca0 | |||
| a095d0ed90 | |||
| a48cce59d4 | |||
| 4c806f83f1 |
@@ -0,0 +1,56 @@
|
|||||||
|
name: Sync flake.lock to dank-qml-common
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- "dank-qml-common"
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create GitHub App token
|
||||||
|
id: app_token
|
||||||
|
uses: actions/create-github-app-token@v1
|
||||||
|
with:
|
||||||
|
app-id: ${{ secrets.APP_ID }}
|
||||||
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ steps.app_token.outputs.token }}
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
- name: Point flake input at the submodule commit
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
submodule_rev=$(git ls-tree HEAD dank-qml-common --object-only)
|
||||||
|
flake_rev=$(python3 -c "import json; print(json.load(open('flake.lock'))['nodes']['dank-qml-common']['locked']['rev'])")
|
||||||
|
[ "$submodule_rev" = "$flake_rev" ] && { echo "flake.lock already matches $submodule_rev"; exit 0; }
|
||||||
|
nix flake lock --override-input dank-qml-common "github:AvengeMedia/dank-qml-common/$submodule_rev"
|
||||||
|
|
||||||
|
- name: Commit and push flake.lock update
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.app_token.outputs.token }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if git diff --quiet flake.lock; then
|
||||||
|
echo "No changes to flake.lock"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
git config user.name "dms-ci[bot]"
|
||||||
|
git config user.email "dms-ci[bot]@users.noreply.github.com"
|
||||||
|
git add flake.lock
|
||||||
|
git commit -m "nix: sync flake.lock to dank-qml-common submodule"
|
||||||
|
git pull --rebase origin ${{ github.ref_name }}
|
||||||
|
git push https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git HEAD:${{ github.ref_name }}
|
||||||
@@ -27,6 +27,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install flatpak
|
- name: Install flatpak
|
||||||
run: sudo apt update && sudo apt install -y flatpak
|
run: sudo apt update && sudo apt install -y flatpak
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install flatpak
|
- name: Install flatpak
|
||||||
run: sudo apt update && sudo apt install -y flatpak
|
run: sudo apt update && sudo apt install -y flatpak
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
ref: ${{ inputs.tag }}
|
ref: ${{ inputs.tag }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v6
|
||||||
@@ -191,11 +192,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
ref: ${{ inputs.tag }}
|
ref: ${{ inputs.tag }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Fetch updated tag after version bump
|
- name: Fetch updated tag after version bump
|
||||||
run: |
|
run: |
|
||||||
git fetch origin --force tag ${TAG}
|
git fetch origin --force tag ${TAG}
|
||||||
git checkout ${TAG}
|
git checkout ${TAG}
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v6
|
||||||
@@ -252,6 +255,7 @@ jobs:
|
|||||||
- **`dankinstall-arm64.gz`** - Installer binary for ARM64 systems
|
- **`dankinstall-arm64.gz`** - Installer binary for ARM64 systems
|
||||||
- **`dms-cli-<version>.tar.gz`** - Go source code with vendored modules (for distro packaging)
|
- **`dms-cli-<version>.tar.gz`** - Go source code with vendored modules (for distro packaging)
|
||||||
- **`dms-qml.tar.gz`** - QML source code only
|
- **`dms-qml.tar.gz`** - QML source code only
|
||||||
|
- **`dms-source.tar.gz`** - Full repository source with bundled DankCommon (for distro packaging)
|
||||||
|
|
||||||
### Checksums
|
### Checksums
|
||||||
- **`*.sha256`** - SHA256 checksums for verifying download integrity
|
- **`*.sha256`** - SHA256 checksums for verifying download integrity
|
||||||
@@ -299,6 +303,22 @@ jobs:
|
|||||||
# Copy completions
|
# Copy completions
|
||||||
cp _core_assets/completion.* _release_assets/ 2>/dev/null || true
|
cp _core_assets/completion.* _release_assets/ 2>/dev/null || true
|
||||||
|
|
||||||
|
# Replace the DankCommon symlink with real submodule content for packaging
|
||||||
|
rm quickshell/DankCommon
|
||||||
|
cp -r dank-qml-common/DankCommon quickshell/DankCommon
|
||||||
|
|
||||||
|
# Create full source tarball (GitHub tag archives never contain submodule content)
|
||||||
|
VERSION_NUM=${TAG#v}
|
||||||
|
tar --exclude='.git' \
|
||||||
|
--exclude='.github' \
|
||||||
|
--exclude='dank-qml-common' \
|
||||||
|
--exclude='_release_assets' \
|
||||||
|
--exclude='_core_assets' \
|
||||||
|
--exclude='RELEASE_BODY.md' \
|
||||||
|
--transform "s,^\.,DankMaterialShell-${VERSION_NUM},S" \
|
||||||
|
-czf _release_assets/dms-source.tar.gz .
|
||||||
|
(cd _release_assets && sha256sum dms-source.tar.gz > dms-source.tar.gz.sha256)
|
||||||
|
|
||||||
# Create QML source package (exclude build artifacts and git files)
|
# Create QML source package (exclude build artifacts and git files)
|
||||||
# Copy root LICENSE and CONTRIBUTING.md to quickshell/ for packaging
|
# Copy root LICENSE and CONTRIBUTING.md to quickshell/ for packaging
|
||||||
cp LICENSE CONTRIBUTING.md quickshell/
|
cp LICENSE CONTRIBUTING.md quickshell/
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ jobs:
|
|||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Check for updates
|
- name: Check for updates
|
||||||
id: check
|
id: check
|
||||||
@@ -199,6 +200,7 @@ jobs:
|
|||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Wait before OBS upload
|
- name: Wait before OBS upload
|
||||||
run: sleep 3
|
run: sleep 3
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ jobs:
|
|||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -94,6 +95,7 @@ jobs:
|
|||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@v6
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
ref: ${{ github.event.release.tag_name || (github.event.inputs.version && (startsWith(github.event.inputs.version, 'v') && github.event.inputs.version || format('v{0}', github.event.inputs.version))) || github.ref }}
|
ref: ${{ github.event.release.tag_name || (github.event.inputs.version && (startsWith(github.event.inputs.version, 'v') && github.event.inputs.version || format('v{0}', github.event.inputs.version))) || github.ref }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Record checked-out source commit
|
- name: Record checked-out source commit
|
||||||
run: echo "SOURCE_COMMIT=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
|
run: echo "SOURCE_COMMIT=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
|
||||||
@@ -225,7 +226,7 @@ jobs:
|
|||||||
if [ -n "$RELEASE_VER" ] && { [ "$BUILD_DMS" = "true" ] || [ "$BUILD_GREETER" = "true" ]; }; then
|
if [ -n "$RELEASE_VER" ] && { [ "$BUILD_DMS" = "true" ] || [ "$BUILD_GREETER" = "true" ]; }; then
|
||||||
echo "🔧 Updating stable templates for $ARCHIVE_TAG"
|
echo "🔧 Updating stable templates for $ARCHIVE_TAG"
|
||||||
TARBALL="$(mktemp)"
|
TARBALL="$(mktemp)"
|
||||||
curl -fsSL -o "$TARBALL" "https://github.com/${{ github.repository }}/archive/refs/tags/${ARCHIVE_TAG}.tar.gz"
|
curl -fsSL -o "$TARBALL" "https://github.com/${{ github.repository }}/releases/download/${ARCHIVE_TAG}/dms-source.tar.gz"
|
||||||
RELEASE_CHECKSUM="$(sha256sum "$TARBALL" | cut -d' ' -f1)"
|
RELEASE_CHECKSUM="$(sha256sum "$TARBALL" | cut -d' ' -f1)"
|
||||||
rm -f "$TARBALL"
|
rm -f "$TARBALL"
|
||||||
|
|
||||||
@@ -246,7 +247,7 @@ jobs:
|
|||||||
# into $wrksrc (create_wrksrc=yes handles the rest).
|
# into $wrksrc (create_wrksrc=yes handles the rest).
|
||||||
SRC_CACHE="hostdir/sources/dms-git-${GIT_VER}"
|
SRC_CACHE="hostdir/sources/dms-git-${GIT_VER}"
|
||||||
mkdir -p "$SRC_CACHE"
|
mkdir -p "$SRC_CACHE"
|
||||||
tar -czf "${SRC_CACHE}/dms-git-${GIT_VER}.tar.gz" \
|
tar -czhf "${SRC_CACHE}/dms-git-${GIT_VER}.tar.gz" \
|
||||||
--exclude=void-packages \
|
--exclude=void-packages \
|
||||||
--exclude=r2-repo \
|
--exclude=r2-repo \
|
||||||
--exclude=.git \
|
--exclude=.git \
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "dank-qml-common"]
|
||||||
|
path = dank-qml-common
|
||||||
|
url = https://github.com/AvengeMedia/dank-qml-common.git
|
||||||
@@ -36,6 +36,14 @@ repos:
|
|||||||
language: system
|
language: system
|
||||||
files: ^quickshell/(.*\.qml|translations/(term_freeze\.json|check_term_freeze\.py|extract_translations\.py))$
|
files: ^quickshell/(.*\.qml|translations/(term_freeze\.json|check_term_freeze\.py|extract_translations\.py))$
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: i18n-term-variants
|
||||||
|
name: i18n term variants (no case/punctuation duplicates)
|
||||||
|
entry: python3 quickshell/translations/check_term_variants.py
|
||||||
|
language: system
|
||||||
|
files: ^quickshell/(.*\.qml|translations/(check_term_variants\.py|extract_translations\.py))$
|
||||||
|
pass_filenames: false
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: no-console-in-qml
|
- id: no-console-in-qml
|
||||||
|
|||||||
@@ -6,6 +6,14 @@ To contribute fork this repository, make your changes, and open a pull request.
|
|||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
|
Clone with submodules — the shared widget library ([dank-qml-common](https://github.com/AvengeMedia/dank-qml-common)) is vendored at `dank-qml-common/` and symlinked into `quickshell/DankCommon`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone --recurse-submodules https://github.com/AvengeMedia/DankMaterialShell.git
|
||||||
|
# or, in an existing clone:
|
||||||
|
git submodule update --init
|
||||||
|
```
|
||||||
|
|
||||||
Install [prek](https://prek.j178.dev/) then activate pre-commit hooks:
|
Install [prek](https://prek.j178.dev/) then activate pre-commit hooks:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -28,6 +36,24 @@ This will provide:
|
|||||||
|
|
||||||
The dev shell automatically creates the `.qmlls.ini` file in the `quickshell/` directory.
|
The dev shell automatically creates the `.qmlls.ini` file in the `quickshell/` directory.
|
||||||
|
|
||||||
|
## Shared widgets (dank-qml-common)
|
||||||
|
|
||||||
|
Everything under `quickshell/DankCommon/` (core widgets, the file browser, scroll physics, bundled fonts) is shared across the DMS suite and lives in the `dank-qml-common` submodule. It is a normal git worktree:
|
||||||
|
|
||||||
|
1. Edit files under `dank-qml-common/` (or through the `quickshell/DankCommon` symlink — same files) and test in the running shell; hot reload works as usual. For isolated widget work, the library is its own runnable config with a gallery: `qs -c dank-qml-common`.
|
||||||
|
2. Commit and PR those changes in the `dank-qml-common` repo: `cd dank-qml-common && git switch -c my-change`, push, open the PR there.
|
||||||
|
3. Once merged, bump the pointer here: `make update-common` (updates the submodule and the nix flake input together), then commit alongside any DMS-side changes. If you only bump the submodule, CI syncs `flake.lock` to it automatically on master.
|
||||||
|
|
||||||
|
The submodule URL in `.gitmodules` is HTTPS so CI and anonymous clones keep working. To push over SSH instead of being prompted for credentials, add a push rewrite to your git config — fetches stay HTTPS, pushes use SSH:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git config --global url."git@github.com:AvengeMedia/".pushInsteadOf "https://github.com/AvengeMedia/"
|
||||||
|
```
|
||||||
|
|
||||||
|
Shared widgets read app-provided singletons (`Theme`, `SettingsData`, ...) through a documented contract — see the dank-qml-common README. If your change needs a new contract property, add it to the library's stub singletons in the same PR, then to `quickshell/Common/` here when you bump.
|
||||||
|
|
||||||
|
Files in `quickshell/Widgets/`, `quickshell/Common/`, and `quickshell/Modals/FileBrowser/` that moved to the library remain in place as thin wrappers, so `import qs.Widgets`, `qs.Common`, and `qs.Modals.FileBrowser` keep working for the shell and for plugins.
|
||||||
|
|
||||||
## VSCode Setup
|
## VSCode Setup
|
||||||
|
|
||||||
This is a monorepo, the easiest thing to do is to open an editor in either `quickshell`, `core`, or both depending on which part of the project you are working on.
|
This is a monorepo, the easiest thing to do is to open an editor in either `quickshell`, `core`, or both depending on which part of the project you are working on.
|
||||||
@@ -104,6 +130,8 @@ Text {
|
|||||||
|
|
||||||
Preferably, try to keep new terms to a minimum and re-use existing terms where possible. See `quickshell/translations/en.json` for the list of existing terms. (This isn't always possible obviously, but instead of using `Auto-connect` you would use `Autoconnect` since it's already translated)
|
Preferably, try to keep new terms to a minimum and re-use existing terms where possible. See `quickshell/translations/en.json` for the list of existing terms. (This isn't always possible obviously, but instead of using `Auto-connect` you would use `Autoconnect` since it's already translated)
|
||||||
|
|
||||||
|
Strings inside `quickshell/DankCommon/` are owned by the dank-qml-common repo but stay in the DMS POEditor project — extraction here deliberately skips them, and `scripts/i18nsync.py sync` uploads the union of app terms and the submodule's terms instead (common terms carry the `dank-qml-common` tag). On download the sync splits the exports: app translations go to `quickshell/translations/poexports/`, common translations go to `dank-qml-common/DankCommon/translations/poexports/` for you to commit in that repo and bump. At runtime `I18n` merges both catalogs (app terms win). Other apps (dankcalendar) keep their own POEditor projects and merge the `dank-qml-common`-tagged terms from the DMS project.
|
||||||
|
|
||||||
### GO (`core` directory)
|
### GO (`core` directory)
|
||||||
|
|
||||||
1. Install the [Go Extension](https://code.visualstudio.com/docs/languages/go)
|
1. Install the [Go Extension](https://code.visualstudio.com/docs/languages/go)
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ clean:
|
|||||||
lint-qml:
|
lint-qml:
|
||||||
@./quickshell/scripts/qmllint-entrypoints.sh
|
@./quickshell/scripts/qmllint-entrypoints.sh
|
||||||
|
|
||||||
|
# Pull the latest dank-qml-common and pin it everywhere it is consumed
|
||||||
|
# (submodule pointer + nix flake input). Commit both in one change.
|
||||||
|
update-common:
|
||||||
|
git submodule update --remote --merge dank-qml-common
|
||||||
|
nix --extra-experimental-features 'nix-command flakes' flake update dank-qml-common
|
||||||
|
|
||||||
# Installation targets
|
# Installation targets
|
||||||
install-bin:
|
install-bin:
|
||||||
@echo "Installing $(BINARY_NAME) to $(INSTALL_DIR)..."
|
@echo "Installing $(BINARY_NAME) to $(INSTALL_DIR)..."
|
||||||
@@ -43,8 +49,9 @@ install-bin:
|
|||||||
|
|
||||||
install-shell:
|
install-shell:
|
||||||
@echo "Installing shell files to $(SHELL_INSTALL_DIR)..."
|
@echo "Installing shell files to $(SHELL_INSTALL_DIR)..."
|
||||||
|
@test -e $(SHELL_DIR)/DankCommon/Widgets/DankIcon.qml || { echo "DankCommon missing: run git submodule update --init"; exit 1; }
|
||||||
@mkdir -p $(SHELL_INSTALL_DIR)
|
@mkdir -p $(SHELL_INSTALL_DIR)
|
||||||
@cp -r $(SHELL_DIR)/* $(SHELL_INSTALL_DIR)/
|
@cp -rL $(SHELL_DIR)/* $(SHELL_INSTALL_DIR)/
|
||||||
@rm -rf $(SHELL_INSTALL_DIR)/.git* $(SHELL_INSTALL_DIR)/.github
|
@rm -rf $(SHELL_INSTALL_DIR)/.git* $(SHELL_INSTALL_DIR)/.github
|
||||||
@echo "Shell files installed"
|
@echo "Shell files installed"
|
||||||
|
|
||||||
|
|||||||
@@ -250,6 +250,10 @@ func updateOtherDistros() error {
|
|||||||
return fmt.Errorf("failed to fetch changes: %w", err)
|
return fmt.Errorf("failed to fetch changes: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := updateSubmodules(); err != nil {
|
||||||
|
return fmt.Errorf("failed to update submodules: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
if currentTag != "" {
|
if currentTag != "" {
|
||||||
latestTagCmd := exec.Command("git", "tag", "-l", "v*", "--sort=-version:refname")
|
latestTagCmd := exec.Command("git", "tag", "-l", "v*", "--sort=-version:refname")
|
||||||
latestTagOutput, err := latestTagCmd.Output()
|
latestTagOutput, err := latestTagCmd.Output()
|
||||||
@@ -291,6 +295,10 @@ func updateOtherDistros() error {
|
|||||||
return fmt.Errorf("update cancelled")
|
return fmt.Errorf("update cancelled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := updateSubmodules(); err != nil {
|
||||||
|
return fmt.Errorf("failed to update submodules: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("\nUpdate complete! Updated from %s to %s\n", currentTag, latestTag)
|
fmt.Printf("\nUpdate complete! Updated from %s to %s\n", currentTag, latestTag)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -320,10 +328,21 @@ func updateOtherDistros() error {
|
|||||||
return fmt.Errorf("update cancelled")
|
return fmt.Errorf("update cancelled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := updateSubmodules(); err != nil {
|
||||||
|
return fmt.Errorf("failed to update submodules: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("\nUpdate complete!")
|
fmt.Println("\nUpdate complete!")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateSubmodules() error {
|
||||||
|
submoduleCmd := exec.Command("git", "submodule", "update", "--init", "--recursive")
|
||||||
|
submoduleCmd.Stdout = os.Stdout
|
||||||
|
submoduleCmd.Stderr = os.Stderr
|
||||||
|
return submoduleCmd.Run()
|
||||||
|
}
|
||||||
|
|
||||||
func offerReclone(dmsPath string) bool {
|
func offerReclone(dmsPath string) bool {
|
||||||
fmt.Println("\nWould you like to backup and re-clone the repository? (y/N): ")
|
fmt.Println("\nWould you like to backup and re-clone the repository? (y/N): ")
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
@@ -342,7 +361,7 @@ func offerReclone(dmsPath string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Cloning fresh copy...")
|
fmt.Println("Cloning fresh copy...")
|
||||||
cloneCmd := exec.Command("git", "clone", "https://github.com/AvengeMedia/DankMaterialShell.git", dmsPath)
|
cloneCmd := exec.Command("git", "clone", "--recurse-submodules", "https://github.com/AvengeMedia/DankMaterialShell.git", dmsPath)
|
||||||
cloneCmd.Stdout = os.Stdout
|
cloneCmd.Stdout = os.Stdout
|
||||||
cloneCmd.Stderr = os.Stderr
|
cloneCmd.Stderr = os.Stderr
|
||||||
if err := cloneCmd.Run(); err != nil {
|
if err := cloneCmd.Run(); err != nil {
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, v
|
|||||||
Progress: 0.90,
|
Progress: 0.90,
|
||||||
Step: "Cloning DankMaterialShell...",
|
Step: "Cloning DankMaterialShell...",
|
||||||
IsComplete: false,
|
IsComplete: false,
|
||||||
CommandInfo: "git clone https://github.com/AvengeMedia/DankMaterialShell.git",
|
CommandInfo: "git clone --recurse-submodules https://github.com/AvengeMedia/DankMaterialShell.git",
|
||||||
}
|
}
|
||||||
|
|
||||||
configDir := filepath.Dir(dmsPath)
|
configDir := filepath.Dir(dmsPath)
|
||||||
@@ -528,7 +528,7 @@ func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, v
|
|||||||
return fmt.Errorf("failed to create quickshell config directory: %w", err)
|
return fmt.Errorf("failed to create quickshell config directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneCmd := exec.CommandContext(ctx, "git", "clone",
|
cloneCmd := exec.CommandContext(ctx, "git", "clone", "--recurse-submodules",
|
||||||
"https://github.com/AvengeMedia/DankMaterialShell.git", dmsPath)
|
"https://github.com/AvengeMedia/DankMaterialShell.git", dmsPath)
|
||||||
if err := cloneCmd.Run(); err != nil {
|
if err := cloneCmd.Run(); err != nil {
|
||||||
return fmt.Errorf("failed to clone DankMaterialShell: %w", err)
|
return fmt.Errorf("failed to clone DankMaterialShell: %w", err)
|
||||||
@@ -553,6 +553,8 @@ func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, v
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.syncDMSSubmodules(ctx, dmsPath)
|
||||||
|
|
||||||
m.log(fmt.Sprintf("Checked out latest tag: %s", latestTag))
|
m.log(fmt.Sprintf("Checked out latest tag: %s", latestTag))
|
||||||
m.log("DankMaterialShell cloned successfully")
|
m.log("DankMaterialShell cloned successfully")
|
||||||
return nil
|
return nil
|
||||||
@@ -591,6 +593,8 @@ func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, v
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.syncDMSSubmodules(ctx, dmsPath)
|
||||||
|
|
||||||
m.log("DankMaterialShell updated successfully (git variant)")
|
m.log("DankMaterialShell updated successfully (git variant)")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -609,10 +613,19 @@ func (m *ManualPackageInstaller) installDankMaterialShell(ctx context.Context, v
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.syncDMSSubmodules(ctx, dmsPath)
|
||||||
|
|
||||||
m.log(fmt.Sprintf("Updated to tag: %s", latestTag))
|
m.log(fmt.Sprintf("Updated to tag: %s", latestTag))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ManualPackageInstaller) syncDMSSubmodules(ctx context.Context, dmsPath string) {
|
||||||
|
submoduleCmd := exec.CommandContext(ctx, "git", "-C", dmsPath, "submodule", "update", "--init", "--recursive")
|
||||||
|
if err := submoduleCmd.Run(); err != nil {
|
||||||
|
m.logError("Failed to update submodules", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *ManualPackageInstaller) installXwaylandSatellite(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
func (m *ManualPackageInstaller) installXwaylandSatellite(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||||
m.log("Installing xwayland-satellite from source...")
|
m.log("Installing xwayland-satellite from source...")
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ type TemplateDef struct {
|
|||||||
ID string
|
ID string
|
||||||
Commands []string
|
Commands []string
|
||||||
Flatpaks []string
|
Flatpaks []string
|
||||||
ConfigDirs []string
|
|
||||||
ConfigFile string
|
ConfigFile string
|
||||||
Kind TemplateKind
|
Kind TemplateKind
|
||||||
RunUnconditionally bool
|
RunUnconditionally bool
|
||||||
@@ -61,9 +60,9 @@ var templateRegistry = []TemplateDef{
|
|||||||
{ID: "firefox", Commands: []string{"firefox"}, ConfigFile: "firefox.toml"},
|
{ID: "firefox", Commands: []string{"firefox"}, ConfigFile: "firefox.toml"},
|
||||||
{ID: "pywalfox", Commands: []string{"pywalfox"}, ConfigFile: "pywalfox.toml"},
|
{ID: "pywalfox", Commands: []string{"pywalfox"}, ConfigFile: "pywalfox.toml"},
|
||||||
{ID: "zenbrowser", Commands: []string{"zen", "zen-browser", "zen-beta", "zen-twilight"}, Flatpaks: []string{"app.zen_browser.zen"}, ConfigFile: "zenbrowser.toml"},
|
{ID: "zenbrowser", Commands: []string{"zen", "zen-browser", "zen-beta", "zen-twilight"}, Flatpaks: []string{"app.zen_browser.zen"}, ConfigFile: "zenbrowser.toml"},
|
||||||
{ID: "vesktop", Commands: []string{"vesktop"}, Flatpaks: []string{"dev.vencord.Vesktop"}, ConfigDirs: []string{"vesktop"}, ConfigFile: "vesktop.toml"},
|
{ID: "vesktop", Commands: []string{"vesktop"}, Flatpaks: []string{"dev.vencord.Vesktop"}, ConfigFile: "vesktop.toml"},
|
||||||
{ID: "vencord", Commands: []string{"discord", "Discord", "discord-canary", "DiscordCanary"}, Flatpaks: []string{"com.discordapp.Discord", "com.discordapp.DiscordCanary"}, ConfigDirs: []string{"Vencord"}, ConfigFile: "vencord.toml"},
|
{ID: "vencord", Commands: []string{"discord", "Discord", "discord-canary", "DiscordCanary"}, Flatpaks: []string{"com.discordapp.Discord", "com.discordapp.DiscordCanary"}, ConfigFile: "vencord.toml"},
|
||||||
{ID: "equibop", Commands: []string{"equibop"}, ConfigDirs: []string{"equibop"}, ConfigFile: "equibop.toml"},
|
{ID: "equibop", Commands: []string{"equibop"}, ConfigFile: "equibop.toml"},
|
||||||
{ID: "ghostty", Commands: []string{"ghostty"}, ConfigFile: "ghostty.toml", Kind: TemplateKindTerminal},
|
{ID: "ghostty", Commands: []string{"ghostty"}, ConfigFile: "ghostty.toml", Kind: TemplateKindTerminal},
|
||||||
{ID: "kitty", Commands: []string{"kitty"}, ConfigFile: "kitty.toml", Kind: TemplateKindTerminal},
|
{ID: "kitty", Commands: []string{"kitty"}, ConfigFile: "kitty.toml", Kind: TemplateKindTerminal},
|
||||||
{ID: "foot", Commands: []string{"foot"}, ConfigFile: "foot.toml", Kind: TemplateKindTerminal},
|
{ID: "foot", Commands: []string{"foot"}, ConfigFile: "foot.toml", Kind: TemplateKindTerminal},
|
||||||
@@ -460,9 +459,9 @@ output_path = '%s'
|
|||||||
case TemplateKindGTK:
|
case TemplateKindGTK:
|
||||||
switch opts.Mode {
|
switch opts.Mode {
|
||||||
case ColorModeLight:
|
case ColorModeLight:
|
||||||
appendConfig(opts, cfgFile, nil, nil, nil, "gtk3-light.toml")
|
appendConfig(opts, cfgFile, nil, nil, "gtk3-light.toml")
|
||||||
default:
|
default:
|
||||||
appendConfig(opts, cfgFile, nil, nil, nil, "gtk3-dark.toml")
|
appendConfig(opts, cfgFile, nil, nil, "gtk3-dark.toml")
|
||||||
}
|
}
|
||||||
case TemplateKindTerminal:
|
case TemplateKindTerminal:
|
||||||
appendTerminalConfig(opts, cfgFile, tmpDir, tmpl.Commands, tmpl.Flatpaks, tmpl.ConfigFile)
|
appendTerminalConfig(opts, cfgFile, tmpDir, tmpl.Commands, tmpl.Flatpaks, tmpl.ConfigFile)
|
||||||
@@ -475,10 +474,10 @@ output_path = '%s'
|
|||||||
appendVSCodeConfig(cfgFile, "vscode-insiders", filepath.Join(homeDir, ".vscode-insiders/extensions"), opts.ShellDir)
|
appendVSCodeConfig(cfgFile, "vscode-insiders", filepath.Join(homeDir, ".vscode-insiders/extensions"), opts.ShellDir)
|
||||||
case TemplateKindEmacs:
|
case TemplateKindEmacs:
|
||||||
if utils.EmacsConfigDir() != "" {
|
if utils.EmacsConfigDir() != "" {
|
||||||
appendConfig(opts, cfgFile, tmpl.Commands, tmpl.Flatpaks, tmpl.ConfigDirs, tmpl.ConfigFile)
|
appendConfig(opts, cfgFile, tmpl.Commands, tmpl.Flatpaks, tmpl.ConfigFile)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
appendConfig(opts, cfgFile, tmpl.Commands, tmpl.Flatpaks, tmpl.ConfigDirs, tmpl.ConfigFile)
|
appendConfig(opts, cfgFile, tmpl.Commands, tmpl.Flatpaks, tmpl.ConfigFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,14 +512,13 @@ func appendConfig(
|
|||||||
cfgFile *os.File,
|
cfgFile *os.File,
|
||||||
checkCmd []string,
|
checkCmd []string,
|
||||||
checkFlatpaks []string,
|
checkFlatpaks []string,
|
||||||
checkConfigDirs []string,
|
|
||||||
fileName string,
|
fileName string,
|
||||||
) {
|
) {
|
||||||
configPath := filepath.Join(opts.ShellDir, "matugen", "configs", fileName)
|
configPath := filepath.Join(opts.ShellDir, "matugen", "configs", fileName)
|
||||||
if _, err := os.Stat(configPath); err != nil {
|
if _, err := os.Stat(configPath); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !appExists(opts.AppChecker, checkCmd, checkFlatpaks) && !configDirExists(checkConfigDirs) {
|
if !appExists(opts.AppChecker, checkCmd, checkFlatpaks) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := os.ReadFile(configPath)
|
data, err := os.ReadFile(configPath)
|
||||||
@@ -601,20 +599,6 @@ func templateSessionActive(tmpl TemplateDef) bool {
|
|||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func configDirExists(names []string) bool {
|
|
||||||
configHome := utils.XDGConfigHome()
|
|
||||||
if configHome == "" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for _, name := range names {
|
|
||||||
info, err := os.Stat(filepath.Join(configHome, name))
|
|
||||||
if err == nil && info.IsDir() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func appExists(checker utils.AppChecker, checkCmd []string, checkFlatpaks []string) bool {
|
func appExists(checker utils.AppChecker, checkCmd []string, checkFlatpaks []string) bool {
|
||||||
// Both nil is treated as "skip check" / unconditionally run
|
// Both nil is treated as "skip check" / unconditionally run
|
||||||
if checkCmd == nil && checkFlatpaks == nil {
|
if checkCmd == nil && checkFlatpaks == nil {
|
||||||
@@ -1112,7 +1096,7 @@ func CheckTemplates(checker utils.AppChecker) []TemplateCheck {
|
|||||||
case tmpl.Kind == TemplateKindEmacs:
|
case tmpl.Kind == TemplateKindEmacs:
|
||||||
detected = appExists(checker, tmpl.Commands, tmpl.Flatpaks) && utils.EmacsConfigDir() != ""
|
detected = appExists(checker, tmpl.Commands, tmpl.Flatpaks) && utils.EmacsConfigDir() != ""
|
||||||
default:
|
default:
|
||||||
detected = (appExists(checker, tmpl.Commands, tmpl.Flatpaks) || configDirExists(tmpl.ConfigDirs)) && templateSessionActive(tmpl)
|
detected = appExists(checker, tmpl.Commands, tmpl.Flatpaks) && templateSessionActive(tmpl)
|
||||||
}
|
}
|
||||||
|
|
||||||
checks = append(checks, TemplateCheck{ID: tmpl.ID, Detected: detected})
|
checks = append(checks, TemplateCheck{ID: tmpl.ID, Detected: detected})
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func TestAppendConfigBinaryExists(t *testing.T) {
|
|||||||
|
|
||||||
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, []string{"sh"}, nil, nil, "test.toml")
|
appendConfig(opts, cfgFile, []string{"sh"}, nil, "test.toml")
|
||||||
|
|
||||||
cfgFile.Close()
|
cfgFile.Close()
|
||||||
output, err := os.ReadFile(outFile)
|
output, err := os.ReadFile(outFile)
|
||||||
@@ -82,7 +82,7 @@ func TestAppendConfigBinaryDoesNotExist(t *testing.T) {
|
|||||||
|
|
||||||
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, []string{"nonexistent-binary-12345"}, []string{}, nil, "test.toml")
|
appendConfig(opts, cfgFile, []string{"nonexistent-binary-12345"}, []string{}, "test.toml")
|
||||||
|
|
||||||
cfgFile.Close()
|
cfgFile.Close()
|
||||||
output, err := os.ReadFile(outFile)
|
output, err := os.ReadFile(outFile)
|
||||||
@@ -122,7 +122,7 @@ func TestAppendConfigFlatpakExists(t *testing.T) {
|
|||||||
|
|
||||||
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, nil, []string{"app.zen_browser.zen"}, nil, "test.toml")
|
appendConfig(opts, cfgFile, nil, []string{"app.zen_browser.zen"}, "test.toml")
|
||||||
|
|
||||||
cfgFile.Close()
|
cfgFile.Close()
|
||||||
output, err := os.ReadFile(outFile)
|
output, err := os.ReadFile(outFile)
|
||||||
@@ -163,7 +163,7 @@ func TestAppendConfigFlatpakDoesNotExist(t *testing.T) {
|
|||||||
|
|
||||||
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, []string{}, []string{"com.nonexistent.flatpak"}, nil, "test.toml")
|
appendConfig(opts, cfgFile, []string{}, []string{"com.nonexistent.flatpak"}, "test.toml")
|
||||||
|
|
||||||
cfgFile.Close()
|
cfgFile.Close()
|
||||||
output, err := os.ReadFile(outFile)
|
output, err := os.ReadFile(outFile)
|
||||||
@@ -203,7 +203,7 @@ func TestAppendConfigBothExist(t *testing.T) {
|
|||||||
|
|
||||||
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, []string{"sh"}, []string{"app.zen_browser.zen"}, nil, "test.toml")
|
appendConfig(opts, cfgFile, []string{"sh"}, []string{"app.zen_browser.zen"}, "test.toml")
|
||||||
|
|
||||||
cfgFile.Close()
|
cfgFile.Close()
|
||||||
output, err := os.ReadFile(outFile)
|
output, err := os.ReadFile(outFile)
|
||||||
@@ -244,7 +244,7 @@ func TestAppendConfigNeitherExists(t *testing.T) {
|
|||||||
|
|
||||||
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, []string{"nonexistent-binary-12345"}, []string{"com.nonexistent.flatpak"}, nil, "test.toml")
|
appendConfig(opts, cfgFile, []string{"nonexistent-binary-12345"}, []string{"com.nonexistent.flatpak"}, "test.toml")
|
||||||
|
|
||||||
cfgFile.Close()
|
cfgFile.Close()
|
||||||
output, err := os.ReadFile(outFile)
|
output, err := os.ReadFile(outFile)
|
||||||
@@ -281,7 +281,7 @@ func TestAppendConfigNoChecks(t *testing.T) {
|
|||||||
|
|
||||||
opts := &Options{ShellDir: shellDir}
|
opts := &Options{ShellDir: shellDir}
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, nil, nil, nil, "test.toml")
|
appendConfig(opts, cfgFile, nil, nil, "test.toml")
|
||||||
|
|
||||||
cfgFile.Close()
|
cfgFile.Close()
|
||||||
output, err := os.ReadFile(outFile)
|
output, err := os.ReadFile(outFile)
|
||||||
@@ -312,7 +312,7 @@ func TestAppendConfigFileDoesNotExist(t *testing.T) {
|
|||||||
|
|
||||||
opts := &Options{ShellDir: shellDir}
|
opts := &Options{ShellDir: shellDir}
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, nil, nil, nil, "nonexistent.toml")
|
appendConfig(opts, cfgFile, nil, nil, "nonexistent.toml")
|
||||||
|
|
||||||
cfgFile.Close()
|
cfgFile.Close()
|
||||||
output, err := os.ReadFile(outFile)
|
output, err := os.ReadFile(outFile)
|
||||||
@@ -487,90 +487,3 @@ func TestBuildMergedConfigSkipsMangowcWithoutActiveSession(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assert.NotContains(t, string(output), "[templates.dmsmango]")
|
assert.NotContains(t, string(output), "[templates.dmsmango]")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAppendConfigConfigDirExists(t *testing.T) {
|
|
||||||
tempDir := t.TempDir()
|
|
||||||
|
|
||||||
shellDir := filepath.Join(tempDir, "shell")
|
|
||||||
configsDir := filepath.Join(shellDir, "matugen", "configs")
|
|
||||||
if err := os.MkdirAll(configsDir, 0o755); err != nil {
|
|
||||||
t.Fatalf("failed to create configs dir: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
testConfig := "vencord config content"
|
|
||||||
if err := os.WriteFile(filepath.Join(configsDir, "vencord.toml"), []byte(testConfig), 0o644); err != nil {
|
|
||||||
t.Fatalf("failed to write config: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
configHome := filepath.Join(tempDir, "config")
|
|
||||||
if err := os.MkdirAll(filepath.Join(configHome, "Vencord"), 0o755); err != nil {
|
|
||||||
t.Fatalf("failed to create Vencord config dir: %v", err)
|
|
||||||
}
|
|
||||||
t.Setenv("XDG_CONFIG_HOME", configHome)
|
|
||||||
|
|
||||||
outFile := filepath.Join(tempDir, "output.toml")
|
|
||||||
cfgFile, err := os.Create(outFile)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to create output file: %v", err)
|
|
||||||
}
|
|
||||||
defer cfgFile.Close()
|
|
||||||
|
|
||||||
mockChecker := mocks_utils.NewMockAppChecker(t)
|
|
||||||
mockChecker.EXPECT().AnyCommandExists("nonexistent-binary-12345").Return(false)
|
|
||||||
mockChecker.EXPECT().AnyFlatpakExists("com.nonexistent.flatpak").Return(false)
|
|
||||||
|
|
||||||
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, []string{"nonexistent-binary-12345"}, []string{"com.nonexistent.flatpak"}, []string{"Vencord"}, "vencord.toml")
|
|
||||||
|
|
||||||
cfgFile.Close()
|
|
||||||
output, err := os.ReadFile(outFile)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to read output: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.Equal(t, testConfig+"\n", string(output))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAppendConfigConfigDirDoesNotExist(t *testing.T) {
|
|
||||||
tempDir := t.TempDir()
|
|
||||||
|
|
||||||
shellDir := filepath.Join(tempDir, "shell")
|
|
||||||
configsDir := filepath.Join(shellDir, "matugen", "configs")
|
|
||||||
if err := os.MkdirAll(configsDir, 0o755); err != nil {
|
|
||||||
t.Fatalf("failed to create configs dir: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.WriteFile(filepath.Join(configsDir, "vencord.toml"), []byte("vencord config content"), 0o644); err != nil {
|
|
||||||
t.Fatalf("failed to write config: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
configHome := filepath.Join(tempDir, "config")
|
|
||||||
if err := os.MkdirAll(configHome, 0o755); err != nil {
|
|
||||||
t.Fatalf("failed to create config home: %v", err)
|
|
||||||
}
|
|
||||||
t.Setenv("XDG_CONFIG_HOME", configHome)
|
|
||||||
|
|
||||||
outFile := filepath.Join(tempDir, "output.toml")
|
|
||||||
cfgFile, err := os.Create(outFile)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to create output file: %v", err)
|
|
||||||
}
|
|
||||||
defer cfgFile.Close()
|
|
||||||
|
|
||||||
mockChecker := mocks_utils.NewMockAppChecker(t)
|
|
||||||
mockChecker.EXPECT().AnyCommandExists("nonexistent-binary-12345").Return(false)
|
|
||||||
mockChecker.EXPECT().AnyFlatpakExists("com.nonexistent.flatpak").Return(false)
|
|
||||||
|
|
||||||
opts := &Options{ShellDir: shellDir, AppChecker: mockChecker}
|
|
||||||
|
|
||||||
appendConfig(opts, cfgFile, []string{"nonexistent-binary-12345"}, []string{"com.nonexistent.flatpak"}, []string{"Vencord"}, "vencord.toml")
|
|
||||||
|
|
||||||
cfgFile.Close()
|
|
||||||
output, err := os.ReadFile(outFile)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to read output: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.Empty(t, string(output))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package qmlchecks
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestGreeterRememberLastSessionFallsBackToDesktopID(t *testing.T) {
|
|
||||||
data, err := os.ReadFile("../../../quickshell/Modules/Greetd/GreeterContent.qml")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("read greeter QML: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
content := string(data)
|
|
||||||
if !strings.Contains(content, "GreetdMemory.lastSessionDesktopId || desktopIdFromPath(GreetdMemory.lastSessionId)") {
|
|
||||||
t.Fatalf("remembered greeter sessions should derive a desktop id from legacy absolute session paths")
|
|
||||||
}
|
|
||||||
if !strings.Contains(content, "GreeterState.sessionDesktopIds[i] === savedDesktopId") {
|
|
||||||
t.Fatalf("remembered greeter sessions should match current sessions by desktop id")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,32 +24,6 @@ func TestLockScreenPasswordFieldBypassesTextInputIME(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLockScreenAuthenticationCardOwnsFactorControls(t *testing.T) {
|
|
||||||
data, err := os.ReadFile("../../../quickshell/Modules/Settings/LockScreenTab.qml")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("read lock screen settings QML: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
content := string(data)
|
|
||||||
authCard := strings.Index(content, `title: I18n.tr("Authentication")`)
|
|
||||||
behaviorCard := strings.Index(content, `title: I18n.tr("Behavior")`)
|
|
||||||
fingerprintToggle := strings.Index(content, `settingKey: "enableFprint"`)
|
|
||||||
u2fToggle := strings.Index(content, `settingKey: "enableU2f"`)
|
|
||||||
u2fSource := strings.Index(content, `settingKey: "lockU2fPamPath"`)
|
|
||||||
if authCard < 0 || behaviorCard < 0 || fingerprintToggle < 0 || u2fToggle < 0 || u2fSource < 0 {
|
|
||||||
t.Fatalf("expected authentication card, factor toggles, and U2F source setting")
|
|
||||||
}
|
|
||||||
for name, position := range map[string]int{
|
|
||||||
"fingerprint toggle": fingerprintToggle,
|
|
||||||
"U2F toggle": u2fToggle,
|
|
||||||
"U2F source": u2fSource,
|
|
||||||
} {
|
|
||||||
if position < authCard || position > behaviorCard {
|
|
||||||
t.Fatalf("%s must remain in the authentication card", name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLockScreenPamSupportsManagedAndSystemPolicies(t *testing.T) {
|
func TestLockScreenPamSupportsManagedAndSystemPolicies(t *testing.T) {
|
||||||
data, err := os.ReadFile("../../../quickshell/Modules/Lock/Pam.qml")
|
data, err := os.ReadFile("../../../quickshell/Modules/Lock/Pam.qml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ func NewManager() (*Manager, error) {
|
|||||||
broker := NewSubscriptionBroker(m.broadcastPairingPrompt)
|
broker := NewSubscriptionBroker(m.broadcastPairingPrompt)
|
||||||
m.promptBroker = broker
|
m.promptBroker = broker
|
||||||
|
|
||||||
adapter, err := findAdapter(conn)
|
adapter, err := m.findAdapter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return nil, err
|
return nil, fmt.Errorf("no bluetooth adapter found: %w", err)
|
||||||
}
|
}
|
||||||
m.adapterPath = adapter
|
m.adapterPath = adapter
|
||||||
|
|
||||||
@@ -74,12 +74,12 @@ func NewManager() (*Manager, error) {
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func findAdapter(conn *dbus.Conn) (dbus.ObjectPath, error) {
|
func (m *Manager) findAdapter() (dbus.ObjectPath, error) {
|
||||||
obj := conn.Object(bluezService, dbus.ObjectPath("/"))
|
obj := m.dbusConn.Object(bluezService, dbus.ObjectPath("/"))
|
||||||
var objects map[dbus.ObjectPath]map[string]map[string]dbus.Variant
|
var objects map[dbus.ObjectPath]map[string]map[string]dbus.Variant
|
||||||
|
|
||||||
if err := obj.Call(objectMgrIface+".GetManagedObjects", 0).Store(&objects); err != nil {
|
if err := obj.Call(objectMgrIface+".GetManagedObjects", 0).Store(&objects); err != nil {
|
||||||
return "", fmt.Errorf("%w: %v", ErrNoAdapter, err)
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
for path, interfaces := range objects {
|
for path, interfaces := range objects {
|
||||||
@@ -89,7 +89,7 @@ func findAdapter(conn *dbus.Conn) (dbus.ObjectPath, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", ErrNoAdapter
|
return "", fmt.Errorf("no adapter found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) initialize() error {
|
func (m *Manager) initialize() error {
|
||||||
@@ -487,11 +487,6 @@ func (m *Manager) StopDiscovery() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) SetPowered(powered bool) error {
|
func (m *Manager) SetPowered(powered bool) error {
|
||||||
if powered {
|
|
||||||
if err := rfkillUnblockBluetooth(); err != nil {
|
|
||||||
log.Debugf("[BluezManager] rfkill unblock failed: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
obj := m.dbusConn.Object(bluezService, m.adapterPath)
|
obj := m.dbusConn.Object(bluezService, m.adapterPath)
|
||||||
return obj.Call(propertiesIface+".Set", 0, adapter1Iface, "Powered", dbus.MakeVariant(powered)).Err
|
return obj.Call(propertiesIface+".Set", 0, adapter1Iface, "Powered", dbus.MakeVariant(powered)).Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package bluez
|
|
||||||
|
|
||||||
func rfkillUnblockBluetooth() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package bluez
|
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
// linux/rfkill.h: struct rfkill_event { __u32 idx; __u8 type; __u8 op; __u8 soft; __u8 hard; },
|
|
||||||
// RFKILL_TYPE_BLUETOOTH=2, RFKILL_OP_CHANGE_ALL=3
|
|
||||||
func rfkillUnblockBluetooth() error {
|
|
||||||
f, err := os.OpenFile("/dev/rfkill", os.O_WRONLY, 0)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
var event [8]byte
|
|
||||||
event[4] = 2
|
|
||||||
event[5] = 3
|
|
||||||
_, err = f.Write(event[:])
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package bluez
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/godbus/dbus/v5"
|
|
||||||
)
|
|
||||||
|
|
||||||
var ErrNoAdapter = errors.New("no bluetooth adapter found")
|
|
||||||
|
|
||||||
func WaitForAdapter() error {
|
|
||||||
conn, err := dbus.ConnectSystemBus()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer conn.Close()
|
|
||||||
|
|
||||||
if err := conn.AddMatchSignal(
|
|
||||||
dbus.WithMatchInterface(objectMgrIface),
|
|
||||||
dbus.WithMatchMember("InterfacesAdded"),
|
|
||||||
); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
signals := make(chan *dbus.Signal, 64)
|
|
||||||
conn.Signal(signals)
|
|
||||||
|
|
||||||
if _, err := findAdapter(conn); err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for sig := range signals {
|
|
||||||
if sig == nil || sig.Name != objectMgrIface+".InterfacesAdded" || len(sig.Body) < 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ifaces, ok := sig.Body[1].(map[string]map[string]dbus.Variant)
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if _, ok := ifaces[adapter1Iface]; ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fmt.Errorf("dbus signal stream closed")
|
|
||||||
}
|
|
||||||
@@ -229,9 +229,6 @@ func (m *Manager) snapshotState() CUPSState {
|
|||||||
func (m *Manager) Subscribe(id string) chan CUPSState {
|
func (m *Manager) Subscribe(id string) chan CUPSState {
|
||||||
ch := make(chan CUPSState, 64)
|
ch := make(chan CUPSState, 64)
|
||||||
|
|
||||||
m.subLifecycleMu.Lock()
|
|
||||||
defer m.subLifecycleMu.Unlock()
|
|
||||||
|
|
||||||
wasEmpty := true
|
wasEmpty := true
|
||||||
m.subscribers.Range(func(key string, ch chan CUPSState) bool {
|
m.subscribers.Range(func(key string, ch chan CUPSState) bool {
|
||||||
wasEmpty = false
|
wasEmpty = false
|
||||||
@@ -240,25 +237,19 @@ func (m *Manager) Subscribe(id string) chan CUPSState {
|
|||||||
|
|
||||||
m.subscribers.Store(id, ch)
|
m.subscribers.Store(id, ch)
|
||||||
|
|
||||||
if !wasEmpty || m.subscription == nil {
|
if wasEmpty && m.subscription != nil {
|
||||||
return ch
|
if err := m.subscription.Start(); err != nil {
|
||||||
|
log.Warnf("[CUPS] Failed to start subscription manager: %v", err)
|
||||||
|
} else {
|
||||||
|
m.eventWG.Add(1)
|
||||||
|
go m.eventHandler()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := m.subscription.Start(); err != nil {
|
|
||||||
log.Warnf("[CUPS] Failed to start subscription manager: %v", err)
|
|
||||||
return ch
|
|
||||||
}
|
|
||||||
|
|
||||||
m.eventWG.Add(1)
|
|
||||||
go m.eventHandler()
|
|
||||||
|
|
||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Unsubscribe(id string) {
|
func (m *Manager) Unsubscribe(id string) {
|
||||||
m.subLifecycleMu.Lock()
|
|
||||||
defer m.subLifecycleMu.Unlock()
|
|
||||||
|
|
||||||
if val, ok := m.subscribers.LoadAndDelete(id); ok {
|
if val, ok := m.subscribers.LoadAndDelete(id); ok {
|
||||||
close(val)
|
close(val)
|
||||||
}
|
}
|
||||||
@@ -269,22 +260,18 @@ func (m *Manager) Unsubscribe(id string) {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
if !isEmpty || m.subscription == nil {
|
if isEmpty && m.subscription != nil {
|
||||||
return
|
m.subscription.Stop()
|
||||||
|
m.eventWG.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
m.subscription.Stop()
|
|
||||||
m.eventWG.Wait()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Close() {
|
func (m *Manager) Close() {
|
||||||
close(m.stopChan)
|
close(m.stopChan)
|
||||||
|
|
||||||
m.subLifecycleMu.Lock()
|
|
||||||
if m.subscription != nil {
|
if m.subscription != nil {
|
||||||
m.subscription.Stop()
|
m.subscription.Stop()
|
||||||
}
|
}
|
||||||
m.subLifecycleMu.Unlock()
|
|
||||||
|
|
||||||
m.eventWG.Wait()
|
m.eventWG.Wait()
|
||||||
m.notifierWg.Wait()
|
m.notifierWg.Wait()
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package cups
|
package cups
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"sync"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
mocks_cups "github.com/AvengeMedia/DankMaterialShell/core/internal/mocks/cups"
|
mocks_cups "github.com/AvengeMedia/DankMaterialShell/core/internal/mocks/cups"
|
||||||
@@ -78,67 +75,6 @@ func TestManager_Subscribe(t *testing.T) {
|
|||||||
assert.Equal(t, 0, count)
|
assert.Equal(t, 0, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// mirrors the real managers: eventChan guarded by mu, conn/running deliberately
|
|
||||||
// unsynchronized so overlapping Start/Stop trips the race detector
|
|
||||||
type stubSubscription struct {
|
|
||||||
mu sync.Mutex
|
|
||||||
events chan SubscriptionEvent
|
|
||||||
conn *int
|
|
||||||
running bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stubSubscription) Start() error {
|
|
||||||
if s.running {
|
|
||||||
return errors.New("already running")
|
|
||||||
}
|
|
||||||
s.running = true
|
|
||||||
|
|
||||||
s.mu.Lock()
|
|
||||||
s.events = make(chan SubscriptionEvent)
|
|
||||||
s.mu.Unlock()
|
|
||||||
|
|
||||||
v := 0
|
|
||||||
s.conn = &v
|
|
||||||
*s.conn++
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stubSubscription) Stop() {
|
|
||||||
if !s.running {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.running = false
|
|
||||||
s.conn = nil
|
|
||||||
|
|
||||||
s.mu.Lock()
|
|
||||||
close(s.events)
|
|
||||||
s.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stubSubscription) Events() <-chan SubscriptionEvent {
|
|
||||||
s.mu.Lock()
|
|
||||||
defer s.mu.Unlock()
|
|
||||||
return s.events
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestManager_SubscribeUnsubscribeRace(t *testing.T) {
|
|
||||||
m := NewTestManager(mocks_cups.NewMockCUPSClientInterface(t), nil)
|
|
||||||
m.subscription = &stubSubscription{}
|
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
for i := range 8 {
|
|
||||||
wg.Go(func() {
|
|
||||||
id := fmt.Sprintf("client-%d", i)
|
|
||||||
for range 50 {
|
|
||||||
m.Subscribe(id)
|
|
||||||
m.Unsubscribe(id)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestManager_Close(t *testing.T) {
|
func TestManager_Close(t *testing.T) {
|
||||||
mockClient := mocks_cups.NewMockCUPSClientInterface(t)
|
mockClient := mocks_cups.NewMockCUPSClientInterface(t)
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ type Manager struct {
|
|||||||
client CUPSClientInterface
|
client CUPSClientInterface
|
||||||
pkHelper PkHelper
|
pkHelper PkHelper
|
||||||
subscription SubscriptionManagerInterface
|
subscription SubscriptionManagerInterface
|
||||||
subLifecycleMu sync.Mutex
|
|
||||||
stateMutex sync.RWMutex
|
stateMutex sync.RWMutex
|
||||||
subscribers syncmap.Map[string, chan CUPSState]
|
subscribers syncmap.Map[string, chan CUPSState]
|
||||||
stopChan chan struct{}
|
stopChan chan struct{}
|
||||||
|
|||||||
@@ -117,12 +117,11 @@ func RouteRequest(conn net.Conn, req models.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(req.Method, "cups.") {
|
if strings.HasPrefix(req.Method, "cups.") {
|
||||||
mgr, err := ensureCupsManager()
|
if cupsManager == nil {
|
||||||
if err != nil {
|
|
||||||
models.RespondError(conn, req.ID, "CUPS manager not initialized")
|
models.RespondError(conn, req.ID, "CUPS manager not initialized")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cups.HandleRequest(conn, req, mgr)
|
cups.HandleRequest(conn, req, cupsManager)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -84,8 +85,8 @@ var geoClientInstance geolocation.Client
|
|||||||
const dbusClientID = "dms-dbus-client"
|
const dbusClientID = "dms-dbus-client"
|
||||||
|
|
||||||
var capabilitySubscribers syncmap.Map[string, chan ServerInfo]
|
var capabilitySubscribers syncmap.Map[string, chan ServerInfo]
|
||||||
var cupsMu sync.Mutex
|
var cupsSubscribers syncmap.Map[string, bool]
|
||||||
var cupsSubscriberCount int
|
var cupsSubscriberCount atomic.Int32
|
||||||
|
|
||||||
func getSocketDir() string {
|
func getSocketDir() string {
|
||||||
if runtime := os.Getenv("XDG_RUNTIME_DIR"); runtime != "" {
|
if runtime := os.Getenv("XDG_RUNTIME_DIR"); runtime != "" {
|
||||||
@@ -242,55 +243,17 @@ func InitializeAppPickerManager() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeCupsManagerLocked() (bool, error) {
|
func InitializeCupsManager() error {
|
||||||
if cupsManager != nil {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
manager, err := cups.NewManager()
|
manager, err := cups.NewManager()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Failed to initialize cups manager: %v", err)
|
log.Warnf("Failed to initialize cups manager: %v", err)
|
||||||
return false, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cupsManager = manager
|
cupsManager = manager
|
||||||
|
|
||||||
log.Info("CUPS manager initialized")
|
log.Info("CUPS manager initialized")
|
||||||
return true, nil
|
return nil
|
||||||
}
|
|
||||||
|
|
||||||
func ensureCupsManager() (*cups.Manager, error) {
|
|
||||||
cupsMu.Lock()
|
|
||||||
created, err := initializeCupsManagerLocked()
|
|
||||||
mgr := cupsManager
|
|
||||||
cupsMu.Unlock()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if created {
|
|
||||||
notifyCapabilityChange()
|
|
||||||
}
|
|
||||||
return mgr, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func cupsAvailable() bool {
|
|
||||||
cupsMu.Lock()
|
|
||||||
defer cupsMu.Unlock()
|
|
||||||
return cupsManager != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func releaseCupsSubscriber() {
|
|
||||||
cupsMu.Lock()
|
|
||||||
cupsSubscriberCount--
|
|
||||||
var mgr *cups.Manager
|
|
||||||
if cupsSubscriberCount == 0 && cupsManager != nil {
|
|
||||||
mgr = cupsManager
|
|
||||||
cupsManager = nil
|
|
||||||
}
|
|
||||||
cupsMu.Unlock()
|
|
||||||
if mgr == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Info("Last CUPS subscriber disconnected, shutting down CUPS manager")
|
|
||||||
mgr.Close()
|
|
||||||
notifyCapabilityChange()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitializeBrightnessManager() error {
|
func InitializeBrightnessManager() error {
|
||||||
@@ -500,7 +463,7 @@ func getCapabilities() Capabilities {
|
|||||||
caps = append(caps, "browser")
|
caps = append(caps, "browser")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cupsAvailable() {
|
if cupsManager != nil {
|
||||||
caps = append(caps, "cups")
|
caps = append(caps, "cups")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,7 +533,7 @@ func getServerInfo() ServerInfo {
|
|||||||
caps = append(caps, "browser")
|
caps = append(caps, "browser")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cupsAvailable() {
|
if cupsManager != nil {
|
||||||
caps = append(caps, "cups")
|
caps = append(caps, "cups")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1034,31 +997,38 @@ func handleSubscribe(conn net.Conn, req models.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if shouldSubscribe("cups") {
|
if shouldSubscribe("cups") {
|
||||||
cupsMu.Lock()
|
cupsSubscribers.Store(clientID+"-cups", true)
|
||||||
cupsSubscriberCount++
|
count := cupsSubscriberCount.Add(1)
|
||||||
created, err := initializeCupsManagerLocked()
|
|
||||||
mgr := cupsManager
|
|
||||||
cupsMu.Unlock()
|
|
||||||
|
|
||||||
if err != nil {
|
if count == 1 {
|
||||||
log.Warnf("Failed to initialize CUPS manager for subscription: %v", err)
|
if err := InitializeCupsManager(); err != nil {
|
||||||
} else if created {
|
log.Warnf("Failed to initialize CUPS manager for subscription: %v", err)
|
||||||
notifyCapabilityChange()
|
} else {
|
||||||
|
notifyCapabilityChange()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if mgr == nil {
|
if cupsManager != nil {
|
||||||
releaseCupsSubscriber()
|
|
||||||
} else {
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
cupsChan := mgr.Subscribe(clientID + "-cups")
|
cupsChan := cupsManager.Subscribe(clientID + "-cups")
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
defer func() {
|
defer func() {
|
||||||
mgr.Unsubscribe(clientID + "-cups")
|
cupsManager.Unsubscribe(clientID + "-cups")
|
||||||
releaseCupsSubscriber()
|
cupsSubscribers.Delete(clientID + "-cups")
|
||||||
|
count := cupsSubscriberCount.Add(-1)
|
||||||
|
|
||||||
|
if count == 0 {
|
||||||
|
log.Info("Last CUPS subscriber disconnected, shutting down CUPS manager")
|
||||||
|
if cupsManager != nil {
|
||||||
|
cupsManager.Close()
|
||||||
|
cupsManager = nil
|
||||||
|
notifyCapabilityChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
initialState := mgr.GetState()
|
initialState := cupsManager.GetState()
|
||||||
select {
|
select {
|
||||||
case eventChan <- ServiceEvent{Service: "cups", Data: initialState}:
|
case eventChan <- ServiceEvent{Service: "cups", Data: initialState}:
|
||||||
case <-stopChan:
|
case <-stopChan:
|
||||||
@@ -1368,12 +1338,9 @@ func cleanupManagers() {
|
|||||||
if appPickerManager != nil {
|
if appPickerManager != nil {
|
||||||
appPickerManager.Close()
|
appPickerManager.Close()
|
||||||
}
|
}
|
||||||
cupsMu.Lock()
|
|
||||||
if cupsManager != nil {
|
if cupsManager != nil {
|
||||||
cupsManager.Close()
|
cupsManager.Close()
|
||||||
cupsManager = nil
|
|
||||||
}
|
}
|
||||||
cupsMu.Unlock()
|
|
||||||
if brightnessManager != nil {
|
if brightnessManager != nil {
|
||||||
brightnessManager.Close()
|
brightnessManager.Close()
|
||||||
}
|
}
|
||||||
@@ -1731,21 +1698,10 @@ func Start(printDocs bool) error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
if err := InitializeBluezManager(); err != nil {
|
||||||
err := InitializeBluezManager()
|
|
||||||
if err == nil {
|
|
||||||
notifyCapabilityChange()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Warnf("Bluez manager unavailable: %v", err)
|
log.Warnf("Bluez manager unavailable: %v", err)
|
||||||
if !errors.Is(err, bluez.ErrNoAdapter) {
|
} else {
|
||||||
return
|
notifyCapabilityChange()
|
||||||
}
|
|
||||||
if err := bluez.WaitForAdapter(); err != nil {
|
|
||||||
log.Warnf("Bluetooth adapter watch failed: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Info("Bluetooth adapter appeared, initializing bluez manager")
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -143,8 +143,7 @@ func wrapInTerminal(term, title, shellCmd string, extraArgs []string) []string {
|
|||||||
case "konsole":
|
case "konsole":
|
||||||
argv = []string{term, "-p", "tabtitle=" + title}
|
argv = []string{term, "-p", "tabtitle=" + title}
|
||||||
case "gnome-terminal":
|
case "gnome-terminal":
|
||||||
// --wait: the factory process otherwise returns immediately
|
argv = []string{term, "--title=" + title}
|
||||||
argv = []string{term, "--wait", "--title=" + title}
|
|
||||||
execFlag = "--"
|
execFlag = "--"
|
||||||
default:
|
default:
|
||||||
argv = []string{term}
|
argv = []string{term}
|
||||||
|
|||||||
@@ -412,30 +412,25 @@ func (m *Manager) runCustomUpgrade(ctx context.Context, opts UpgradeOptions) {
|
|||||||
onLine := func(line string) { m.appendLog(line) }
|
onLine := func(line string) { m.appendLog(line) }
|
||||||
argv := wrapInTerminal(term, "DMS — System Update (custom)", opts.CustomCommand, opts.TerminalArgs)
|
argv := wrapInTerminal(term, "DMS — System Update (custom)", opts.CustomCommand, opts.TerminalArgs)
|
||||||
if err := Run(ctx, argv, RunOptions{OnLine: onLine}); err != nil {
|
if err := Run(ctx, argv, RunOptions{OnLine: onLine}); err != nil {
|
||||||
|
code := ErrCodeBackendFailed
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(ctx.Err(), context.DeadlineExceeded):
|
case errors.Is(ctx.Err(), context.DeadlineExceeded):
|
||||||
m.failCustomUpgrade(ErrCodeTimeout, err)
|
code = ErrCodeTimeout
|
||||||
return
|
|
||||||
case errors.Is(ctx.Err(), context.Canceled):
|
case errors.Is(ctx.Err(), context.Canceled):
|
||||||
m.failCustomUpgrade(ErrCodeCancelled, err)
|
code = ErrCodeCancelled
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// exit status reflects the trailing `read`, not the update command
|
m.mu.Lock()
|
||||||
m.appendLog(fmt.Sprintf("Terminal exited early: %v", err))
|
m.state.Phase = PhaseError
|
||||||
|
m.state.Error = &ErrorInfo{Code: code, Message: err.Error()}
|
||||||
|
m.mu.Unlock()
|
||||||
|
m.markDirty()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.finishSuccessfulUpgrade(false)
|
m.finishSuccessfulUpgrade(false)
|
||||||
m.runRefresh(context.Background(), false)
|
m.runRefresh(context.Background(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) failCustomUpgrade(code ErrorCode, err error) {
|
|
||||||
m.mu.Lock()
|
|
||||||
m.state.Phase = PhaseError
|
|
||||||
m.state.Error = &ErrorInfo{Code: code, Message: err.Error()}
|
|
||||||
m.mu.Unlock()
|
|
||||||
m.markDirty()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Manager) finishSuccessfulUpgrade(clearPackages bool) {
|
func (m *Manager) finishSuccessfulUpgrade(clearPackages bool) {
|
||||||
m.appendLog("Upgrade complete.")
|
m.appendLog("Upgrade complete.")
|
||||||
|
|
||||||
|
|||||||
@@ -233,27 +233,3 @@ func TestUpgradeBackendsFiltersFlatpakOnly(t *testing.T) {
|
|||||||
t.Fatalf("upgradeBackends(mixed) = %#v, want dnf5 then flatpak", got)
|
t.Fatalf("upgradeBackends(mixed) = %#v, want dnf5 then flatpak", got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrapInTerminal(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
term string
|
|
||||||
wantPrefix []string
|
|
||||||
}{
|
|
||||||
{"kitty", []string{"kitty", "--class", "com.danklinux.dms", "-T", "Title"}},
|
|
||||||
{"gnome-terminal", []string{"gnome-terminal", "--wait", "--title=Title"}},
|
|
||||||
{"foot", []string{"foot", "--app-id=com.danklinux.dms", "--title=Title"}},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
got := wrapInTerminal(tt.term, "Title", "echo hi", nil)
|
|
||||||
if len(got) < len(tt.wantPrefix) || !reflect.DeepEqual(got[:len(tt.wantPrefix)], tt.wantPrefix) {
|
|
||||||
t.Errorf("wrapInTerminal(%q) = %#v, want prefix %#v", tt.term, got, tt.wantPrefix)
|
|
||||||
}
|
|
||||||
tail := got[len(got)-3:]
|
|
||||||
if tail[0] != "sh" || tail[1] != "-c" {
|
|
||||||
t.Errorf("wrapInTerminal(%q) tail = %#v, want [sh -c <cmd>]", tt.term, tail)
|
|
||||||
}
|
|
||||||
if !strings.Contains(tail[2], "echo hi") {
|
|
||||||
t.Errorf("wrapInTerminal(%q) command %q does not contain shell command", tt.term, tail[2])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -928,8 +928,8 @@ func (p *NiriWritableProvider) formatRule(rule windowrules.WindowRule) string {
|
|||||||
if a.Opacity != nil {
|
if a.Opacity != nil {
|
||||||
lines = append(lines, fmt.Sprintf(" opacity %.2f", *a.Opacity))
|
lines = append(lines, fmt.Sprintf(" opacity %.2f", *a.Opacity))
|
||||||
}
|
}
|
||||||
if a.OpenFloating != nil {
|
if a.OpenFloating != nil && *a.OpenFloating {
|
||||||
lines = append(lines, fmt.Sprintf(" open-floating %t", *a.OpenFloating))
|
lines = append(lines, " open-floating true")
|
||||||
}
|
}
|
||||||
if a.OpenMaximized != nil && *a.OpenMaximized {
|
if a.OpenMaximized != nil && *a.OpenMaximized {
|
||||||
lines = append(lines, " open-maximized true")
|
lines = append(lines, " open-maximized true")
|
||||||
|
|||||||
Submodule
+1
Submodule dank-qml-common added at 5942bc1c60
@@ -70,7 +70,7 @@ override_dh_auto_install:
|
|||||||
|
|
||||||
mkdir -p debian/dms-git/usr/share/quickshell/dms debian/dms-git/usr/lib/systemd/user
|
mkdir -p debian/dms-git/usr/share/quickshell/dms debian/dms-git/usr/lib/systemd/user
|
||||||
if [ -d quickshell ]; then \
|
if [ -d quickshell ]; then \
|
||||||
cp -r quickshell/* debian/dms-git/usr/share/quickshell/dms/; \
|
cp -rL quickshell/* debian/dms-git/usr/share/quickshell/dms/; \
|
||||||
install -Dm644 assets/systemd/dms.service debian/dms-git/usr/lib/systemd/user/dms.service; \
|
install -Dm644 assets/systemd/dms.service debian/dms-git/usr/lib/systemd/user/dms.service; \
|
||||||
install -Dm644 assets/dms-open.desktop debian/dms-git/usr/share/applications/dms-open.desktop; \
|
install -Dm644 assets/dms-open.desktop debian/dms-git/usr/share/applications/dms-open.desktop; \
|
||||||
install -Dm644 assets/com.danklinux.dms.desktop debian/dms-git/usr/share/applications/com.danklinux.dms.desktop; \
|
install -Dm644 assets/com.danklinux.dms.desktop debian/dms-git/usr/share/applications/com.danklinux.dms.desktop; \
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ override_dh_auto_install:
|
|||||||
fi; \
|
fi; \
|
||||||
if [ -n "$$SOURCE_DIR" ]; then \
|
if [ -n "$$SOURCE_DIR" ]; then \
|
||||||
mkdir -p debian/dms-greeter/usr/share/quickshell/dms-greeter && \
|
mkdir -p debian/dms-greeter/usr/share/quickshell/dms-greeter && \
|
||||||
( cd $$SOURCE_DIR && tar cf - --exclude=debian . ) | \
|
( cd $$SOURCE_DIR && tar chf - --exclude=debian . ) | \
|
||||||
( cd debian/dms-greeter/usr/share/quickshell/dms-greeter && tar xf - ) && \
|
( cd debian/dms-greeter/usr/share/quickshell/dms-greeter && tar xf - ) && \
|
||||||
install -Dm755 $$SOURCE_DIR/Modules/Greetd/assets/dms-greeter \
|
install -Dm755 $$SOURCE_DIR/Modules/Greetd/assets/dms-greeter \
|
||||||
debian/dms-greeter/usr/bin/dms-greeter && \
|
debian/dms-greeter/usr/bin/dms-greeter && \
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<service name="download_url">
|
<service name="download_url">
|
||||||
<param name="protocol">https</param>
|
<param name="protocol">https</param>
|
||||||
<param name="host">github.com</param>
|
<param name="host">github.com</param>
|
||||||
<param name="path">/AvengeMedia/DankMaterialShell/archive/refs/tags/v1.2.3.tar.gz</param>
|
<param name="path">/AvengeMedia/DankMaterialShell/releases/download/v1.2.3/dms-source.tar.gz</param>
|
||||||
<param name="filename">dms-source.tar.gz</param>
|
<param name="filename">dms-source.tar.gz</param>
|
||||||
</service>
|
</service>
|
||||||
<!-- Download amd64 binary -->
|
<!-- Download amd64 binary -->
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ override_dh_auto_install:
|
|||||||
mv "$$SOURCE_DIR" DankMaterialShell-$(UPSTREAM_VERSION); \
|
mv "$$SOURCE_DIR" DankMaterialShell-$(UPSTREAM_VERSION); \
|
||||||
fi
|
fi
|
||||||
if [ -d DankMaterialShell-$(UPSTREAM_VERSION) ]; then \
|
if [ -d DankMaterialShell-$(UPSTREAM_VERSION) ]; then \
|
||||||
cp -r DankMaterialShell-$(UPSTREAM_VERSION)/quickshell/* debian/dms/usr/share/quickshell/dms/; \
|
cp -rL DankMaterialShell-$(UPSTREAM_VERSION)/quickshell/* debian/dms/usr/share/quickshell/dms/; \
|
||||||
install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/systemd/dms.service debian/dms/usr/lib/systemd/user/dms.service; \
|
install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/systemd/dms.service debian/dms/usr/lib/systemd/user/dms.service; \
|
||||||
install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/dms-open.desktop debian/dms/usr/share/applications/dms-open.desktop; \
|
install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/dms-open.desktop debian/dms/usr/share/applications/dms-open.desktop; \
|
||||||
install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/com.danklinux.dms.desktop debian/dms/usr/share/applications/com.danklinux.dms.desktop; \
|
install -Dm644 DankMaterialShell-$(UPSTREAM_VERSION)/assets/com.danklinux.dms.desktop debian/dms/usr/share/applications/com.danklinux.dms.desktop; \
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ update_debian_dms_service() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i "s|/archive/refs/tags/v[0-9][^\"]*\.tar\.gz|/archive/refs/tags/v${base_version}.tar.gz|" "$service_path"
|
sed -i "s|/releases/download/v[0-9][^\"]*/dms-source\.tar\.gz|/releases/download/v${base_version}/dms-source.tar.gz|" "$service_path"
|
||||||
sed -i "s|/releases/download/v[0-9][^\"]*/dms-distropkg-amd64\.gz|/releases/download/v${base_version}/dms-distropkg-amd64.gz|" "$service_path"
|
sed -i "s|/releases/download/v[0-9][^\"]*/dms-distropkg-amd64\.gz|/releases/download/v${base_version}/dms-distropkg-amd64.gz|" "$service_path"
|
||||||
sed -i "s|/releases/download/v[0-9][^\"]*/dms-distropkg-arm64\.gz|/releases/download/v${base_version}/dms-distropkg-arm64.gz|" "$service_path"
|
sed -i "s|/releases/download/v[0-9][^\"]*/dms-distropkg-arm64\.gz|/releases/download/v${base_version}/dms-distropkg-arm64.gz|" "$service_path"
|
||||||
}
|
}
|
||||||
@@ -542,8 +542,8 @@ if [[ "$UPLOAD_OPENSUSE" == true ]] && [[ "$UPLOAD_DEBIAN" == false ]] && [[ -f
|
|||||||
if [[ -n "$GIT_URL" ]]; then
|
if [[ -n "$GIT_URL" ]]; then
|
||||||
echo " Cloning git source from: $GIT_URL (revision: ${GIT_REVISION:-master})"
|
echo " Cloning git source from: $GIT_URL (revision: ${GIT_REVISION:-master})"
|
||||||
SOURCE_DIR="$TEMP_DIR/dms-git-source"
|
SOURCE_DIR="$TEMP_DIR/dms-git-source"
|
||||||
if git clone --depth 1 --branch "${GIT_REVISION:-master}" "$GIT_URL" "$SOURCE_DIR" 2>/dev/null ||
|
if git clone --depth 1 --recurse-submodules --shallow-submodules --branch "${GIT_REVISION:-master}" "$GIT_URL" "$SOURCE_DIR" 2>/dev/null ||
|
||||||
git clone --depth 1 "$GIT_URL" "$SOURCE_DIR" 2>/dev/null; then
|
git clone --depth 1 --recurse-submodules --shallow-submodules "$GIT_URL" "$SOURCE_DIR" 2>/dev/null; then
|
||||||
cd "$SOURCE_DIR"
|
cd "$SOURCE_DIR"
|
||||||
if [[ -n "$GIT_REVISION" ]]; then
|
if [[ -n "$GIT_REVISION" ]]; then
|
||||||
git checkout "$GIT_REVISION" 2>/dev/null || true
|
git checkout "$GIT_REVISION" 2>/dev/null || true
|
||||||
@@ -586,7 +586,7 @@ if [[ "$UPLOAD_OPENSUSE" == true ]] && [[ "$UPLOAD_DEBIAN" == false ]] && [[ -f
|
|||||||
echo " Creating $SOURCE0 (directory: $EXPECTED_DIR)"
|
echo " Creating $SOURCE0 (directory: $EXPECTED_DIR)"
|
||||||
mkdir -p "$EXPECTED_DIR"
|
mkdir -p "$EXPECTED_DIR"
|
||||||
cp -a "$SOURCE_DIR"/. "$EXPECTED_DIR/"
|
cp -a "$SOURCE_DIR"/. "$EXPECTED_DIR/"
|
||||||
tar -czf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar -czhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
rm -rf "$EXPECTED_DIR"
|
rm -rf "$EXPECTED_DIR"
|
||||||
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
||||||
;;
|
;;
|
||||||
@@ -604,7 +604,7 @@ if [[ "$UPLOAD_OPENSUSE" == true ]] && [[ "$UPLOAD_DEBIAN" == false ]] && [[ -f
|
|||||||
|
|
||||||
echo " Creating $SOURCE0 (directory: $EXPECTED_DIR)"
|
echo " Creating $SOURCE0 (directory: $EXPECTED_DIR)"
|
||||||
cp -r "$SOURCE_DIR" "$EXPECTED_DIR"
|
cp -r "$SOURCE_DIR" "$EXPECTED_DIR"
|
||||||
tar -czf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar -czhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
rm -rf "$EXPECTED_DIR"
|
rm -rf "$EXPECTED_DIR"
|
||||||
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
||||||
|
|
||||||
@@ -656,8 +656,8 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ -d "distro/debian/$PACKAGE/debian" ]]; t
|
|||||||
if [[ -n "$GIT_URL" ]]; then
|
if [[ -n "$GIT_URL" ]]; then
|
||||||
echo " Cloning git source from: $GIT_URL (revision: ${GIT_REVISION:-master})"
|
echo " Cloning git source from: $GIT_URL (revision: ${GIT_REVISION:-master})"
|
||||||
SOURCE_DIR="$TEMP_DIR/dms-git-source"
|
SOURCE_DIR="$TEMP_DIR/dms-git-source"
|
||||||
if git clone --depth 1 --branch "${GIT_REVISION:-master}" "$GIT_URL" "$SOURCE_DIR" 2>/dev/null ||
|
if git clone --depth 1 --recurse-submodules --shallow-submodules --branch "${GIT_REVISION:-master}" "$GIT_URL" "$SOURCE_DIR" 2>/dev/null ||
|
||||||
git clone --depth 1 "$GIT_URL" "$SOURCE_DIR" 2>/dev/null; then
|
git clone --depth 1 --recurse-submodules --shallow-submodules "$GIT_URL" "$SOURCE_DIR" 2>/dev/null; then
|
||||||
cd "$SOURCE_DIR"
|
cd "$SOURCE_DIR"
|
||||||
if [[ -n "$GIT_REVISION" ]]; then
|
if [[ -n "$GIT_REVISION" ]]; then
|
||||||
git checkout "$GIT_REVISION" 2>/dev/null || true
|
git checkout "$GIT_REVISION" 2>/dev/null || true
|
||||||
@@ -820,11 +820,11 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ -d "distro/debian/$PACKAGE/debian" ]]; t
|
|||||||
mkdir -p "$EXPECTED_DIR"
|
mkdir -p "$EXPECTED_DIR"
|
||||||
cp -a "$SOURCE_DIR"/. "$EXPECTED_DIR/"
|
cp -a "$SOURCE_DIR"/. "$EXPECTED_DIR/"
|
||||||
if [[ "$SOURCE0" == *.tar.xz ]]; then
|
if [[ "$SOURCE0" == *.tar.xz ]]; then
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cJf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cJhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
elif [[ "$SOURCE0" == *.tar.bz2 ]]; then
|
elif [[ "$SOURCE0" == *.tar.bz2 ]]; then
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cjf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cjhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
else
|
else
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -czf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -czhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
fi
|
fi
|
||||||
rm -rf "$EXPECTED_DIR"
|
rm -rf "$EXPECTED_DIR"
|
||||||
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
||||||
@@ -835,11 +835,11 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ -d "distro/debian/$PACKAGE/debian" ]]; t
|
|||||||
echo " Creating $SOURCE0 (directory: $EXPECTED_DIR)"
|
echo " Creating $SOURCE0 (directory: $EXPECTED_DIR)"
|
||||||
cp -r "$SOURCE_DIR" "$EXPECTED_DIR"
|
cp -r "$SOURCE_DIR" "$EXPECTED_DIR"
|
||||||
if [[ "$SOURCE0" == *.tar.xz ]]; then
|
if [[ "$SOURCE0" == *.tar.xz ]]; then
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cJf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cJhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
elif [[ "$SOURCE0" == *.tar.bz2 ]]; then
|
elif [[ "$SOURCE0" == *.tar.bz2 ]]; then
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cjf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cjhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
else
|
else
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -czf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -czhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
fi
|
fi
|
||||||
rm -rf "$EXPECTED_DIR"
|
rm -rf "$EXPECTED_DIR"
|
||||||
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
||||||
@@ -849,11 +849,11 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ -d "distro/debian/$PACKAGE/debian" ]]; t
|
|||||||
echo " Creating $SOURCE0 (directory: $EXPECTED_DIR)"
|
echo " Creating $SOURCE0 (directory: $EXPECTED_DIR)"
|
||||||
cp -r "$SOURCE_DIR" "$EXPECTED_DIR"
|
cp -r "$SOURCE_DIR" "$EXPECTED_DIR"
|
||||||
if [[ "$SOURCE0" == *.tar.xz ]]; then
|
if [[ "$SOURCE0" == *.tar.xz ]]; then
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cJf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cJhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
elif [[ "$SOURCE0" == *.tar.bz2 ]]; then
|
elif [[ "$SOURCE0" == *.tar.bz2 ]]; then
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cjf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cjhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
else
|
else
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -czf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -czhf "$WORK_DIR/$SOURCE0" "$EXPECTED_DIR"
|
||||||
fi
|
fi
|
||||||
rm -rf "$EXPECTED_DIR"
|
rm -rf "$EXPECTED_DIR"
|
||||||
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
||||||
@@ -863,11 +863,11 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ -d "distro/debian/$PACKAGE/debian" ]]; t
|
|||||||
echo " Creating $SOURCE0 (directory: $DIR_NAME)"
|
echo " Creating $SOURCE0 (directory: $DIR_NAME)"
|
||||||
cp -r "$SOURCE_DIR" "$DIR_NAME"
|
cp -r "$SOURCE_DIR" "$DIR_NAME"
|
||||||
if [[ "$SOURCE0" == *.tar.xz ]]; then
|
if [[ "$SOURCE0" == *.tar.xz ]]; then
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cJf "$WORK_DIR/$SOURCE0" "$DIR_NAME"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cJhf "$WORK_DIR/$SOURCE0" "$DIR_NAME"
|
||||||
elif [[ "$SOURCE0" == *.tar.bz2 ]]; then
|
elif [[ "$SOURCE0" == *.tar.bz2 ]]; then
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cjf "$WORK_DIR/$SOURCE0" "$DIR_NAME"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -cjhf "$WORK_DIR/$SOURCE0" "$DIR_NAME"
|
||||||
else
|
else
|
||||||
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -czf "$WORK_DIR/$SOURCE0" "$DIR_NAME"
|
tar --sort=name --mtime='2000-01-01 00:00:00' --owner=0 --group=0 -czhf "$WORK_DIR/$SOURCE0" "$DIR_NAME"
|
||||||
fi
|
fi
|
||||||
rm -rf "$DIR_NAME"
|
rm -rf "$DIR_NAME"
|
||||||
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
echo " Created $SOURCE0 ($(stat -c%s "$WORK_DIR/$SOURCE0" 2>/dev/null || echo 0) bytes)"
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ EOF
|
|||||||
|
|
||||||
if [ ! -f "dms-source.tar.gz" ]; then
|
if [ ! -f "dms-source.tar.gz" ]; then
|
||||||
info "Downloading dms source for QML files..."
|
info "Downloading dms source for QML files..."
|
||||||
if wget -O dms-source.tar.gz "https://github.com/AvengeMedia/DankMaterialShell/archive/refs/tags/v${VERSION}.tar.gz"; then
|
if wget -O dms-source.tar.gz "https://github.com/AvengeMedia/DankMaterialShell/releases/download/v${VERSION}/dms-source.tar.gz"; then
|
||||||
success "source tarball downloaded"
|
success "source tarball downloaded"
|
||||||
else
|
else
|
||||||
error "Failed to download dms-source.tar.gz"
|
error "Failed to download dms-source.tar.gz"
|
||||||
@@ -356,7 +356,7 @@ EOF
|
|||||||
info "Downloading source for dms-greeter..."
|
info "Downloading source for dms-greeter..."
|
||||||
if [ ! -f "dms-greeter-source.tar.gz" ]; then
|
if [ ! -f "dms-greeter-source.tar.gz" ]; then
|
||||||
info "Downloading dms-greeter source..."
|
info "Downloading dms-greeter source..."
|
||||||
if wget -O dms-greeter-source.tar.gz "https://github.com/AvengeMedia/DankMaterialShell/archive/refs/tags/v${VERSION}.tar.gz"; then
|
if wget -O dms-greeter-source.tar.gz "https://github.com/AvengeMedia/DankMaterialShell/releases/download/v${VERSION}/dms-source.tar.gz"; then
|
||||||
success "source tarball downloaded"
|
success "source tarball downloaded"
|
||||||
else
|
else
|
||||||
error "Failed to download dms-greeter-source.tar.gz"
|
error "Failed to download dms-greeter-source.tar.gz"
|
||||||
@@ -386,7 +386,7 @@ if [ "$IS_GIT_PACKAGE" = true ] && [ -n "$GIT_REPO" ]; then
|
|||||||
|
|
||||||
info "Cloning $GIT_REPO from GitHub (getting latest commit info)..."
|
info "Cloning $GIT_REPO from GitHub (getting latest commit info)..."
|
||||||
TEMP_CLONE=$(mktemp -d "$TEMP_BASE/ppa_clone_XXXXXX")
|
TEMP_CLONE=$(mktemp -d "$TEMP_BASE/ppa_clone_XXXXXX")
|
||||||
if git clone "https://github.com/$GIT_REPO.git" "$TEMP_CLONE"; then
|
if git clone --recurse-submodules --shallow-submodules "https://github.com/$GIT_REPO.git" "$TEMP_CLONE"; then
|
||||||
GIT_COMMIT_HASH=$(cd "$TEMP_CLONE" && git rev-parse --short HEAD)
|
GIT_COMMIT_HASH=$(cd "$TEMP_CLONE" && git rev-parse --short HEAD)
|
||||||
GIT_COMMIT_COUNT=$(cd "$TEMP_CLONE" && git rev-list --count HEAD)
|
GIT_COMMIT_COUNT=$(cd "$TEMP_CLONE" && git rev-list --count HEAD)
|
||||||
UPSTREAM_VERSION=$(cd "$TEMP_CLONE" && git tag -l "v*" | sed 's/^v//' | sort -V | tail -1)
|
UPSTREAM_VERSION=$(cd "$TEMP_CLONE" && git tag -l "v*" | sed 's/^v//' | sort -V | tail -1)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ override_dh_auto_install:
|
|||||||
|
|
||||||
# Install QML files from git clone
|
# Install QML files from git clone
|
||||||
mkdir -p debian/dms-git/usr/share/quickshell/dms
|
mkdir -p debian/dms-git/usr/share/quickshell/dms
|
||||||
cp -r dms-git-repo/* debian/dms-git/usr/share/quickshell/dms/
|
cp -rL dms-git-repo/* debian/dms-git/usr/share/quickshell/dms/
|
||||||
|
|
||||||
# Remove unnecessary directories
|
# Remove unnecessary directories
|
||||||
rm -rf debian/dms-git/usr/share/quickshell/dms/core
|
rm -rf debian/dms-git/usr/share/quickshell/dms/core
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ override_dh_auto_build:
|
|||||||
override_dh_auto_install:
|
override_dh_auto_install:
|
||||||
# Install greeter files to shared data location
|
# Install greeter files to shared data location
|
||||||
mkdir -p debian/dms-greeter/usr/share/quickshell/dms-greeter
|
mkdir -p debian/dms-greeter/usr/share/quickshell/dms-greeter
|
||||||
cp -r DankMaterialShell-$(BASE_VERSION)/quickshell/* debian/dms-greeter/usr/share/quickshell/dms-greeter/
|
cp -rL DankMaterialShell-$(BASE_VERSION)/quickshell/* debian/dms-greeter/usr/share/quickshell/dms-greeter/
|
||||||
|
|
||||||
# Install launcher script
|
# Install launcher script
|
||||||
install -Dm755 DankMaterialShell-$(BASE_VERSION)/quickshell/Modules/Greetd/assets/dms-greeter \
|
install -Dm755 DankMaterialShell-$(BASE_VERSION)/quickshell/Modules/Greetd/assets/dms-greeter \
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ override_dh_auto_install:
|
|||||||
|
|
||||||
# Install QML files from source tarball
|
# Install QML files from source tarball
|
||||||
mkdir -p debian/dms/usr/share/quickshell/dms
|
mkdir -p debian/dms/usr/share/quickshell/dms
|
||||||
cp -r DankMaterialShell-$(BASE_VERSION)/* debian/dms/usr/share/quickshell/dms/
|
cp -rL DankMaterialShell-$(BASE_VERSION)/* debian/dms/usr/share/quickshell/dms/
|
||||||
|
|
||||||
# Remove unnecessary directories
|
# Remove unnecessary directories
|
||||||
rm -rf debian/dms/usr/share/quickshell/dms/core
|
rm -rf debian/dms/usr/share/quickshell/dms/core
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ short_desc="DankMaterialShell greeter for greetd"
|
|||||||
maintainer="AvengeMedia <AvengeMedia.US@gmail.com>"
|
maintainer="AvengeMedia <AvengeMedia.US@gmail.com>"
|
||||||
license="MIT"
|
license="MIT"
|
||||||
homepage="https://danklinux.com"
|
homepage="https://danklinux.com"
|
||||||
distfiles="https://github.com/AvengeMedia/DankMaterialShell/archive/refs/tags/v${version}.tar.gz"
|
distfiles="https://github.com/AvengeMedia/DankMaterialShell/releases/download/v${version}/dms-source.tar.gz"
|
||||||
checksum=14f2678d6a15223ba069d1b8c8a21a5564b735d190c231f62ed44fd8bf48677c
|
checksum=14f2678d6a15223ba069d1b8c8a21a5564b735d190c231f62ed44fd8bf48677c
|
||||||
|
|
||||||
depends="greetd quickshell acl-progs dbus elogind pam_rundir mesa-dri"
|
depends="greetd quickshell acl-progs dbus elogind pam_rundir mesa-dri"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ maintainer="AvengeMedia <AvengeMedia.US@gmail.com>"
|
|||||||
license="MIT"
|
license="MIT"
|
||||||
homepage="https://danklinux.com"
|
homepage="https://danklinux.com"
|
||||||
changelog="https://github.com/AvengeMedia/DankMaterialShell/releases"
|
changelog="https://github.com/AvengeMedia/DankMaterialShell/releases"
|
||||||
distfiles="https://github.com/AvengeMedia/DankMaterialShell/archive/refs/tags/v${version}.tar.gz"
|
distfiles="https://github.com/AvengeMedia/DankMaterialShell/releases/download/v${version}/dms-source.tar.gz"
|
||||||
checksum=14f2678d6a15223ba069d1b8c8a21a5564b735d190c231f62ed44fd8bf48677c
|
checksum=14f2678d6a15223ba069d1b8c8a21a5564b735d190c231f62ed44fd8bf48677c
|
||||||
|
|
||||||
# Optional feature deps are listed in distro/void/README.md.
|
# Optional feature deps are listed in distro/void/README.md.
|
||||||
|
|||||||
Generated
+17
@@ -1,5 +1,21 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"dank-qml-common": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1784332064,
|
||||||
|
"narHash": "sha256-n0LKLirPnNSXYxElK1IpnybEwU0nnyso4kpsEFX88U0=",
|
||||||
|
"owner": "AvengeMedia",
|
||||||
|
"repo": "dank-qml-common",
|
||||||
|
"rev": "5942bc1c60b4538940922b58112c8ae125880891",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "AvengeMedia",
|
||||||
|
"repo": "dank-qml-common",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
@@ -34,6 +50,7 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"dank-qml-common": "dank-qml-common",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,17 @@
|
|||||||
url = "github:NixOS/flake-compat";
|
url = "github:NixOS/flake-compat";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
dank-qml-common = {
|
||||||
|
url = "github:AvengeMedia/dank-qml-common";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{
|
{
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
|
dank-qml-common,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -125,6 +130,10 @@
|
|||||||
mkdir -p $out/share/quickshell/dms
|
mkdir -p $out/share/quickshell/dms
|
||||||
cp -r ${rootSrc}/quickshell/. $out/share/quickshell/dms/
|
cp -r ${rootSrc}/quickshell/. $out/share/quickshell/dms/
|
||||||
|
|
||||||
|
rm -f $out/share/quickshell/dms/DankCommon
|
||||||
|
cp -r ${dank-qml-common}/DankCommon $out/share/quickshell/dms/DankCommon
|
||||||
|
chmod -R u+w $out/share/quickshell/dms/DankCommon
|
||||||
|
|
||||||
chmod u+w $out/share/quickshell/dms/VERSION
|
chmod u+w $out/share/quickshell/dms/VERSION
|
||||||
echo "${version}" > $out/share/quickshell/dms/VERSION
|
echo "${version}" > $out/share/quickshell/dms/VERSION
|
||||||
|
|
||||||
|
|||||||
@@ -141,13 +141,15 @@ DankMaterialShell/
|
|||||||
│ │ ├── ipp/ # Internet Printing Protocol
|
│ │ ├── ipp/ # Internet Printing Protocol
|
||||||
│ │ └── syncmap/ # Thread-safe map
|
│ │ └── syncmap/ # Thread-safe map
|
||||||
│ └── go.mod # Go module definition
|
│ └── go.mod # Go module definition
|
||||||
|
├── dank-qml-common/ # Shared widget library (git submodule)
|
||||||
├── quickshell/ # QML frontend (UI layer) - see "QML Frontend Architecture" below
|
├── quickshell/ # QML frontend (UI layer) - see "QML Frontend Architecture" below
|
||||||
│ ├── shell.qml # Main entry point
|
│ ├── shell.qml # Main entry point
|
||||||
│ ├── Services/ # IPC client wrappers
|
│ ├── Services/ # IPC client wrappers
|
||||||
│ ├── Modules/ # UI components
|
│ ├── Modules/ # UI components
|
||||||
│ ├── Widgets/ # Reusable controls
|
│ ├── Widgets/ # Reusable controls
|
||||||
│ ├── Modals/ # Full-screen overlays
|
│ ├── Modals/ # Full-screen overlays
|
||||||
│ └── Common/ # Shared resources
|
│ ├── Common/ # Shared resources
|
||||||
|
│ └── DankCommon/ # Symlink to ../dank-qml-common/DankCommon
|
||||||
├── distro/ # Distribution packaging
|
├── distro/ # Distribution packaging
|
||||||
│ ├── arch/ # AUR packages
|
│ ├── arch/ # AUR packages
|
||||||
│ ├── fedora/ # RPM specs
|
│ ├── fedora/ # RPM specs
|
||||||
@@ -490,6 +492,8 @@ import qs.Services // For service access
|
|||||||
import qs.Widgets // For reusable widgets (DankIcon, etc.)
|
import qs.Widgets // For reusable widgets (DankIcon, etc.)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Many widgets in `Widgets/`, `Common/`, and `Modals/FileBrowser/` are thin wrappers over the shared dank-qml-common library (`quickshell/DankCommon/`, a submodule symlink). Keep importing them through `qs.Widgets`, `qs.Common`, and `qs.Modals.FileBrowser` — the wrappers are the stable API for the shell and for plugins. Edit the implementations in `dank-qml-common/` (see CONTRIBUTING.md, "Shared widgets").
|
||||||
|
|
||||||
#### Go Import Order
|
#### Go Import Order
|
||||||
|
|
||||||
Follow standard Go conventions:
|
Follow standard Go conventions:
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
The Wolverine
|
Marble Tabby
|
||||||
|
|||||||
@@ -1,66 +1,11 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
pragma ComponentBehavior: Bound
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import qs.DankCommon.Common as DankCommon
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
readonly property var rounding: DankCommon.Appearance.rounding
|
||||||
|
readonly property var spacing: DankCommon.Appearance.spacing
|
||||||
readonly property Rounding rounding: Rounding {}
|
readonly property var fontSize: DankCommon.Appearance.fontSize
|
||||||
readonly property Spacing spacing: Spacing {}
|
readonly property var anim: DankCommon.Appearance.anim
|
||||||
readonly property FontSize fontSize: FontSize {}
|
|
||||||
readonly property Anim anim: Anim {}
|
|
||||||
|
|
||||||
component Rounding: QtObject {
|
|
||||||
readonly property int small: 8
|
|
||||||
readonly property int normal: 12
|
|
||||||
readonly property int large: 16
|
|
||||||
readonly property int extraLarge: 24
|
|
||||||
readonly property int full: 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
component Spacing: QtObject {
|
|
||||||
readonly property int small: 4
|
|
||||||
readonly property int normal: 8
|
|
||||||
readonly property int large: 12
|
|
||||||
readonly property int extraLarge: 16
|
|
||||||
readonly property int huge: 24
|
|
||||||
}
|
|
||||||
|
|
||||||
component FontSize: QtObject {
|
|
||||||
readonly property int small: 12
|
|
||||||
readonly property int normal: 14
|
|
||||||
readonly property int large: 16
|
|
||||||
readonly property int extraLarge: 20
|
|
||||||
readonly property int huge: 24
|
|
||||||
}
|
|
||||||
|
|
||||||
component AnimCurves: QtObject {
|
|
||||||
readonly property list<real> standard: [0.2, 0, 0, 1, 1, 1]
|
|
||||||
readonly property list<real> standardAccel: [0.3, 0, 1, 1, 1, 1]
|
|
||||||
readonly property list<real> standardDecel: [0, 0, 0, 1, 1, 1]
|
|
||||||
readonly property list<real> emphasized: [0.05, 0, 2 / 15, 0.06, 1
|
|
||||||
/ 6, 0.4, 5 / 24, 0.82, 0.25, 1, 1, 1]
|
|
||||||
readonly property list<real> emphasizedAccel: [0.3, 0, 0.8, 0.15, 1, 1]
|
|
||||||
readonly property list<real> emphasizedDecel: [0.05, 0.7, 0.1, 1, 1, 1]
|
|
||||||
readonly property list<real> expressiveFastSpatial: [0.42, 1.67, 0.21, 0.9, 1, 1]
|
|
||||||
readonly property list<real> expressiveDefaultSpatial: [0.38, 1.21, 0.22, 1, 1, 1]
|
|
||||||
readonly property list<real> expressiveEffects: [0.34, 0.8, 0.34, 1, 1, 1]
|
|
||||||
}
|
|
||||||
|
|
||||||
component AnimDurations: QtObject {
|
|
||||||
readonly property int quick: 150
|
|
||||||
readonly property int normal: 300
|
|
||||||
readonly property int slow: 500
|
|
||||||
readonly property int extraSlow: 1000
|
|
||||||
readonly property int expressiveFastSpatial: 350
|
|
||||||
readonly property int expressiveDefaultSpatial: 500
|
|
||||||
readonly property int expressiveEffects: 200
|
|
||||||
}
|
|
||||||
|
|
||||||
component Anim: QtObject {
|
|
||||||
readonly property AnimCurves curves: AnimCurves {}
|
|
||||||
readonly property AnimDurations durations: AnimDurations {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Singleton {
|
|||||||
id: root
|
id: root
|
||||||
readonly property var log: Log.scoped("CacheData")
|
readonly property var log: Log.scoped("CacheData")
|
||||||
|
|
||||||
readonly property int cacheConfigVersion: 2
|
readonly property int cacheConfigVersion: 1
|
||||||
|
|
||||||
readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true"
|
readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true"
|
||||||
|
|
||||||
@@ -19,21 +19,10 @@ Singleton {
|
|||||||
readonly property string _stateDir: Paths.strip(_stateUrl)
|
readonly property string _stateDir: Paths.strip(_stateUrl)
|
||||||
|
|
||||||
property bool _loading: false
|
property bool _loading: false
|
||||||
property bool _hasLoaded: false
|
|
||||||
property int _loadedCacheVersion: 0
|
|
||||||
|
|
||||||
readonly property var _pinKeys: ["brightnessDevicePins", "wifiNetworkPins", "bluetoothDevicePins", "audioInputDevicePins", "audioOutputDevicePins"]
|
|
||||||
readonly property var _dataKeys: ["wallpaperLastPath", "profileLastPath", "fileBrowserSettings"].concat(_pinKeys)
|
|
||||||
|
|
||||||
property string wallpaperLastPath: ""
|
property string wallpaperLastPath: ""
|
||||||
property string profileLastPath: ""
|
property string profileLastPath: ""
|
||||||
|
|
||||||
property var brightnessDevicePins: ({})
|
|
||||||
property var wifiNetworkPins: ({})
|
|
||||||
property var bluetoothDevicePins: ({})
|
|
||||||
property var audioInputDevicePins: ({})
|
|
||||||
property var audioOutputDevicePins: ({})
|
|
||||||
|
|
||||||
property var fileBrowserSettings: ({
|
property var fileBrowserSettings: ({
|
||||||
"wallpaper": {
|
"wallpaper": {
|
||||||
"lastPath": "",
|
"lastPath": "",
|
||||||
@@ -93,46 +82,8 @@ Singleton {
|
|||||||
|
|
||||||
function loadCache() {
|
function loadCache() {
|
||||||
_loading = true;
|
_loading = true;
|
||||||
try {
|
parseCache(cacheFile.text());
|
||||||
parseCache(cacheFile.text());
|
_loading = false;
|
||||||
} finally {
|
|
||||||
_loading = false;
|
|
||||||
_hasLoaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(key, value) {
|
|
||||||
if (_dataKeys.indexOf(key) < 0) {
|
|
||||||
log.warn("Unknown cache key:", key);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
root[key] = value;
|
|
||||||
saveCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
function migratePins(pins) {
|
|
||||||
if (!pins)
|
|
||||||
return;
|
|
||||||
if (!_hasLoaded)
|
|
||||||
loadCache();
|
|
||||||
if (_loadedCacheVersion >= cacheConfigVersion)
|
|
||||||
return;
|
|
||||||
|
|
||||||
let migrated = false;
|
|
||||||
for (const key of _pinKeys) {
|
|
||||||
const legacy = pins[key];
|
|
||||||
if (!legacy || Object.keys(legacy).length === 0)
|
|
||||||
continue;
|
|
||||||
if (Object.keys(root[key] || {}).length > 0)
|
|
||||||
continue;
|
|
||||||
root[key] = legacy;
|
|
||||||
migrated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!migrated)
|
|
||||||
return;
|
|
||||||
log.info("Migrated device pins from settings.json");
|
|
||||||
saveCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCache(content) {
|
function parseCache(content) {
|
||||||
@@ -140,7 +91,6 @@ Singleton {
|
|||||||
try {
|
try {
|
||||||
if (content && content.trim()) {
|
if (content && content.trim()) {
|
||||||
const cache = JSON.parse(content);
|
const cache = JSON.parse(content);
|
||||||
_loadedCacheVersion = cache.configVersion || 0;
|
|
||||||
|
|
||||||
wallpaperLastPath = cache.wallpaperLastPath !== undefined ? cache.wallpaperLastPath : "";
|
wallpaperLastPath = cache.wallpaperLastPath !== undefined ? cache.wallpaperLastPath : "";
|
||||||
profileLastPath = cache.profileLastPath !== undefined ? cache.profileLastPath : "";
|
profileLastPath = cache.profileLastPath !== undefined ? cache.profileLastPath : "";
|
||||||
@@ -176,10 +126,6 @@ Singleton {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key of _pinKeys) {
|
|
||||||
root[key] = cache[key] !== undefined ? cache[key] : {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cache.configVersion === undefined) {
|
if (cache.configVersion === undefined) {
|
||||||
migrateFromUndefinedToV1(cache);
|
migrateFromUndefinedToV1(cache);
|
||||||
cleanupUnusedKeys();
|
cleanupUnusedKeys();
|
||||||
@@ -196,16 +142,12 @@ Singleton {
|
|||||||
function saveCache() {
|
function saveCache() {
|
||||||
if (_loading)
|
if (_loading)
|
||||||
return;
|
return;
|
||||||
const data = {
|
cacheFile.setText(JSON.stringify({
|
||||||
"wallpaperLastPath": wallpaperLastPath,
|
"wallpaperLastPath": wallpaperLastPath,
|
||||||
"profileLastPath": profileLastPath,
|
"profileLastPath": profileLastPath,
|
||||||
"fileBrowserSettings": fileBrowserSettings,
|
"fileBrowserSettings": fileBrowserSettings,
|
||||||
"configVersion": cacheConfigVersion
|
"configVersion": cacheConfigVersion
|
||||||
};
|
}, null, 2));
|
||||||
for (const key of _pinKeys) {
|
|
||||||
data[key] = root[key];
|
|
||||||
}
|
|
||||||
cacheFile.setText(JSON.stringify(data, null, 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateFromUndefinedToV1(cache) {
|
function migrateFromUndefinedToV1(cache) {
|
||||||
@@ -213,7 +155,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanupUnusedKeys() {
|
function cleanupUnusedKeys() {
|
||||||
const validKeys = _dataKeys.concat(["configVersion"]);
|
const validKeys = ["wallpaperLastPath", "profileLastPath", "fileBrowserSettings", "configVersion"];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const content = cacheFile.text();
|
const content = cacheFile.text();
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Common as DankCommon
|
||||||
import qs.Common
|
|
||||||
|
|
||||||
// Reusable NumberAnimation wrapper
|
DankCommon.DankAnim {}
|
||||||
NumberAnimation {
|
|
||||||
duration: Theme.expressiveDurations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Theme.expressiveCurves.standard
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Common as DankCommon
|
||||||
import qs.Common
|
|
||||||
|
|
||||||
// Reusable ColorAnimation wrapper
|
DankCommon.DankColorAnim {}
|
||||||
ColorAnimation {
|
|
||||||
duration: Theme.expressiveDurations.normal
|
|
||||||
easing.type: Easing.BezierSpline
|
|
||||||
easing.bezierCurve: Theme.expressiveCurves.standard
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,64 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Common as DankCommon
|
||||||
import Quickshell.Io
|
|
||||||
|
|
||||||
Item {
|
DankCommon.DankSocket {}
|
||||||
id: root
|
|
||||||
|
|
||||||
property alias path: socket.path
|
|
||||||
property alias parser: socket.parser
|
|
||||||
property bool connected: false
|
|
||||||
property bool linkUp: false
|
|
||||||
|
|
||||||
property int reconnectBaseMs: 400
|
|
||||||
property int reconnectMaxMs: 15000
|
|
||||||
|
|
||||||
property int _reconnectAttempt: 0
|
|
||||||
|
|
||||||
signal connectionStateChanged
|
|
||||||
|
|
||||||
onConnectedChanged: {
|
|
||||||
socket.connected = connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
Socket {
|
|
||||||
id: socket
|
|
||||||
|
|
||||||
onConnectionStateChanged: {
|
|
||||||
root.linkUp = connected;
|
|
||||||
root.connectionStateChanged();
|
|
||||||
if (connected) {
|
|
||||||
root._reconnectAttempt = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (root.connected) {
|
|
||||||
root._scheduleReconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: reconnectTimer
|
|
||||||
interval: 0
|
|
||||||
repeat: false
|
|
||||||
onTriggered: {
|
|
||||||
socket.connected = false;
|
|
||||||
Qt.callLater(() => socket.connected = true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function send(data) {
|
|
||||||
const json = typeof data === "string" ? data : JSON.stringify(data);
|
|
||||||
const message = json.endsWith("\n") ? json : json + "\n";
|
|
||||||
socket.write(message);
|
|
||||||
socket.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _scheduleReconnect() {
|
|
||||||
const pow = Math.min(_reconnectAttempt, 10);
|
|
||||||
const base = Math.min(reconnectBaseMs * Math.pow(2, pow), reconnectMaxMs);
|
|
||||||
const jitter = Math.floor(Math.random() * Math.floor(base / 4));
|
|
||||||
reconnectTimer.interval = base + jitter;
|
|
||||||
reconnectTimer.restart();
|
|
||||||
_reconnectAttempt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,54 +1,3 @@
|
|||||||
pragma ComponentBehavior: Bound
|
import qs.DankCommon.Common as DankCommon
|
||||||
|
|
||||||
import QtQuick
|
DankCommon.ElevationShadow {}
|
||||||
import qs.Common
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property var level: Theme.elevationLevel2
|
|
||||||
property string direction: Theme.elevationLightDirection
|
|
||||||
property real fallbackOffset: 4
|
|
||||||
|
|
||||||
property color targetColor: "white"
|
|
||||||
property real targetRadius: Theme.cornerRadius
|
|
||||||
property real topLeftRadius: targetRadius
|
|
||||||
property real topRightRadius: targetRadius
|
|
||||||
property real bottomLeftRadius: targetRadius
|
|
||||||
property real bottomRightRadius: targetRadius
|
|
||||||
property color borderColor: "transparent"
|
|
||||||
property real borderWidth: 0
|
|
||||||
|
|
||||||
property real sourceX: 0
|
|
||||||
property real sourceY: 0
|
|
||||||
property real sourceWidth: width
|
|
||||||
property real sourceHeight: height
|
|
||||||
|
|
||||||
property bool shadowEnabled: Theme.elevationEnabled
|
|
||||||
property real shadowBlurPx: level && level.blurPx !== undefined ? level.blurPx : 0
|
|
||||||
property real shadowSpreadPx: level && level.spreadPx !== undefined ? level.spreadPx : 0
|
|
||||||
property real shadowOffsetX: Theme.elevationOffsetXFor(level, direction, fallbackOffset)
|
|
||||||
property real shadowOffsetY: Theme.elevationOffsetYFor(level, direction, fallbackOffset)
|
|
||||||
property color shadowColor: Theme.elevationShadowColor(level)
|
|
||||||
property real shadowOpacity: 1
|
|
||||||
|
|
||||||
readonly property var _ambient: Theme.elevationAmbient(level)
|
|
||||||
readonly property real _pad: shadowEnabled ? Math.ceil(Math.max(shadowBlurPx + shadowSpreadPx + Math.max(Math.abs(shadowOffsetX), Math.abs(shadowOffsetY)), _ambient.blurPx + _ambient.spreadPx) + 2) : 0
|
|
||||||
|
|
||||||
ShaderEffect {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: -root._pad
|
|
||||||
fragmentShader: Qt.resolvedUrl("../Shaders/qsb/elevation_rect.frag.qsb")
|
|
||||||
|
|
||||||
property real widthPx: width
|
|
||||||
property real heightPx: height
|
|
||||||
property real borderWidth: root.borderWidth
|
|
||||||
property vector4d rectPx: Qt.vector4d(root._pad + root.sourceX, root._pad + root.sourceY, root.sourceWidth, root.sourceHeight)
|
|
||||||
property vector4d cornerRadius: Qt.vector4d(root.topLeftRadius, root.topRightRadius, root.bottomRightRadius, root.bottomLeftRadius)
|
|
||||||
property vector4d fillColor: Qt.vector4d(root.targetColor.r, root.targetColor.g, root.targetColor.b, root.targetColor.a)
|
|
||||||
property vector4d borderColor: Qt.vector4d(root.borderColor.r, root.borderColor.g, root.borderColor.b, root.borderColor.a)
|
|
||||||
property vector4d shadowColor: Qt.vector4d(root.shadowColor.r, root.shadowColor.g, root.shadowColor.b, root.shadowEnabled ? root.shadowColor.a * root.shadowOpacity : 0)
|
|
||||||
property vector4d shadowParam: Qt.vector4d(Math.max(0, root.shadowBlurPx), root.shadowSpreadPx, root.shadowOffsetX, root.shadowOffsetY)
|
|
||||||
property vector4d ambientParam: Qt.vector4d(root._ambient.blurPx, root._ambient.spreadPx, root.shadowEnabled ? root._ambient.alpha * root.shadowOpacity : 0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+78
-12
@@ -25,6 +25,7 @@ Singleton {
|
|||||||
readonly property bool isRtl: _rtlLanguages.includes(_lang)
|
readonly property bool isRtl: _rtlLanguages.includes(_lang)
|
||||||
|
|
||||||
readonly property url translationsFolder: Qt.resolvedUrl("../translations/poexports")
|
readonly property url translationsFolder: Qt.resolvedUrl("../translations/poexports")
|
||||||
|
readonly property url commonTranslationsFolder: Qt.resolvedUrl("../DankCommon/translations/poexports")
|
||||||
|
|
||||||
readonly property alias folder: dir.folder
|
readonly property alias folder: dir.folder
|
||||||
property var presentLocales: ({
|
property var presentLocales: ({
|
||||||
@@ -32,8 +33,11 @@ Singleton {
|
|||||||
})
|
})
|
||||||
property var translations: ({})
|
property var translations: ({})
|
||||||
property bool translationsLoaded: false
|
property bool translationsLoaded: false
|
||||||
|
property var commonTranslations: ({})
|
||||||
|
property bool commonTranslationsLoaded: false
|
||||||
|
|
||||||
property url _selectedPath: ""
|
property url _selectedPath: ""
|
||||||
|
property url _commonSelectedPath: ""
|
||||||
|
|
||||||
FolderListModel {
|
FolderListModel {
|
||||||
id: dir
|
id: dir
|
||||||
@@ -48,6 +52,18 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FolderListModel {
|
||||||
|
id: commonDir
|
||||||
|
folder: root.commonTranslationsFolder
|
||||||
|
nameFilters: ["*.json"]
|
||||||
|
showDirs: false
|
||||||
|
showDotAndDotDot: false
|
||||||
|
|
||||||
|
onStatusChanged: if (status === FolderListModel.Ready) {
|
||||||
|
root._pickCommonTranslation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
id: translationLoader
|
id: translationLoader
|
||||||
path: root._selectedPath
|
path: root._selectedPath
|
||||||
@@ -69,6 +85,22 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileView {
|
||||||
|
id: commonTranslationLoader
|
||||||
|
path: root._commonSelectedPath
|
||||||
|
printErrors: false
|
||||||
|
|
||||||
|
onLoaded: {
|
||||||
|
try {
|
||||||
|
root.commonTranslations = JSON.parse(text());
|
||||||
|
root.commonTranslationsLoaded = true;
|
||||||
|
log.info(`I18n: Loaded DankCommon translations (${Object.keys(root.commonTranslations).length} contexts)`);
|
||||||
|
} catch (e) {
|
||||||
|
log.warn("I18n: Error parsing DankCommon translations:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function locale() {
|
function locale() {
|
||||||
if (SessionData.timeLocale)
|
if (SessionData.timeLocale)
|
||||||
return Qt.locale(SessionData.timeLocale);
|
return Qt.locale(SessionData.timeLocale);
|
||||||
@@ -117,24 +149,58 @@ Singleton {
|
|||||||
log.warn("Falling back to built-in English strings");
|
log.warn("Falling back to built-in English strings");
|
||||||
}
|
}
|
||||||
|
|
||||||
function tr(term, context) {
|
function _pickCommonTranslation() {
|
||||||
if (!translationsLoaded || !translations)
|
const present = {};
|
||||||
return term;
|
for (let i = 0; i < commonDir.count; i++) {
|
||||||
const ctx = context || term;
|
const name = commonDir.get(i, "fileName");
|
||||||
if (translations[ctx] && translations[ctx][term])
|
if (name && name.endsWith(".json"))
|
||||||
return translations[ctx][term];
|
present[name.slice(0, -5)] = true;
|
||||||
for (const c in translations) {
|
}
|
||||||
if (translations[c] && translations[c][term])
|
for (let i = 0; i < _candidates.length; i++) {
|
||||||
return translations[c][term];
|
if (!present[_candidates[i]])
|
||||||
|
continue;
|
||||||
|
_commonSelectedPath = commonTranslationsFolder + "/" + _candidates[i] + ".json";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _lookup(table, term, context) {
|
||||||
|
if (!table)
|
||||||
|
return "";
|
||||||
|
if (context && table[context] && table[context][term])
|
||||||
|
return table[context][term];
|
||||||
|
if (table[term] && table[term][term])
|
||||||
|
return table[term][term];
|
||||||
|
for (const c in table) {
|
||||||
|
if (table[c] && table[c][term])
|
||||||
|
return table[c][term];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// isRealContext is consumed by translations/extract_translations.py only:
|
||||||
|
// pass a literal `true` (same line) to give (term, context) its own POEditor
|
||||||
|
// translation slot. Lookup ignores it -- a real context exists as a bucket
|
||||||
|
// in the export, a comment-only context does not.
|
||||||
|
function tr(term, context, isRealContext) {
|
||||||
|
if (translationsLoaded) {
|
||||||
|
const hit = _lookup(translations, term, context);
|
||||||
|
if (hit)
|
||||||
|
return hit;
|
||||||
|
}
|
||||||
|
if (commonTranslationsLoaded) {
|
||||||
|
const hit = _lookup(commonTranslations, term, context);
|
||||||
|
if (hit)
|
||||||
|
return hit;
|
||||||
}
|
}
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trContext(context, term) {
|
function trContext(context, term) {
|
||||||
if (!translationsLoaded || !translations)
|
if (translationsLoaded && translations[context] && translations[context][term])
|
||||||
return term;
|
|
||||||
if (translations[context] && translations[context][term])
|
|
||||||
return translations[context][term];
|
return translations[context][term];
|
||||||
|
if (commonTranslationsLoaded && commonTranslations[context] && commonTranslations[context][term])
|
||||||
|
return commonTranslations[context][term];
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,72 +1,13 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
pragma ComponentBehavior: Bound
|
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import qs.Common
|
import qs.DankCommon.Common as DankCommon
|
||||||
|
|
||||||
// Reusable ListView/GridView transitions
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
readonly property bool enabled: DankCommon.ListViewTransitions.enabled
|
||||||
|
readonly property Transition add: DankCommon.ListViewTransitions.add
|
||||||
// 0ms ViewTransitions break ListView delegate cleanup, so null the set when the shortest
|
readonly property Transition remove: DankCommon.ListViewTransitions.remove
|
||||||
// duration truncates to 0. Keep this gate - don't inline these back into add/remove/etc.
|
readonly property Transition displaced: DankCommon.ListViewTransitions.displaced
|
||||||
readonly property bool enabled: Math.floor(Theme.currentAnimationBaseDuration * 0.4) >= 1
|
readonly property Transition move: DankCommon.ListViewTransitions.move
|
||||||
|
|
||||||
readonly property Transition add: enabled ? _add : null
|
|
||||||
readonly property Transition remove: null
|
|
||||||
readonly property Transition displaced: enabled ? _displaced : null
|
|
||||||
readonly property Transition move: enabled ? _move : null
|
|
||||||
|
|
||||||
readonly property int _staggerMs: Math.round(Theme.currentAnimationBaseDuration * 0.03)
|
|
||||||
readonly property int _staggerCap: 8
|
|
||||||
|
|
||||||
readonly property Transition _add: Transition {
|
|
||||||
id: addTransition
|
|
||||||
|
|
||||||
SequentialAnimation {
|
|
||||||
PropertyAction {
|
|
||||||
property: "opacity"
|
|
||||||
value: 0
|
|
||||||
}
|
|
||||||
PauseAnimation {
|
|
||||||
duration: Math.max(0, Math.min(addTransition.ViewTransition.index - (addTransition.ViewTransition.targetIndexes[0] ?? 0), root._staggerCap)) * root._staggerMs
|
|
||||||
}
|
|
||||||
DankAnim {
|
|
||||||
property: "opacity"
|
|
||||||
from: 0
|
|
||||||
to: 1
|
|
||||||
duration: Theme.expressiveDurations.fast
|
|
||||||
easing.bezierCurve: Theme.expressiveCurves.emphasizedDecel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly property Transition _displaced: Transition {
|
|
||||||
DankAnim {
|
|
||||||
property: "y"
|
|
||||||
duration: Theme.expressiveDurations.fast
|
|
||||||
easing.bezierCurve: Theme.expressiveCurves.standard
|
|
||||||
}
|
|
||||||
DankAnim {
|
|
||||||
property: "opacity"
|
|
||||||
to: 1
|
|
||||||
duration: Theme.expressiveDurations.fast
|
|
||||||
easing.bezierCurve: Theme.expressiveCurves.standard
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly property Transition _move: Transition {
|
|
||||||
DankAnim {
|
|
||||||
property: "y"
|
|
||||||
duration: Theme.expressiveDurations.fast
|
|
||||||
easing.bezierCurve: Theme.expressiveCurves.standard
|
|
||||||
}
|
|
||||||
DankAnim {
|
|
||||||
property: "opacity"
|
|
||||||
to: 1
|
|
||||||
duration: Theme.expressiveDurations.fast
|
|
||||||
easing.bezierCurve: Theme.expressiveCurves.standard
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,14 @@ Singleton {
|
|||||||
return themedIconPath(iconName) || DesktopService.resolveIconPath(iconName);
|
return themedIconPath(iconName) || DesktopService.resolveIconPath(iconName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function trashPath(path: string, callback): void {
|
||||||
|
TrashService.trashPath(path, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyPathToClipboard(path: string): void {
|
||||||
|
Quickshell.execDetached([Proc.dmsBin, "cl", "copy", path]);
|
||||||
|
}
|
||||||
|
|
||||||
function resolveIconUrl(iconName: string): string {
|
function resolveIconUrl(iconName: string): string {
|
||||||
if (!iconName)
|
if (!iconName)
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -65,35 +65,16 @@ Singleton {
|
|||||||
|
|
||||||
function _openPopout(popout) {
|
function _openPopout(popout) {
|
||||||
if (popout.dashVisible !== undefined) {
|
if (popout.dashVisible !== undefined) {
|
||||||
let flagStayedTrue = popout.dashVisible === true;
|
if (popout.dashVisible && !popout.shouldBeVisible && !popout.isClosing)
|
||||||
if (popout.dashVisible && !popout.shouldBeVisible && !popout.isClosing) {
|
|
||||||
popout.dashVisible = false;
|
popout.dashVisible = false;
|
||||||
flagStayedTrue = false;
|
|
||||||
}
|
|
||||||
popout.dashVisible = true;
|
popout.dashVisible = true;
|
||||||
// Flag already true (e.g. retargeting to another monitor) won't re-fire
|
|
||||||
// the change handler, so drive the surface open explicitly.
|
|
||||||
if (flagStayedTrue)
|
|
||||||
_ensureSurfaceOpen(popout);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (popout.notificationHistoryVisible !== undefined) {
|
if (popout.notificationHistoryVisible !== undefined) {
|
||||||
const flagStayedTrue = popout.notificationHistoryVisible === true;
|
|
||||||
popout.notificationHistoryVisible = true;
|
popout.notificationHistoryVisible = true;
|
||||||
if (flagStayedTrue)
|
|
||||||
_ensureSurfaceOpen(popout);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_ensureSurfaceOpen(popout);
|
popout.open();
|
||||||
}
|
|
||||||
|
|
||||||
function _ensureSurfaceOpen(popout) {
|
|
||||||
if (typeof popout.present === "function") {
|
|
||||||
popout.present();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (typeof popout.open === "function")
|
|
||||||
popout.open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _closePopout(popout) {
|
function _closePopout(popout) {
|
||||||
|
|||||||
+4
-148
@@ -1,157 +1,13 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
pragma ComponentBehavior: Bound
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import qs.DankCommon.Common as DankCommon
|
||||||
import qs.Services
|
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
readonly property int noTimeout: DankCommon.Proc.noTimeout
|
||||||
readonly property var log: Log.scoped("Proc")
|
readonly property string dmsBin: DankCommon.Proc.dmsBin
|
||||||
|
|
||||||
readonly property int noTimeout: -1
|
|
||||||
readonly property string dmsBin: Quickshell.env("DMS_EXECUTABLE") || "dms"
|
|
||||||
property int defaultDebounceMs: 50
|
|
||||||
property int defaultTimeoutMs: 10000
|
|
||||||
property var _procDebouncers: ({})
|
|
||||||
|
|
||||||
function runCommand(id, command, callback, debounceMs, timeoutMs) {
|
function runCommand(id, command, callback, debounceMs, timeoutMs) {
|
||||||
const wait = (typeof debounceMs === "number" && debounceMs >= 0) ? debounceMs : defaultDebounceMs;
|
DankCommon.Proc.runCommand(id, command, callback, debounceMs, timeoutMs);
|
||||||
const timeout = (typeof timeoutMs === "number") ? timeoutMs : defaultTimeoutMs;
|
|
||||||
let procId = id ? id : Math.random();
|
|
||||||
const isRandomId = !id;
|
|
||||||
|
|
||||||
if (!_procDebouncers[procId]) {
|
|
||||||
const t = debounceTimerComp.createObject(root);
|
|
||||||
t.triggered.connect(function () {
|
|
||||||
_launchProc(procId, isRandomId);
|
|
||||||
});
|
|
||||||
_procDebouncers[procId] = {
|
|
||||||
timer: t,
|
|
||||||
command: command,
|
|
||||||
callback: callback,
|
|
||||||
waitMs: wait,
|
|
||||||
timeoutMs: timeout,
|
|
||||||
isRandomId: isRandomId
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
_procDebouncers[procId].command = command;
|
|
||||||
_procDebouncers[procId].callback = callback;
|
|
||||||
_procDebouncers[procId].waitMs = wait;
|
|
||||||
_procDebouncers[procId].timeoutMs = timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
const entry = _procDebouncers[procId];
|
|
||||||
entry.timer.interval = entry.waitMs;
|
|
||||||
entry.timer.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _launchProc(id, isRandomId) {
|
|
||||||
const entry = _procDebouncers[id];
|
|
||||||
if (!entry)
|
|
||||||
return;
|
|
||||||
const proc = procComp.createObject(root, {
|
|
||||||
command: entry.command
|
|
||||||
});
|
|
||||||
const timeoutTimer = debounceTimerComp.createObject(root);
|
|
||||||
|
|
||||||
let capturedOut = "";
|
|
||||||
let capturedErr = "";
|
|
||||||
let exitSeen = false;
|
|
||||||
let exitCodeValue = -1;
|
|
||||||
let outSeen = false;
|
|
||||||
let errSeen = false;
|
|
||||||
let timedOut = false;
|
|
||||||
|
|
||||||
timeoutTimer.interval = entry.timeoutMs;
|
|
||||||
timeoutTimer.triggered.connect(function () {
|
|
||||||
if (!exitSeen) {
|
|
||||||
timedOut = true;
|
|
||||||
proc.running = false;
|
|
||||||
exitSeen = true;
|
|
||||||
exitCodeValue = 124;
|
|
||||||
maybeComplete();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
proc.stdout.streamFinished.connect(function () {
|
|
||||||
try {
|
|
||||||
capturedOut = proc.stdout.text || "";
|
|
||||||
} catch (e) {
|
|
||||||
capturedOut = "";
|
|
||||||
}
|
|
||||||
outSeen = true;
|
|
||||||
maybeComplete();
|
|
||||||
});
|
|
||||||
|
|
||||||
proc.stderr.streamFinished.connect(function () {
|
|
||||||
try {
|
|
||||||
capturedErr = proc.stderr.text || "";
|
|
||||||
} catch (e) {
|
|
||||||
capturedErr = "";
|
|
||||||
}
|
|
||||||
errSeen = true;
|
|
||||||
maybeComplete();
|
|
||||||
});
|
|
||||||
|
|
||||||
proc.exited.connect(function (code) {
|
|
||||||
timeoutTimer.stop();
|
|
||||||
exitSeen = true;
|
|
||||||
exitCodeValue = code;
|
|
||||||
maybeComplete();
|
|
||||||
});
|
|
||||||
|
|
||||||
function maybeComplete() {
|
|
||||||
if (!exitSeen || !outSeen || !errSeen)
|
|
||||||
return;
|
|
||||||
timeoutTimer.stop();
|
|
||||||
if (entry && entry.callback && typeof entry.callback === "function") {
|
|
||||||
try {
|
|
||||||
const safeOutput = capturedOut !== null && capturedOut !== undefined ? capturedOut : "";
|
|
||||||
const safeExitCode = exitCodeValue !== null && exitCodeValue !== undefined ? exitCodeValue : -1;
|
|
||||||
entry.callback(safeOutput, safeExitCode);
|
|
||||||
} catch (e) {
|
|
||||||
log.warn("runCommand callback error for command:", entry.command, "Error:", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
proc.destroy();
|
|
||||||
} catch (_) {}
|
|
||||||
try {
|
|
||||||
timeoutTimer.destroy();
|
|
||||||
} catch (_) {}
|
|
||||||
|
|
||||||
if (isRandomId || entry.isRandomId) {
|
|
||||||
Qt.callLater(function () {
|
|
||||||
if (_procDebouncers[id]) {
|
|
||||||
try {
|
|
||||||
_procDebouncers[id].timer.destroy();
|
|
||||||
} catch (_) {}
|
|
||||||
delete _procDebouncers[id];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
proc.running = true;
|
|
||||||
if (entry.timeoutMs !== noTimeout)
|
|
||||||
timeoutTimer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: debounceTimerComp
|
|
||||||
Timer {
|
|
||||||
repeat: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: procComp
|
|
||||||
Process {
|
|
||||||
running: false
|
|
||||||
stdout: StdioCollector {}
|
|
||||||
stderr: StdioCollector {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ Singleton {
|
|||||||
_parseError = true;
|
_parseError = true;
|
||||||
const msg = e.message;
|
const msg = e.message;
|
||||||
log.error("Failed to parse session.json - file will not be overwritten.");
|
log.error("Failed to parse session.json - file will not be overwritten.");
|
||||||
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse session.json"), msg));
|
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse %1").arg("session.json"), msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ Singleton {
|
|||||||
_parseError = true;
|
_parseError = true;
|
||||||
const msg = e.message;
|
const msg = e.message;
|
||||||
log.error("Failed to parse session.json - file will not be overwritten.");
|
log.error("Failed to parse session.json - file will not be overwritten.");
|
||||||
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse session.json"), msg));
|
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse %1").arg("session.json"), msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Singleton {
|
|||||||
id: root
|
id: root
|
||||||
readonly property var log: Log.scoped("SettingsData")
|
readonly property var log: Log.scoped("SettingsData")
|
||||||
|
|
||||||
readonly property int settingsConfigVersion: 13
|
readonly property int settingsConfigVersion: 12
|
||||||
|
|
||||||
readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true"
|
readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true"
|
||||||
|
|
||||||
@@ -760,6 +760,7 @@ Singleton {
|
|||||||
property int batteryLowNotificationType: 0
|
property int batteryLowNotificationType: 0
|
||||||
property int batteryCriticalNotificationType: 1
|
property int batteryCriticalNotificationType: 1
|
||||||
property bool batteryAutoPowerSaver: false
|
property bool batteryAutoPowerSaver: false
|
||||||
|
property bool lowerDisplayRefreshRateOnBattery: false
|
||||||
property bool showBatteryPercent: true
|
property bool showBatteryPercent: true
|
||||||
property bool showBatteryPercentOnlyOnBattery: false
|
property bool showBatteryPercentOnlyOnBattery: false
|
||||||
property bool showBatteryTime: false
|
property bool showBatteryTime: false
|
||||||
@@ -773,6 +774,11 @@ Singleton {
|
|||||||
property bool fadeToDpmsEnabled: true
|
property bool fadeToDpmsEnabled: true
|
||||||
property int fadeToDpmsGracePeriod: 5
|
property int fadeToDpmsGracePeriod: 5
|
||||||
property string launchPrefix: ""
|
property string launchPrefix: ""
|
||||||
|
property var brightnessDevicePins: ({})
|
||||||
|
property var wifiNetworkPins: ({})
|
||||||
|
property var bluetoothDevicePins: ({})
|
||||||
|
property var audioInputDevicePins: ({})
|
||||||
|
property var audioOutputDevicePins: ({})
|
||||||
|
|
||||||
property bool gtkThemingEnabled: false
|
property bool gtkThemingEnabled: false
|
||||||
property bool qtThemingEnabled: false
|
property bool qtThemingEnabled: false
|
||||||
@@ -969,6 +975,8 @@ Singleton {
|
|||||||
property var hyprlandOutputSettings: ({})
|
property var hyprlandOutputSettings: ({})
|
||||||
property var displayProfiles: ({})
|
property var displayProfiles: ({})
|
||||||
property var activeDisplayProfile: ({})
|
property var activeDisplayProfile: ({})
|
||||||
|
property var activeDisplayProfileModes: ({})
|
||||||
|
property var displayPreviousRefreshModes: ({})
|
||||||
property bool displayProfileAutoSelect: false
|
property bool displayProfileAutoSelect: false
|
||||||
property bool displayShowDisconnected: false
|
property bool displayShowDisconnected: false
|
||||||
property bool displaySnapToEdge: true
|
property bool displaySnapToEdge: true
|
||||||
@@ -1736,7 +1744,6 @@ Singleton {
|
|||||||
let obj = (txt && txt.trim()) ? JSON.parse(txt) : null;
|
let obj = (txt && txt.trim()) ? JSON.parse(txt) : null;
|
||||||
|
|
||||||
const oldVersion = obj?.configVersion ?? 0;
|
const oldVersion = obj?.configVersion ?? 0;
|
||||||
const legacyPins = oldVersion < 13 ? Store.extractPins(obj) : null;
|
|
||||||
if (oldVersion < settingsConfigVersion) {
|
if (oldVersion < settingsConfigVersion) {
|
||||||
const migrated = Store.migrateToVersion(obj, settingsConfigVersion);
|
const migrated = Store.migrateToVersion(obj, settingsConfigVersion);
|
||||||
if (migrated) {
|
if (migrated) {
|
||||||
@@ -1744,8 +1751,6 @@ Singleton {
|
|||||||
obj = migrated;
|
obj = migrated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (legacyPins)
|
|
||||||
Qt.callLater(() => CacheData.migratePins(legacyPins));
|
|
||||||
|
|
||||||
if (obj?.lockScreenActiveMonitor !== undefined) {
|
if (obj?.lockScreenActiveMonitor !== undefined) {
|
||||||
var oldVal = obj.lockScreenActiveMonitor;
|
var oldVal = obj.lockScreenActiveMonitor;
|
||||||
@@ -1794,7 +1799,7 @@ Singleton {
|
|||||||
_parseError = true;
|
_parseError = true;
|
||||||
const msg = e.message;
|
const msg = e.message;
|
||||||
log.error("Failed to parse settings.json - file will not be overwritten. Error:", msg);
|
log.error("Failed to parse settings.json - file will not be overwritten. Error:", msg);
|
||||||
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse settings.json"), msg));
|
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse %1").arg("settings.json"), msg));
|
||||||
applyStoredTheme();
|
applyStoredTheme();
|
||||||
} finally {
|
} finally {
|
||||||
_loading = false;
|
_loading = false;
|
||||||
@@ -1892,7 +1897,7 @@ Singleton {
|
|||||||
_pluginParseError = true;
|
_pluginParseError = true;
|
||||||
const msg = e.message;
|
const msg = e.message;
|
||||||
log.error("Failed to parse plugin_settings.json - file will not be overwritten. Error:", msg);
|
log.error("Failed to parse plugin_settings.json - file will not be overwritten. Error:", msg);
|
||||||
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse plugin_settings.json"), msg));
|
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse %1").arg("plugin_settings.json"), msg));
|
||||||
pluginSettings = {};
|
pluginSettings = {};
|
||||||
} finally {
|
} finally {
|
||||||
_pluginSettingsLoading = false;
|
_pluginSettingsLoading = false;
|
||||||
@@ -3559,6 +3564,27 @@ Singleton {
|
|||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setActiveDisplayProfileModes(compositor, modes) {
|
||||||
|
if (JSON.stringify(activeDisplayProfileModes[compositor] || {}) === JSON.stringify(modes || {}))
|
||||||
|
return;
|
||||||
|
const updated = JSON.parse(JSON.stringify(activeDisplayProfileModes));
|
||||||
|
updated[compositor] = modes;
|
||||||
|
activeDisplayProfileModes = updated;
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setDisplayPreviousRefreshModes(compositor, modes) {
|
||||||
|
if (JSON.stringify(displayPreviousRefreshModes[compositor] || {}) === JSON.stringify(modes || {}))
|
||||||
|
return;
|
||||||
|
const updated = JSON.parse(JSON.stringify(displayPreviousRefreshModes));
|
||||||
|
if (Object.keys(modes || {}).length > 0)
|
||||||
|
updated[compositor] = modes;
|
||||||
|
else
|
||||||
|
delete updated[compositor];
|
||||||
|
displayPreviousRefreshModes = updated;
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
ListModel {
|
ListModel {
|
||||||
id: leftWidgetsModel
|
id: leftWidgetsModel
|
||||||
}
|
}
|
||||||
@@ -3654,7 +3680,7 @@ Singleton {
|
|||||||
_parseError = true;
|
_parseError = true;
|
||||||
const msg = e.message;
|
const msg = e.message;
|
||||||
log.error("Failed to reload settings.json - file will not be overwritten. Error:", msg);
|
log.error("Failed to reload settings.json - file will not be overwritten. Error:", msg);
|
||||||
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse settings.json"), msg));
|
Qt.callLater(() => ToastService.showError(I18n.tr("Failed to parse %1").arg("settings.json"), msg));
|
||||||
} finally {
|
} finally {
|
||||||
_loading = false;
|
_loading = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import QtQuick
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import qs.Common
|
import qs.Common
|
||||||
|
import qs.DankCommon.Common as DankCommon
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Modules.Greetd
|
import qs.Modules.Greetd
|
||||||
import "StockThemes.js" as StockThemes
|
import "StockThemes.js" as StockThemes
|
||||||
@@ -1230,16 +1231,28 @@ Singleton {
|
|||||||
|
|
||||||
property string fontFamily: {
|
property string fontFamily: {
|
||||||
if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") {
|
if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") {
|
||||||
return GreetdSettings.getEffectiveFontFamily();
|
return resolvedFontFamily(GreetdSettings.getEffectiveFontFamily());
|
||||||
}
|
}
|
||||||
return typeof SettingsData !== "undefined" ? SettingsData.fontFamily : "Inter Variable";
|
return typeof SettingsData !== "undefined" ? resolvedFontFamily(SettingsData.fontFamily) : DankCommon.Fonts.sans;
|
||||||
}
|
}
|
||||||
|
|
||||||
property string monoFontFamily: {
|
property string monoFontFamily: {
|
||||||
if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") {
|
if (typeof SessionData !== "undefined" && SessionData.isGreeterMode && typeof GreetdSettings !== "undefined") {
|
||||||
return GreetdSettings.monoFontFamily;
|
return resolvedMonoFontFamily(GreetdSettings.monoFontFamily);
|
||||||
}
|
}
|
||||||
return typeof SettingsData !== "undefined" ? SettingsData.monoFontFamily : "Fira Code";
|
return typeof SettingsData !== "undefined" ? resolvedMonoFontFamily(SettingsData.monoFontFamily) : DankCommon.Fonts.mono;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvedFontFamily(family) {
|
||||||
|
if (family === defaultFontFamily)
|
||||||
|
return DankCommon.Fonts.sans;
|
||||||
|
return family;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvedMonoFontFamily(family) {
|
||||||
|
if (family === defaultMonoFontFamily)
|
||||||
|
return DankCommon.Fonts.mono;
|
||||||
|
return family;
|
||||||
}
|
}
|
||||||
|
|
||||||
property int fontWeight: {
|
property int fontWeight: {
|
||||||
@@ -1960,7 +1973,7 @@ Singleton {
|
|||||||
function applyGtkColors() {
|
function applyGtkColors() {
|
||||||
if (!matugenAvailable) {
|
if (!matugenAvailable) {
|
||||||
if (typeof ToastService !== "undefined") {
|
if (typeof ToastService !== "undefined") {
|
||||||
ToastService.showError(I18n.tr("matugen not available or disabled - cannot apply GTK colors"));
|
ToastService.showError(I18n.tr("matugen not available or disabled - cannot apply %1 colors").arg("GTK"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1973,7 +1986,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (typeof ToastService !== "undefined") {
|
if (typeof ToastService !== "undefined") {
|
||||||
ToastService.showError(I18n.tr("Failed to apply GTK colors"));
|
ToastService.showError(I18n.tr("Failed to apply %1 colors").arg("GTK"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1982,7 +1995,7 @@ Singleton {
|
|||||||
function applyQtColors() {
|
function applyQtColors() {
|
||||||
if (!matugenAvailable) {
|
if (!matugenAvailable) {
|
||||||
if (typeof ToastService !== "undefined") {
|
if (typeof ToastService !== "undefined") {
|
||||||
ToastService.showError(I18n.tr("matugen not available or disabled - cannot apply Qt colors"));
|
ToastService.showError(I18n.tr("matugen not available or disabled - cannot apply %1 colors").arg("Qt"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1994,7 +2007,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (typeof ToastService !== "undefined") {
|
if (typeof ToastService !== "undefined") {
|
||||||
ToastService.showError(I18n.tr("Failed to apply Qt colors"));
|
ToastService.showError(I18n.tr("Failed to apply %1 colors").arg("Qt"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -604,7 +604,7 @@ Singleton {
|
|||||||
let details = out;
|
let details = out;
|
||||||
if (err !== "")
|
if (err !== "")
|
||||||
details = details !== "" ? details + "\n\nstderr:\n" + err : "stderr:\n" + err;
|
details = details !== "" ? details + "\n\nstderr:\n" + err : "stderr:\n" + err;
|
||||||
ToastService.showInfo(I18n.tr("Authentication changes applied."), details, "", "auth-sync");
|
ToastService.showInfo(I18n.tr("Authentication changes applied"), details, "", "auth-sync");
|
||||||
root.detectAuthCapabilities();
|
root.detectAuthCapabilities();
|
||||||
root.finishAuthApply();
|
root.finishAuthApply();
|
||||||
return;
|
return;
|
||||||
@@ -650,7 +650,7 @@ Singleton {
|
|||||||
|
|
||||||
onExited: exitCode => {
|
onExited: exitCode => {
|
||||||
if (exitCode === 0) {
|
if (exitCode === 0) {
|
||||||
const message = root.authApplyTerminalFallbackFromPrecheck ? I18n.tr("Terminal opened. Complete authentication setup there; it will close automatically when done.") : I18n.tr("Terminal fallback opened. Complete authentication setup there; it will close automatically when done.");
|
const message = root.authApplyTerminalFallbackFromPrecheck ? I18n.tr("Terminal opened. Complete authentication there; it will close automatically when done.") : I18n.tr("Terminal fallback opened. Complete authentication there; it will close automatically when done.");
|
||||||
ToastService.showInfo(message, "", "", "auth-sync");
|
ToastService.showInfo(message, "", "", "auth-sync");
|
||||||
} else {
|
} else {
|
||||||
let details = (root.authApplyTerminalFallbackStderr || "").trim();
|
let details = (root.authApplyTerminalFallbackStderr || "").trim();
|
||||||
|
|||||||
@@ -347,6 +347,7 @@ var SPEC = {
|
|||||||
batteryLowNotificationType: { def: 0 },
|
batteryLowNotificationType: { def: 0 },
|
||||||
batteryCriticalNotificationType: { def: 1 },
|
batteryCriticalNotificationType: { def: 1 },
|
||||||
batteryAutoPowerSaver: { def: false },
|
batteryAutoPowerSaver: { def: false },
|
||||||
|
lowerDisplayRefreshRateOnBattery: { def: false },
|
||||||
lockBeforeSuspend: { def: false },
|
lockBeforeSuspend: { def: false },
|
||||||
loginctlLockIntegration: { def: true },
|
loginctlLockIntegration: { def: true },
|
||||||
fadeToLockEnabled: { def: true },
|
fadeToLockEnabled: { def: true },
|
||||||
@@ -354,6 +355,11 @@ var SPEC = {
|
|||||||
fadeToDpmsEnabled: { def: true },
|
fadeToDpmsEnabled: { def: true },
|
||||||
fadeToDpmsGracePeriod: { def: 5 },
|
fadeToDpmsGracePeriod: { def: 5 },
|
||||||
launchPrefix: { def: "" },
|
launchPrefix: { def: "" },
|
||||||
|
brightnessDevicePins: { def: {} },
|
||||||
|
wifiNetworkPins: { def: {} },
|
||||||
|
bluetoothDevicePins: { def: {} },
|
||||||
|
audioInputDevicePins: { def: {} },
|
||||||
|
audioOutputDevicePins: { def: {} },
|
||||||
|
|
||||||
gtkThemingEnabled: { def: false, onChange: "regenSystemThemes" },
|
gtkThemingEnabled: { def: false, onChange: "regenSystemThemes" },
|
||||||
qtThemingEnabled: { def: false, onChange: "regenSystemThemes" },
|
qtThemingEnabled: { def: false, onChange: "regenSystemThemes" },
|
||||||
@@ -527,6 +533,8 @@ var SPEC = {
|
|||||||
hyprlandOutputSettings: { def: {} },
|
hyprlandOutputSettings: { def: {} },
|
||||||
displayProfiles: { def: {} },
|
displayProfiles: { def: {} },
|
||||||
activeDisplayProfile: { def: {} },
|
activeDisplayProfile: { def: {} },
|
||||||
|
activeDisplayProfileModes: { def: {} },
|
||||||
|
displayPreviousRefreshModes: { def: {} },
|
||||||
displayProfileAutoSelect: { def: false },
|
displayProfileAutoSelect: { def: false },
|
||||||
displayShowDisconnected: { def: false },
|
displayShowDisconnected: { def: false },
|
||||||
displaySnapToEdge: { def: true },
|
displaySnapToEdge: { def: true },
|
||||||
|
|||||||
@@ -2,21 +2,6 @@
|
|||||||
|
|
||||||
.import "./SettingsSpec.js" as SpecModule
|
.import "./SettingsSpec.js" as SpecModule
|
||||||
|
|
||||||
var PIN_KEYS = ["brightnessDevicePins", "wifiNetworkPins", "bluetoothDevicePins", "audioInputDevicePins", "audioOutputDevicePins"];
|
|
||||||
|
|
||||||
function extractPins(obj) {
|
|
||||||
if (!obj) return null;
|
|
||||||
|
|
||||||
var pins = null;
|
|
||||||
for (var i = 0; i < PIN_KEYS.length; i++) {
|
|
||||||
var value = obj[PIN_KEYS[i]];
|
|
||||||
if (!value || Object.keys(value).length === 0) continue;
|
|
||||||
if (!pins) pins = {};
|
|
||||||
pins[PIN_KEYS[i]] = value;
|
|
||||||
}
|
|
||||||
return pins;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parse(root, jsonObj) {
|
function parse(root, jsonObj) {
|
||||||
var SPEC = SpecModule.SPEC;
|
var SPEC = SpecModule.SPEC;
|
||||||
|
|
||||||
@@ -278,17 +263,6 @@ function migrateToVersion(obj, targetVersion) {
|
|||||||
settings.configVersion = 12;
|
settings.configVersion = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentVersion < 13) {
|
|
||||||
console.info("Migrating settings from version", currentVersion, "to version 13");
|
|
||||||
console.info("Moving device and network pins to cache.json");
|
|
||||||
|
|
||||||
for (var p = 0; p < PIN_KEYS.length; p++) {
|
|
||||||
delete settings[PIN_KEYS[p]];
|
|
||||||
}
|
|
||||||
|
|
||||||
settings.configVersion = 13;
|
|
||||||
}
|
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,14 +139,6 @@ Item {
|
|||||||
return;
|
return;
|
||||||
fadeDpmsWindowLoader.loadedWindow.cancelFade();
|
fadeDpmsWindowLoader.loadedWindow.cancelFade();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMonitorsOffChanged() {
|
|
||||||
if (IdleService.monitorsOff)
|
|
||||||
return;
|
|
||||||
if (!fadeDpmsWindowLoader.loadedWindow)
|
|
||||||
return;
|
|
||||||
fadeDpmsWindowLoader.loadedWindow.dismiss();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,7 +323,7 @@ Item {
|
|||||||
target: TrashService
|
target: TrashService
|
||||||
function onEmptyTrashConfirmRequested(itemCount) {
|
function onEmptyTrashConfirmRequested(itemCount) {
|
||||||
emptyTrashConfirm.showWithOptions({
|
emptyTrashConfirm.showWithOptions({
|
||||||
title: I18n.tr("Empty Trash?"),
|
title: I18n.tr("Empty Trash"),
|
||||||
message: I18n.tr("Permanently delete %1 item(s)? This cannot be undone.").arg(itemCount),
|
message: I18n.tr("Permanently delete %1 item(s)? This cannot be undone.").arg(itemCount),
|
||||||
confirmText: I18n.tr("Empty"),
|
confirmText: I18n.tr("Empty"),
|
||||||
cancelText: I18n.tr("Cancel"),
|
cancelText: I18n.tr("Cancel"),
|
||||||
|
|||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../dank-qml-common/DankCommon
|
||||||
@@ -449,12 +449,7 @@ Item {
|
|||||||
searchQuery = query;
|
searchQuery = query;
|
||||||
requestSearch();
|
requestSearch();
|
||||||
|
|
||||||
if (autoSwitchedToFiles && !query.startsWith("/")) {
|
if (searchMode !== "plugins" && query.startsWith("/")) {
|
||||||
restorePreviousMode();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query.startsWith("/")) {
|
|
||||||
var prefix = Utils.parseFileSearchPrefix(query);
|
var prefix = Utils.parseFileSearchPrefix(query);
|
||||||
var explicitType = prefix && prefix.type !== null ? prefix.type : null;
|
var explicitType = prefix && prefix.type !== null ? prefix.type : null;
|
||||||
var targetType = explicitType !== null ? explicitType : (SessionData.launcherLastFileSearchType || "all");
|
var targetType = explicitType !== null ? explicitType : (SessionData.launcherLastFileSearchType || "all");
|
||||||
|
|||||||
@@ -174,12 +174,9 @@ Item {
|
|||||||
spotlightContent.controller.selectedFlatIndex = 0;
|
spotlightContent.controller.selectedFlatIndex = 0;
|
||||||
spotlightContent.controller.selectedItem = null;
|
spotlightContent.controller.selectedItem = null;
|
||||||
spotlightContent.controller.historyIndex = -1;
|
spotlightContent.controller.historyIndex = -1;
|
||||||
if (targetQuery) {
|
spotlightContent.controller.searchQuery = targetQuery;
|
||||||
spotlightContent.controller.setSearchQuery(targetQuery);
|
|
||||||
} else {
|
spotlightContent.controller.performSearch();
|
||||||
spotlightContent.controller.searchQuery = "";
|
|
||||||
spotlightContent.controller.performSearch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (spotlightContent.resetScroll) {
|
if (spotlightContent.resetScroll) {
|
||||||
spotlightContent.resetScroll();
|
spotlightContent.resetScroll();
|
||||||
@@ -274,7 +271,7 @@ Item {
|
|||||||
target: spotlightContent?.controller ?? null
|
target: spotlightContent?.controller ?? null
|
||||||
|
|
||||||
function onModeChanged(mode, userInitiated) {
|
function onModeChanged(mode, userInitiated) {
|
||||||
if (!userInitiated || !SettingsData.rememberLastMode)
|
if (!userInitiated || !SettingsData.rememberLastMode || (mode !== "all" && mode !== "apps"))
|
||||||
return;
|
return;
|
||||||
SessionData.setLauncherLastMode(mode);
|
SessionData.setLauncherLastMode(mode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,14 +408,14 @@ FocusScope {
|
|||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: "↵ " + I18n.tr("open")
|
text: "↵ " + I18n.tr("Open")
|
||||||
font.pixelSize: Theme.fontSizeSmall - 1
|
font.pixelSize: Theme.fontSizeSmall - 1
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: "Tab " + I18n.tr("actions")
|
text: "Tab " + I18n.tr("Actions")
|
||||||
font.pixelSize: Theme.fontSizeSmall - 1
|
font.pixelSize: Theme.fontSizeSmall - 1
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
visible: actionPanel.hasActions
|
visible: actionPanel.hasActions
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ Item {
|
|||||||
|
|
||||||
function statusTitle() {
|
function statusTitle() {
|
||||||
if (root.controller?.isSearching || root.controller?.isFileSearching)
|
if (root.controller?.isSearching || root.controller?.isFileSearching)
|
||||||
return I18n.tr("Searching");
|
return I18n.tr("Searching...");
|
||||||
if ((root.controller?.searchMode ?? "") === "files" && !DSearchService.dsearchAvailable)
|
if ((root.controller?.searchMode ?? "") === "files" && !DSearchService.dsearchAvailable)
|
||||||
return I18n.tr("File search unavailable");
|
return I18n.tr("File search unavailable");
|
||||||
if ((root.controller?.searchMode ?? "") === "files" && (root.controller?.searchQuery?.length ?? 0) < 2)
|
if ((root.controller?.searchMode ?? "") === "files" && (root.controller?.searchQuery?.length ?? 0) < 2)
|
||||||
|
|||||||
@@ -1,935 +1,3 @@
|
|||||||
import Qt.labs.folderlistmodel
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import QtCore
|
|
||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
FocusScope {
|
DankCommon.FileBrowserContent {}
|
||||||
id: root
|
|
||||||
|
|
||||||
LayoutMirroring.enabled: I18n.isRtl
|
|
||||||
LayoutMirroring.childrenInherit: true
|
|
||||||
|
|
||||||
property string homeDir: StandardPaths.writableLocation(StandardPaths.HomeLocation)
|
|
||||||
property string docsDir: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
|
|
||||||
property string musicDir: StandardPaths.writableLocation(StandardPaths.MusicLocation)
|
|
||||||
property string videosDir: StandardPaths.writableLocation(StandardPaths.MoviesLocation)
|
|
||||||
property string picsDir: StandardPaths.writableLocation(StandardPaths.PicturesLocation)
|
|
||||||
property string downloadDir: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
|
|
||||||
property string desktopDir: StandardPaths.writableLocation(StandardPaths.DesktopLocation)
|
|
||||||
property string currentPath: ""
|
|
||||||
property var fileExtensions: ["*.*"]
|
|
||||||
property alias filterExtensions: root.fileExtensions
|
|
||||||
property string browserTitle: "Select File"
|
|
||||||
property string browserIcon: "folder_open"
|
|
||||||
property string browserType: "generic"
|
|
||||||
property bool showHiddenFiles: false
|
|
||||||
property int selectedIndex: -1
|
|
||||||
property bool keyboardNavigationActive: false
|
|
||||||
property bool backButtonFocused: false
|
|
||||||
property bool saveMode: false
|
|
||||||
property string defaultFileName: ""
|
|
||||||
property int keyboardSelectionIndex: -1
|
|
||||||
property bool keyboardSelectionRequested: false
|
|
||||||
property bool showKeyboardHints: false
|
|
||||||
property bool showFileInfo: false
|
|
||||||
property string selectedFilePath: ""
|
|
||||||
property string selectedFileName: ""
|
|
||||||
property bool selectedFileIsDir: false
|
|
||||||
property bool showOverwriteConfirmation: false
|
|
||||||
property string pendingFilePath: ""
|
|
||||||
property bool showSidebar: true
|
|
||||||
property string viewMode: "grid"
|
|
||||||
property string sortBy: "name"
|
|
||||||
property bool sortAscending: true
|
|
||||||
property int iconSizeIndex: 1
|
|
||||||
property var iconSizes: [80, 120, 160, 200]
|
|
||||||
property bool pathEditMode: false
|
|
||||||
property bool pathInputHasFocus: false
|
|
||||||
property int actualGridColumns: 5
|
|
||||||
property bool _initialized: false
|
|
||||||
property bool closeOnEscape: true
|
|
||||||
property var windowControls: null
|
|
||||||
|
|
||||||
signal fileSelected(string path)
|
|
||||||
signal closeRequested
|
|
||||||
|
|
||||||
function encodeFileUrl(path) {
|
|
||||||
if (!path)
|
|
||||||
return "";
|
|
||||||
return "file://" + path.split('/').map(s => encodeURIComponent(s)).join('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
loadSettings();
|
|
||||||
currentPath = getLastPath();
|
|
||||||
_initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function reset() {
|
|
||||||
currentPath = getLastPath();
|
|
||||||
selectedIndex = -1;
|
|
||||||
keyboardNavigationActive = false;
|
|
||||||
backButtonFocused = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadSettings() {
|
|
||||||
const type = browserType || "default";
|
|
||||||
const settings = CacheData.fileBrowserSettings[type];
|
|
||||||
const isImageBrowser = ["wallpaper", "profile"].includes(browserType);
|
|
||||||
|
|
||||||
if (settings) {
|
|
||||||
viewMode = settings.viewMode || (isImageBrowser ? "grid" : "list");
|
|
||||||
sortBy = settings.sortBy || "name";
|
|
||||||
sortAscending = settings.sortAscending !== undefined ? settings.sortAscending : true;
|
|
||||||
iconSizeIndex = settings.iconSizeIndex !== undefined ? settings.iconSizeIndex : 1;
|
|
||||||
showSidebar = settings.showSidebar !== undefined ? settings.showSidebar : true;
|
|
||||||
} else {
|
|
||||||
viewMode = isImageBrowser ? "grid" : "list";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveSettings() {
|
|
||||||
if (!_initialized)
|
|
||||||
return;
|
|
||||||
const type = browserType || "default";
|
|
||||||
let settings = CacheData.fileBrowserSettings;
|
|
||||||
if (!settings[type]) {
|
|
||||||
settings[type] = {};
|
|
||||||
}
|
|
||||||
settings[type].viewMode = viewMode;
|
|
||||||
settings[type].sortBy = sortBy;
|
|
||||||
settings[type].sortAscending = sortAscending;
|
|
||||||
settings[type].iconSizeIndex = iconSizeIndex;
|
|
||||||
settings[type].showSidebar = showSidebar;
|
|
||||||
settings[type].lastPath = currentPath;
|
|
||||||
CacheData.fileBrowserSettings = settings;
|
|
||||||
|
|
||||||
if (browserType === "wallpaper") {
|
|
||||||
CacheData.wallpaperLastPath = currentPath;
|
|
||||||
} else if (browserType === "profile") {
|
|
||||||
CacheData.profileLastPath = currentPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
CacheData.saveCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
onViewModeChanged: saveSettings()
|
|
||||||
onSortByChanged: saveSettings()
|
|
||||||
onSortAscendingChanged: saveSettings()
|
|
||||||
onIconSizeIndexChanged: saveSettings()
|
|
||||||
onShowSidebarChanged: saveSettings()
|
|
||||||
|
|
||||||
function isImageFile(fileName) {
|
|
||||||
if (!fileName)
|
|
||||||
return false;
|
|
||||||
const ext = fileName.toLowerCase().split('.').pop();
|
|
||||||
return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'].includes(ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLastPath() {
|
|
||||||
const type = browserType || "default";
|
|
||||||
const settings = CacheData.fileBrowserSettings[type];
|
|
||||||
const lastPath = settings?.lastPath || "";
|
|
||||||
return (lastPath && lastPath !== "") ? lastPath : homeDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveLastPath(path) {
|
|
||||||
const type = browserType || "default";
|
|
||||||
let settings = CacheData.fileBrowserSettings;
|
|
||||||
if (!settings[type]) {
|
|
||||||
settings[type] = {};
|
|
||||||
}
|
|
||||||
settings[type].lastPath = path;
|
|
||||||
CacheData.fileBrowserSettings = settings;
|
|
||||||
CacheData.saveCache();
|
|
||||||
|
|
||||||
if (browserType === "wallpaper") {
|
|
||||||
CacheData.wallpaperLastPath = path;
|
|
||||||
} else if (browserType === "profile") {
|
|
||||||
CacheData.profileLastPath = path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setSelectedFileData(path, name, isDir) {
|
|
||||||
selectedFilePath = path;
|
|
||||||
selectedFileName = name;
|
|
||||||
selectedFileIsDir = isDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openItemContextMenu(sender, localX, localY, path, name, isDir) {
|
|
||||||
if (!sender)
|
|
||||||
return;
|
|
||||||
const pos = sender.mapToItem(root, localX, localY);
|
|
||||||
itemContextMenu.showAt(root, pos.x, pos.y, path, name, isDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
function navigateUp() {
|
|
||||||
const path = currentPath;
|
|
||||||
if (path === homeDir)
|
|
||||||
return;
|
|
||||||
const lastSlash = path.lastIndexOf('/');
|
|
||||||
if (lastSlash <= 0)
|
|
||||||
return;
|
|
||||||
const newPath = path.substring(0, lastSlash);
|
|
||||||
if (newPath.length < homeDir.length) {
|
|
||||||
currentPath = homeDir;
|
|
||||||
saveLastPath(homeDir);
|
|
||||||
} else {
|
|
||||||
currentPath = newPath;
|
|
||||||
saveLastPath(newPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function navigateTo(path) {
|
|
||||||
currentPath = path;
|
|
||||||
saveLastPath(path);
|
|
||||||
selectedIndex = -1;
|
|
||||||
backButtonFocused = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function keyboardFileSelection(index) {
|
|
||||||
if (index < 0)
|
|
||||||
return;
|
|
||||||
keyboardSelectionTimer.targetIndex = index;
|
|
||||||
keyboardSelectionTimer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
function executeKeyboardSelection(index) {
|
|
||||||
keyboardSelectionIndex = index;
|
|
||||||
keyboardSelectionRequested = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function activateFile(path, name, isDir) {
|
|
||||||
if (isDir) {
|
|
||||||
navigateTo(path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (saveMode) {
|
|
||||||
saveRow.fileName = name;
|
|
||||||
pendingFilePath = path;
|
|
||||||
showOverwriteConfirmation = true;
|
|
||||||
} else {
|
|
||||||
fileSelected(path);
|
|
||||||
closeRequested();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSaveFile(filePath) {
|
|
||||||
var normalizedPath = filePath;
|
|
||||||
if (!normalizedPath.startsWith("file://")) {
|
|
||||||
normalizedPath = encodeFileUrl(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
var exists = false;
|
|
||||||
var fileName = filePath.split('/').pop();
|
|
||||||
|
|
||||||
for (var i = 0; i < folderModel.count; i++) {
|
|
||||||
if (folderModel.get(i, "fileName") === fileName && !folderModel.get(i, "fileIsDir")) {
|
|
||||||
exists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exists) {
|
|
||||||
pendingFilePath = normalizedPath;
|
|
||||||
showOverwriteConfirmation = true;
|
|
||||||
} else {
|
|
||||||
fileSelected(normalizedPath);
|
|
||||||
closeRequested();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onCurrentPathChanged: {
|
|
||||||
selectedFilePath = "";
|
|
||||||
selectedFileName = "";
|
|
||||||
selectedFileIsDir = false;
|
|
||||||
saveSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
onSelectedIndexChanged: {
|
|
||||||
if (selectedIndex >= 0 && folderModel && selectedIndex < folderModel.count) {
|
|
||||||
selectedFilePath = "";
|
|
||||||
selectedFileName = "";
|
|
||||||
selectedFileIsDir = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
property var steamPaths: [StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.steam/steam/steamapps/workshop/content/431960", StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.local/share/Steam/steamapps/workshop/content/431960", StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/workshop/content/431960", StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/snap/steam/common/.local/share/Steam/steamapps/workshop/content/431960"]
|
|
||||||
|
|
||||||
property var quickAccessLocations: [
|
|
||||||
{
|
|
||||||
"name": I18n.tr("Home"),
|
|
||||||
"path": homeDir,
|
|
||||||
"icon": "home"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": I18n.tr("Documents"),
|
|
||||||
"path": docsDir,
|
|
||||||
"icon": "description"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": I18n.tr("Downloads"),
|
|
||||||
"path": downloadDir,
|
|
||||||
"icon": "download"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": I18n.tr("Pictures"),
|
|
||||||
"path": picsDir,
|
|
||||||
"icon": "image"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": I18n.tr("Music"),
|
|
||||||
"path": musicDir,
|
|
||||||
"icon": "music_note"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": I18n.tr("Videos"),
|
|
||||||
"path": videosDir,
|
|
||||||
"icon": "movie"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": I18n.tr("Desktop"),
|
|
||||||
"path": desktopDir,
|
|
||||||
"icon": "computer"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
FolderListModel {
|
|
||||||
id: folderModel
|
|
||||||
|
|
||||||
showDirsFirst: true
|
|
||||||
showDotAndDotDot: false
|
|
||||||
showHidden: root.showHiddenFiles
|
|
||||||
caseSensitive: false
|
|
||||||
nameFilters: fileExtensions
|
|
||||||
showFiles: true
|
|
||||||
showDirs: true
|
|
||||||
folder: encodeFileUrl(currentPath || homeDir)
|
|
||||||
sortField: {
|
|
||||||
switch (sortBy) {
|
|
||||||
case "name":
|
|
||||||
return FolderListModel.Name;
|
|
||||||
case "size":
|
|
||||||
return FolderListModel.Size;
|
|
||||||
case "modified":
|
|
||||||
return FolderListModel.Time;
|
|
||||||
case "type":
|
|
||||||
return FolderListModel.Type;
|
|
||||||
default:
|
|
||||||
return FolderListModel.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sortReversed: !sortAscending
|
|
||||||
}
|
|
||||||
|
|
||||||
QtObject {
|
|
||||||
id: keyboardController
|
|
||||||
|
|
||||||
property int totalItems: folderModel.count
|
|
||||||
property int gridColumns: viewMode === "list" ? 1 : Math.max(1, actualGridColumns)
|
|
||||||
|
|
||||||
function handleKey(event) {
|
|
||||||
if (event.key === Qt.Key_Escape && root.closeOnEscape) {
|
|
||||||
closeRequested();
|
|
||||||
event.accepted = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.key === Qt.Key_F10) {
|
|
||||||
showKeyboardHints = !showKeyboardHints;
|
|
||||||
event.accepted = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.key === Qt.Key_F1 || event.key === Qt.Key_I) {
|
|
||||||
showFileInfo = !showFileInfo;
|
|
||||||
event.accepted = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((event.modifiers & Qt.AltModifier && event.key === Qt.Key_Left) || event.key === Qt.Key_Backspace) {
|
|
||||||
if (currentPath !== homeDir) {
|
|
||||||
navigateUp();
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!keyboardNavigationActive) {
|
|
||||||
const isInitKey = event.key === Qt.Key_Tab || event.key === Qt.Key_Down || event.key === Qt.Key_Right || (event.key === Qt.Key_N && event.modifiers & Qt.ControlModifier) || (event.key === Qt.Key_J && event.modifiers & Qt.ControlModifier) || (event.key === Qt.Key_L && event.modifiers & Qt.ControlModifier);
|
|
||||||
|
|
||||||
if (isInitKey) {
|
|
||||||
keyboardNavigationActive = true;
|
|
||||||
if (currentPath !== homeDir) {
|
|
||||||
backButtonFocused = true;
|
|
||||||
selectedIndex = -1;
|
|
||||||
} else {
|
|
||||||
backButtonFocused = false;
|
|
||||||
selectedIndex = 0;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (event.key) {
|
|
||||||
case Qt.Key_Tab:
|
|
||||||
if (backButtonFocused) {
|
|
||||||
backButtonFocused = false;
|
|
||||||
selectedIndex = 0;
|
|
||||||
} else if (selectedIndex < totalItems - 1) {
|
|
||||||
selectedIndex++;
|
|
||||||
} else if (currentPath !== homeDir) {
|
|
||||||
backButtonFocused = true;
|
|
||||||
selectedIndex = -1;
|
|
||||||
} else {
|
|
||||||
selectedIndex = 0;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
break;
|
|
||||||
case Qt.Key_Backtab:
|
|
||||||
if (backButtonFocused) {
|
|
||||||
backButtonFocused = false;
|
|
||||||
selectedIndex = totalItems - 1;
|
|
||||||
} else if (selectedIndex > 0) {
|
|
||||||
selectedIndex--;
|
|
||||||
} else if (currentPath !== homeDir) {
|
|
||||||
backButtonFocused = true;
|
|
||||||
selectedIndex = -1;
|
|
||||||
} else {
|
|
||||||
selectedIndex = totalItems - 1;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
break;
|
|
||||||
case Qt.Key_N:
|
|
||||||
if (event.modifiers & Qt.ControlModifier) {
|
|
||||||
if (backButtonFocused) {
|
|
||||||
backButtonFocused = false;
|
|
||||||
selectedIndex = 0;
|
|
||||||
} else if (selectedIndex < totalItems - 1) {
|
|
||||||
selectedIndex++;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Qt.Key_P:
|
|
||||||
if (event.modifiers & Qt.ControlModifier) {
|
|
||||||
if (selectedIndex > 0) {
|
|
||||||
selectedIndex--;
|
|
||||||
} else if (currentPath !== homeDir) {
|
|
||||||
backButtonFocused = true;
|
|
||||||
selectedIndex = -1;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Qt.Key_J:
|
|
||||||
if (event.modifiers & Qt.ControlModifier) {
|
|
||||||
if (selectedIndex < totalItems - 1) {
|
|
||||||
selectedIndex++;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Qt.Key_K:
|
|
||||||
if (event.modifiers & Qt.ControlModifier) {
|
|
||||||
if (selectedIndex > 0) {
|
|
||||||
selectedIndex--;
|
|
||||||
} else if (currentPath !== homeDir) {
|
|
||||||
backButtonFocused = true;
|
|
||||||
selectedIndex = -1;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Qt.Key_H:
|
|
||||||
if (event.modifiers & Qt.ControlModifier) {
|
|
||||||
if (!backButtonFocused && selectedIndex > 0) {
|
|
||||||
selectedIndex--;
|
|
||||||
} else if (currentPath !== homeDir) {
|
|
||||||
backButtonFocused = true;
|
|
||||||
selectedIndex = -1;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Qt.Key_L:
|
|
||||||
if (event.modifiers & Qt.ControlModifier) {
|
|
||||||
if (backButtonFocused) {
|
|
||||||
backButtonFocused = false;
|
|
||||||
selectedIndex = 0;
|
|
||||||
} else if (selectedIndex < totalItems - 1) {
|
|
||||||
selectedIndex++;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Qt.Key_Left:
|
|
||||||
if (pathInputHasFocus)
|
|
||||||
return;
|
|
||||||
if (backButtonFocused)
|
|
||||||
return;
|
|
||||||
if (selectedIndex > 0) {
|
|
||||||
selectedIndex--;
|
|
||||||
} else if (currentPath !== homeDir) {
|
|
||||||
backButtonFocused = true;
|
|
||||||
selectedIndex = -1;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
break;
|
|
||||||
case Qt.Key_Right:
|
|
||||||
if (pathInputHasFocus)
|
|
||||||
return;
|
|
||||||
if (backButtonFocused) {
|
|
||||||
backButtonFocused = false;
|
|
||||||
selectedIndex = 0;
|
|
||||||
} else if (selectedIndex < totalItems - 1) {
|
|
||||||
selectedIndex++;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
break;
|
|
||||||
case Qt.Key_Up:
|
|
||||||
if (backButtonFocused) {
|
|
||||||
backButtonFocused = false;
|
|
||||||
if (gridColumns === 1) {
|
|
||||||
selectedIndex = 0;
|
|
||||||
} else {
|
|
||||||
var col = selectedIndex % gridColumns;
|
|
||||||
selectedIndex = Math.min(col, totalItems - 1);
|
|
||||||
}
|
|
||||||
} else if (selectedIndex >= gridColumns) {
|
|
||||||
selectedIndex -= gridColumns;
|
|
||||||
} else if (selectedIndex > 0 && gridColumns === 1) {
|
|
||||||
selectedIndex--;
|
|
||||||
} else if (currentPath !== homeDir) {
|
|
||||||
backButtonFocused = true;
|
|
||||||
selectedIndex = -1;
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
break;
|
|
||||||
case Qt.Key_Down:
|
|
||||||
if (backButtonFocused) {
|
|
||||||
backButtonFocused = false;
|
|
||||||
selectedIndex = 0;
|
|
||||||
} else if (gridColumns === 1) {
|
|
||||||
if (selectedIndex < totalItems - 1) {
|
|
||||||
selectedIndex++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var newIndex = selectedIndex + gridColumns;
|
|
||||||
if (newIndex < totalItems) {
|
|
||||||
selectedIndex = newIndex;
|
|
||||||
} else {
|
|
||||||
var lastRowStart = Math.floor((totalItems - 1) / gridColumns) * gridColumns;
|
|
||||||
var col = selectedIndex % gridColumns;
|
|
||||||
var targetIndex = lastRowStart + col;
|
|
||||||
if (targetIndex < totalItems && targetIndex > selectedIndex) {
|
|
||||||
selectedIndex = targetIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
break;
|
|
||||||
case Qt.Key_Return:
|
|
||||||
case Qt.Key_Enter:
|
|
||||||
case Qt.Key_Space:
|
|
||||||
if (backButtonFocused) {
|
|
||||||
navigateUp();
|
|
||||||
} else if (selectedIndex >= 0 && selectedIndex < totalItems) {
|
|
||||||
root.keyboardFileSelection(selectedIndex);
|
|
||||||
}
|
|
||||||
event.accepted = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: keyboardSelectionTimer
|
|
||||||
|
|
||||||
property int targetIndex: -1
|
|
||||||
|
|
||||||
interval: 1
|
|
||||||
onTriggered: {
|
|
||||||
executeKeyboardSelection(targetIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
focus: true
|
|
||||||
|
|
||||||
Keys.onPressed: event => {
|
|
||||||
keyboardController.handleKey(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
anchors.fill: parent
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: parent.width
|
|
||||||
height: 48
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onPressed: if (windowControls)
|
|
||||||
windowControls.tryStartMove()
|
|
||||||
onDoubleClicked: if (windowControls)
|
|
||||||
windowControls.tryToggleMaximize()
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
spacing: Theme.spacingM
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.leftMargin: Theme.spacingL
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
name: browserIcon
|
|
||||||
size: Theme.iconSizeLarge
|
|
||||||
color: Theme.primary
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: browserTitle
|
|
||||||
font.pixelSize: Theme.fontSizeXLarge
|
|
||||||
color: Theme.surfaceText
|
|
||||||
font.weight: Font.Medium
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: Theme.spacingM
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
circular: false
|
|
||||||
iconName: showHiddenFiles ? "visibility_off" : "visibility"
|
|
||||||
iconSize: Theme.iconSize - 4
|
|
||||||
iconColor: showHiddenFiles ? Theme.primary : Theme.surfaceText
|
|
||||||
onClicked: showHiddenFiles = !showHiddenFiles
|
|
||||||
}
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
circular: false
|
|
||||||
iconName: viewMode === "grid" ? "view_list" : "grid_view"
|
|
||||||
iconSize: Theme.iconSize - 4
|
|
||||||
iconColor: Theme.surfaceText
|
|
||||||
onClicked: viewMode = viewMode === "grid" ? "list" : "grid"
|
|
||||||
}
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
circular: false
|
|
||||||
iconName: iconSizeIndex === 0 ? "photo_size_select_small" : iconSizeIndex === 1 ? "photo_size_select_large" : iconSizeIndex === 2 ? "photo_size_select_actual" : "zoom_in"
|
|
||||||
iconSize: Theme.iconSize - 4
|
|
||||||
iconColor: Theme.surfaceText
|
|
||||||
visible: viewMode === "grid"
|
|
||||||
onClicked: iconSizeIndex = (iconSizeIndex + 1) % iconSizes.length
|
|
||||||
}
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
circular: false
|
|
||||||
iconName: "info"
|
|
||||||
iconSize: Theme.iconSize - 4
|
|
||||||
iconColor: Theme.surfaceText
|
|
||||||
onClicked: root.showKeyboardHints = !root.showKeyboardHints
|
|
||||||
}
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
visible: windowControls?.supported ?? false
|
|
||||||
circular: false
|
|
||||||
iconName: windowControls?.targetWindow?.maximized ? "fullscreen_exit" : "fullscreen"
|
|
||||||
iconSize: Theme.iconSize - 4
|
|
||||||
iconColor: Theme.surfaceText
|
|
||||||
onClicked: if (windowControls)
|
|
||||||
windowControls.tryToggleMaximize()
|
|
||||||
}
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
circular: false
|
|
||||||
iconName: "close"
|
|
||||||
iconSize: Theme.iconSize - 4
|
|
||||||
iconColor: Theme.surfaceText
|
|
||||||
onClicked: root.closeRequested()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: parent.width
|
|
||||||
height: 1
|
|
||||||
color: Theme.outline
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: parent.width
|
|
||||||
height: parent.height - 49
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.bottomMargin: root.saveMode ? 40 + Theme.spacingL * 2 : 0
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
Row {
|
|
||||||
width: showSidebar ? 201 : 0
|
|
||||||
height: parent.height
|
|
||||||
spacing: 0
|
|
||||||
visible: showSidebar
|
|
||||||
|
|
||||||
FileBrowserSidebar {
|
|
||||||
height: parent.height
|
|
||||||
quickAccessLocations: root.quickAccessLocations
|
|
||||||
currentPath: root.currentPath
|
|
||||||
onLocationSelected: path => navigateTo(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: 1
|
|
||||||
height: parent.height
|
|
||||||
color: Theme.outline
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
width: parent.width - (showSidebar ? 201 : 0)
|
|
||||||
height: parent.height
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
FileBrowserNavigation {
|
|
||||||
width: parent.width
|
|
||||||
currentPath: root.currentPath
|
|
||||||
homeDir: root.homeDir
|
|
||||||
backButtonFocused: root.backButtonFocused
|
|
||||||
keyboardNavigationActive: root.keyboardNavigationActive
|
|
||||||
showSidebar: root.showSidebar
|
|
||||||
pathEditMode: root.pathEditMode
|
|
||||||
onNavigateUp: root.navigateUp()
|
|
||||||
onNavigateTo: path => root.navigateTo(path)
|
|
||||||
onPathInputFocusChanged: hasFocus => {
|
|
||||||
root.pathInputHasFocus = hasFocus;
|
|
||||||
if (hasFocus) {
|
|
||||||
root.pathEditMode = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: parent.width
|
|
||||||
height: 1
|
|
||||||
color: Theme.outline
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: gridContainer
|
|
||||||
width: parent.width
|
|
||||||
height: parent.height - 41
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
property real gridCellWidth: iconSizes[iconSizeIndex] + 24
|
|
||||||
property real gridCellHeight: iconSizes[iconSizeIndex] + 56
|
|
||||||
property real availableGridWidth: width - Theme.spacingM * 2
|
|
||||||
property int gridColumns: Math.max(1, Math.floor(availableGridWidth / gridCellWidth))
|
|
||||||
property real gridLeftMargin: Theme.spacingM + Math.max(0, (availableGridWidth - (gridColumns * gridCellWidth)) / 2)
|
|
||||||
|
|
||||||
onGridColumnsChanged: {
|
|
||||||
root.actualGridColumns = gridColumns;
|
|
||||||
}
|
|
||||||
Component.onCompleted: {
|
|
||||||
root.actualGridColumns = gridColumns;
|
|
||||||
}
|
|
||||||
|
|
||||||
DankGridView {
|
|
||||||
id: fileGrid
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: gridContainer.gridLeftMargin
|
|
||||||
anchors.rightMargin: Theme.spacingM
|
|
||||||
anchors.topMargin: Theme.spacingS
|
|
||||||
anchors.bottomMargin: Theme.spacingS
|
|
||||||
visible: viewMode === "grid"
|
|
||||||
cellWidth: gridContainer.gridCellWidth
|
|
||||||
cellHeight: gridContainer.gridCellHeight
|
|
||||||
cacheBuffer: 260
|
|
||||||
model: folderModel
|
|
||||||
currentIndex: selectedIndex
|
|
||||||
onCurrentIndexChanged: {
|
|
||||||
if (keyboardNavigationActive && currentIndex >= 0)
|
|
||||||
positionViewAtIndex(currentIndex, GridView.Contain);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollBar.vertical: DankScrollbar {
|
|
||||||
id: gridScrollbar
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollBar.horizontal: DankScrollbar {
|
|
||||||
policy: ScrollBar.AlwaysOff
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: FileBrowserGridDelegate {
|
|
||||||
iconSizes: root.iconSizes
|
|
||||||
iconSizeIndex: root.iconSizeIndex
|
|
||||||
selectedIndex: root.selectedIndex
|
|
||||||
keyboardNavigationActive: root.keyboardNavigationActive
|
|
||||||
onItemClicked: (index, path, name, isDir) => {
|
|
||||||
selectedIndex = index;
|
|
||||||
setSelectedFileData(path, name, isDir);
|
|
||||||
root.activateFile(path, name, isDir);
|
|
||||||
}
|
|
||||||
onItemSelected: (index, path, name, isDir) => {
|
|
||||||
setSelectedFileData(path, name, isDir);
|
|
||||||
}
|
|
||||||
onItemContextMenuRequested: (sender, localX, localY, path, name, isDir) => {
|
|
||||||
root.openItemContextMenu(sender, localX, localY, path, name, isDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
function onKeyboardSelectionRequestedChanged() {
|
|
||||||
if (root.keyboardSelectionRequested && root.keyboardSelectionIndex === index) {
|
|
||||||
root.keyboardSelectionRequested = false;
|
|
||||||
selectedIndex = index;
|
|
||||||
setSelectedFileData(filePath, fileName, fileIsDir);
|
|
||||||
root.activateFile(filePath, fileName, fileIsDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
target: root
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DankListView {
|
|
||||||
id: fileList
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: Theme.spacingM
|
|
||||||
anchors.rightMargin: Theme.spacingM
|
|
||||||
anchors.topMargin: Theme.spacingS
|
|
||||||
anchors.bottomMargin: Theme.spacingS
|
|
||||||
visible: viewMode === "list"
|
|
||||||
spacing: Theme.spacingXXS
|
|
||||||
model: folderModel
|
|
||||||
currentIndex: selectedIndex
|
|
||||||
onCurrentIndexChanged: {
|
|
||||||
if (keyboardNavigationActive && currentIndex >= 0)
|
|
||||||
positionViewAtIndex(currentIndex, ListView.Contain);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollBar.vertical: DankScrollbar {
|
|
||||||
id: listScrollbar
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: FileBrowserListDelegate {
|
|
||||||
width: fileList.width
|
|
||||||
selectedIndex: root.selectedIndex
|
|
||||||
keyboardNavigationActive: root.keyboardNavigationActive
|
|
||||||
onItemClicked: (index, path, name, isDir) => {
|
|
||||||
selectedIndex = index;
|
|
||||||
setSelectedFileData(path, name, isDir);
|
|
||||||
root.activateFile(path, name, isDir);
|
|
||||||
}
|
|
||||||
onItemSelected: (index, path, name, isDir) => {
|
|
||||||
setSelectedFileData(path, name, isDir);
|
|
||||||
}
|
|
||||||
onItemContextMenuRequested: (sender, localX, localY, path, name, isDir) => {
|
|
||||||
root.openItemContextMenu(sender, localX, localY, path, name, isDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
function onKeyboardSelectionRequestedChanged() {
|
|
||||||
if (root.keyboardSelectionRequested && root.keyboardSelectionIndex === index) {
|
|
||||||
root.keyboardSelectionRequested = false;
|
|
||||||
selectedIndex = index;
|
|
||||||
setSelectedFileData(filePath, fileName, fileIsDir);
|
|
||||||
root.activateFile(filePath, fileName, fileIsDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
target: root
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileBrowserSaveRow {
|
|
||||||
id: saveRow
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: Theme.spacingL
|
|
||||||
saveMode: root.saveMode
|
|
||||||
defaultFileName: root.defaultFileName
|
|
||||||
currentPath: root.currentPath
|
|
||||||
onSaveRequested: filePath => handleSaveFile(filePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyboardHints {
|
|
||||||
id: keyboardHints
|
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: Theme.spacingL
|
|
||||||
showHints: root.showKeyboardHints
|
|
||||||
}
|
|
||||||
|
|
||||||
FileInfo {
|
|
||||||
id: fileInfo
|
|
||||||
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: Theme.spacingL
|
|
||||||
width: 300
|
|
||||||
showFileInfo: root.showFileInfo
|
|
||||||
selectedIndex: root.selectedIndex
|
|
||||||
sourceFolderModel: folderModel
|
|
||||||
currentPath: root.currentPath
|
|
||||||
currentFileName: root.selectedFileName
|
|
||||||
currentFileIsDir: root.selectedFileIsDir
|
|
||||||
currentFileExtension: {
|
|
||||||
if (root.selectedFileIsDir || !root.selectedFileName)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
var lastDot = root.selectedFileName.lastIndexOf('.');
|
|
||||||
return lastDot > 0 ? root.selectedFileName.substring(lastDot + 1).toLowerCase() : "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileBrowserSortMenu {
|
|
||||||
id: sortMenu
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.topMargin: 120
|
|
||||||
anchors.rightMargin: Theme.spacingL
|
|
||||||
sortBy: root.sortBy
|
|
||||||
sortAscending: root.sortAscending
|
|
||||||
onSortBySelected: value => {
|
|
||||||
root.sortBy = value;
|
|
||||||
}
|
|
||||||
onSortOrderSelected: ascending => {
|
|
||||||
root.sortAscending = ascending;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileBrowserOverwriteDialog {
|
|
||||||
anchors.fill: parent
|
|
||||||
showDialog: showOverwriteConfirmation
|
|
||||||
pendingFilePath: root.pendingFilePath
|
|
||||||
onConfirmed: filePath => {
|
|
||||||
showOverwriteConfirmation = false;
|
|
||||||
fileSelected(filePath);
|
|
||||||
pendingFilePath = "";
|
|
||||||
Qt.callLater(() => root.closeRequested());
|
|
||||||
}
|
|
||||||
onCancelled: {
|
|
||||||
showOverwriteConfirmation = false;
|
|
||||||
pendingFilePath = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileBrowserItemContextMenu {
|
|
||||||
id: itemContextMenu
|
|
||||||
parentFocusItem: root
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,252 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import Quickshell.Widgets
|
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
StyledRect {
|
DankCommon.FileBrowserGridDelegate {}
|
||||||
id: delegateRoot
|
|
||||||
|
|
||||||
required property bool fileIsDir
|
|
||||||
required property string filePath
|
|
||||||
required property string fileName
|
|
||||||
required property int index
|
|
||||||
|
|
||||||
property bool weMode: false
|
|
||||||
property var iconSizes: [80, 120, 160, 200]
|
|
||||||
property int iconSizeIndex: 1
|
|
||||||
property int selectedIndex: -1
|
|
||||||
property bool keyboardNavigationActive: false
|
|
||||||
|
|
||||||
signal itemClicked(int index, string path, string name, bool isDir)
|
|
||||||
signal itemSelected(int index, string path, string name, bool isDir)
|
|
||||||
signal itemContextMenuRequested(var sender, real localX, real localY, string path, string name, bool isDir)
|
|
||||||
|
|
||||||
function getFileExtension(fileName) {
|
|
||||||
const parts = fileName.split('.');
|
|
||||||
if (parts.length > 1) {
|
|
||||||
return parts[parts.length - 1].toLowerCase();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function determineFileType(fileName) {
|
|
||||||
const ext = getFileExtension(fileName);
|
|
||||||
|
|
||||||
const imageExts = ["png", "jpg", "jpeg", "gif", "bmp", "webp", "svg", "ico", "jxl", "avif", "heif", "exr"];
|
|
||||||
if (imageExts.includes(ext)) {
|
|
||||||
return "image";
|
|
||||||
}
|
|
||||||
|
|
||||||
const videoExts = ["mp4", "mkv", "avi", "mov", "webm", "flv", "wmv", "m4v"];
|
|
||||||
if (videoExts.includes(ext)) {
|
|
||||||
return "video";
|
|
||||||
}
|
|
||||||
|
|
||||||
const audioExts = ["mp3", "wav", "flac", "ogg", "m4a", "aac", "wma"];
|
|
||||||
if (audioExts.includes(ext)) {
|
|
||||||
return "audio";
|
|
||||||
}
|
|
||||||
|
|
||||||
const codeExts = ["js", "ts", "jsx", "tsx", "py", "go", "rs", "c", "cpp", "h", "java", "kt", "swift", "rb", "php", "html", "css", "scss", "json", "xml", "yaml", "yml", "toml", "sh", "bash", "zsh", "fish", "qml", "vue", "svelte"];
|
|
||||||
if (codeExts.includes(ext)) {
|
|
||||||
return "code";
|
|
||||||
}
|
|
||||||
|
|
||||||
const docExts = ["txt", "md", "pdf", "doc", "docx", "odt", "rtf"];
|
|
||||||
if (docExts.includes(ext)) {
|
|
||||||
return "document";
|
|
||||||
}
|
|
||||||
|
|
||||||
const archiveExts = ["zip", "tar", "gz", "bz2", "xz", "7z", "rar"];
|
|
||||||
if (archiveExts.includes(ext)) {
|
|
||||||
return "archive";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ext || fileName.indexOf('.') === -1) {
|
|
||||||
return "binary";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "file";
|
|
||||||
}
|
|
||||||
|
|
||||||
function isImageFile(fileName) {
|
|
||||||
if (!fileName) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return determineFileType(fileName) === "image";
|
|
||||||
}
|
|
||||||
|
|
||||||
function isVideoFile(fileName) {
|
|
||||||
if (!fileName) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return determineFileType(fileName) === "video";
|
|
||||||
}
|
|
||||||
|
|
||||||
property bool isImage: isImageFile(delegateRoot.fileName)
|
|
||||||
property bool isVideo: isVideoFile(delegateRoot.fileName)
|
|
||||||
|
|
||||||
property string _xdgCacheHome: Paths.strip(Paths.xdgCache)
|
|
||||||
property string _thumbnailSize: iconSizeIndex >= 2 ? "x-large" : "large"
|
|
||||||
property int _thumbnailPx: iconSizeIndex >= 2 ? 512 : 256
|
|
||||||
property string videoThumbnailPath: {
|
|
||||||
if (!delegateRoot.fileIsDir && isVideo) {
|
|
||||||
const hash = Qt.md5("file://" + delegateRoot.filePath);
|
|
||||||
return _xdgCacheHome + "/thumbnails/" + _thumbnailSize + "/" + hash + ".png";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
property string _videoThumb: ""
|
|
||||||
property bool _thumbGenAttempted: false
|
|
||||||
|
|
||||||
// Probe the thumbnail optimistically; Image.Error triggers generation
|
|
||||||
onVideoThumbnailPathChanged: {
|
|
||||||
_thumbGenAttempted = false;
|
|
||||||
_videoThumb = videoThumbnailPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateVideoThumbnail() {
|
|
||||||
if (_thumbGenAttempted)
|
|
||||||
return;
|
|
||||||
_thumbGenAttempted = true;
|
|
||||||
_videoThumb = "";
|
|
||||||
const thumbPath = videoThumbnailPath;
|
|
||||||
const thumbDir = _xdgCacheHome + "/thumbnails/" + _thumbnailSize;
|
|
||||||
const script = "mkdir -p \"$1\" && ffmpegthumbnailer -i \"$2\" -o \"$3\" -s " + _thumbnailPx + " -f";
|
|
||||||
Proc.runCommand(null, ["sh", "-c", script, "thumb", thumbDir, delegateRoot.filePath, thumbPath], function (output, exitCode) {
|
|
||||||
if (exitCode === 0)
|
|
||||||
_videoThumb = thumbPath;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIconForFile(fileName) {
|
|
||||||
const lowerName = fileName.toLowerCase();
|
|
||||||
if (lowerName.startsWith("dockerfile")) {
|
|
||||||
return "docker";
|
|
||||||
}
|
|
||||||
const ext = fileName.split('.').pop();
|
|
||||||
return ext || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
width: weMode ? 245 : iconSizes[iconSizeIndex] + 16
|
|
||||||
height: weMode ? 205 : iconSizes[iconSizeIndex] + 48
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: {
|
|
||||||
if (keyboardNavigationActive && delegateRoot.index === selectedIndex)
|
|
||||||
return Theme.surfacePressed;
|
|
||||||
|
|
||||||
return mouseArea.containsMouse ? Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) : Theme.withAlpha(Theme.surfaceContainerHigh, 0);
|
|
||||||
}
|
|
||||||
border.color: keyboardNavigationActive && delegateRoot.index === selectedIndex ? Theme.primary : Theme.withAlpha(Theme.primary, 0)
|
|
||||||
border.width: (keyboardNavigationActive && delegateRoot.index === selectedIndex) ? 2 : 0
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
if (keyboardNavigationActive && delegateRoot.index === selectedIndex)
|
|
||||||
itemSelected(delegateRoot.index, delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
onSelectedIndexChanged: {
|
|
||||||
if (keyboardNavigationActive && selectedIndex === delegateRoot.index)
|
|
||||||
itemSelected(delegateRoot.index, delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: weMode ? 225 : (iconSizes[iconSizeIndex] - 8)
|
|
||||||
height: weMode ? 165 : (iconSizes[iconSizeIndex] - 8)
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
|
|
||||||
ClippingRectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 2
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: "transparent"
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: gridPreviewImage
|
|
||||||
anchors.fill: parent
|
|
||||||
property var weExtensions: [".jpg", ".jpeg", ".png", ".webp", ".gif", ".bmp", ".tga", ".jxl", ".avif", ".heif", ".exr"]
|
|
||||||
property int weExtIndex: 0
|
|
||||||
property string imagePath: {
|
|
||||||
if (weMode && delegateRoot.fileIsDir)
|
|
||||||
return delegateRoot.filePath + "/preview" + weExtensions[weExtIndex];
|
|
||||||
if (_videoThumb)
|
|
||||||
return _videoThumb;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
source: imagePath ? "file://" + imagePath.split('/').map(s => encodeURIComponent(s)).join('/') : ""
|
|
||||||
onStatusChanged: {
|
|
||||||
if (status !== Image.Error)
|
|
||||||
return;
|
|
||||||
if (weMode && delegateRoot.fileIsDir) {
|
|
||||||
if (weExtIndex < weExtensions.length - 1) {
|
|
||||||
weExtIndex++;
|
|
||||||
} else {
|
|
||||||
imagePath = "";
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_videoThumb)
|
|
||||||
generateVideoThumbnail();
|
|
||||||
}
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
|
||||||
sourceSize.width: weMode ? 225 : iconSizes[iconSizeIndex]
|
|
||||||
sourceSize.height: weMode ? 225 : iconSizes[iconSizeIndex]
|
|
||||||
asynchronous: true
|
|
||||||
visible: status === Image.Ready && ((!delegateRoot.fileIsDir && isVideo) || (weMode && delegateRoot.fileIsDir))
|
|
||||||
}
|
|
||||||
|
|
||||||
CachingImage {
|
|
||||||
anchors.fill: parent
|
|
||||||
imagePath: !delegateRoot.fileIsDir && isImage ? delegateRoot.filePath : ""
|
|
||||||
maxCacheSize: 256
|
|
||||||
animate: false
|
|
||||||
visible: !delegateRoot.fileIsDir && isImage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DankNFIcon {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
name: delegateRoot.fileIsDir ? "folder" : getIconForFile(delegateRoot.fileName)
|
|
||||||
size: iconSizes[iconSizeIndex] * 0.45
|
|
||||||
color: delegateRoot.fileIsDir ? Theme.primary : Theme.surfaceText
|
|
||||||
visible: (!delegateRoot.fileIsDir && !isImage && !(isVideo && gridPreviewImage.status === Image.Ready)) || (delegateRoot.fileIsDir && !weMode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: delegateRoot.fileName || ""
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceText
|
|
||||||
width: delegateRoot.width - Theme.spacingM
|
|
||||||
elide: Text.ElideRight
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
maximumLineCount: 2
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mouseArea
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
||||||
onClicked: mouse => {
|
|
||||||
switch (mouse.button) {
|
|
||||||
case Qt.LeftButton:
|
|
||||||
itemClicked(delegateRoot.index, delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir);
|
|
||||||
break;
|
|
||||||
case Qt.RightButton:
|
|
||||||
itemContextMenuRequested(delegateRoot, mouse.x, mouse.y, delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,153 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import QtQuick.Controls
|
|
||||||
import Quickshell
|
|
||||||
import qs.Common
|
|
||||||
import qs.Services
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
Popup {
|
DankCommon.FileBrowserItemContextMenu {}
|
||||||
id: root
|
|
||||||
|
|
||||||
property string filePath: ""
|
|
||||||
property string fileName: ""
|
|
||||||
property bool fileIsDir: false
|
|
||||||
property var parentFocusItem: null
|
|
||||||
|
|
||||||
signal trashed
|
|
||||||
signal menuClosed
|
|
||||||
|
|
||||||
readonly property var menuItems: [
|
|
||||||
{
|
|
||||||
text: I18n.tr("Move to Trash"),
|
|
||||||
icon: "delete",
|
|
||||||
action: trashItem,
|
|
||||||
enabled: filePath.length > 0,
|
|
||||||
dangerous: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: I18n.tr("Copy path"),
|
|
||||||
icon: "content_copy",
|
|
||||||
action: copyPath,
|
|
||||||
enabled: filePath.length > 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
function showAt(parentItem, localX, localY, path, name, isDir) {
|
|
||||||
if (!parentItem)
|
|
||||||
return;
|
|
||||||
parent = parentItem;
|
|
||||||
filePath = path || "";
|
|
||||||
fileName = name || "";
|
|
||||||
fileIsDir = !!isDir;
|
|
||||||
x = Math.max(0, Math.min(parentItem.width - width, localX));
|
|
||||||
y = Math.max(0, Math.min(parentItem.height - height, localY));
|
|
||||||
open();
|
|
||||||
}
|
|
||||||
|
|
||||||
function trashItem() {
|
|
||||||
if (!filePath)
|
|
||||||
return;
|
|
||||||
TrashService.trashPath(filePath, ok => {
|
|
||||||
if (ok)
|
|
||||||
root.trashed();
|
|
||||||
});
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyPath() {
|
|
||||||
if (!filePath)
|
|
||||||
return;
|
|
||||||
Quickshell.execDetached(["dms", "cl", "copy", filePath]);
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
width: 220
|
|
||||||
height: menuColumn.implicitHeight + Theme.spacingS * 2
|
|
||||||
padding: 0
|
|
||||||
modal: false
|
|
||||||
closePolicy: Popup.CloseOnEscape
|
|
||||||
|
|
||||||
onClosed: {
|
|
||||||
closePolicy = Popup.CloseOnEscape;
|
|
||||||
menuClosed();
|
|
||||||
if (parentFocusItem)
|
|
||||||
Qt.callLater(() => parentFocusItem.forceActiveFocus());
|
|
||||||
}
|
|
||||||
|
|
||||||
onOpened: outsideClickTimer.start()
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: outsideClickTimer
|
|
||||||
interval: 100
|
|
||||||
onTriggered: root.closePolicy = Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
||||||
}
|
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
color: "transparent"
|
|
||||||
}
|
|
||||||
|
|
||||||
contentItem: Rectangle {
|
|
||||||
color: Theme.floatingSurface
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
border.color: BlurService.borderColor
|
|
||||||
border.width: BlurService.borderWidth
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: menuColumn
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: Theme.spacingS
|
|
||||||
spacing: 1
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: root.menuItems
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: parent.width
|
|
||||||
height: 32
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
opacity: modelData.enabled ? 1 : 0.5
|
|
||||||
color: {
|
|
||||||
if (!modelData.enabled || !area.containsMouse)
|
|
||||||
return "transparent";
|
|
||||||
if (modelData.dangerous)
|
|
||||||
return Theme.errorHover;
|
|
||||||
return BlurService.hoverColor(Theme.widgetBaseHoverColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.leftMargin: Theme.spacingS
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: Theme.spacingS
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
name: modelData.icon
|
|
||||||
size: 16
|
|
||||||
color: modelData.dangerous && area.containsMouse && modelData.enabled ? Theme.error : Theme.surfaceText
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
text: modelData.text
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: modelData.dangerous && area.containsMouse && modelData.enabled ? Theme.error : Theme.surfaceText
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: area
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
enabled: modelData.enabled
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: modelData.action()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,256 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import Quickshell.Widgets
|
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
StyledRect {
|
DankCommon.FileBrowserListDelegate {}
|
||||||
id: listDelegateRoot
|
|
||||||
|
|
||||||
required property bool fileIsDir
|
|
||||||
required property string filePath
|
|
||||||
required property string fileName
|
|
||||||
required property int index
|
|
||||||
required property var fileModified
|
|
||||||
required property int fileSize
|
|
||||||
|
|
||||||
property int selectedIndex: -1
|
|
||||||
property bool keyboardNavigationActive: false
|
|
||||||
|
|
||||||
signal itemClicked(int index, string path, string name, bool isDir)
|
|
||||||
signal itemSelected(int index, string path, string name, bool isDir)
|
|
||||||
signal itemContextMenuRequested(var sender, real localX, real localY, string path, string name, bool isDir)
|
|
||||||
|
|
||||||
function getFileExtension(fileName) {
|
|
||||||
const parts = fileName.split('.');
|
|
||||||
if (parts.length > 1) {
|
|
||||||
return parts[parts.length - 1].toLowerCase();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function determineFileType(fileName) {
|
|
||||||
const ext = getFileExtension(fileName);
|
|
||||||
|
|
||||||
const imageExts = ["png", "jpg", "jpeg", "gif", "bmp", "webp", "svg", "ico", "jxl", "avif", "heif", "exr"];
|
|
||||||
if (imageExts.includes(ext)) {
|
|
||||||
return "image";
|
|
||||||
}
|
|
||||||
|
|
||||||
const videoExts = ["mp4", "mkv", "avi", "mov", "webm", "flv", "wmv", "m4v"];
|
|
||||||
if (videoExts.includes(ext)) {
|
|
||||||
return "video";
|
|
||||||
}
|
|
||||||
|
|
||||||
const audioExts = ["mp3", "wav", "flac", "ogg", "m4a", "aac", "wma"];
|
|
||||||
if (audioExts.includes(ext)) {
|
|
||||||
return "audio";
|
|
||||||
}
|
|
||||||
|
|
||||||
const codeExts = ["js", "ts", "jsx", "tsx", "py", "go", "rs", "c", "cpp", "h", "java", "kt", "swift", "rb", "php", "html", "css", "scss", "json", "xml", "yaml", "yml", "toml", "sh", "bash", "zsh", "fish", "qml", "vue", "svelte"];
|
|
||||||
if (codeExts.includes(ext)) {
|
|
||||||
return "code";
|
|
||||||
}
|
|
||||||
|
|
||||||
const docExts = ["txt", "md", "pdf", "doc", "docx", "odt", "rtf"];
|
|
||||||
if (docExts.includes(ext)) {
|
|
||||||
return "document";
|
|
||||||
}
|
|
||||||
|
|
||||||
const archiveExts = ["zip", "tar", "gz", "bz2", "xz", "7z", "rar"];
|
|
||||||
if (archiveExts.includes(ext)) {
|
|
||||||
return "archive";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ext || fileName.indexOf('.') === -1) {
|
|
||||||
return "binary";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "file";
|
|
||||||
}
|
|
||||||
|
|
||||||
function isImageFile(fileName) {
|
|
||||||
if (!fileName) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return determineFileType(fileName) === "image";
|
|
||||||
}
|
|
||||||
|
|
||||||
function isVideoFile(fileName) {
|
|
||||||
if (!fileName) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return determineFileType(fileName) === "video";
|
|
||||||
}
|
|
||||||
|
|
||||||
property bool isImage: isImageFile(listDelegateRoot.fileName)
|
|
||||||
property bool isVideo: isVideoFile(listDelegateRoot.fileName)
|
|
||||||
|
|
||||||
property string _xdgCacheHome: Paths.strip(Paths.xdgCache)
|
|
||||||
property string videoThumbnailPath: {
|
|
||||||
if (!listDelegateRoot.fileIsDir && isVideo) {
|
|
||||||
const hash = Qt.md5("file://" + listDelegateRoot.filePath);
|
|
||||||
return _xdgCacheHome + "/thumbnails/normal/" + hash + ".png";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
property string _videoThumb: ""
|
|
||||||
property bool _thumbGenAttempted: false
|
|
||||||
|
|
||||||
// Probe the thumbnail optimistically; Image.Error triggers generation
|
|
||||||
onVideoThumbnailPathChanged: {
|
|
||||||
_thumbGenAttempted = false;
|
|
||||||
_videoThumb = videoThumbnailPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateVideoThumbnail() {
|
|
||||||
if (_thumbGenAttempted)
|
|
||||||
return;
|
|
||||||
_thumbGenAttempted = true;
|
|
||||||
_videoThumb = "";
|
|
||||||
const thumbPath = videoThumbnailPath;
|
|
||||||
const thumbDir = _xdgCacheHome + "/thumbnails/normal";
|
|
||||||
const script = "mkdir -p \"$1\" && ffmpegthumbnailer -i \"$2\" -o \"$3\" -s 128 -f";
|
|
||||||
Proc.runCommand(null, ["sh", "-c", script, "thumb", thumbDir, listDelegateRoot.filePath, thumbPath], function (output, exitCode) {
|
|
||||||
if (exitCode === 0)
|
|
||||||
_videoThumb = thumbPath;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIconForFile(fileName) {
|
|
||||||
const lowerName = fileName.toLowerCase();
|
|
||||||
if (lowerName.startsWith("dockerfile")) {
|
|
||||||
return "docker";
|
|
||||||
}
|
|
||||||
const ext = fileName.split('.').pop();
|
|
||||||
return ext || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatFileSize(size) {
|
|
||||||
if (size < 1024)
|
|
||||||
return size + " B";
|
|
||||||
if (size < 1024 * 1024)
|
|
||||||
return (size / 1024).toFixed(1) + " KB";
|
|
||||||
if (size < 1024 * 1024 * 1024)
|
|
||||||
return (size / (1024 * 1024)).toFixed(1) + " MB";
|
|
||||||
return (size / (1024 * 1024 * 1024)).toFixed(1) + " GB";
|
|
||||||
}
|
|
||||||
|
|
||||||
height: 44
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: {
|
|
||||||
if (keyboardNavigationActive && listDelegateRoot.index === selectedIndex)
|
|
||||||
return Theme.surfacePressed;
|
|
||||||
return listMouseArea.containsMouse ? Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) : Theme.withAlpha(Theme.surfaceContainerHigh, 0);
|
|
||||||
}
|
|
||||||
border.color: keyboardNavigationActive && listDelegateRoot.index === selectedIndex ? Theme.primary : Theme.withAlpha(Theme.primary, 0)
|
|
||||||
border.width: (keyboardNavigationActive && listDelegateRoot.index === selectedIndex) ? 2 : 0
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
if (keyboardNavigationActive && listDelegateRoot.index === selectedIndex)
|
|
||||||
itemSelected(listDelegateRoot.index, listDelegateRoot.filePath, listDelegateRoot.fileName, listDelegateRoot.fileIsDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
onSelectedIndexChanged: {
|
|
||||||
if (keyboardNavigationActive && selectedIndex === listDelegateRoot.index)
|
|
||||||
itemSelected(listDelegateRoot.index, listDelegateRoot.filePath, listDelegateRoot.fileName, listDelegateRoot.fileIsDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: Theme.spacingS
|
|
||||||
anchors.rightMargin: Theme.spacingS
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: 28
|
|
||||||
height: 28
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
|
|
||||||
ClippingRectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: "transparent"
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: listPreviewImage
|
|
||||||
anchors.fill: parent
|
|
||||||
property string imagePath: _videoThumb
|
|
||||||
source: imagePath ? "file://" + imagePath.split('/').map(s => encodeURIComponent(s)).join('/') : ""
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
|
||||||
sourceSize.width: 32
|
|
||||||
sourceSize.height: 32
|
|
||||||
asynchronous: true
|
|
||||||
visible: status === Image.Ready && !listDelegateRoot.fileIsDir && isVideo
|
|
||||||
onStatusChanged: {
|
|
||||||
if (status === Image.Error && _videoThumb)
|
|
||||||
generateVideoThumbnail();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CachingImage {
|
|
||||||
anchors.fill: parent
|
|
||||||
imagePath: !listDelegateRoot.fileIsDir && isImage ? listDelegateRoot.filePath : ""
|
|
||||||
maxCacheSize: 256
|
|
||||||
animate: false
|
|
||||||
visible: !listDelegateRoot.fileIsDir && isImage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DankNFIcon {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
name: listDelegateRoot.fileIsDir ? "folder" : getIconForFile(listDelegateRoot.fileName)
|
|
||||||
size: Theme.iconSize - 2
|
|
||||||
color: listDelegateRoot.fileIsDir ? Theme.primary : Theme.surfaceText
|
|
||||||
visible: listDelegateRoot.fileIsDir || (!isImage && !(isVideo && listPreviewImage.status === Image.Ready))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: listDelegateRoot.fileName || ""
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: Theme.surfaceText
|
|
||||||
width: parent.width - 280
|
|
||||||
elide: Text.ElideRight
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
maximumLineCount: 1
|
|
||||||
clip: true
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: listDelegateRoot.fileIsDir ? "" : formatFileSize(listDelegateRoot.fileSize)
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
width: 70
|
|
||||||
horizontalAlignment: Text.AlignRight
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: Qt.formatDateTime(listDelegateRoot.fileModified, "MMM d, yyyy h:mm AP")
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
width: 140
|
|
||||||
horizontalAlignment: Text.AlignRight
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: listMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
||||||
onClicked: mouse => {
|
|
||||||
switch (mouse.button) {
|
|
||||||
case Qt.LeftButton:
|
|
||||||
itemClicked(listDelegateRoot.index, listDelegateRoot.filePath, listDelegateRoot.fileName, listDelegateRoot.fileIsDir);
|
|
||||||
break;
|
|
||||||
case Qt.RightButton:
|
|
||||||
itemContextMenuRequested(listDelegateRoot, mouse.x, mouse.y, listDelegateRoot.filePath, listDelegateRoot.fileName, listDelegateRoot.fileIsDir);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,100 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import Quickshell
|
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
FloatingWindow {
|
DankCommon.FileBrowserModal {}
|
||||||
id: fileBrowserModal
|
|
||||||
|
|
||||||
property bool disablePopupTransparency: true
|
|
||||||
property string browserTitle: "Select File"
|
|
||||||
property string browserIcon: "folder_open"
|
|
||||||
property string browserType: "generic"
|
|
||||||
property var fileExtensions: ["*.*"]
|
|
||||||
property alias filterExtensions: fileBrowserModal.fileExtensions
|
|
||||||
property bool showHiddenFiles: false
|
|
||||||
property bool saveMode: false
|
|
||||||
property string defaultFileName: ""
|
|
||||||
property var parentModal: null
|
|
||||||
parentWindow: parentModal
|
|
||||||
property bool shouldHaveFocus: visible
|
|
||||||
property bool allowFocusOverride: false
|
|
||||||
property bool shouldBeVisible: visible
|
|
||||||
property bool allowStacking: true
|
|
||||||
|
|
||||||
signal fileSelected(string path)
|
|
||||||
signal dialogClosed
|
|
||||||
|
|
||||||
function open() {
|
|
||||||
visible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function close() {
|
|
||||||
visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
objectName: "fileBrowserModal"
|
|
||||||
title: "Files - " + browserTitle
|
|
||||||
minimumSize: Qt.size(500, 400)
|
|
||||||
implicitWidth: 800
|
|
||||||
implicitHeight: 600
|
|
||||||
color: Theme.surfaceContainer
|
|
||||||
visible: false
|
|
||||||
|
|
||||||
onClosed: close()
|
|
||||||
|
|
||||||
onVisibleChanged: {
|
|
||||||
if (visible) {
|
|
||||||
if (parentModal && "shouldHaveFocus" in parentModal) {
|
|
||||||
parentModal.shouldHaveFocus = false;
|
|
||||||
parentModal.allowFocusOverride = true;
|
|
||||||
}
|
|
||||||
Qt.callLater(() => {
|
|
||||||
if (content) {
|
|
||||||
content.reset();
|
|
||||||
content.forceActiveFocus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (parentModal && "allowFocusOverride" in parentModal) {
|
|
||||||
parentModal.allowFocusOverride = false;
|
|
||||||
parentModal.shouldHaveFocus = Qt.binding(() => parentModal.shouldBeVisible);
|
|
||||||
}
|
|
||||||
dialogClosed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Loader {
|
|
||||||
id: contentLoader
|
|
||||||
anchors.fill: parent
|
|
||||||
active: fileBrowserModal.visible
|
|
||||||
sourceComponent: FileBrowserContent {
|
|
||||||
id: content
|
|
||||||
anchors.fill: parent
|
|
||||||
focus: true
|
|
||||||
closeOnEscape: false
|
|
||||||
windowControls: fileBrowserModal.windowControlsRef
|
|
||||||
|
|
||||||
browserTitle: fileBrowserModal.browserTitle
|
|
||||||
browserIcon: fileBrowserModal.browserIcon
|
|
||||||
browserType: fileBrowserModal.browserType
|
|
||||||
fileExtensions: fileBrowserModal.fileExtensions
|
|
||||||
showHiddenFiles: fileBrowserModal.showHiddenFiles
|
|
||||||
saveMode: fileBrowserModal.saveMode
|
|
||||||
defaultFileName: fileBrowserModal.defaultFileName
|
|
||||||
|
|
||||||
Component.onCompleted: initialize()
|
|
||||||
|
|
||||||
onFileSelected: path => fileBrowserModal.fileSelected(path)
|
|
||||||
onCloseRequested: fileBrowserModal.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
property alias content: contentLoader.item
|
|
||||||
property alias windowControlsRef: windowControls
|
|
||||||
|
|
||||||
FloatingWindowControls {
|
|
||||||
id: windowControls
|
|
||||||
targetWindow: fileBrowserModal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,130 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
Row {
|
DankCommon.FileBrowserNavigation {}
|
||||||
id: navigation
|
|
||||||
|
|
||||||
property string currentPath: ""
|
|
||||||
property string homeDir: ""
|
|
||||||
property bool backButtonFocused: false
|
|
||||||
property bool keyboardNavigationActive: false
|
|
||||||
property bool showSidebar: true
|
|
||||||
property bool pathEditMode: false
|
|
||||||
property bool pathInputHasFocus: false
|
|
||||||
|
|
||||||
signal navigateUp
|
|
||||||
signal navigateTo(string path)
|
|
||||||
signal pathInputFocusChanged(bool hasFocus)
|
|
||||||
|
|
||||||
height: 40
|
|
||||||
leftPadding: Theme.spacingM
|
|
||||||
rightPadding: Theme.spacingM
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: 32
|
|
||||||
height: 32
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: (backButtonMouseArea.containsMouse || (backButtonFocused && keyboardNavigationActive)) && currentPath !== homeDir ? Theme.surfaceVariant : Theme.withAlpha(Theme.surfaceVariant, 0)
|
|
||||||
opacity: currentPath !== homeDir ? 1 : 0
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
name: "arrow_back"
|
|
||||||
size: Theme.iconSizeSmall
|
|
||||||
color: Theme.surfaceText
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: backButtonMouseArea
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: currentPath !== homeDir
|
|
||||||
cursorShape: currentPath !== homeDir ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
||||||
enabled: currentPath !== homeDir
|
|
||||||
onClicked: navigation.navigateUp()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: Math.max(0, (parent?.width ?? 0) - 40 - Theme.spacingS - (showSidebar ? 0 : 80))
|
|
||||||
height: 32
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
anchors.fill: parent
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: pathEditMode ? Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency) : Theme.withAlpha(Theme.surfaceContainer, 0)
|
|
||||||
border.color: pathEditMode ? Theme.primary : Theme.withAlpha(Theme.primary, 0)
|
|
||||||
border.width: pathEditMode ? 1 : 0
|
|
||||||
visible: !pathEditMode
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
id: pathDisplay
|
|
||||||
text: currentPath.replace("file://", "")
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: Theme.surfaceText
|
|
||||||
font.weight: Font.Medium
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: Theme.spacingS
|
|
||||||
anchors.rightMargin: Theme.spacingS
|
|
||||||
elide: Text.ElideMiddle
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
maximumLineCount: 1
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
cursorShape: Qt.IBeamCursor
|
|
||||||
onClicked: {
|
|
||||||
pathEditMode = true;
|
|
||||||
pathInput.text = currentPath.replace("file://", "");
|
|
||||||
Qt.callLater(() => pathInput.forceActiveFocus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DankTextField {
|
|
||||||
id: pathInput
|
|
||||||
anchors.fill: parent
|
|
||||||
visible: pathEditMode
|
|
||||||
topPadding: Theme.spacingXS
|
|
||||||
bottomPadding: Theme.spacingXS
|
|
||||||
onAccepted: {
|
|
||||||
const newPath = text.trim();
|
|
||||||
if (newPath !== "") {
|
|
||||||
navigation.navigateTo(newPath);
|
|
||||||
}
|
|
||||||
pathEditMode = false;
|
|
||||||
}
|
|
||||||
Keys.onEscapePressed: {
|
|
||||||
pathEditMode = false;
|
|
||||||
}
|
|
||||||
Keys.onDownPressed: {
|
|
||||||
pathEditMode = false;
|
|
||||||
}
|
|
||||||
onActiveFocusChanged: {
|
|
||||||
navigation.pathInputFocusChanged(activeFocus);
|
|
||||||
if (!activeFocus && pathEditMode) {
|
|
||||||
pathEditMode = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
spacing: Theme.spacingXS
|
|
||||||
visible: !showSidebar
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
|
|
||||||
DankActionButton {
|
|
||||||
circular: false
|
|
||||||
iconName: "sort"
|
|
||||||
iconSize: Theme.iconSize - 6
|
|
||||||
iconColor: Theme.surfaceText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,127 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
Item {
|
DankCommon.FileBrowserOverwriteDialog {}
|
||||||
id: overwriteDialog
|
|
||||||
|
|
||||||
property bool showDialog: false
|
|
||||||
property string pendingFilePath: ""
|
|
||||||
|
|
||||||
signal confirmed(string filePath)
|
|
||||||
signal cancelled
|
|
||||||
|
|
||||||
visible: showDialog
|
|
||||||
focus: showDialog
|
|
||||||
|
|
||||||
Keys.onEscapePressed: {
|
|
||||||
cancelled();
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onReturnPressed: {
|
|
||||||
confirmed(pendingFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
color: Theme.shadowStrong
|
|
||||||
opacity: 0.8
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
cancelled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
width: 400
|
|
||||||
height: 160
|
|
||||||
color: Theme.surfaceContainer
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
border.color: Theme.outlineMedium
|
|
||||||
border.width: 1
|
|
||||||
|
|
||||||
Column {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
width: parent.width - Theme.spacingL * 2
|
|
||||||
spacing: Theme.spacingM
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: I18n.tr("File Already Exists")
|
|
||||||
font.pixelSize: Theme.fontSizeLarge
|
|
||||||
font.weight: Font.Medium
|
|
||||||
color: Theme.surfaceText
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: I18n.tr("A file with this name already exists. Do you want to overwrite it?")
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
width: parent.width
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
spacing: Theme.spacingM
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: 80
|
|
||||||
height: 36
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: cancelArea.containsMouse ? Qt.lighter(Theme.surfaceVariant, 1.2) : Theme.surfaceVariant
|
|
||||||
border.color: Theme.outline
|
|
||||||
border.width: 1
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: I18n.tr("Cancel")
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: Theme.surfaceText
|
|
||||||
font.weight: Font.Medium
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: cancelArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
cancelled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: 90
|
|
||||||
height: 36
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: overwriteArea.containsMouse ? Qt.darker(Theme.primary, 1.1) : Theme.primary
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: I18n.tr("Overwrite")
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: Theme.background
|
|
||||||
font.weight: Font.Medium
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: overwriteArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
confirmed(pendingFilePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,75 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
Row {
|
DankCommon.FileBrowserSaveRow {}
|
||||||
id: saveRow
|
|
||||||
|
|
||||||
property bool saveMode: false
|
|
||||||
property string defaultFileName: ""
|
|
||||||
property string currentPath: ""
|
|
||||||
property alias fileName: fileNameInput.text
|
|
||||||
|
|
||||||
signal saveRequested(string filePath)
|
|
||||||
|
|
||||||
height: saveMode ? 40 : 0
|
|
||||||
visible: saveMode
|
|
||||||
spacing: Theme.spacingM
|
|
||||||
|
|
||||||
DankTextField {
|
|
||||||
id: fileNameInput
|
|
||||||
|
|
||||||
width: parent.width - saveButton.width - Theme.spacingM
|
|
||||||
height: 40
|
|
||||||
text: defaultFileName
|
|
||||||
placeholderText: I18n.tr("Enter filename...")
|
|
||||||
ignoreLeftRightKeys: false
|
|
||||||
focus: saveMode
|
|
||||||
topPadding: Theme.spacingS
|
|
||||||
bottomPadding: Theme.spacingS
|
|
||||||
Component.onCompleted: {
|
|
||||||
if (saveMode)
|
|
||||||
Qt.callLater(() => {
|
|
||||||
forceActiveFocus();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
onAccepted: {
|
|
||||||
if (text.trim() !== "") {
|
|
||||||
var basePath = currentPath.replace(/^file:\/\//, '');
|
|
||||||
var fullPath = basePath + "/" + text.trim();
|
|
||||||
fullPath = fullPath.replace(/\/+/g, '/');
|
|
||||||
saveRequested(fullPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
id: saveButton
|
|
||||||
|
|
||||||
width: 80
|
|
||||||
height: 40
|
|
||||||
color: fileNameInput.text.trim() !== "" ? Theme.primary : Theme.surfaceVariant
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: I18n.tr("Save")
|
|
||||||
color: fileNameInput.text.trim() !== "" ? Theme.primaryText : Theme.surfaceVariantText
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
}
|
|
||||||
|
|
||||||
StateLayer {
|
|
||||||
stateColor: Theme.primary
|
|
||||||
cornerRadius: Theme.cornerRadius
|
|
||||||
enabled: fileNameInput.text.trim() !== ""
|
|
||||||
onClicked: {
|
|
||||||
if (fileNameInput.text.trim() !== "") {
|
|
||||||
var basePath = currentPath.replace(/^file:\/\//, '');
|
|
||||||
var fullPath = basePath + "/" + fileNameInput.text.trim();
|
|
||||||
fullPath = fullPath.replace(/\/+/g, '/');
|
|
||||||
saveRequested(fullPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,70 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
StyledRect {
|
DankCommon.FileBrowserSidebar {}
|
||||||
id: sidebar
|
|
||||||
|
|
||||||
property var quickAccessLocations: []
|
|
||||||
property string currentPath: ""
|
|
||||||
signal locationSelected(string path)
|
|
||||||
|
|
||||||
width: 200
|
|
||||||
color: Theme.nestedSurface
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
Column {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: Theme.spacingS
|
|
||||||
spacing: Theme.spacingXS
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: I18n.tr("Quick Access")
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
font.weight: Font.Medium
|
|
||||||
leftPadding: Theme.spacingS
|
|
||||||
bottomPadding: Theme.spacingXS
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: quickAccessLocations
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: parent?.width ?? 0
|
|
||||||
height: 38
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: quickAccessMouseArea.containsMouse ? Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) : (currentPath === modelData?.path ? Theme.surfacePressed : Theme.withAlpha(Theme.surfacePressed, 0))
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: Theme.spacingM
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
name: modelData?.icon ?? ""
|
|
||||||
size: Theme.iconSize - 2
|
|
||||||
color: currentPath === modelData?.path ? Theme.primary : Theme.surfaceText
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: modelData?.name ?? ""
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: currentPath === modelData?.path ? Theme.primary : Theme.surfaceText
|
|
||||||
font.weight: currentPath === modelData?.path ? Font.Medium : Font.Normal
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: quickAccessMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: locationSelected(modelData?.path ?? "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,189 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
StyledRect {
|
DankCommon.FileBrowserSortMenu {}
|
||||||
id: sortMenu
|
|
||||||
|
|
||||||
property string sortBy: "name"
|
|
||||||
property bool sortAscending: true
|
|
||||||
property color surfaceColor: Theme.surfaceContainer
|
|
||||||
|
|
||||||
signal sortBySelected(string value)
|
|
||||||
signal sortOrderSelected(bool ascending)
|
|
||||||
|
|
||||||
width: 200
|
|
||||||
height: sortColumn.height + Theme.spacingM * 2
|
|
||||||
color: surfaceColor
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
border.color: Theme.outlineMedium
|
|
||||||
border.width: 1
|
|
||||||
visible: false
|
|
||||||
z: 100
|
|
||||||
|
|
||||||
Column {
|
|
||||||
id: sortColumn
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.margins: Theme.spacingM
|
|
||||||
spacing: Theme.spacingXS
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: "Sort By"
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
font.weight: Font.Medium
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: [
|
|
||||||
{
|
|
||||||
"name": "Name",
|
|
||||||
"value": "name"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Size",
|
|
||||||
"value": "size"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Modified",
|
|
||||||
"value": "modified"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Type",
|
|
||||||
"value": "type"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: sortColumn?.width ?? 0
|
|
||||||
height: 32
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: sortMouseArea.containsMouse ? Theme.surfaceVariant : (sortBy === modelData?.value ? Theme.surfacePressed : Theme.withAlpha(Theme.surfacePressed, 0))
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: Theme.spacingS
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
name: sortBy === modelData?.value ? "check" : ""
|
|
||||||
size: Theme.iconSizeSmall
|
|
||||||
color: Theme.primary
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
visible: sortBy === modelData?.value
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: modelData?.name ?? ""
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: sortBy === modelData?.value ? Theme.primary : Theme.surfaceText
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: sortMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
sortMenu.sortBySelected(modelData?.value ?? "name");
|
|
||||||
sortMenu.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: sortColumn.width
|
|
||||||
height: 1
|
|
||||||
color: Theme.outline
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: "Order"
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
font.weight: Font.Medium
|
|
||||||
topPadding: Theme.spacingXS
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: sortColumn?.width ?? 0
|
|
||||||
height: 32
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: ascMouseArea.containsMouse ? Theme.surfaceVariant : (sortAscending ? Theme.surfacePressed : Theme.withAlpha(Theme.surfacePressed, 0))
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: Theme.spacingS
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
name: "arrow_upward"
|
|
||||||
size: Theme.iconSizeSmall
|
|
||||||
color: sortAscending ? Theme.primary : Theme.surfaceText
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: "Ascending"
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: sortAscending ? Theme.primary : Theme.surfaceText
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: ascMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
sortMenu.sortOrderSelected(true);
|
|
||||||
sortMenu.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledRect {
|
|
||||||
width: sortColumn?.width ?? 0
|
|
||||||
height: 32
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: descMouseArea.containsMouse ? Theme.surfaceVariant : (!sortAscending ? Theme.surfacePressed : Theme.withAlpha(Theme.surfacePressed, 0))
|
|
||||||
|
|
||||||
Row {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: Theme.spacingS
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
name: "arrow_downward"
|
|
||||||
size: Theme.iconSizeSmall
|
|
||||||
color: !sortAscending ? Theme.primary : Theme.surfaceText
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: "Descending"
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: !sortAscending ? Theme.primary : Theme.surfaceText
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: descMouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
sortMenu.sortOrderSelected(false);
|
|
||||||
sortMenu.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,236 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import Quickshell.Io
|
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
Rectangle {
|
DankCommon.FileInfo {}
|
||||||
id: root
|
|
||||||
|
|
||||||
property bool showFileInfo: false
|
|
||||||
property int selectedIndex: -1
|
|
||||||
property var sourceFolderModel: null
|
|
||||||
property string currentPath: ""
|
|
||||||
|
|
||||||
height: 200
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: Theme.withAlpha(Theme.surfaceContainer, 0.95)
|
|
||||||
border.color: Theme.secondary
|
|
||||||
border.width: 2
|
|
||||||
opacity: showFileInfo ? 1 : 0
|
|
||||||
z: 100
|
|
||||||
|
|
||||||
onShowFileInfoChanged: {
|
|
||||||
if (showFileInfo && currentFileName && currentPath) {
|
|
||||||
const fullPath = currentPath + "/" + currentFileName;
|
|
||||||
fileStatProcess.selectedFilePath = fullPath;
|
|
||||||
fileStatProcess.running = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
|
||||||
id: fileStatProcess
|
|
||||||
command: ["stat", "-c", "%y|%A|%s|%n", selectedFilePath]
|
|
||||||
property string selectedFilePath: ""
|
|
||||||
property var fileStats: null
|
|
||||||
running: false
|
|
||||||
|
|
||||||
stdout: StdioCollector {
|
|
||||||
onStreamFinished: {
|
|
||||||
if (text && text.trim()) {
|
|
||||||
const parts = text.trim().split('|');
|
|
||||||
if (parts.length >= 4) {
|
|
||||||
fileStatProcess.fileStats = {
|
|
||||||
"modifiedTime": parts[0],
|
|
||||||
"permissions": parts[1],
|
|
||||||
"size": parseInt(parts[2]) || 0,
|
|
||||||
"fullPath": parts[3]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: function (exitCode) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
property string currentFileName: ""
|
|
||||||
property bool currentFileIsDir: false
|
|
||||||
property string currentFileExtension: ""
|
|
||||||
|
|
||||||
onCurrentFileNameChanged: {
|
|
||||||
if (showFileInfo && currentFileName && currentPath) {
|
|
||||||
const fullPath = currentPath + "/" + currentFileName;
|
|
||||||
if (fullPath !== fileStatProcess.selectedFilePath) {
|
|
||||||
fileStatProcess.selectedFilePath = fullPath;
|
|
||||||
fileStatProcess.running = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateFileInfo(filePath, fileName, isDirectory) {
|
|
||||||
if (filePath && filePath !== fileStatProcess.selectedFilePath) {
|
|
||||||
fileStatProcess.selectedFilePath = filePath;
|
|
||||||
currentFileName = fileName || "";
|
|
||||||
currentFileIsDir = isDirectory || false;
|
|
||||||
|
|
||||||
let ext = "";
|
|
||||||
if (!isDirectory && fileName) {
|
|
||||||
const lastDot = fileName.lastIndexOf('.');
|
|
||||||
if (lastDot > 0) {
|
|
||||||
ext = fileName.substring(lastDot + 1).toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentFileExtension = ext;
|
|
||||||
|
|
||||||
if (showFileInfo) {
|
|
||||||
fileStatProcess.running = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly property var currentFileDisplayData: {
|
|
||||||
if (selectedIndex < 0 || !sourceFolderModel) {
|
|
||||||
return {
|
|
||||||
"exists": false,
|
|
||||||
"name": "No selection",
|
|
||||||
"type": "",
|
|
||||||
"size": "",
|
|
||||||
"modified": "",
|
|
||||||
"permissions": "",
|
|
||||||
"extension": "",
|
|
||||||
"position": "N/A"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasValidFile = currentFileName !== "";
|
|
||||||
return {
|
|
||||||
"exists": hasValidFile,
|
|
||||||
"name": hasValidFile ? currentFileName : "Loading...",
|
|
||||||
"type": currentFileIsDir ? "Directory" : "File",
|
|
||||||
"size": fileStatProcess.fileStats ? formatFileSize(fileStatProcess.fileStats.size) : "Calculating...",
|
|
||||||
"modified": fileStatProcess.fileStats ? formatDateTime(fileStatProcess.fileStats.modifiedTime) : "Loading...",
|
|
||||||
"permissions": fileStatProcess.fileStats ? fileStatProcess.fileStats.permissions : "Loading...",
|
|
||||||
"extension": currentFileExtension,
|
|
||||||
"position": sourceFolderModel ? ((selectedIndex + 1) + " of " + sourceFolderModel.count) : "N/A"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: Theme.spacingM
|
|
||||||
spacing: Theme.spacingXS
|
|
||||||
|
|
||||||
Row {
|
|
||||||
width: parent.width
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
name: "info"
|
|
||||||
size: Theme.iconSize
|
|
||||||
color: Theme.secondary
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: I18n.tr("File Information")
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: Theme.surfaceText
|
|
||||||
font.weight: Font.Medium
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
|
||||||
width: parent.width
|
|
||||||
spacing: Theme.spacingXS
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: currentFileDisplayData.name
|
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
|
||||||
color: Theme.surfaceText
|
|
||||||
width: parent.width
|
|
||||||
elide: Text.ElideMiddle
|
|
||||||
wrapMode: Text.NoWrap
|
|
||||||
font.weight: Font.Medium
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: currentFileDisplayData.type + (currentFileDisplayData.extension ? " (." + currentFileDisplayData.extension + ")" : "")
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
width: parent.width
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: currentFileDisplayData.size
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
width: parent.width
|
|
||||||
visible: currentFileDisplayData.exists && !currentFileIsDir
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: currentFileDisplayData.modified
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
width: parent.width
|
|
||||||
elide: Text.ElideRight
|
|
||||||
visible: currentFileDisplayData.exists
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: currentFileDisplayData.permissions
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
visible: currentFileDisplayData.exists
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: currentFileDisplayData.position
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
width: parent.width
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: I18n.tr("F1/I: Toggle • F10: Help")
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceTextMedium
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: Theme.spacingM
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatFileSize(bytes) {
|
|
||||||
if (bytes === 0 || !bytes) {
|
|
||||||
return "0 B";
|
|
||||||
}
|
|
||||||
const k = 1024;
|
|
||||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
||||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
||||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDateTime(dateTimeString) {
|
|
||||||
if (!dateTimeString) {
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
const parts = dateTimeString.split(' ');
|
|
||||||
if (parts.length >= 2) {
|
|
||||||
return parts[0] + " " + parts[1].split('.')[0];
|
|
||||||
}
|
|
||||||
return dateTimeString;
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Theme.shortDuration
|
|
||||||
easing.type: Theme.standardEasing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,50 +1,3 @@
|
|||||||
import QtQuick
|
import qs.DankCommon.Modals.FileBrowser as DankCommon
|
||||||
import qs.Common
|
|
||||||
import qs.Widgets
|
|
||||||
|
|
||||||
Rectangle {
|
DankCommon.KeyboardHints {}
|
||||||
id: root
|
|
||||||
|
|
||||||
property bool showHints: false
|
|
||||||
|
|
||||||
height: 80
|
|
||||||
radius: Theme.cornerRadius
|
|
||||||
color: Theme.withAlpha(Theme.surfaceContainer, 0.95)
|
|
||||||
border.color: Theme.primary
|
|
||||||
border.width: 2
|
|
||||||
opacity: showHints ? 1 : 0
|
|
||||||
z: 100
|
|
||||||
|
|
||||||
Column {
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: Theme.spacingS
|
|
||||||
spacing: Theme.spacingXXS
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: I18n.tr("Tab/Shift+Tab: Nav • ←→↑↓: Grid Nav • Enter/Space: Select")
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceText
|
|
||||||
width: parent.width
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
text: I18n.tr("Alt+←/Backspace: Back • F1/I: File Info • F10: Help • Esc: Close")
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceText
|
|
||||||
width: parent.width
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on opacity {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: Theme.shortDuration
|
|
||||||
easing.type: Theme.standardEasing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ FocusScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: I18n.tr("Authentication failed, please try again")
|
text: I18n.tr("Authentication failed - try again")
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.error
|
color: Theme.error
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ DankModal {
|
|||||||
property real holdProgress: 0
|
property real holdProgress: 0
|
||||||
property bool showHoldHint: false
|
property bool showHoldHint: false
|
||||||
property bool holdFromKeyboard: false
|
property bool holdFromKeyboard: false
|
||||||
property string committedAction: ""
|
property string pendingKeyAction: ""
|
||||||
|
|
||||||
readonly property bool needsConfirmation: SettingsData.powerActionConfirm
|
readonly property bool needsConfirmation: SettingsData.powerActionConfirm
|
||||||
readonly property int holdDurationMs: SettingsData.powerActionHoldDuration * 1000
|
readonly property int holdDurationMs: SettingsData.powerActionHoldDuration * 1000
|
||||||
@@ -39,16 +39,10 @@ DankModal {
|
|||||||
return action !== "lock" && action !== "restart";
|
return action !== "lock" && action !== "restart";
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionWakesOnKeyRelease(action) {
|
|
||||||
return action === "suspend" || action === "hibernate";
|
|
||||||
}
|
|
||||||
|
|
||||||
function startHold(action, actionIndex) {
|
function startHold(action, actionIndex) {
|
||||||
if (committedAction !== "")
|
|
||||||
return;
|
|
||||||
if (!needsConfirmation || !actionNeedsConfirm(action)) {
|
if (!needsConfirmation || !actionNeedsConfirm(action)) {
|
||||||
if (holdFromKeyboard && actionWakesOnKeyRelease(action)) {
|
if (holdFromKeyboard) {
|
||||||
commitAction(action, actionIndex);
|
pendingKeyAction = action;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
executeAction(action);
|
executeAction(action);
|
||||||
@@ -62,6 +56,7 @@ DankModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cancelHold() {
|
function cancelHold() {
|
||||||
|
pendingKeyAction = "";
|
||||||
if (holdAction === "")
|
if (holdAction === "")
|
||||||
return;
|
return;
|
||||||
const wasHolding = holdProgress > 0;
|
const wasHolding = holdProgress > 0;
|
||||||
@@ -81,8 +76,8 @@ DankModal {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
holdTimer.stop();
|
holdTimer.stop();
|
||||||
if (holdFromKeyboard && actionWakesOnKeyRelease(holdAction)) {
|
if (holdFromKeyboard) {
|
||||||
commitAction(holdAction, holdActionIndex);
|
pendingKeyAction = holdAction;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const action = holdAction;
|
const action = holdAction;
|
||||||
@@ -92,25 +87,6 @@ DankModal {
|
|||||||
executeAction(action);
|
executeAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
function commitAction(action, actionIndex) {
|
|
||||||
holdTimer.stop();
|
|
||||||
holdAction = "";
|
|
||||||
holdActionIndex = actionIndex;
|
|
||||||
committedAction = action;
|
|
||||||
commitFallbackTimer.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
function executeCommittedAction() {
|
|
||||||
if (committedAction === "")
|
|
||||||
return;
|
|
||||||
commitFallbackTimer.stop();
|
|
||||||
const action = committedAction;
|
|
||||||
committedAction = "";
|
|
||||||
holdActionIndex = -1;
|
|
||||||
holdProgress = 0;
|
|
||||||
executeAction(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
signal switchUserRequested
|
signal switchUserRequested
|
||||||
|
|
||||||
function executeAction(action) {
|
function executeAction(action) {
|
||||||
@@ -152,12 +128,6 @@ DankModal {
|
|||||||
onTriggered: root.showHoldHint = false
|
onTriggered: root.showHoldHint = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: commitFallbackTimer
|
|
||||||
interval: 5000
|
|
||||||
onTriggered: root.executeCommittedAction()
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCentered() {
|
function openCentered() {
|
||||||
parentBounds = Qt.rect(0, 0, 0, 0);
|
parentBounds = Qt.rect(0, 0, 0, 0);
|
||||||
parentScreen = null;
|
parentScreen = null;
|
||||||
@@ -316,8 +286,7 @@ DankModal {
|
|||||||
holdProgress = 0;
|
holdProgress = 0;
|
||||||
showHoldHint = false;
|
showHoldHint = false;
|
||||||
holdFromKeyboard = false;
|
holdFromKeyboard = false;
|
||||||
committedAction = "";
|
pendingKeyAction = "";
|
||||||
commitFallbackTimer.stop();
|
|
||||||
updateVisibleActions();
|
updateVisibleActions();
|
||||||
const defaultIndex = getDefaultActionIndex();
|
const defaultIndex = getDefaultActionIndex();
|
||||||
selectedIndex = defaultIndex;
|
selectedIndex = defaultIndex;
|
||||||
@@ -340,10 +309,6 @@ DankModal {
|
|||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (committedAction !== "") {
|
|
||||||
event.accepted = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
holdFromKeyboard = true;
|
holdFromKeyboard = true;
|
||||||
if (SettingsData.powerMenuGridLayout) {
|
if (SettingsData.powerMenuGridLayout) {
|
||||||
handleGridNavigation(event, true);
|
handleGridNavigation(event, true);
|
||||||
@@ -356,11 +321,6 @@ DankModal {
|
|||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (committedAction !== "") {
|
|
||||||
event.accepted = true;
|
|
||||||
executeCommittedAction();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (SettingsData.powerMenuGridLayout) {
|
if (SettingsData.powerMenuGridLayout) {
|
||||||
handleGridNavigation(event, false);
|
handleGridNavigation(event, false);
|
||||||
} else {
|
} else {
|
||||||
@@ -371,7 +331,16 @@ DankModal {
|
|||||||
function handleListNavigation(event, isPressed) {
|
function handleListNavigation(event, isPressed) {
|
||||||
if (!isPressed) {
|
if (!isPressed) {
|
||||||
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter || event.key === Qt.Key_R || event.key === Qt.Key_X || event.key === Qt.Key_L || event.key === Qt.Key_S || event.key === Qt.Key_H || event.key === Qt.Key_D || (event.key === Qt.Key_P && !(event.modifiers & Qt.ControlModifier))) {
|
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter || event.key === Qt.Key_R || event.key === Qt.Key_X || event.key === Qt.Key_L || event.key === Qt.Key_S || event.key === Qt.Key_H || event.key === Qt.Key_D || (event.key === Qt.Key_P && !(event.modifiers & Qt.ControlModifier))) {
|
||||||
cancelHold();
|
if (pendingKeyAction !== "") {
|
||||||
|
const action = pendingKeyAction;
|
||||||
|
pendingKeyAction = "";
|
||||||
|
holdAction = "";
|
||||||
|
holdActionIndex = -1;
|
||||||
|
holdProgress = 0;
|
||||||
|
executeAction(action);
|
||||||
|
} else {
|
||||||
|
cancelHold();
|
||||||
|
}
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -465,7 +434,16 @@ DankModal {
|
|||||||
function handleGridNavigation(event, isPressed) {
|
function handleGridNavigation(event, isPressed) {
|
||||||
if (!isPressed) {
|
if (!isPressed) {
|
||||||
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter || event.key === Qt.Key_R || event.key === Qt.Key_X || event.key === Qt.Key_L || event.key === Qt.Key_S || event.key === Qt.Key_H || event.key === Qt.Key_D || (event.key === Qt.Key_P && !(event.modifiers & Qt.ControlModifier))) {
|
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter || event.key === Qt.Key_R || event.key === Qt.Key_X || event.key === Qt.Key_L || event.key === Qt.Key_S || event.key === Qt.Key_H || event.key === Qt.Key_D || (event.key === Qt.Key_P && !(event.modifiers & Qt.ControlModifier))) {
|
||||||
cancelHold();
|
if (pendingKeyAction !== "") {
|
||||||
|
const action = pendingKeyAction;
|
||||||
|
pendingKeyAction = "";
|
||||||
|
holdAction = "";
|
||||||
|
holdActionIndex = -1;
|
||||||
|
holdProgress = 0;
|
||||||
|
executeAction(action);
|
||||||
|
} else {
|
||||||
|
cancelHold();
|
||||||
|
}
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -834,7 +812,6 @@ DankModal {
|
|||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: hintRow
|
id: hintRow
|
||||||
readonly property bool selectedNeedsHold: root.actionNeedsConfirm(root.getActionAtIndex(root.selectedIndex))
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: Theme.spacingS
|
anchors.bottomMargin: Theme.spacingS
|
||||||
@@ -849,13 +826,7 @@ DankModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
name: {
|
name: root.showHoldHint ? "warning" : "touch_app"
|
||||||
if (root.showHoldHint)
|
|
||||||
return "warning";
|
|
||||||
if (!hintRow.selectedNeedsHold)
|
|
||||||
return "bolt";
|
|
||||||
return "touch_app";
|
|
||||||
}
|
|
||||||
size: Theme.fontSizeSmall
|
size: Theme.fontSizeSmall
|
||||||
color: root.showHoldHint ? Theme.warning : Theme.surfaceTextSecondary
|
color: root.showHoldHint ? Theme.warning : Theme.surfaceTextSecondary
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
@@ -865,12 +836,8 @@ DankModal {
|
|||||||
readonly property real totalMs: SettingsData.powerActionHoldDuration * 1000
|
readonly property real totalMs: SettingsData.powerActionHoldDuration * 1000
|
||||||
readonly property int remainingMs: Math.ceil(totalMs * (1 - root.holdProgress))
|
readonly property int remainingMs: Math.ceil(totalMs * (1 - root.holdProgress))
|
||||||
text: {
|
text: {
|
||||||
if (root.committedAction !== "")
|
|
||||||
return I18n.tr("Release to confirm");
|
|
||||||
if (root.showHoldHint)
|
if (root.showHoldHint)
|
||||||
return I18n.tr("Hold longer to confirm");
|
return I18n.tr("Hold longer to confirm");
|
||||||
if (!hintRow.selectedNeedsHold)
|
|
||||||
return I18n.tr("Activates immediately");
|
|
||||||
if (root.holdProgress > 0) {
|
if (root.holdProgress > 0) {
|
||||||
if (totalMs < 1000)
|
if (totalMs < 1000)
|
||||||
return I18n.tr("Hold to confirm (%1 ms)").arg(remainingMs);
|
return I18n.tr("Hold to confirm (%1 ms)").arg(remainingMs);
|
||||||
|
|||||||
@@ -494,7 +494,7 @@ FloatingWindow {
|
|||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: I18n.tr("Processes:", "process count label in footer")
|
text: I18n.tr("Processes", "process count label in footer") + ":"
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
}
|
}
|
||||||
@@ -511,7 +511,7 @@ FloatingWindow {
|
|||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: I18n.tr("Uptime:", "uptime label in footer")
|
text: I18n.tr("Uptime", "uptime label in footer") + ":"
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.surfaceVariantText
|
color: Theme.surfaceVariantText
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,6 @@ FloatingWindow {
|
|||||||
signal closingModal
|
signal closingModal
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
if (visible && !backingWindowVisible) {
|
|
||||||
visible = false;
|
|
||||||
}
|
|
||||||
visible = true;
|
visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,11 +49,7 @@ FloatingWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
if (visible && backingWindowVisible) {
|
visible = !visible;
|
||||||
hide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTabIndex(tabIndex: int) {
|
function setTabIndex(tabIndex: int) {
|
||||||
@@ -68,12 +61,13 @@ FloatingWindow {
|
|||||||
|
|
||||||
function showWithTab(tabIndex: int) {
|
function showWithTab(tabIndex: int) {
|
||||||
setTabIndex(tabIndex);
|
setTabIndex(tabIndex);
|
||||||
show();
|
visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showWithTabName(tabName: string) {
|
function showWithTabName(tabName: string) {
|
||||||
setTabIndex(sidebar.resolveTabIndex(tabName));
|
var idx = sidebar.resolveTabIndex(tabName);
|
||||||
show();
|
setTabIndex(idx);
|
||||||
|
visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveTabIndex(tabName: string): int {
|
function resolveTabIndex(tabName: string): int {
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ FloatingWindow {
|
|||||||
condInitialised.triState = 0;
|
condInitialised.triState = 0;
|
||||||
opacityEnabled.checked = false;
|
opacityEnabled.checked = false;
|
||||||
opacitySlider.value = 100;
|
opacitySlider.value = 100;
|
||||||
floatingCond.triState = 0;
|
|
||||||
floatingToggle.checked = false;
|
floatingToggle.checked = false;
|
||||||
maximizedToggle.checked = false;
|
maximizedToggle.checked = false;
|
||||||
maximizedToEdgesToggle.checked = false;
|
maximizedToEdgesToggle.checked = false;
|
||||||
@@ -165,7 +164,6 @@ FloatingWindow {
|
|||||||
opacityEnabled.checked = hasOpacity;
|
opacityEnabled.checked = hasOpacity;
|
||||||
opacitySlider.value = hasOpacity ? Math.round(actions.opacity * 100) : 100;
|
opacitySlider.value = hasOpacity ? Math.round(actions.opacity * 100) : 100;
|
||||||
|
|
||||||
floatingCond.triState = triFromBool(actions.openFloating);
|
|
||||||
floatingToggle.checked = actions.openFloating || false;
|
floatingToggle.checked = actions.openFloating || false;
|
||||||
maximizedToggle.checked = actions.openMaximized || false;
|
maximizedToggle.checked = actions.openMaximized || false;
|
||||||
maximizedToEdgesToggle.checked = actions.openMaximizedToEdges || false;
|
maximizedToEdgesToggle.checked = actions.openMaximizedToEdges || false;
|
||||||
@@ -320,9 +318,7 @@ FloatingWindow {
|
|||||||
|
|
||||||
if (opacityEnabled.checked)
|
if (opacityEnabled.checked)
|
||||||
actions.opacity = opacitySlider.value / 100;
|
actions.opacity = opacitySlider.value / 100;
|
||||||
if (isNiri)
|
if (floatingToggle.checked)
|
||||||
applyCond(actions, "openFloating", floatingCond.triState);
|
|
||||||
else if (floatingToggle.checked)
|
|
||||||
actions.openFloating = true;
|
actions.openFloating = true;
|
||||||
if (maximizedToggle.checked)
|
if (maximizedToggle.checked)
|
||||||
actions.openMaximized = true;
|
actions.openMaximized = true;
|
||||||
@@ -947,17 +943,6 @@ FloatingWindow {
|
|||||||
title: I18n.tr("Window Opening")
|
title: I18n.tr("Window Opening")
|
||||||
}
|
}
|
||||||
|
|
||||||
Flow {
|
|
||||||
width: parent.width
|
|
||||||
spacing: Theme.spacingS
|
|
||||||
visible: isNiri
|
|
||||||
|
|
||||||
MatchCond {
|
|
||||||
id: floatingCond
|
|
||||||
label: I18n.tr("Float")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Flow {
|
Flow {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingL
|
spacing: Theme.spacingL
|
||||||
@@ -965,7 +950,6 @@ FloatingWindow {
|
|||||||
CheckboxRow {
|
CheckboxRow {
|
||||||
id: floatingToggle
|
id: floatingToggle
|
||||||
label: I18n.tr("Float")
|
label: I18n.tr("Float")
|
||||||
visible: !isNiri
|
|
||||||
}
|
}
|
||||||
CheckboxRow {
|
CheckboxRow {
|
||||||
id: maximizedToggle
|
id: maximizedToggle
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ PluginComponent {
|
|||||||
ccWidgetPrimaryText: I18n.tr("Printers")
|
ccWidgetPrimaryText: I18n.tr("Printers")
|
||||||
ccWidgetSecondaryText: {
|
ccWidgetSecondaryText: {
|
||||||
if (CupsService.cupsAvailable && CupsService.getPrintersNum() > 0) {
|
if (CupsService.cupsAvailable && CupsService.getPrintersNum() > 0) {
|
||||||
return I18n.tr("Printers: ") + CupsService.getPrintersNum() + " - " + I18n.tr("Jobs: ") + CupsService.getTotalJobsNum();
|
return I18n.tr("Printers") + ": " + CupsService.getPrintersNum() + " - " + I18n.tr("Jobs") + ": " + CupsService.getTotalJobsNum();
|
||||||
} else {
|
} else {
|
||||||
if (!CupsService.cupsAvailable) {
|
if (!CupsService.cupsAvailable) {
|
||||||
return I18n.tr("Print Server not available");
|
return I18n.tr("Print Server not available");
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ PluginComponent {
|
|||||||
ccWidgetPrimaryText: I18n.tr("VPN")
|
ccWidgetPrimaryText: I18n.tr("VPN")
|
||||||
ccWidgetSecondaryText: {
|
ccWidgetSecondaryText: {
|
||||||
if (vpnActivating)
|
if (vpnActivating)
|
||||||
return I18n.tr("Connecting…");
|
return I18n.tr("Connecting...");
|
||||||
if (!vpnActivated)
|
if (!vpnActivated)
|
||||||
return I18n.tr("Disconnected");
|
return I18n.tr("Disconnected");
|
||||||
const names = DMSNetworkService.activeNames || [];
|
const names = DMSNetworkService.activeNames || [];
|
||||||
|
|||||||
@@ -77,12 +77,6 @@ DankPopout {
|
|||||||
|
|
||||||
readonly property color _containerBg: Theme.nestedSurface
|
readonly property color _containerBg: Theme.nestedSurface
|
||||||
|
|
||||||
// Defer open one tick so screen-change geometry settles before the surface
|
|
||||||
// maps; a synchronous open churns the surface and loses the blur on a switch.
|
|
||||||
function present() {
|
|
||||||
Qt.callLater(open);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openWithSection(section) {
|
function openWithSection(section) {
|
||||||
StateUtils.openWithSection(root, section);
|
StateUtils.openWithSection(root, section);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPinnedInputs() {
|
function getPinnedInputs() {
|
||||||
const pins = CacheData.audioInputDevicePins || {};
|
const pins = SettingsData.audioInputDevicePins || {};
|
||||||
return normalizePinList(pins["preferredInput"]);
|
return normalizePinList(pins["preferredInput"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ Rectangle {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onPressed: mouse => pinRipple.trigger(mouse.x, mouse.y)
|
onPressed: mouse => pinRipple.trigger(mouse.x, mouse.y)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
const pins = JSON.parse(JSON.stringify(CacheData.audioInputDevicePins || {}));
|
const pins = JSON.parse(JSON.stringify(SettingsData.audioInputDevicePins || {}));
|
||||||
let pinnedList = audioContent.normalizePinList(pins["preferredInput"]);
|
let pinnedList = audioContent.normalizePinList(pins["preferredInput"]);
|
||||||
const pinIndex = pinnedList.indexOf(modelData.name);
|
const pinIndex = pinnedList.indexOf(modelData.name);
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ Rectangle {
|
|||||||
else
|
else
|
||||||
delete pins["preferredInput"];
|
delete pins["preferredInput"];
|
||||||
|
|
||||||
CacheData.set("audioInputDevicePins", pins);
|
SettingsData.set("audioInputDevicePins", pins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPinnedOutputs() {
|
function getPinnedOutputs() {
|
||||||
const pins = CacheData.audioOutputDevicePins || {};
|
const pins = SettingsData.audioOutputDevicePins || {};
|
||||||
return normalizePinList(pins["preferredOutput"]);
|
return normalizePinList(pins["preferredOutput"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ Rectangle {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onPressed: mouse => pinRipple.trigger(mouse.x, mouse.y)
|
onPressed: mouse => pinRipple.trigger(mouse.x, mouse.y)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
const pins = JSON.parse(JSON.stringify(CacheData.audioOutputDevicePins || {}));
|
const pins = JSON.parse(JSON.stringify(SettingsData.audioOutputDevicePins || {}));
|
||||||
let pinnedList = audioContent.normalizePinList(pins["preferredOutput"]);
|
let pinnedList = audioContent.normalizePinList(pins["preferredOutput"]);
|
||||||
const pinIndex = pinnedList.indexOf(modelData.name);
|
const pinIndex = pinnedList.indexOf(modelData.name);
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ Rectangle {
|
|||||||
else
|
else
|
||||||
delete pins["preferredOutput"];
|
delete pins["preferredOutput"];
|
||||||
|
|
||||||
CacheData.set("audioOutputDevicePins", pins);
|
SettingsData.set("audioOutputDevicePins", pins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPinnedDevices() {
|
function getPinnedDevices() {
|
||||||
const pins = CacheData.bluetoothDevicePins || {};
|
const pins = SettingsData.bluetoothDevicePins || {};
|
||||||
return normalizePinList(pins["preferredDevice"]);
|
return normalizePinList(pins["preferredDevice"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: scanButton.isDiscovering ? I18n.tr("Scanning") : I18n.tr("Scan")
|
text: scanButton.isDiscovering ? I18n.tr("Scanning...") : I18n.tr("Scan")
|
||||||
color: scanButton.adapterEnabled ? Theme.primary : Theme.surfaceVariantText
|
color: scanButton.adapterEnabled ? Theme.primary : Theme.surfaceVariantText
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
@@ -400,7 +400,7 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
const pins = JSON.parse(JSON.stringify(CacheData.bluetoothDevicePins || {}));
|
const pins = JSON.parse(JSON.stringify(SettingsData.bluetoothDevicePins || {}));
|
||||||
let pinnedList = root.normalizePinList(pins["preferredDevice"]);
|
let pinnedList = root.normalizePinList(pins["preferredDevice"]);
|
||||||
const pinIndex = pinnedList.indexOf(pairedDelegate.modelData.address);
|
const pinIndex = pinnedList.indexOf(pairedDelegate.modelData.address);
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ Rectangle {
|
|||||||
delete pins["preferredDevice"];
|
delete pins["preferredDevice"];
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheData.set("bluetoothDevicePins", pins);
|
SettingsData.set("bluetoothDevicePins", pins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ Rectangle {
|
|||||||
|
|
||||||
const pinKey = getScreenPinKey();
|
const pinKey = getScreenPinKey();
|
||||||
if (pinKey.length > 0) {
|
if (pinKey.length > 0) {
|
||||||
const pins = CacheData.brightnessDevicePins || {};
|
const pins = SettingsData.brightnessDevicePins || {};
|
||||||
const pinnedDevice = pins[pinKey];
|
const pinnedDevice = pins[pinKey];
|
||||||
if (pinnedDevice && pinnedDevice.length > 0) {
|
if (pinnedDevice && pinnedDevice.length > 0) {
|
||||||
const found = devices.find(d => d.name === pinnedDevice);
|
const found = devices.find(d => d.name === pinnedDevice);
|
||||||
@@ -85,12 +85,12 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
const pinKey = getScreenPinKey();
|
const pinKey = getScreenPinKey();
|
||||||
if (pinKey.length > 0) {
|
if (pinKey.length > 0) {
|
||||||
const pins = CacheData.brightnessDevicePins || {};
|
const pins = SettingsData.brightnessDevicePins || {};
|
||||||
const existing = pins[pinKey];
|
const existing = pins[pinKey];
|
||||||
if (existing && existing !== deviceName) {
|
if (existing && existing !== deviceName) {
|
||||||
const next = JSON.parse(JSON.stringify(pins));
|
const next = JSON.parse(JSON.stringify(pins));
|
||||||
delete next[pinKey];
|
delete next[pinKey];
|
||||||
CacheData.set("brightnessDevicePins", next);
|
SettingsData.set("brightnessDevicePins", next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
root.currentDeviceName = deviceName;
|
root.currentDeviceName = deviceName;
|
||||||
@@ -106,7 +106,7 @@ Rectangle {
|
|||||||
const pinKey = getScreenPinKey();
|
const pinKey = getScreenPinKey();
|
||||||
if (!pinKey || !deviceName)
|
if (!pinKey || !deviceName)
|
||||||
return false;
|
return false;
|
||||||
const pins = CacheData.brightnessDevicePins || {};
|
const pins = SettingsData.brightnessDevicePins || {};
|
||||||
return pins[pinKey] === deviceName;
|
return pins[pinKey] === deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,13 +114,13 @@ Rectangle {
|
|||||||
const pinKey = getScreenPinKey();
|
const pinKey = getScreenPinKey();
|
||||||
if (!pinKey || !deviceName)
|
if (!pinKey || !deviceName)
|
||||||
return;
|
return;
|
||||||
const pins = JSON.parse(JSON.stringify(CacheData.brightnessDevicePins || {}));
|
const pins = JSON.parse(JSON.stringify(SettingsData.brightnessDevicePins || {}));
|
||||||
if (pins[pinKey] === deviceName) {
|
if (pins[pinKey] === deviceName) {
|
||||||
delete pins[pinKey];
|
delete pins[pinKey];
|
||||||
} else {
|
} else {
|
||||||
pins[pinKey] = deviceName;
|
pins[pinKey] = deviceName;
|
||||||
}
|
}
|
||||||
CacheData.set("brightnessDevicePins", pins);
|
SettingsData.set("brightnessDevicePins", pins);
|
||||||
}
|
}
|
||||||
|
|
||||||
implicitHeight: {
|
implicitHeight: {
|
||||||
@@ -269,7 +269,7 @@ Rectangle {
|
|||||||
|
|
||||||
readonly property bool selected: !!(modelData && modelData.name === root.currentDeviceName)
|
readonly property bool selected: !!(modelData && modelData.name === root.currentDeviceName)
|
||||||
readonly property bool devicePinnedHere: {
|
readonly property bool devicePinnedHere: {
|
||||||
CacheData.brightnessDevicePins;
|
SettingsData.brightnessDevicePins;
|
||||||
return root.isDevicePinnedToScreen(modelData ? modelData.name : "");
|
return root.isDevicePinnedToScreen(modelData ? modelData.name : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPinnedNetworks() {
|
function getPinnedNetworks() {
|
||||||
const pins = CacheData.wifiNetworkPins || {};
|
const pins = SettingsData.wifiNetworkPins || {};
|
||||||
return normalizePinList(pins["preferredWifi"]);
|
return normalizePinList(pins["preferredWifi"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +624,7 @@ Rectangle {
|
|||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: wifiDelegate.isConnecting ? I18n.tr("Connecting...") + " \u2022" : (wifiDelegate.isConnected ? I18n.tr("Connected") + " \u2022" : (modelData.secured ? I18n.tr("Secured") + " \u2022" : I18n.tr("Open") + " \u2022"))
|
text: wifiDelegate.isConnecting ? I18n.tr("Connecting...") + " \u2022" : (wifiDelegate.isConnected ? I18n.tr("Connected") + " \u2022" : (modelData.secured ? I18n.tr("Secured") + " \u2022" : I18n.tr("Open", "network security type", true) + " \u2022"))
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: wifiDelegate.isConnecting ? Theme.warning : Theme.surfaceVariantText
|
color: wifiDelegate.isConnecting ? Theme.warning : Theme.surfaceVariantText
|
||||||
}
|
}
|
||||||
@@ -710,7 +710,7 @@ Rectangle {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onPressed: mouse => pinRipple.trigger(mouse.x, mouse.y)
|
onPressed: mouse => pinRipple.trigger(mouse.x, mouse.y)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
const pins = JSON.parse(JSON.stringify(CacheData.wifiNetworkPins || {}));
|
const pins = JSON.parse(JSON.stringify(SettingsData.wifiNetworkPins || {}));
|
||||||
let pinnedList = root.normalizePinList(pins["preferredWifi"]);
|
let pinnedList = root.normalizePinList(pins["preferredWifi"]);
|
||||||
const pinIndex = pinnedList.indexOf(modelData.ssid);
|
const pinIndex = pinnedList.indexOf(modelData.ssid);
|
||||||
|
|
||||||
@@ -727,7 +727,7 @@ Rectangle {
|
|||||||
else
|
else
|
||||||
delete pins["preferredWifi"];
|
delete pins["preferredWifi"];
|
||||||
|
|
||||||
CacheData.set("wifiNetworkPins", pins);
|
SettingsData.set("wifiNetworkPins", pins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Row {
|
|||||||
if (screenName && screenName.length > 0) {
|
if (screenName && screenName.length > 0) {
|
||||||
const screen = Quickshell.screens.find(s => s.name === screenName);
|
const screen = Quickshell.screens.find(s => s.name === screenName);
|
||||||
const pinKey = screen ? SettingsData.getScreenDisplayName(screen) : screenName;
|
const pinKey = screen ? SettingsData.getScreenDisplayName(screen) : screenName;
|
||||||
const pins = CacheData.brightnessDevicePins || {};
|
const pins = SettingsData.brightnessDevicePins || {};
|
||||||
const pinnedDevice = pins[pinKey];
|
const pinnedDevice = pins[pinKey];
|
||||||
if (pinnedDevice && pinnedDevice.length > 0) {
|
if (pinnedDevice && pinnedDevice.length > 0) {
|
||||||
const found = DisplayService.devices.find(dev => dev.name === pinnedDevice);
|
const found = DisplayService.devices.find(dev => dev.name === pinnedDevice);
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ Item {
|
|||||||
property var centerWidgets: []
|
property var centerWidgets: []
|
||||||
property int totalWidgets: 0
|
property int totalWidgets: 0
|
||||||
property real totalSize: 0
|
property real totalSize: 0
|
||||||
property real contentStart: 0
|
|
||||||
property real contentSize: 0
|
|
||||||
|
|
||||||
function updateLayout() {
|
function updateLayout() {
|
||||||
if (SettingsData.centeringMode === "geometric") {
|
if (SettingsData.centeringMode === "geometric") {
|
||||||
@@ -38,25 +36,6 @@ Item {
|
|||||||
} else {
|
} else {
|
||||||
applyIndexLayout();
|
applyIndexLayout();
|
||||||
}
|
}
|
||||||
updateContentExtent();
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateContentExtent() {
|
|
||||||
if (centerWidgets.length === 0) {
|
|
||||||
contentStart = 0;
|
|
||||||
contentSize = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let start = Infinity;
|
|
||||||
let end = -Infinity;
|
|
||||||
for (const widget of centerWidgets) {
|
|
||||||
const pos = isVertical ? widget.y : widget.x;
|
|
||||||
const size = isVertical ? widget.height : widget.width;
|
|
||||||
start = Math.min(start, pos);
|
|
||||||
end = Math.max(end, pos + size);
|
|
||||||
}
|
|
||||||
contentStart = start;
|
|
||||||
contentSize = end - start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyGeometricLayout() {
|
function applyGeometricLayout() {
|
||||||
|
|||||||
@@ -833,30 +833,16 @@ PanelWindow {
|
|||||||
const pos = section.mapToItem(barWindow.contentItem, 0, 0);
|
const pos = section.mapToItem(barWindow.contentItem, 0, 0);
|
||||||
const implW = section.implicitWidth || 0;
|
const implW = section.implicitWidth || 0;
|
||||||
const implH = section.implicitHeight || 0;
|
const implH = section.implicitHeight || 0;
|
||||||
const contentSize = isCenter ? (section.contentSize || 0) : 0;
|
|
||||||
|
|
||||||
let offsetX = isCenter && !barWindow.isVertical ? (section.width - implW) / 2 : 0;
|
const offsetX = isCenter && !barWindow.isVertical ? (section.width - implW) / 2 : 0;
|
||||||
let offsetY = !barWindow.isVertical ? (section.height - implH) / 2 : (isCenter ? (section.height - implH) / 2 : 0);
|
const offsetY = !barWindow.isVertical ? (section.height - implH) / 2 : (isCenter ? (section.height - implH) / 2 : 0);
|
||||||
let w = implW;
|
|
||||||
let h = implH;
|
|
||||||
|
|
||||||
// index centering lays content out asymmetrically; use the real extent
|
|
||||||
if (contentSize > 0) {
|
|
||||||
if (barWindow.isVertical) {
|
|
||||||
offsetY = section.contentStart;
|
|
||||||
h = contentSize;
|
|
||||||
} else {
|
|
||||||
offsetX = section.contentStart;
|
|
||||||
w = contentSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const edgePad = 2;
|
const edgePad = 2;
|
||||||
return {
|
return {
|
||||||
"x": pos.x + offsetX - edgePad,
|
"x": pos.x + offsetX - edgePad,
|
||||||
"y": pos.y + offsetY - edgePad,
|
"y": pos.y + offsetY - edgePad,
|
||||||
"w": w + edgePad * 2,
|
"w": implW + edgePad * 2,
|
||||||
"h": h + edgePad * 2
|
"h": implH + edgePad * 2
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ BasePill {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onPressed: function (mouse) {
|
onPressed: mouse => root.triggerRipple(this, mouse.x, mouse.y)
|
||||||
root.triggerRipple(this, mouse.x, mouse.y);
|
onClicked: function (mouse) {
|
||||||
switch (mouse.button) {
|
switch (mouse.button) {
|
||||||
case Qt.RightButton:
|
case Qt.RightButton:
|
||||||
openContextMenu();
|
openContextMenu();
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ BasePill {
|
|||||||
const pinKey = getScreenPinKey();
|
const pinKey = getScreenPinKey();
|
||||||
if (!pinKey)
|
if (!pinKey)
|
||||||
return "";
|
return "";
|
||||||
const pins = CacheData.brightnessDevicePins || {};
|
const pins = SettingsData.brightnessDevicePins || {};
|
||||||
return pins[pinKey] || "";
|
return pins[pinKey] || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user