mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
Compare commits
7 Commits
de8f2e6a68
...
734456785f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
734456785f | ||
|
|
4f24312432 | ||
|
|
d79b1ff3b4 | ||
|
|
bbe1c1f1e0 | ||
|
|
1978e67401 | ||
|
|
e129e4a2d0 | ||
|
|
f7f1bbbdd2 |
5
.github/workflows/run-obs.yml
vendored
5
.github/workflows/run-obs.yml
vendored
@@ -189,6 +189,11 @@ jobs:
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
|
||||
- name: Install OSC
|
||||
run: |
|
||||
sudo apt-get update
|
||||
|
||||
6
.github/workflows/run-ppa.yml
vendored
6
.github/workflows/run-ppa.yml
vendored
@@ -24,6 +24,12 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
cache: false
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<services>
|
||||
<!-- Pull full git repository for master branch -->
|
||||
<!-- Git source and vendoring -->
|
||||
<service name="tar_scm" mode="disabled">
|
||||
<param name="scm">git</param>
|
||||
<param name="url">https://github.com/AvengeMedia/DankMaterialShell.git</param>
|
||||
@@ -10,7 +10,7 @@
|
||||
<param name="file">*.tar</param>
|
||||
<param name="compression">gz</param>
|
||||
</service>
|
||||
<!-- Download pre-built binaries (fallback for Debian 13 with Go 1.22) -->
|
||||
<!-- Binary downloads kept for backwards compat - removed after successful source builds
|
||||
<service name="download_url">
|
||||
<param name="protocol">https</param>
|
||||
<param name="host">github.com</param>
|
||||
@@ -21,4 +21,5 @@
|
||||
<param name="host">github.com</param>
|
||||
<param name="path">/AvengeMedia/DankMaterialShell/releases/latest/download/dms-distropkg-arm64.gz</param>
|
||||
</service>
|
||||
-->
|
||||
</services>
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
dms-git (0.6.2+git) nightly; urgency=medium
|
||||
dms-git (0.6.2+git5) nightly; urgency=medium
|
||||
|
||||
* Fix debian/rules to use source at root level (native format)
|
||||
* Remove incorrect dms-git-source subdirectory references
|
||||
* Fix Build-Depends parsing path issue in obs-upload.sh auto-increment
|
||||
* Fix Build-Depends parsing in obs-upload.sh for proper dependency extraction
|
||||
* Build dms binary from source for true git version strings
|
||||
* Match Fedora COPR git build behavior
|
||||
* Now shows proper git version (e.g., v0.6.2-11-g12e91534)
|
||||
* Add golang-go and make as build dependencies
|
||||
|
||||
-- Avenge Media <AvengeMedia.US@gmail.com> Fri, 22 Nov 2025 00:00:00 -0500
|
||||
-- Avenge Media <AvengeMedia.US@gmail.com> Wed, 27 Nov 2025 04:15:00 -0500
|
||||
|
||||
@@ -2,7 +2,8 @@ Source: dms-git
|
||||
Section: x11
|
||||
Priority: optional
|
||||
Maintainer: Avenge Media <AvengeMedia.US@gmail.com>
|
||||
Build-Depends: debhelper-compat (= 13)
|
||||
Build-Depends: debhelper-compat (= 13),
|
||||
golang-go | golang (>= 2:1.22~) | golang-any
|
||||
Standards-Version: 4.6.2
|
||||
Homepage: https://github.com/AvengeMedia/DankMaterialShell
|
||||
Vcs-Browser: https://github.com/AvengeMedia/DankMaterialShell
|
||||
|
||||
@@ -1,31 +1,55 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
export DH_VERBOSE = 1
|
||||
|
||||
# Version info from changelog
|
||||
DEB_VERSION := $(shell dpkg-parsechangelog -S Version)
|
||||
UPSTREAM_VERSION := $(shell echo $(DEB_VERSION) | sed 's/-[^-]*$$//')
|
||||
DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
|
||||
|
||||
# Go needs writable directories for cache
|
||||
export HOME := $(CURDIR)/debian/tmp-home
|
||||
export GOCACHE := $(CURDIR)/debian/tmp-home/go-cache
|
||||
export GOMODCACHE := $(CURDIR)/debian/tmp-home/go-mod
|
||||
|
||||
export GOTOOLCHAIN := local
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_build:
|
||||
# Create Go cache directories
|
||||
mkdir -p $(HOME) $(GOCACHE) $(GOMODCACHE)
|
||||
|
||||
# Verify core directory exists (native package format has source at root)
|
||||
test -d core || (echo "ERROR: core directory not found!" && exit 1)
|
||||
|
||||
# Patch go.mod to use Go 1.24 base version (Debian 13 has 1.23.x, may vary)
|
||||
sed -i 's/^go 1\.24\.[0-9]*/go 1.24/' core/go.mod
|
||||
|
||||
# Extract version info for embedding
|
||||
VERSION="$(UPSTREAM_VERSION)"
|
||||
COMMIT=$$(echo "$(UPSTREAM_VERSION)" | grep -oP '(?<=git)[0-9]+\.[a-f0-9]+' | cut -d. -f2 | head -c8 || echo "unknown")
|
||||
|
||||
# Build dms-cli from source using vendored dependencies
|
||||
# Architecture mapping: Debian amd64/arm64 -> Makefile amd64/arm64
|
||||
if [ "$(DEB_HOST_ARCH)" = "amd64" ]; then \
|
||||
if [ -f dms-distropkg-amd64.gz ]; then \
|
||||
gunzip -c dms-distropkg-amd64.gz > dms; \
|
||||
elif [ -f ../SOURCES/dms-distropkg-amd64.gz ]; then \
|
||||
gunzip -c ../SOURCES/dms-distropkg-amd64.gz > dms; \
|
||||
else \
|
||||
echo "ERROR: dms-distropkg-amd64.gz not found!" && exit 1; \
|
||||
fi \
|
||||
MAKE_ARCH=amd64; \
|
||||
BINARY_NAME=dms-linux-amd64; \
|
||||
elif [ "$(DEB_HOST_ARCH)" = "arm64" ]; then \
|
||||
if [ -f dms-distropkg-arm64.gz ]; then \
|
||||
gunzip -c dms-distropkg-arm64.gz > dms; \
|
||||
elif [ -f ../SOURCES/dms-distropkg-arm64.gz ]; then \
|
||||
gunzip -c ../SOURCES/dms-distropkg-arm64.gz > dms; \
|
||||
MAKE_ARCH=arm64; \
|
||||
BINARY_NAME=dms-linux-arm64; \
|
||||
else \
|
||||
echo "ERROR: dms-distropkg-arm64.gz not found!" && exit 1; \
|
||||
fi \
|
||||
else \
|
||||
echo "Unsupported architecture: $(DEB_HOST_ARCH)" && exit 1; \
|
||||
echo "ERROR: Unsupported architecture: $(DEB_HOST_ARCH)" && exit 1; \
|
||||
fi; \
|
||||
echo "Building with VERSION=$$VERSION COMMIT=$$COMMIT ARCH=$$MAKE_ARCH"; \
|
||||
cd core && $(MAKE) GOFLAGS="-mod=vendor" dist ARCH=$$MAKE_ARCH VERSION="$$VERSION" COMMIT="$$COMMIT"
|
||||
|
||||
# Copy binary to expected location
|
||||
if [ "$(DEB_HOST_ARCH)" = "amd64" ]; then \
|
||||
cp core/bin/dms-linux-amd64 dms; \
|
||||
elif [ "$(DEB_HOST_ARCH)" = "arm64" ]; then \
|
||||
cp core/bin/dms-linux-arm64 dms; \
|
||||
fi
|
||||
chmod +x dms
|
||||
|
||||
@@ -36,11 +60,8 @@ override_dh_auto_install:
|
||||
if [ -d quickshell ]; then \
|
||||
cp -r quickshell/* debian/dms-git/usr/share/quickshell/dms/; \
|
||||
install -Dm644 quickshell/assets/systemd/dms.service debian/dms-git/usr/lib/systemd/user/dms.service; \
|
||||
elif [ -d dms-git-source/quickshell ]; then \
|
||||
cp -r dms-git-source/quickshell/* debian/dms-git/usr/share/quickshell/dms/; \
|
||||
install -Dm644 dms-git-source/quickshell/assets/systemd/dms.service debian/dms-git/usr/lib/systemd/user/dms.service; \
|
||||
else \
|
||||
echo "ERROR: quickshell directory not found (checked root and dms-git-source/)!" && \
|
||||
echo "ERROR: quickshell directory not found!" && \
|
||||
echo "Contents of current directory:" && ls -la && \
|
||||
exit 1; \
|
||||
fi
|
||||
@@ -49,6 +70,8 @@ override_dh_auto_install:
|
||||
debian/dms-git/usr/share/quickshell/dms/distro
|
||||
|
||||
override_dh_auto_clean:
|
||||
# Clean up build artifacts
|
||||
rm -f dms
|
||||
[ ! -d dms-git-source ] || rm -rf dms-git-source
|
||||
rm -rf core/bin
|
||||
rm -rf debian/tmp-home
|
||||
dh_auto_clean
|
||||
|
||||
@@ -1 +1 @@
|
||||
dms-distropkg-amd64.gz
|
||||
# dms-cli is built from source
|
||||
|
||||
@@ -18,7 +18,7 @@ in {
|
||||
|
||||
systemd.user.services.dms = lib.mkIf cfg.systemd.enable {
|
||||
description = "DankMaterialShell";
|
||||
path = [cfg.quickshell.package];
|
||||
path = lib.mkForce [];
|
||||
|
||||
partOf = ["graphical-session.target"];
|
||||
after = ["graphical-session.target"];
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<services>
|
||||
<!-- Pull full git repository for master branch (QML code) -->
|
||||
<service name="tar_scm">
|
||||
<!-- Git source and vendoring -->
|
||||
<service name="tar_scm" mode="disabled">
|
||||
<param name="scm">git</param>
|
||||
<param name="url">https://github.com/AvengeMedia/DankMaterialShell.git</param>
|
||||
<param name="revision">master</param>
|
||||
<param name="filename">dms-git-source</param>
|
||||
</service>
|
||||
<service name="recompress">
|
||||
<service name="recompress" mode="disabled">
|
||||
<param name="file">*.tar</param>
|
||||
<param name="compression">gz</param>
|
||||
</service>
|
||||
<!-- Download pre-built binaries -->
|
||||
<!-- Binary downloads removed - building from source
|
||||
<service name="download_url">
|
||||
<param name="protocol">https</param>
|
||||
<param name="host">github.com</param>
|
||||
@@ -21,4 +21,5 @@
|
||||
<param name="host">github.com</param>
|
||||
<param name="path">/AvengeMedia/DankMaterialShell/releases/latest/download/dms-distropkg-arm64.gz</param>
|
||||
</service>
|
||||
-->
|
||||
</services>
|
||||
|
||||
@@ -9,10 +9,10 @@ Summary: DankMaterialShell - Material 3 inspired shell (git nightly)
|
||||
License: MIT
|
||||
URL: https://github.com/AvengeMedia/DankMaterialShell
|
||||
Source0: dms-git-source.tar.gz
|
||||
Source1: dms-distropkg-amd64.gz
|
||||
Source2: dms-distropkg-arm64.gz
|
||||
|
||||
BuildRequires: gzip
|
||||
BuildRequires: golang >= 1.22
|
||||
BuildRequires: golang-packaging
|
||||
BuildRequires: git-core
|
||||
BuildRequires: systemd-rpm-macros
|
||||
|
||||
Requires: (quickshell-git or quickshell)
|
||||
@@ -44,15 +44,40 @@ and fixes. Includes pre-built dms CLI binary and QML shell files.
|
||||
%prep
|
||||
%setup -q -n dms-git-source
|
||||
|
||||
%ifarch x86_64
|
||||
gunzip -c %{SOURCE1} > dms
|
||||
%endif
|
||||
%ifarch aarch64
|
||||
gunzip -c %{SOURCE2} > dms
|
||||
%endif
|
||||
chmod +x dms
|
||||
# Verify vendored Go dependencies exist (vendored by obs-upload.sh before packaging)
|
||||
# OBS build environment has no network access
|
||||
test -d core/vendor || (echo "ERROR: Go vendor directory missing!" && exit 1)
|
||||
|
||||
%build
|
||||
# Create Go cache directories (OBS build env may have restricted HOME)
|
||||
export HOME=%{_builddir}/go-home
|
||||
export GOCACHE=%{_builddir}/go-cache
|
||||
export GOMODCACHE=%{_builddir}/go-mod
|
||||
mkdir -p $HOME $GOCACHE $GOMODCACHE
|
||||
|
||||
# OBS has no network access, so use local toolchain only
|
||||
export GOTOOLCHAIN=local
|
||||
|
||||
# Patch go.mod to use base Go version (e.g., go 1.24 instead of go 1.24.6)
|
||||
sed -i 's/^go 1\.24\.[0-9]*/go 1.24/' core/go.mod
|
||||
|
||||
# Extract version info for embedding in binary
|
||||
VERSION="%{version}"
|
||||
COMMIT=$(echo "%{version}" | grep -oP '(?<=git)[0-9]+\.[a-f0-9]+' | cut -d. -f2 | head -c8 || echo "unknown")
|
||||
|
||||
# Build dms-cli from source using vendored dependencies
|
||||
# Architecture mapping: RPM x86_64/aarch64 -> Makefile amd64/arm64
|
||||
cd core
|
||||
%ifarch x86_64
|
||||
make GOFLAGS="-mod=vendor" dist ARCH=amd64 VERSION="$VERSION" COMMIT="$COMMIT"
|
||||
mv bin/dms-linux-amd64 ../dms
|
||||
%endif
|
||||
%ifarch aarch64
|
||||
make GOFLAGS="-mod=vendor" dist ARCH=arm64 VERSION="$VERSION" COMMIT="$COMMIT"
|
||||
mv bin/dms-linux-arm64 ../dms
|
||||
%endif
|
||||
cd ..
|
||||
chmod +x dms
|
||||
|
||||
%install
|
||||
install -Dm755 dms %{buildroot}%{_bindir}/dms
|
||||
|
||||
@@ -401,8 +401,31 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ -d "distro/debian/$PACKAGE/debian" ]]; t
|
||||
|
||||
echo " Found source directory: $SOURCE_DIR"
|
||||
|
||||
# Vendor Go dependencies for dms-git
|
||||
if [[ "$PACKAGE" == "dms-git" ]] && [[ -d "$SOURCE_DIR/core" ]]; then
|
||||
echo " - Vendoring Go dependencies for offline OBS build..."
|
||||
cd "$SOURCE_DIR/core"
|
||||
|
||||
if ! command -v go &> /dev/null; then
|
||||
echo "ERROR: Go not found. Install Go to vendor dependencies."
|
||||
echo " Install: sudo apt-get install golang-go (Debian/Ubuntu)"
|
||||
echo " or: sudo dnf install golang (Fedora)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Vendor dependencies
|
||||
go mod vendor
|
||||
if [ ! -d "vendor" ]; then
|
||||
echo "ERROR: Failed to vendor Go dependencies"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VENDOR_SIZE=$(du -sh vendor | cut -f1)
|
||||
echo " ✓ Go dependencies vendored ($VENDOR_SIZE)"
|
||||
cd "$REPO_ROOT"
|
||||
fi
|
||||
|
||||
# Create OpenSUSE-compatible source tarballs BEFORE adding debian/ directory
|
||||
# (OpenSUSE doesn't need debian/ directory)
|
||||
if [[ "$UPLOAD_OPENSUSE" == true ]] && [[ -f "distro/opensuse/$PACKAGE.spec" ]]; then
|
||||
echo " - Creating OpenSUSE-compatible source tarballs"
|
||||
|
||||
@@ -518,16 +541,29 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ -d "distro/debian/$PACKAGE/debian" ]]; t
|
||||
TARBALL_SIZE=$(stat -c%s "$WORK_DIR/$COMBINED_TARBALL" 2>/dev/null || stat -f%z "$WORK_DIR/$COMBINED_TARBALL" 2>/dev/null)
|
||||
TARBALL_MD5=$(md5sum "$WORK_DIR/$COMBINED_TARBALL" | cut -d' ' -f1)
|
||||
|
||||
# Extract Build-Depends from debian/control using awk for proper multi-line parsing
|
||||
if [[ -f "$REPO_ROOT/distro/debian/$PACKAGE/debian/control" ]]; then
|
||||
BUILD_DEPS=$(awk '
|
||||
/^Build-Depends:/ {
|
||||
in_build_deps=1;
|
||||
sub(/^Build-Depends:[[:space:]]*/, "");
|
||||
printf "%s", $0;
|
||||
next;
|
||||
}
|
||||
in_build_deps && /^[[:space:]]/ {
|
||||
sub(/^[[:space:]]+/, " ");
|
||||
printf "%s", $0;
|
||||
next;
|
||||
}
|
||||
in_build_deps { exit; }
|
||||
' "$REPO_ROOT/distro/debian/$PACKAGE/debian/control" | sed 's/[[:space:]]\+/ /g; s/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
|
||||
# If extraction failed or is empty, use default fallback
|
||||
if [[ -z "$BUILD_DEPS" ]]; then
|
||||
BUILD_DEPS="debhelper-compat (= 13)"
|
||||
if [[ -f "distro/debian/$PACKAGE/debian/control" ]]; then
|
||||
CONTROL_DEPS=$(sed -n '/^Build-Depends:/,/^[A-Z]/p' "distro/debian/$PACKAGE/debian/control" | \
|
||||
sed '/^Build-Depends:/s/^Build-Depends: *//' | \
|
||||
sed '/^[A-Z]/d' | \
|
||||
tr '\n' ' ' | \
|
||||
sed 's/^[[:space:]]*//;s/[[:space:]]*$//;s/[[:space:]]\+/ /g')
|
||||
if [[ -n "$CONTROL_DEPS" && "$CONTROL_DEPS" != "" ]]; then
|
||||
BUILD_DEPS="$CONTROL_DEPS"
|
||||
fi
|
||||
else
|
||||
BUILD_DEPS="debhelper-compat (= 13)"
|
||||
fi
|
||||
|
||||
cat > "$WORK_DIR/$PACKAGE.dsc" << EOF
|
||||
@@ -774,16 +810,29 @@ if [[ "$UPLOAD_DEBIAN" == true ]] && [[ "$SOURCE_FORMAT" == *"native"* ]] && [[
|
||||
TARBALL_SIZE=$(stat -c%s "$WORK_DIR/$COMBINED_TARBALL" 2>/dev/null || stat -f%z "$WORK_DIR/$COMBINED_TARBALL" 2>/dev/null)
|
||||
TARBALL_MD5=$(md5sum "$WORK_DIR/$COMBINED_TARBALL" | cut -d' ' -f1)
|
||||
|
||||
# Extract Build-Depends from debian/control using awk for proper multi-line parsing
|
||||
if [[ -f "$REPO_ROOT/distro/debian/$PACKAGE/debian/control" ]]; then
|
||||
BUILD_DEPS=$(awk '
|
||||
/^Build-Depends:/ {
|
||||
in_build_deps=1;
|
||||
sub(/^Build-Depends:[[:space:]]*/, "");
|
||||
printf "%s", $0;
|
||||
next;
|
||||
}
|
||||
in_build_deps && /^[[:space:]]/ {
|
||||
sub(/^[[:space:]]+/, " ");
|
||||
printf "%s", $0;
|
||||
next;
|
||||
}
|
||||
in_build_deps { exit; }
|
||||
' "$REPO_ROOT/distro/debian/$PACKAGE/debian/control" | sed 's/[[:space:]]\+/ /g; s/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
|
||||
# If extraction failed or is empty, use default fallback
|
||||
if [[ -z "$BUILD_DEPS" ]]; then
|
||||
BUILD_DEPS="debhelper-compat (= 13)"
|
||||
if [[ -f "distro/debian/$PACKAGE/debian/control" ]]; then
|
||||
CONTROL_DEPS=$(sed -n '/^Build-Depends:/,/^[A-Z]/p' "distro/debian/$PACKAGE/debian/control" | \
|
||||
sed '/^Build-Depends:/s/^Build-Depends: *//' | \
|
||||
sed '/^[A-Z]/d' | \
|
||||
tr '\n' ' ' | \
|
||||
sed 's/^[[:space:]]*//;s/[[:space:]]*$//;s/[[:space:]]\+/ /g')
|
||||
if [[ -n "$CONTROL_DEPS" && "$CONTROL_DEPS" != "" ]]; then
|
||||
BUILD_DEPS="$CONTROL_DEPS"
|
||||
fi
|
||||
else
|
||||
BUILD_DEPS="debhelper-compat (= 13)"
|
||||
fi
|
||||
|
||||
cat > "$WORK_DIR/$PACKAGE.dsc" << EOF
|
||||
|
||||
@@ -296,6 +296,30 @@ if [ "$IS_GIT_PACKAGE" = true ] && [ -n "$GIT_REPO" ]; then
|
||||
# Now clone to source directory (without .git for inclusion in package)
|
||||
rm -rf "$SOURCE_DIR"
|
||||
cp -r "$TEMP_CLONE" "$SOURCE_DIR"
|
||||
|
||||
# Save version info for dms-git build process
|
||||
if [ "$PACKAGE_NAME" = "dms-git" ]; then
|
||||
info "Saving version info to .dms-version for build process..."
|
||||
echo "VERSION=${UPSTREAM_VERSION}+git${GIT_COMMIT_COUNT}.${GIT_COMMIT_HASH}" > "$SOURCE_DIR/.dms-version"
|
||||
echo "COMMIT=${GIT_COMMIT_HASH}" >> "$SOURCE_DIR/.dms-version"
|
||||
success "Version info saved: ${UPSTREAM_VERSION}+git${GIT_COMMIT_COUNT}.${GIT_COMMIT_HASH}"
|
||||
|
||||
# Vendor Go dependencies (Launchpad has no internet access)
|
||||
info "Vendoring Go dependencies for offline build..."
|
||||
cd "$SOURCE_DIR/core"
|
||||
|
||||
# Create vendor directory with all dependencies
|
||||
go mod vendor
|
||||
|
||||
if [ ! -d "vendor" ]; then
|
||||
error "Failed to vendor Go dependencies"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
success "Go dependencies vendored successfully"
|
||||
cd "$PACKAGE_DIR"
|
||||
fi
|
||||
|
||||
rm -rf "$SOURCE_DIR/.git"
|
||||
rm -rf "$TEMP_CLONE"
|
||||
|
||||
@@ -349,21 +373,6 @@ if [ "$IS_GIT_PACKAGE" = true ] && [ -n "$GIT_REPO" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Download pre-built binary for dms-git
|
||||
# dms-git uses latest release binary with git master QML files
|
||||
if [ "$PACKAGE_NAME" = "dms-git" ]; then
|
||||
info "Downloading latest release binary for dms-git..."
|
||||
if [ ! -f "dms-distropkg-amd64.gz" ]; then
|
||||
if wget -O dms-distropkg-amd64.gz "https://github.com/AvengeMedia/DankMaterialShell/releases/latest/download/dms-distropkg-amd64.gz"; then
|
||||
success "Latest release binary downloaded"
|
||||
else
|
||||
error "Failed to download dms-distropkg-amd64.gz"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
info "Release binary already downloaded"
|
||||
fi
|
||||
fi
|
||||
|
||||
success "Source prepared for packaging"
|
||||
else
|
||||
|
||||
@@ -218,12 +218,7 @@ if [ "$KEEP_BUILDS" = "false" ]; then
|
||||
fi
|
||||
;;
|
||||
dms-git)
|
||||
# Remove downloaded binary
|
||||
if [ -f "$PACKAGE_DIR/dms-distropkg-amd64.gz" ]; then
|
||||
rm -f "$PACKAGE_DIR/dms-distropkg-amd64.gz"
|
||||
REMOVED=$((REMOVED + 1))
|
||||
fi
|
||||
# Remove git source directory
|
||||
# Remove git source directory binary
|
||||
if [ -d "$PACKAGE_DIR/dms-git-repo" ]; then
|
||||
rm -rf "$PACKAGE_DIR/dms-git-repo"
|
||||
REMOVED=$((REMOVED + 1))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
dms-git (0.6.2+git2094.6cc6e7c8ppa1) questing; urgency=medium
|
||||
dms-git (0.6.2+git2169.f7f1bbbdppa10) questing; urgency=medium
|
||||
|
||||
* Git snapshot (commit 2094: 6cc6e7c8)
|
||||
* Git snapshot (commit 2169: f7f1bbbd)
|
||||
|
||||
-- Avenge Media <AvengeMedia.US@gmail.com> Sun, 23 Nov 2025 00:43:28 -0500
|
||||
-- Avenge Media <AvengeMedia.US@gmail.com> Wed, 26 Nov 2025 21:43:12 -0500
|
||||
|
||||
@@ -2,7 +2,8 @@ Source: dms-git
|
||||
Section: x11
|
||||
Priority: optional
|
||||
Maintainer: Avenge Media <AvengeMedia.US@gmail.com>
|
||||
Build-Depends: debhelper-compat (= 13)
|
||||
Build-Depends: debhelper-compat (= 13),
|
||||
golang-go (>= 2:1.22~)
|
||||
Standards-Version: 4.6.2
|
||||
Homepage: https://github.com/AvengeMedia/DankMaterialShell
|
||||
Vcs-Browser: https://github.com/AvengeMedia/DankMaterialShell
|
||||
|
||||
@@ -1 +1 @@
|
||||
dms-git_0.6.2+git2094.6cc6e7c8ppa1_source.buildinfo x11 optional
|
||||
dms-git_0.6.2+git2169.f7f1bbbdppa10_source.buildinfo x11 optional
|
||||
|
||||
@@ -6,19 +6,38 @@ export DH_VERBOSE = 1
|
||||
GIT_DATE := $(shell date +%Y%m%d)
|
||||
GIT_COMMIT := HEAD
|
||||
|
||||
# Go needs writable directories for its caches
|
||||
export HOME := $(CURDIR)/debian/tmp-home
|
||||
export GOCACHE := $(CURDIR)/debian/tmp-home/go-cache
|
||||
export GOMODCACHE := $(CURDIR)/debian/tmp-home/go-mod
|
||||
|
||||
# Launchpad has no network access, so use local toolchain only
|
||||
export GOTOOLCHAIN := local
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_build:
|
||||
# Git source is already included in source package (cloned by build-source.sh)
|
||||
# Create Go cache directories (sbuild sets HOME to non-existent path)
|
||||
mkdir -p $(HOME) $(GOCACHE) $(GOMODCACHE)
|
||||
|
||||
# Git source is already included in source package (cloned by ppa-build.sh)
|
||||
# Launchpad build environment has no internet access
|
||||
test -d dms-git-repo || (echo "ERROR: dms-git-repo directory not found!" && exit 1)
|
||||
test -f dms-distropkg-amd64.gz || (echo "ERROR: dms-distropkg-amd64.gz not found!" && exit 1)
|
||||
|
||||
# Extract pre-built binary from latest release
|
||||
# Note: For git versions, we use the latest release binary
|
||||
# The QML files come from git master
|
||||
gunzip -c dms-distropkg-amd64.gz > dms
|
||||
# Patch go.mod to use Go 1.24 base version (Ubuntu has 1.24.4, project requires 1.24.6)
|
||||
sed -i 's/^go 1\.24\.[0-9]*/go 1.24/' dms-git-repo/core/go.mod
|
||||
|
||||
# Build dms-cli from source
|
||||
@if [ -f dms-git-repo/.dms-version ]; then \
|
||||
. dms-git-repo/.dms-version; \
|
||||
echo "Building with VERSION=$$VERSION COMMIT=$$COMMIT"; \
|
||||
cd dms-git-repo/core && $(MAKE) GOFLAGS="-mod=vendor" dist ARCH=amd64 VERSION="$$VERSION" COMMIT="$$COMMIT"; \
|
||||
else \
|
||||
echo "Warning: .dms-version not found, building without version info"; \
|
||||
cd dms-git-repo/core && $(MAKE) GOFLAGS="-mod=vendor" dist ARCH=amd64; \
|
||||
fi
|
||||
cp dms-git-repo/core/bin/dms-linux-amd64 dms
|
||||
chmod +x dms
|
||||
|
||||
override_dh_auto_install:
|
||||
@@ -39,7 +58,8 @@ override_dh_auto_install:
|
||||
|
||||
override_dh_auto_clean:
|
||||
# Don't delete dms-git-repo directory - it's part of the source package (native format)
|
||||
# Clean up build artifacts (but keep dms-distropkg-amd64.gz for Launchpad)
|
||||
# Clean up build artifacts
|
||||
rm -f dms
|
||||
# Don't remove dms-distropkg-amd64.gz - it needs to be included in the source package for Launchpad builds
|
||||
rm -rf dms-git-repo/core/bin
|
||||
rm -rf debian/tmp-home
|
||||
dh_auto_clean
|
||||
|
||||
@@ -1 +1 @@
|
||||
dms-distropkg-amd64.gz
|
||||
# No pre-built binaries needed - dms-cli is built from source
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# Include files that are normally excluded by .gitignore
|
||||
# These are needed for the build process on Launchpad (which has no internet access)
|
||||
tar-ignore = !dms-distropkg-amd64.gz
|
||||
tar-ignore = !dms-git-repo
|
||||
|
||||
@@ -1099,6 +1099,12 @@ Singleton {
|
||||
Process {
|
||||
id: systemThemeGenerator
|
||||
running: false
|
||||
stdout: SplitParser {
|
||||
onRead: data => console.info("Theme worker:", data)
|
||||
}
|
||||
stderr: SplitParser {
|
||||
onRead: data => console.warn("Theme worker:", data)
|
||||
}
|
||||
|
||||
onExited: exitCode => {
|
||||
workerRunning = false;
|
||||
|
||||
891
quickshell/Modals/FileBrowser/FileBrowserContent.qml
Normal file
891
quickshell/Modals/FileBrowser/FileBrowserContent.qml
Normal file
@@ -0,0 +1,891 @@
|
||||
import Qt.labs.folderlistmodel
|
||||
import QtCore
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import qs.Common
|
||||
import qs.Widgets
|
||||
|
||||
FocusScope {
|
||||
id: root
|
||||
|
||||
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
|
||||
|
||||
signal fileSelected(string path)
|
||||
signal closeRequested
|
||||
|
||||
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 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 handleSaveFile(filePath) {
|
||||
var normalizedPath = filePath;
|
||||
if (!normalizedPath.startsWith("file://")) {
|
||||
normalizedPath = "file://" + 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": "Home",
|
||||
"path": homeDir,
|
||||
"icon": "home"
|
||||
},
|
||||
{
|
||||
"name": "Documents",
|
||||
"path": docsDir,
|
||||
"icon": "description"
|
||||
},
|
||||
{
|
||||
"name": "Downloads",
|
||||
"path": downloadDir,
|
||||
"icon": "download"
|
||||
},
|
||||
{
|
||||
"name": "Pictures",
|
||||
"path": picsDir,
|
||||
"icon": "image"
|
||||
},
|
||||
{
|
||||
"name": "Music",
|
||||
"path": musicDir,
|
||||
"icon": "music_note"
|
||||
},
|
||||
{
|
||||
"name": "Videos",
|
||||
"path": videosDir,
|
||||
"icon": "movie"
|
||||
},
|
||||
{
|
||||
"name": "Desktop",
|
||||
"path": desktopDir,
|
||||
"icon": "computer"
|
||||
}
|
||||
]
|
||||
|
||||
FolderListModel {
|
||||
id: folderModel
|
||||
|
||||
showDirsFirst: true
|
||||
showDotAndDotDot: false
|
||||
showHidden: root.showHiddenFiles
|
||||
nameFilters: fileExtensions
|
||||
showFiles: true
|
||||
showDirs: true
|
||||
folder: currentPath ? "file://" + currentPath : "file://" + 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) {
|
||||
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
|
||||
|
||||
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 {
|
||||
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
|
||||
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: ScrollBar {
|
||||
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);
|
||||
if (isDir) {
|
||||
navigateTo(path);
|
||||
} else {
|
||||
fileSelected(path);
|
||||
root.closeRequested();
|
||||
}
|
||||
}
|
||||
onItemSelected: (index, path, name, isDir) => {
|
||||
setSelectedFileData(path, name, isDir);
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onKeyboardSelectionRequestedChanged() {
|
||||
if (root.keyboardSelectionRequested && root.keyboardSelectionIndex === index) {
|
||||
root.keyboardSelectionRequested = false;
|
||||
selectedIndex = index;
|
||||
setSelectedFileData(filePath, fileName, fileIsDir);
|
||||
if (fileIsDir) {
|
||||
navigateTo(filePath);
|
||||
} else {
|
||||
fileSelected(filePath);
|
||||
root.closeRequested();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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: 2
|
||||
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);
|
||||
if (isDir) {
|
||||
navigateTo(path);
|
||||
} else {
|
||||
fileSelected(path);
|
||||
root.closeRequested();
|
||||
}
|
||||
}
|
||||
onItemSelected: (index, path, name, isDir) => {
|
||||
setSelectedFileData(path, name, isDir);
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onKeyboardSelectionRequestedChanged() {
|
||||
if (root.keyboardSelectionRequested && root.keyboardSelectionIndex === index) {
|
||||
root.keyboardSelectionRequested = false;
|
||||
selectedIndex = index;
|
||||
setSelectedFileData(filePath, fileName, fileIsDir);
|
||||
if (fileIsDir) {
|
||||
navigateTo(filePath);
|
||||
} else {
|
||||
fileSelected(filePath);
|
||||
root.closeRequested();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
target: root
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileBrowserSaveRow {
|
||||
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 = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +1,19 @@
|
||||
import Qt.labs.folderlistmodel
|
||||
import QtCore
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import qs.Common
|
||||
import qs.Modals.FileBrowser
|
||||
import qs.Widgets
|
||||
|
||||
FloatingWindow {
|
||||
id: fileBrowserModal
|
||||
|
||||
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: fileBrowserModal.fileExtensions
|
||||
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 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 var parentModal: null
|
||||
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 shouldHaveFocus: visible
|
||||
property bool allowFocusOverride: false
|
||||
property bool shouldBeVisible: visible
|
||||
@@ -65,152 +30,6 @@ FloatingWindow {
|
||||
visible = 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 navigateUp() {
|
||||
const path = currentPath;
|
||||
if (path === homeDir)
|
||||
return;
|
||||
const lastSlash = path.lastIndexOf('/');
|
||||
if (lastSlash > 0) {
|
||||
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) {
|
||||
keyboardSelectionTimer.targetIndex = index;
|
||||
keyboardSelectionTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
function executeKeyboardSelection(index) {
|
||||
keyboardSelectionIndex = index;
|
||||
keyboardSelectionRequested = true;
|
||||
}
|
||||
|
||||
function handleSaveFile(filePath) {
|
||||
var normalizedPath = filePath;
|
||||
if (!normalizedPath.startsWith("file://")) {
|
||||
normalizedPath = "file://" + 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);
|
||||
fileBrowserModal.close();
|
||||
}
|
||||
}
|
||||
|
||||
objectName: "fileBrowserModal"
|
||||
title: "Files - " + browserTitle
|
||||
minimumSize: Qt.size(500, 400)
|
||||
@@ -219,718 +38,39 @@ FloatingWindow {
|
||||
color: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
|
||||
visible: false
|
||||
|
||||
Component.onCompleted: {
|
||||
loadSettings();
|
||||
currentPath = getLastPath();
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
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 int currentPathIndex: 0
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
if (parentModal) {
|
||||
parentModal.shouldHaveFocus = false;
|
||||
parentModal.allowFocusOverride = true;
|
||||
}
|
||||
currentPath = getLastPath();
|
||||
selectedIndex = -1;
|
||||
keyboardNavigationActive = false;
|
||||
backButtonFocused = false;
|
||||
Qt.callLater(() => {
|
||||
if (contentFocusScope) {
|
||||
contentFocusScope.forceActiveFocus();
|
||||
}
|
||||
});
|
||||
content.reset();
|
||||
Qt.callLater(() => content.forceActiveFocus());
|
||||
} else {
|
||||
if (parentModal) {
|
||||
parentModal.allowFocusOverride = false;
|
||||
parentModal.shouldHaveFocus = Qt.binding(() => {
|
||||
return parentModal.shouldBeVisible;
|
||||
});
|
||||
parentModal.shouldHaveFocus = Qt.binding(() => parentModal.shouldBeVisible);
|
||||
}
|
||||
dialogClosed();
|
||||
}
|
||||
}
|
||||
onCurrentPathChanged: {
|
||||
selectedFilePath = "";
|
||||
selectedFileName = "";
|
||||
selectedFileIsDir = false;
|
||||
saveSettings();
|
||||
}
|
||||
onSelectedIndexChanged: {
|
||||
if (selectedIndex >= 0 && folderModel && selectedIndex < folderModel.count) {
|
||||
selectedFilePath = "";
|
||||
selectedFileName = "";
|
||||
selectedFileIsDir = false;
|
||||
}
|
||||
}
|
||||
|
||||
FolderListModel {
|
||||
id: folderModel
|
||||
|
||||
showDirsFirst: true
|
||||
showDotAndDotDot: false
|
||||
showHidden: fileBrowserModal.showHiddenFiles
|
||||
nameFilters: fileExtensions
|
||||
showFiles: true
|
||||
showDirs: true
|
||||
folder: currentPath ? "file://" + currentPath : "file://" + 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
|
||||
}
|
||||
|
||||
property var quickAccessLocations: [
|
||||
{
|
||||
"name": "Home",
|
||||
"path": homeDir,
|
||||
"icon": "home"
|
||||
},
|
||||
{
|
||||
"name": "Documents",
|
||||
"path": docsDir,
|
||||
"icon": "description"
|
||||
},
|
||||
{
|
||||
"name": "Downloads",
|
||||
"path": downloadDir,
|
||||
"icon": "download"
|
||||
},
|
||||
{
|
||||
"name": "Pictures",
|
||||
"path": picsDir,
|
||||
"icon": "image"
|
||||
},
|
||||
{
|
||||
"name": "Music",
|
||||
"path": musicDir,
|
||||
"icon": "music_note"
|
||||
},
|
||||
{
|
||||
"name": "Videos",
|
||||
"path": videosDir,
|
||||
"icon": "movie"
|
||||
},
|
||||
{
|
||||
"name": "Desktop",
|
||||
"path": desktopDir,
|
||||
"icon": "computer"
|
||||
}
|
||||
]
|
||||
|
||||
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) {
|
||||
close();
|
||||
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)
|
||||
fileBrowserModal.keyboardFileSelection(selectedIndex);
|
||||
event.accepted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: keyboardSelectionTimer
|
||||
|
||||
property int targetIndex: -1
|
||||
|
||||
interval: 1
|
||||
onTriggered: {
|
||||
executeKeyboardSelection(targetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: contentFocusScope
|
||||
|
||||
FileBrowserContent {
|
||||
id: content
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
|
||||
Keys.onPressed: event => {
|
||||
keyboardController.handleKey(event);
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 48
|
||||
|
||||
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: fileBrowserModal.showKeyboardHints = !fileBrowserModal.showKeyboardHints
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
circular: false
|
||||
iconName: "close"
|
||||
iconSize: Theme.iconSize - 4
|
||||
iconColor: Theme.surfaceText
|
||||
onClicked: fileBrowserModal.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledRect {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: parent.height - 49
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
spacing: 0
|
||||
|
||||
Row {
|
||||
width: showSidebar ? 201 : 0
|
||||
height: parent.height
|
||||
spacing: 0
|
||||
visible: showSidebar
|
||||
|
||||
FileBrowserSidebar {
|
||||
height: parent.height
|
||||
quickAccessLocations: fileBrowserModal.quickAccessLocations
|
||||
currentPath: fileBrowserModal.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: fileBrowserModal.currentPath
|
||||
homeDir: fileBrowserModal.homeDir
|
||||
backButtonFocused: fileBrowserModal.backButtonFocused
|
||||
keyboardNavigationActive: fileBrowserModal.keyboardNavigationActive
|
||||
showSidebar: fileBrowserModal.showSidebar
|
||||
pathEditMode: fileBrowserModal.pathEditMode
|
||||
onNavigateUp: fileBrowserModal.navigateUp()
|
||||
onNavigateTo: path => fileBrowserModal.navigateTo(path)
|
||||
onPathInputFocusChanged: hasFocus => {
|
||||
fileBrowserModal.pathInputHasFocus = hasFocus;
|
||||
if (hasFocus) {
|
||||
fileBrowserModal.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: {
|
||||
fileBrowserModal.actualGridColumns = gridColumns;
|
||||
}
|
||||
Component.onCompleted: {
|
||||
fileBrowserModal.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: ScrollBar {
|
||||
policy: ScrollBar.AlwaysOff
|
||||
}
|
||||
|
||||
delegate: FileBrowserGridDelegate {
|
||||
iconSizes: fileBrowserModal.iconSizes
|
||||
iconSizeIndex: fileBrowserModal.iconSizeIndex
|
||||
selectedIndex: fileBrowserModal.selectedIndex
|
||||
keyboardNavigationActive: fileBrowserModal.keyboardNavigationActive
|
||||
onItemClicked: (index, path, name, isDir) => {
|
||||
selectedIndex = index;
|
||||
setSelectedFileData(path, name, isDir);
|
||||
if (isDir) {
|
||||
navigateTo(path);
|
||||
} else {
|
||||
fileSelected(path);
|
||||
fileBrowserModal.close();
|
||||
}
|
||||
}
|
||||
onItemSelected: (index, path, name, isDir) => {
|
||||
setSelectedFileData(path, name, isDir);
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onKeyboardSelectionRequestedChanged() {
|
||||
if (fileBrowserModal.keyboardSelectionRequested && fileBrowserModal.keyboardSelectionIndex === index) {
|
||||
fileBrowserModal.keyboardSelectionRequested = false;
|
||||
selectedIndex = index;
|
||||
setSelectedFileData(filePath, fileName, fileIsDir);
|
||||
if (fileIsDir) {
|
||||
navigateTo(filePath);
|
||||
} else {
|
||||
fileSelected(filePath);
|
||||
fileBrowserModal.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
target: fileBrowserModal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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: 2
|
||||
model: folderModel
|
||||
currentIndex: selectedIndex
|
||||
onCurrentIndexChanged: {
|
||||
if (keyboardNavigationActive && currentIndex >= 0)
|
||||
positionViewAtIndex(currentIndex, ListView.Contain);
|
||||
}
|
||||
|
||||
ScrollBar.vertical: DankScrollbar {
|
||||
id: listScrollbar
|
||||
}
|
||||
|
||||
delegate: FileBrowserListDelegate {
|
||||
width: fileList.width
|
||||
selectedIndex: fileBrowserModal.selectedIndex
|
||||
keyboardNavigationActive: fileBrowserModal.keyboardNavigationActive
|
||||
onItemClicked: (index, path, name, isDir) => {
|
||||
selectedIndex = index;
|
||||
setSelectedFileData(path, name, isDir);
|
||||
if (isDir) {
|
||||
navigateTo(path);
|
||||
} else {
|
||||
fileSelected(path);
|
||||
fileBrowserModal.close();
|
||||
}
|
||||
}
|
||||
onItemSelected: (index, path, name, isDir) => {
|
||||
setSelectedFileData(path, name, isDir);
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onKeyboardSelectionRequestedChanged() {
|
||||
if (fileBrowserModal.keyboardSelectionRequested && fileBrowserModal.keyboardSelectionIndex === index) {
|
||||
fileBrowserModal.keyboardSelectionRequested = false;
|
||||
selectedIndex = index;
|
||||
setSelectedFileData(filePath, fileName, fileIsDir);
|
||||
if (fileIsDir) {
|
||||
navigateTo(filePath);
|
||||
} else {
|
||||
fileSelected(filePath);
|
||||
fileBrowserModal.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
target: fileBrowserModal
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileBrowserSaveRow {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
browserTitle: fileBrowserModal.browserTitle
|
||||
browserIcon: fileBrowserModal.browserIcon
|
||||
browserType: fileBrowserModal.browserType
|
||||
fileExtensions: fileBrowserModal.fileExtensions
|
||||
showHiddenFiles: fileBrowserModal.showHiddenFiles
|
||||
saveMode: fileBrowserModal.saveMode
|
||||
defaultFileName: fileBrowserModal.defaultFileName
|
||||
currentPath: fileBrowserModal.currentPath
|
||||
onSaveRequested: filePath => handleSaveFile(filePath)
|
||||
}
|
||||
|
||||
KeyboardHints {
|
||||
id: keyboardHints
|
||||
Component.onCompleted: initialize()
|
||||
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
showHints: fileBrowserModal.showKeyboardHints
|
||||
}
|
||||
|
||||
FileInfo {
|
||||
id: fileInfo
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
width: 300
|
||||
showFileInfo: fileBrowserModal.showFileInfo
|
||||
selectedIndex: fileBrowserModal.selectedIndex
|
||||
sourceFolderModel: folderModel
|
||||
currentPath: fileBrowserModal.currentPath
|
||||
currentFileName: fileBrowserModal.selectedFileName
|
||||
currentFileIsDir: fileBrowserModal.selectedFileIsDir
|
||||
currentFileExtension: {
|
||||
if (fileBrowserModal.selectedFileIsDir || !fileBrowserModal.selectedFileName)
|
||||
return "";
|
||||
|
||||
var lastDot = fileBrowserModal.selectedFileName.lastIndexOf('.');
|
||||
return lastDot > 0 ? fileBrowserModal.selectedFileName.substring(lastDot + 1).toLowerCase() : "";
|
||||
}
|
||||
}
|
||||
|
||||
FileBrowserSortMenu {
|
||||
id: sortMenu
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 120
|
||||
anchors.rightMargin: Theme.spacingL
|
||||
sortBy: fileBrowserModal.sortBy
|
||||
sortAscending: fileBrowserModal.sortAscending
|
||||
onSortBySelected: value => {
|
||||
fileBrowserModal.sortBy = value;
|
||||
}
|
||||
onSortOrderSelected: ascending => {
|
||||
fileBrowserModal.sortAscending = ascending;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileBrowserOverwriteDialog {
|
||||
anchors.fill: parent
|
||||
showDialog: showOverwriteConfirmation
|
||||
pendingFilePath: fileBrowserModal.pendingFilePath
|
||||
onConfirmed: filePath => {
|
||||
showOverwriteConfirmation = false;
|
||||
fileSelected(filePath);
|
||||
pendingFilePath = "";
|
||||
Qt.callLater(() => fileBrowserModal.close());
|
||||
}
|
||||
onCancelled: {
|
||||
showOverwriteConfirmation = false;
|
||||
pendingFilePath = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
onFileSelected: path => fileBrowserModal.fileSelected(path)
|
||||
onCloseRequested: fileBrowserModal.close()
|
||||
}
|
||||
}
|
||||
|
||||
63
quickshell/Modals/FileBrowser/FileBrowserSurfaceModal.qml
Normal file
63
quickshell/Modals/FileBrowser/FileBrowserSurfaceModal.qml
Normal file
@@ -0,0 +1,63 @@
|
||||
import QtQuick
|
||||
import Quickshell.Wayland
|
||||
import qs.Common
|
||||
import qs.Modals.Common
|
||||
|
||||
DankModal {
|
||||
id: fileBrowserSurfaceModal
|
||||
|
||||
property string browserTitle: "Select File"
|
||||
property string browserIcon: "folder_open"
|
||||
property string browserType: "generic"
|
||||
property var fileExtensions: ["*.*"]
|
||||
property alias filterExtensions: fileBrowserSurfaceModal.fileExtensions
|
||||
property bool showHiddenFiles: false
|
||||
property bool saveMode: false
|
||||
property string defaultFileName: ""
|
||||
property var parentPopout: null
|
||||
|
||||
signal fileSelected(string path)
|
||||
|
||||
layerNamespace: "dms:filebrowser"
|
||||
modalWidth: 800
|
||||
modalHeight: 600
|
||||
backgroundColor: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
|
||||
closeOnEscapeKey: true
|
||||
closeOnBackgroundClick: true
|
||||
allowStacking: true
|
||||
keepPopoutsOpen: true
|
||||
|
||||
onBackgroundClicked: close()
|
||||
|
||||
onOpened: {
|
||||
if (parentPopout) {
|
||||
parentPopout.customKeyboardFocus = WlrKeyboardFocus.None;
|
||||
}
|
||||
content.reset();
|
||||
Qt.callLater(() => content.forceActiveFocus());
|
||||
}
|
||||
|
||||
onDialogClosed: {
|
||||
if (parentPopout) {
|
||||
parentPopout.customKeyboardFocus = null;
|
||||
}
|
||||
}
|
||||
|
||||
directContent: FileBrowserContent {
|
||||
id: content
|
||||
focus: true
|
||||
|
||||
browserTitle: fileBrowserSurfaceModal.browserTitle
|
||||
browserIcon: fileBrowserSurfaceModal.browserIcon
|
||||
browserType: fileBrowserSurfaceModal.browserType
|
||||
fileExtensions: fileBrowserSurfaceModal.fileExtensions
|
||||
showHiddenFiles: fileBrowserSurfaceModal.showHiddenFiles
|
||||
saveMode: fileBrowserSurfaceModal.saveMode
|
||||
defaultFileName: fileBrowserSurfaceModal.defaultFileName
|
||||
|
||||
Component.onCompleted: initialize()
|
||||
|
||||
onFileSelected: path => fileBrowserSurfaceModal.fileSelected(path)
|
||||
onCloseRequested: fileBrowserSurfaceModal.close()
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,8 @@ import QtCore
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import qs.Common
|
||||
import qs.Modals.FileBrowser
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Item {
|
||||
@@ -38,222 +34,222 @@ Item {
|
||||
|
||||
function getCurrentWallpaper() {
|
||||
if (SessionData.perMonitorWallpaper && targetScreenName) {
|
||||
return SessionData.getMonitorWallpaper(targetScreenName)
|
||||
return SessionData.getMonitorWallpaper(targetScreenName);
|
||||
}
|
||||
return SessionData.wallpaperPath
|
||||
return SessionData.wallpaperPath;
|
||||
}
|
||||
|
||||
function setCurrentWallpaper(path) {
|
||||
if (SessionData.perMonitorWallpaper && targetScreenName) {
|
||||
SessionData.setMonitorWallpaper(targetScreenName, path)
|
||||
SessionData.setMonitorWallpaper(targetScreenName, path);
|
||||
} else {
|
||||
SessionData.setWallpaper(path)
|
||||
SessionData.setWallpaper(path);
|
||||
}
|
||||
}
|
||||
|
||||
onCurrentPageChanged: {
|
||||
if (currentPage !== lastPage) {
|
||||
enableAnimation = false
|
||||
lastPage = currentPage
|
||||
enableAnimation = false;
|
||||
lastPage = currentPage;
|
||||
}
|
||||
updateSelectedFileName()
|
||||
updateSelectedFileName();
|
||||
}
|
||||
|
||||
onGridIndexChanged: {
|
||||
updateSelectedFileName()
|
||||
updateSelectedFileName();
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible && active) {
|
||||
setInitialSelection()
|
||||
setInitialSelection();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
loadWallpaperDirectory()
|
||||
loadWallpaperDirectory();
|
||||
}
|
||||
|
||||
onActiveChanged: {
|
||||
if (active && visible) {
|
||||
setInitialSelection()
|
||||
setInitialSelection();
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyEvent(event) {
|
||||
const columns = 4
|
||||
const currentCol = gridIndex % columns
|
||||
const visibleCount = Math.min(itemsPerPage, wallpaperFolderModel.count - currentPage * itemsPerPage)
|
||||
const columns = 4;
|
||||
const currentCol = gridIndex % columns;
|
||||
const visibleCount = Math.min(itemsPerPage, wallpaperFolderModel.count - currentPage * itemsPerPage);
|
||||
|
||||
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
||||
if (gridIndex >= 0 && gridIndex < visibleCount) {
|
||||
const absoluteIndex = currentPage * itemsPerPage + gridIndex
|
||||
const absoluteIndex = currentPage * itemsPerPage + gridIndex;
|
||||
if (absoluteIndex < wallpaperFolderModel.count) {
|
||||
const filePath = wallpaperFolderModel.get(absoluteIndex, "filePath")
|
||||
const filePath = wallpaperFolderModel.get(absoluteIndex, "filePath");
|
||||
if (filePath) {
|
||||
setCurrentWallpaper(filePath.toString().replace(/^file:\/\//, ''))
|
||||
setCurrentWallpaper(filePath.toString().replace(/^file:\/\//, ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.key === Qt.Key_Right) {
|
||||
if (gridIndex + 1 < visibleCount) {
|
||||
gridIndex++
|
||||
gridIndex++;
|
||||
} else if (currentPage < totalPages - 1) {
|
||||
gridIndex = 0
|
||||
currentPage++
|
||||
gridIndex = 0;
|
||||
currentPage++;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.key === Qt.Key_Left) {
|
||||
if (gridIndex > 0) {
|
||||
gridIndex--
|
||||
gridIndex--;
|
||||
} else if (currentPage > 0) {
|
||||
currentPage--
|
||||
const prevPageCount = Math.min(itemsPerPage, wallpaperFolderModel.count - currentPage * itemsPerPage)
|
||||
gridIndex = prevPageCount - 1
|
||||
currentPage--;
|
||||
const prevPageCount = Math.min(itemsPerPage, wallpaperFolderModel.count - currentPage * itemsPerPage);
|
||||
gridIndex = prevPageCount - 1;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.key === Qt.Key_Down) {
|
||||
if (gridIndex + columns < visibleCount) {
|
||||
gridIndex += columns
|
||||
gridIndex += columns;
|
||||
} else if (currentPage < totalPages - 1) {
|
||||
gridIndex = currentCol
|
||||
currentPage++
|
||||
gridIndex = currentCol;
|
||||
currentPage++;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.key === Qt.Key_Up) {
|
||||
if (gridIndex >= columns) {
|
||||
gridIndex -= columns
|
||||
gridIndex -= columns;
|
||||
} else if (currentPage > 0) {
|
||||
currentPage--
|
||||
const prevPageCount = Math.min(itemsPerPage, wallpaperFolderModel.count - currentPage * itemsPerPage)
|
||||
const prevPageRows = Math.ceil(prevPageCount / columns)
|
||||
gridIndex = (prevPageRows - 1) * columns + currentCol
|
||||
gridIndex = Math.min(gridIndex, prevPageCount - 1)
|
||||
currentPage--;
|
||||
const prevPageCount = Math.min(itemsPerPage, wallpaperFolderModel.count - currentPage * itemsPerPage);
|
||||
const prevPageRows = Math.ceil(prevPageCount / columns);
|
||||
gridIndex = (prevPageRows - 1) * columns + currentCol;
|
||||
gridIndex = Math.min(gridIndex, prevPageCount - 1);
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.key === Qt.Key_PageUp && currentPage > 0) {
|
||||
gridIndex = 0
|
||||
currentPage--
|
||||
return true
|
||||
gridIndex = 0;
|
||||
currentPage--;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.key === Qt.Key_PageDown && currentPage < totalPages - 1) {
|
||||
gridIndex = 0
|
||||
currentPage++
|
||||
return true
|
||||
gridIndex = 0;
|
||||
currentPage++;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.key === Qt.Key_Home && event.modifiers & Qt.ControlModifier) {
|
||||
gridIndex = 0
|
||||
currentPage = 0
|
||||
return true
|
||||
gridIndex = 0;
|
||||
currentPage = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.key === Qt.Key_End && event.modifiers & Qt.ControlModifier) {
|
||||
currentPage = totalPages - 1
|
||||
const lastPageCount = Math.min(itemsPerPage, wallpaperFolderModel.count - currentPage * itemsPerPage)
|
||||
gridIndex = Math.max(0, lastPageCount - 1)
|
||||
return true
|
||||
currentPage = totalPages - 1;
|
||||
const lastPageCount = Math.min(itemsPerPage, wallpaperFolderModel.count - currentPage * itemsPerPage);
|
||||
gridIndex = Math.max(0, lastPageCount - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
function setInitialSelection() {
|
||||
const currentWallpaper = getCurrentWallpaper()
|
||||
const currentWallpaper = getCurrentWallpaper();
|
||||
if (!currentWallpaper || wallpaperFolderModel.count === 0) {
|
||||
gridIndex = 0
|
||||
updateSelectedFileName()
|
||||
gridIndex = 0;
|
||||
updateSelectedFileName();
|
||||
Qt.callLater(() => {
|
||||
enableAnimation = true
|
||||
})
|
||||
return
|
||||
enableAnimation = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < wallpaperFolderModel.count; i++) {
|
||||
const filePath = wallpaperFolderModel.get(i, "filePath")
|
||||
const filePath = wallpaperFolderModel.get(i, "filePath");
|
||||
if (filePath && filePath.toString().replace(/^file:\/\//, '') === currentWallpaper) {
|
||||
const targetPage = Math.floor(i / itemsPerPage)
|
||||
const targetIndex = i % itemsPerPage
|
||||
currentPage = targetPage
|
||||
gridIndex = targetIndex
|
||||
updateSelectedFileName()
|
||||
const targetPage = Math.floor(i / itemsPerPage);
|
||||
const targetIndex = i % itemsPerPage;
|
||||
currentPage = targetPage;
|
||||
gridIndex = targetIndex;
|
||||
updateSelectedFileName();
|
||||
Qt.callLater(() => {
|
||||
enableAnimation = true
|
||||
})
|
||||
return
|
||||
enableAnimation = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
gridIndex = 0
|
||||
updateSelectedFileName()
|
||||
gridIndex = 0;
|
||||
updateSelectedFileName();
|
||||
Qt.callLater(() => {
|
||||
enableAnimation = true
|
||||
})
|
||||
enableAnimation = true;
|
||||
});
|
||||
}
|
||||
|
||||
function loadWallpaperDirectory() {
|
||||
const currentWallpaper = getCurrentWallpaper()
|
||||
const currentWallpaper = getCurrentWallpaper();
|
||||
|
||||
if (!currentWallpaper || currentWallpaper.startsWith("#")) {
|
||||
if (CacheData.wallpaperLastPath && CacheData.wallpaperLastPath !== "") {
|
||||
wallpaperDir = CacheData.wallpaperLastPath
|
||||
wallpaperDir = CacheData.wallpaperLastPath;
|
||||
} else {
|
||||
wallpaperDir = ""
|
||||
wallpaperDir = "";
|
||||
}
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
wallpaperDir = currentWallpaper.substring(0, currentWallpaper.lastIndexOf('/'))
|
||||
wallpaperDir = currentWallpaper.substring(0, currentWallpaper.lastIndexOf('/'));
|
||||
}
|
||||
|
||||
function updateSelectedFileName() {
|
||||
if (wallpaperFolderModel.count === 0) {
|
||||
selectedFileName = ""
|
||||
return
|
||||
selectedFileName = "";
|
||||
return;
|
||||
}
|
||||
|
||||
const absoluteIndex = currentPage * itemsPerPage + gridIndex
|
||||
const absoluteIndex = currentPage * itemsPerPage + gridIndex;
|
||||
if (absoluteIndex < wallpaperFolderModel.count) {
|
||||
const filePath = wallpaperFolderModel.get(absoluteIndex, "filePath")
|
||||
const filePath = wallpaperFolderModel.get(absoluteIndex, "filePath");
|
||||
if (filePath) {
|
||||
const pathStr = filePath.toString().replace(/^file:\/\//, '')
|
||||
selectedFileName = pathStr.substring(pathStr.lastIndexOf('/') + 1)
|
||||
return
|
||||
const pathStr = filePath.toString().replace(/^file:\/\//, '');
|
||||
selectedFileName = pathStr.substring(pathStr.lastIndexOf('/') + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
selectedFileName = ""
|
||||
selectedFileName = "";
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SessionData
|
||||
function onWallpaperPathChanged() {
|
||||
loadWallpaperDirectory()
|
||||
loadWallpaperDirectory();
|
||||
if (visible && active) {
|
||||
setInitialSelection()
|
||||
setInitialSelection();
|
||||
}
|
||||
}
|
||||
function onMonitorWallpapersChanged() {
|
||||
loadWallpaperDirectory()
|
||||
loadWallpaperDirectory();
|
||||
if (visible && active) {
|
||||
setInitialSelection()
|
||||
setInitialSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onTargetScreenNameChanged: {
|
||||
loadWallpaperDirectory()
|
||||
loadWallpaperDirectory();
|
||||
if (visible && active) {
|
||||
setInitialSelection()
|
||||
setInitialSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,17 +258,17 @@ Item {
|
||||
function onCountChanged() {
|
||||
if (wallpaperFolderModel.status === FolderListModel.Ready) {
|
||||
if (visible && active) {
|
||||
setInitialSelection()
|
||||
setInitialSelection();
|
||||
}
|
||||
updateSelectedFileName()
|
||||
updateSelectedFileName();
|
||||
}
|
||||
}
|
||||
function onStatusChanged() {
|
||||
if (wallpaperFolderModel.status === FolderListModel.Ready && wallpaperFolderModel.count > 0) {
|
||||
if (visible && active) {
|
||||
setInitialSelection()
|
||||
setInitialSelection();
|
||||
}
|
||||
updateSelectedFileName()
|
||||
updateSelectedFileName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,51 +286,27 @@ Item {
|
||||
folder: wallpaperDir ? "file://" + wallpaperDir : ""
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: wallpaperBrowserLoader
|
||||
active: false
|
||||
asynchronous: true
|
||||
FileBrowserSurfaceModal {
|
||||
id: wallpaperBrowser
|
||||
|
||||
onActiveChanged: {
|
||||
if (active && parentPopout) {
|
||||
parentPopout.WlrLayershell.keyboardFocus = WlrKeyboardFocus.None
|
||||
}
|
||||
}
|
||||
|
||||
sourceComponent: FileBrowserModal {
|
||||
Component.onCompleted: {
|
||||
open()
|
||||
}
|
||||
browserTitle: I18n.tr("Select Wallpaper Directory", "wallpaper directory file browser title")
|
||||
browserIcon: "folder_open"
|
||||
browserType: "wallpaper"
|
||||
showHiddenFiles: false
|
||||
fileExtensions: ["*.jpg", "*.jpeg", "*.png", "*.bmp", "*.gif", "*.webp"]
|
||||
allowStacking: true
|
||||
parentPopout: root.parentPopout
|
||||
|
||||
onFileSelected: path => {
|
||||
const cleanPath = path.replace(/^file:\/\//, '')
|
||||
setCurrentWallpaper(cleanPath)
|
||||
const cleanPath = path.replace(/^file:\/\//, '');
|
||||
setCurrentWallpaper(cleanPath);
|
||||
|
||||
const dirPath = cleanPath.substring(0, cleanPath.lastIndexOf('/'))
|
||||
const dirPath = cleanPath.substring(0, cleanPath.lastIndexOf('/'));
|
||||
if (dirPath) {
|
||||
wallpaperDir = dirPath
|
||||
CacheData.wallpaperLastPath = dirPath
|
||||
CacheData.saveCache()
|
||||
}
|
||||
close()
|
||||
}
|
||||
|
||||
onDialogClosed: {
|
||||
if (parentPopout) {
|
||||
if (CompositorService.isHyprland) {
|
||||
parentPopout.WlrLayershell.keyboardFocus = WlrKeyboardFocus.OnDemand
|
||||
} else {
|
||||
parentPopout.WlrLayershell.keyboardFocus = WlrKeyboardFocus.Exclusive
|
||||
}
|
||||
}
|
||||
Qt.callLater(() => wallpaperBrowserLoader.active = false)
|
||||
wallpaperDir = dirPath;
|
||||
CacheData.wallpaperLastPath = dirPath;
|
||||
CacheData.saveCache();
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,41 +348,41 @@ Item {
|
||||
}
|
||||
|
||||
model: {
|
||||
const startIndex = currentPage * itemsPerPage
|
||||
const endIndex = Math.min(startIndex + itemsPerPage, wallpaperFolderModel.count)
|
||||
const items = []
|
||||
const startIndex = currentPage * itemsPerPage;
|
||||
const endIndex = Math.min(startIndex + itemsPerPage, wallpaperFolderModel.count);
|
||||
const items = [];
|
||||
for (var i = startIndex; i < endIndex; i++) {
|
||||
const filePath = wallpaperFolderModel.get(i, "filePath")
|
||||
const filePath = wallpaperFolderModel.get(i, "filePath");
|
||||
if (filePath) {
|
||||
items.push(filePath.toString().replace(/^file:\/\//, ''))
|
||||
items.push(filePath.toString().replace(/^file:\/\//, ''));
|
||||
}
|
||||
}
|
||||
return items
|
||||
return items;
|
||||
}
|
||||
|
||||
onModelChanged: {
|
||||
const clampedIndex = model.length > 0 ? Math.min(Math.max(0, gridIndex), model.length - 1) : 0
|
||||
const clampedIndex = model.length > 0 ? Math.min(Math.max(0, gridIndex), model.length - 1) : 0;
|
||||
if (gridIndex !== clampedIndex) {
|
||||
gridIndex = clampedIndex
|
||||
gridIndex = clampedIndex;
|
||||
}
|
||||
}
|
||||
|
||||
onCountChanged: {
|
||||
if (count > 0) {
|
||||
const clampedIndex = Math.min(gridIndex, count - 1)
|
||||
currentIndex = clampedIndex
|
||||
positionViewAtIndex(clampedIndex, GridView.Contain)
|
||||
const clampedIndex = Math.min(gridIndex, count - 1);
|
||||
currentIndex = clampedIndex;
|
||||
positionViewAtIndex(clampedIndex, GridView.Contain);
|
||||
}
|
||||
enableAnimation = true
|
||||
enableAnimation = true;
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root
|
||||
function onGridIndexChanged() {
|
||||
if (wallpaperGrid.count > 0) {
|
||||
wallpaperGrid.currentIndex = gridIndex
|
||||
wallpaperGrid.currentIndex = gridIndex;
|
||||
if (!enableAnimation) {
|
||||
wallpaperGrid.positionViewAtIndex(gridIndex, GridView.Contain)
|
||||
wallpaperGrid.positionViewAtIndex(gridIndex, GridView.Contain);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -487,9 +459,9 @@ Item {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
onClicked: {
|
||||
gridIndex = index
|
||||
gridIndex = index;
|
||||
if (modelData) {
|
||||
setCurrentWallpaper(modelData)
|
||||
setCurrentWallpaper(modelData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,7 +507,7 @@ Item {
|
||||
opacity: enabled ? 1.0 : 0.3
|
||||
onClicked: {
|
||||
if (currentPage > 0) {
|
||||
currentPage--
|
||||
currentPage--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -557,7 +529,7 @@ Item {
|
||||
opacity: enabled ? 1.0 : 0.3
|
||||
onClicked: {
|
||||
if (currentPage < totalPages - 1) {
|
||||
currentPage++
|
||||
currentPage++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -570,7 +542,7 @@ Item {
|
||||
iconSize: 20
|
||||
buttonSize: 32
|
||||
opacity: 0.7
|
||||
onClicked: wallpaperBrowserLoader.active = true
|
||||
onClicked: wallpaperBrowser.open()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -685,8 +685,16 @@ Item {
|
||||
Row {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
property var wlrOutput: WlrOutputService.wlrOutputAvailable ? WlrOutputService.getOutput(modelData.name) : null
|
||||
property var currentMode: wlrOutput?.currentMode
|
||||
|
||||
StyledText {
|
||||
text: modelData.width + "×" + modelData.height
|
||||
text: {
|
||||
if (parent.currentMode) {
|
||||
return parent.currentMode.width + "×" + parent.currentMode.height + "@" + Math.round(parent.currentMode.refresh / 1000) + "Hz"
|
||||
}
|
||||
return modelData.width + "×" + modelData.height
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import qs.Widgets
|
||||
Item {
|
||||
id: personalizationTab
|
||||
|
||||
property var wallpaperBrowser: wallpaperBrowserLoader.item
|
||||
property var parentModal: null
|
||||
property var cachedFontFamilies: []
|
||||
property bool fontsEnumerated: false
|
||||
@@ -207,9 +206,7 @@ Item {
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
wallpaperBrowserLoader.active = true;
|
||||
}
|
||||
onClicked: mainWallpaperBrowser.open()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,7 +595,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
lightWallpaperBrowserLoader.active = true;
|
||||
lightWallpaperBrowser.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -787,7 +784,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
darkWallpaperBrowserLoader.active = true;
|
||||
darkWallpaperBrowser.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2140,16 +2137,10 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: wallpaperBrowserLoader
|
||||
active: false
|
||||
asynchronous: true
|
||||
FileBrowserModal {
|
||||
id: mainWallpaperBrowser
|
||||
|
||||
sourceComponent: FileBrowserModal {
|
||||
parentModal: personalizationTab.parentModal
|
||||
Component.onCompleted: {
|
||||
open();
|
||||
}
|
||||
browserTitle: I18n.tr("Select Wallpaper", "wallpaper file browser title")
|
||||
browserIcon: "wallpaper"
|
||||
browserType: "wallpaper"
|
||||
@@ -2163,22 +2154,12 @@ Item {
|
||||
}
|
||||
close();
|
||||
}
|
||||
onDialogClosed: {
|
||||
Qt.callLater(() => wallpaperBrowserLoader.active = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: lightWallpaperBrowserLoader
|
||||
active: false
|
||||
asynchronous: true
|
||||
FileBrowserModal {
|
||||
id: lightWallpaperBrowser
|
||||
|
||||
sourceComponent: FileBrowserModal {
|
||||
parentModal: personalizationTab.parentModal
|
||||
Component.onCompleted: {
|
||||
open();
|
||||
}
|
||||
browserTitle: I18n.tr("Select Wallpaper", "light mode wallpaper file browser title")
|
||||
browserIcon: "light_mode"
|
||||
browserType: "wallpaper"
|
||||
@@ -2190,22 +2171,12 @@ Item {
|
||||
SessionData.saveSettings();
|
||||
close();
|
||||
}
|
||||
onDialogClosed: {
|
||||
Qt.callLater(() => lightWallpaperBrowserLoader.active = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: darkWallpaperBrowserLoader
|
||||
active: false
|
||||
asynchronous: true
|
||||
FileBrowserModal {
|
||||
id: darkWallpaperBrowser
|
||||
|
||||
sourceComponent: FileBrowserModal {
|
||||
parentModal: personalizationTab.parentModal
|
||||
Component.onCompleted: {
|
||||
open();
|
||||
}
|
||||
browserTitle: I18n.tr("Select Wallpaper", "dark mode wallpaper file browser title")
|
||||
browserIcon: "dark_mode"
|
||||
browserType: "wallpaper"
|
||||
@@ -2217,9 +2188,5 @@ Item {
|
||||
SessionData.saveSettings();
|
||||
close();
|
||||
}
|
||||
onDialogClosed: {
|
||||
Qt.callLater(() => darkWallpaperBrowserLoader.active = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +141,17 @@ set_system_color_scheme() {
|
||||
dconf write /org/gnome/desktop/interface/color-scheme "'$scheme'" 2>/dev/null || true
|
||||
}
|
||||
|
||||
sync_color_scheme_on_exit() {
|
||||
[[ "$SYNC_MODE_WITH_PORTAL" != "true" ]] && return
|
||||
[[ ! -f "$DESIRED_JSON" ]] && return
|
||||
local json mode
|
||||
json=$(cat "$DESIRED_JSON" 2>/dev/null) || return
|
||||
mode=$(read_json_field "$json" "mode")
|
||||
[[ -n "$mode" ]] && set_system_color_scheme "$mode"
|
||||
}
|
||||
|
||||
trap sync_color_scheme_on_exit EXIT
|
||||
|
||||
refresh_gtk() {
|
||||
local mode="$1"
|
||||
local gtk_css="$CONFIG_DIR/gtk-3.0/gtk.css"
|
||||
@@ -249,7 +260,6 @@ build_once() {
|
||||
refresh_gtk "$mode"
|
||||
setup_vscode_extension "code" "$HOME/.vscode/extensions/local.dynamic-base16-dankshell-0.0.1" "$HOME/.vscode"
|
||||
setup_vscode_extension "codium" "$HOME/.vscode-oss/extensions/local.dynamic-base16-dankshell-0.0.1" "$HOME/.vscode-oss"
|
||||
set_system_color_scheme "$mode"
|
||||
signal_terminals
|
||||
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user