Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa8e8fecf4 | ||
|
|
56af1c154a | ||
|
|
22cae20707 | ||
|
|
447a6b45af | ||
|
|
f946247d1d | ||
|
|
f9991998ed | ||
|
|
40d82e757e | ||
|
|
da190a22c1 | ||
|
|
2995f06d49 | ||
|
|
ff6a9ebfae | ||
|
|
e01718928c | ||
|
|
f5dbf44ec7 | ||
|
|
f55f8c731d | ||
|
|
4ed491c78a | ||
|
|
b54cde2cbf | ||
|
|
b1d12cc406 | ||
|
|
aa13355966 | ||
|
|
bd35a8c3e0 | ||
|
|
81413b51da | ||
|
|
a01d640c27 | ||
|
|
16800df138 | ||
|
|
7e8fd4ea21 | ||
|
|
04fa491cd8 | ||
|
|
dbf8c09368 | ||
|
|
369a17ed7d | ||
|
|
b19a4f8723 | ||
|
|
a8e5464e9f | ||
|
|
46f46480cb | ||
|
|
c06f900ac5 | ||
|
|
31303a20c7 | ||
|
|
319fd64fc6 | ||
|
|
cdd0b764a7 | ||
|
|
2a69482adb | ||
|
|
fc3ef1cd7f | ||
|
|
1de1517a81 | ||
|
|
04a4ab9bff | ||
|
|
011c1e858f | ||
|
|
4fe09757b3 | ||
|
|
82f1f10cca | ||
|
|
60eebea741 | ||
|
|
9b151e2fea | ||
|
|
9db9c3e9f7 | ||
|
|
9a18a41b8f | ||
|
|
c93ed94210 | ||
|
|
f4d272e014 | ||
|
|
d536e8c611 | ||
|
|
c8dfccb460 | ||
|
|
6fde9474ae | ||
|
|
c19fcaa560 | ||
|
|
602e2cccf8 | ||
|
|
3c1a3c54a7 | ||
|
|
032752faf9 | ||
|
|
457647c59f | ||
|
|
821e0f9fd6 | ||
|
|
26f51e418d | ||
|
|
cd2eac44f1 | ||
|
|
f0bb945c7d | ||
|
|
870e472f53 | ||
|
|
76677381de | ||
|
|
d2bd521ad0 | ||
|
|
265e894b3f | ||
|
|
6339a93c6c | ||
|
|
6da53ced81 | ||
|
|
8f0d4da7ad | ||
|
|
9c8ffb6c1b | ||
|
|
4c5c5e6fc6 | ||
|
|
b8cb10bb33 | ||
|
|
6e2f40633e | ||
|
|
a0ba7c1d17 | ||
|
|
b6d759d7c6 | ||
|
|
437c2f5618 | ||
|
|
7fd4924e64 | ||
|
|
c77808f3d8 | ||
|
|
86075a1ad0 | ||
|
|
a8e40a725c | ||
|
|
8edb6b015e | ||
|
|
5b2255e903 | ||
|
|
4948ea7445 | ||
|
|
e09348e064 | ||
|
|
fce6a835b7 | ||
|
|
afcd126c00 | ||
|
|
aa025b0f3b | ||
|
|
e6e738412d | ||
|
|
2e748e19e1 | ||
|
|
4b5c9e9ebd | ||
|
|
cdfa8b78a4 | ||
|
|
1ba5ae60dc | ||
|
|
08d1c09033 | ||
|
|
612b542e2a | ||
|
|
d74db66ab5 | ||
|
|
9dd34b3fce | ||
|
|
adfe6c51da | ||
|
|
96565b2ccf | ||
|
|
107440145a | ||
|
|
1c55e3194e | ||
|
|
9021ff2579 | ||
|
|
10e1e91e7b | ||
|
|
ef887d7a06 | ||
|
|
5446d94966 | ||
|
|
a2f42c2e3d | ||
|
|
56b18353db | ||
|
|
9170765344 | ||
|
|
ee7b3beda4 | ||
|
|
919a672c17 | ||
|
|
e52a6d8eed | ||
|
|
8b0c8ec194 | ||
|
|
1da7fff518 | ||
|
|
e216592205 | ||
|
|
8fc9d06937 | ||
|
|
73b15da182 | ||
|
|
f4f7d93e38 | ||
|
|
591b01a83a | ||
|
|
f8d3dcc899 | ||
|
|
f0ed9d0ca1 | ||
|
|
13227cfac9 | ||
|
|
b73df5ea1a | ||
|
|
4375fe1c2d | ||
|
|
4654cb21a0 | ||
|
|
ba23208a7a | ||
|
|
ed5a602332 | ||
|
|
347681e604 | ||
|
|
505ab9e2a6 | ||
|
|
c787e14a69 |
@@ -0,0 +1,3 @@
|
|||||||
|
# .git-blame-ignore-revs
|
||||||
|
# CR LF to LF
|
||||||
|
ed5a6023326fd2ab420ded76976501be33e0b389
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
*.txt text eol=lf
|
||||||
|
*.cpp text eol=lf
|
||||||
|
*.h text eol=lf
|
||||||
|
*.ui text eol=lf
|
||||||
|
*.qml text eol=lf
|
||||||
@@ -8,12 +8,19 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
enable-cache: true
|
||||||
|
- name: Install MetaGlot
|
||||||
|
run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
uses: jurplel/install-qt-action@v4
|
uses: jurplel/install-qt-action@v4
|
||||||
with:
|
with:
|
||||||
version: '6.9.1'
|
version: '6.11.2'
|
||||||
modules: 'qtimageformats'
|
modules: 'qtimageformats'
|
||||||
|
cache: true
|
||||||
- name: Install Conan and Dependencies
|
- name: Install Conan and Dependencies
|
||||||
id: conan
|
id: conan
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
@@ -32,7 +39,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
macdeployqt ./ppic.app -dmg
|
macdeployqt ./ppic.app -dmg
|
||||||
ls
|
ls
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: "macos-bundle"
|
name: "macos-bundle"
|
||||||
path: "*.dmg"
|
path: "*.dmg"
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
name: Ubuntu CI
|
name: Ubuntu CI
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-24-04-build:
|
ubuntu-24-04-build:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
enable-cache: true
|
||||||
|
- name: Install MetaGlot
|
||||||
|
run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git
|
||||||
- name: Get build dept.
|
- name: Get build dept.
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
@@ -22,7 +28,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd build
|
cd build
|
||||||
sudo apt install ./*.deb
|
sudo apt install ./*.deb
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: ubuntu-24.04-deb-package
|
name: ubuntu-24.04-deb-package
|
||||||
path: build/*.deb
|
path: build/*.deb
|
||||||
|
|||||||
@@ -3,48 +3,12 @@ name: Windows CI
|
|||||||
on: [push, pull_request, workflow_dispatch]
|
on: [push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
msvc-qmake-build:
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- qt_ver: '6.9.1'
|
|
||||||
vs: '2022'
|
|
||||||
aqt_arch: 'win64_msvc2022_64'
|
|
||||||
msvc_arch: 'x64'
|
|
||||||
|
|
||||||
runs-on: windows-2022
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Install Qt
|
|
||||||
uses: jurplel/install-qt-action@v4
|
|
||||||
with:
|
|
||||||
arch: ${{ matrix.aqt_arch }}
|
|
||||||
version: ${{ matrix.qt_ver }}
|
|
||||||
modules: 'qtimageformats'
|
|
||||||
- name: Build
|
|
||||||
shell: cmd
|
|
||||||
run: |
|
|
||||||
set VS=${{ matrix.vs }}
|
|
||||||
set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
|
|
||||||
if not exist %VCVARS% set VCVARS="C:\Program Files\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
|
|
||||||
call %VCVARS% ${{ matrix.msvc_arch }}
|
|
||||||
qmake pineapple-pictures.pro
|
|
||||||
nmake
|
|
||||||
nmake clean
|
|
||||||
windeployqt --verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-system-d3d-compiler --no-system-dxc-compiler --skip-plugin-types tls,networkinformation release\ppic.exe
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: "windows-msvc${{ matrix.vs }}-qt${{ matrix.qt_ver }}-qmake-package"
|
|
||||||
path: release/*
|
|
||||||
|
|
||||||
msvc-cmake-build:
|
msvc-cmake-build:
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- qt_ver: '6.9.1'
|
- qt_ver: '6.11.2'
|
||||||
vs: '2022'
|
vs: '2022'
|
||||||
aqt_arch: 'win64_msvc2022_64'
|
aqt_arch: 'win64_msvc2022_64'
|
||||||
msvc_arch: 'x64'
|
msvc_arch: 'x64'
|
||||||
@@ -52,13 +16,22 @@ jobs:
|
|||||||
runs-on: windows-2022
|
runs-on: windows-2022
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
enable-cache: true
|
||||||
|
- name: Install MetaGlot
|
||||||
|
run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
uses: jurplel/install-qt-action@v4
|
uses: jurplel/install-qt-action@v4
|
||||||
with:
|
with:
|
||||||
arch: ${{ matrix.aqt_arch }}
|
arch: ${{ matrix.aqt_arch }}
|
||||||
version: ${{ matrix.qt_ver }}
|
version: ${{ matrix.qt_ver }}
|
||||||
modules: 'qtimageformats'
|
modules: 'qtimageformats'
|
||||||
|
cache: true
|
||||||
|
# we need this until miurahr/aqtinstall#1007 ships 3.3.1 for Qt >= 6.11.0 for Windows.
|
||||||
|
aqtsource: 'aqtinstall @ git+https://github.com/miurahr/aqtinstall@16db45a70b5905ad596941b223469bc86a56901a'
|
||||||
- name: Build
|
- name: Build
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
@@ -72,33 +45,33 @@ jobs:
|
|||||||
set CMAKE_PREFIX_PATH=%PWD%/dependencies_bin
|
set CMAKE_PREFIX_PATH=%PWD%/dependencies_bin
|
||||||
mkdir dependencies_src
|
mkdir dependencies_src
|
||||||
echo ::group::===== exiv2 =====
|
echo ::group::===== exiv2 =====
|
||||||
curl -fsSL -o exiv2_bin.zip https://github.com/Exiv2/exiv2/releases/download/v0.28.3/exiv2-0.28.3-2019msvc64.zip
|
curl -fsSL -o exiv2_bin.zip https://github.com/Exiv2/exiv2/releases/download/v0.28.7/exiv2-0.28.7-2022msvc-AMD64.zip
|
||||||
7z x exiv2_bin.zip -y
|
7z x exiv2_bin.zip -y
|
||||||
ren .\exiv2-0.28.3-2019msvc64 dependencies_bin
|
ren .\exiv2-0.28.7-2022msvc-AMD64 dependencies_bin
|
||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
echo ::group::===== zlib =====
|
echo ::group::===== zlib =====
|
||||||
curl -fsSL -o zlib_src.zip https://zlib.net/zlib131.zip
|
curl -fsSL -o zlib_src.zip https://github.com/madler/zlib/releases/download/v1.3.2/zlib132.zip
|
||||||
7z x zlib_src.zip -y -o"dependencies_src"
|
7z x zlib_src.zip -y -o"dependencies_src"
|
||||||
ren .\dependencies_src\zlib-1.3.1 zlib || goto :error
|
ren .\dependencies_src\zlib-1.3.2 zlib || goto :error
|
||||||
cmake ./dependencies_src/zlib -Bbuild_dependencies/zlib -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
|
cmake ./dependencies_src/zlib -Bbuild_dependencies/zlib -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
|
||||||
cmake --build build_dependencies/zlib --config Release --target=install || goto :error
|
cmake --build build_dependencies/zlib --config Release --target=install || goto :error
|
||||||
curl -fsSL -o expat_src.zip https://github.com/libexpat/libexpat/archive/R_2_6_2.zip
|
|
||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
echo ::group::===== AOM for libavif AVI decoding support =====
|
echo ::group::===== AOM for libavif AVI decoding support =====
|
||||||
git clone -q -b v3.12.0 --depth 1 https://aomedia.googlesource.com/aom dependencies_src/aom
|
git clone -q -b v3.13.1 --depth 1 https://aomedia.googlesource.com/aom dependencies_src/aom
|
||||||
cmake ./dependencies_src/aom -Bbuild_dependencies/aom -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DENABLE_DOCS=OFF -DBUILD_SHARED_LIBS=ON -DAOM_TARGET_CPU=generic -DENABLE_TESTS=OFF -DENABLE_TESTDATA=OFF -DENABLE_TOOLS=OFF -DENABLE_EXAMPLES=0 || goto :error
|
cmake ./dependencies_src/aom -Bbuild_dependencies/aom -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DENABLE_DOCS=OFF -DBUILD_SHARED_LIBS=ON -DAOM_TARGET_CPU=generic -DENABLE_TESTS=OFF -DENABLE_TESTDATA=OFF -DENABLE_TOOLS=OFF -DENABLE_EXAMPLES=0 || goto :error
|
||||||
cmake --build build_dependencies/aom --config Release --target=install || goto :error
|
cmake --build build_dependencies/aom --config Release --target=install || goto :error
|
||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
echo ::group::===== libavif =====
|
echo ::group::===== libavif =====
|
||||||
curl -fsSL -o libavif-v1_2_1.zip https://github.com/AOMediaCodec/libavif/archive/v1.2.1.zip
|
curl -fsSL -o libavif-v1_3_0.zip https://github.com/AOMediaCodec/libavif/archive/v1.3.0.zip
|
||||||
7z x libavif-v1_2_1.zip -y -o"dependencies_src"
|
7z x libavif-v1_3_0.zip -y -o"dependencies_src"
|
||||||
ren .\dependencies_src\libavif-1.2.1 libavif || goto :error
|
ren .\dependencies_src\libavif-1.3.0 libavif || goto :error
|
||||||
cmake ./dependencies_src/libavif -Bbuild_dependencies/libavif -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DAVIF_CODEC_AOM=ON -DAVIF_LIBYUV=LOCAL
|
cmake ./dependencies_src/libavif -Bbuild_dependencies/libavif -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DAVIF_CODEC_AOM=SYSTEM -DAVIF_CODEC_AOM_DECODE=ON -DAVIF_CODEC_AOM_ENCODE=ON -DAVIF_LIBYUV=LOCAL
|
||||||
cmake --build build_dependencies/libavif --config Release --target=install || goto :error
|
cmake --build build_dependencies/libavif --config Release --target=install || goto :error
|
||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
echo ::group::===== expat =====
|
echo ::group::===== expat =====
|
||||||
|
curl -fsSL -o expat_src.zip https://github.com/libexpat/libexpat/archive/R_2_7_3.zip
|
||||||
7z x expat_src.zip -y -o"dependencies_src"
|
7z x expat_src.zip -y -o"dependencies_src"
|
||||||
ren .\dependencies_src\libexpat-R_2_6_2 expat || goto :error
|
ren .\dependencies_src\libexpat-R_2_7_3 expat || goto :error
|
||||||
cmake ./dependencies_src/expat/expat -Bbuild_dependencies/expat -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
|
cmake ./dependencies_src/expat/expat -Bbuild_dependencies/expat -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
|
||||||
cmake --build build_dependencies/expat --config Release --target=install || goto :error
|
cmake --build build_dependencies/expat --config Release --target=install || goto :error
|
||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
@@ -109,25 +82,27 @@ jobs:
|
|||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
echo ::group::===== KArchive =====
|
echo ::group::===== KArchive =====
|
||||||
git clone -q https://invent.kde.org/frameworks/karchive.git dependencies_src/karchive
|
git clone -q https://invent.kde.org/frameworks/karchive.git dependencies_src/karchive
|
||||||
cmake .\dependencies_src\karchive -Bbuild_dependencies/karchive -DWITH_LIBZSTD=OFF -DWITH_BZIP2=OFF -DWITH_LIBLZMA=OFF -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
|
cmake .\dependencies_src\karchive -Bbuild_dependencies/karchive -DBUILD_TESTING=OFF -DWITH_LIBZSTD=OFF -DWITH_BZIP2=OFF -DWITH_LIBLZMA=OFF -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error
|
||||||
cmake --build build_dependencies/karchive --config Release --target=install || goto :error
|
cmake --build build_dependencies/karchive --config Release --target=install || goto :error
|
||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
echo ::group::===== KImageFormats =====
|
echo ::group::===== KImageFormats =====
|
||||||
git clone -q https://invent.kde.org/frameworks/kimageformats.git dependencies_src/kimageformats
|
git clone -q https://invent.kde.org/frameworks/kimageformats.git dependencies_src/kimageformats
|
||||||
cmake .\dependencies_src\kimageformats -Bbuild_dependencies/kimageformats -DKDE_INSTALL_QTPLUGINDIR=%QT_ROOT_DIR%\plugins || goto :error
|
cmake .\dependencies_src\kimageformats -Bbuild_dependencies/kimageformats -DBUILD_TESTING=OFF -DKDE_INSTALL_QTPLUGINDIR=%QT_ROOT_DIR%\plugins || goto :error
|
||||||
cmake --build build_dependencies/kimageformats --config Release --target=install || goto :error
|
cmake --build build_dependencies/kimageformats --config Release --target=install || goto :error
|
||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
:: ------ app ------
|
:: ------ app ------
|
||||||
cmake -Bbuild . -DCMAKE_INSTALL_PREFIX="%PWD%\build\"
|
echo ::group::===== App (Build'n'Install) =====
|
||||||
|
cmake -Bbuild .
|
||||||
cmake --build build --config Release
|
cmake --build build --config Release
|
||||||
cmake --build build --config Release --target=install
|
cmake --install build --config Release --prefix "%PWD%\build"
|
||||||
|
echo ::endgroup::
|
||||||
:: ------ pkg ------
|
:: ------ pkg ------
|
||||||
windeployqt --verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-system-d3d-compiler --no-system-dxc-compiler --skip-plugin-types tls,networkinformation build\bin\ppic.exe
|
windeployqt --verbose=2 --no-compiler-runtime --no-quick-import --no-translations --no-network --no-opengl-sw --no-system-d3d-compiler --no-system-dxc-compiler --skip-plugin-types tls,networkinformation build\bin\ppic.exe
|
||||||
robocopy ./dependencies_bin/bin build/bin *.dll
|
robocopy ./dependencies_bin/bin build/bin *.dll
|
||||||
if ErrorLevel 8 (exit /B 1)
|
if ErrorLevel 8 (exit /B 1)
|
||||||
copy LICENSE build\bin
|
copy LICENSE build\bin
|
||||||
exit /B 0
|
exit /B 0
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: "windows-msvc${{ matrix.vs }}-qt${{ matrix.qt_ver }}-cmake-package"
|
name: "windows-msvc${{ matrix.vs }}-qt${{ matrix.qt_ver }}-cmake-package"
|
||||||
path: build/bin/*
|
path: build/bin/*
|
||||||
|
|||||||
@@ -16,3 +16,7 @@ cmake-build-*/
|
|||||||
# IDE/Editor config folders
|
# IDE/Editor config folders
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
.qtcreator/
|
||||||
|
|
||||||
|
# Clangd cache
|
||||||
|
.cache/
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
project(pineapple-pictures VERSION 1.1.0) # don't forget to update NEWS file and AppStream metadata.
|
project(pineapple-pictures VERSION 1.6.0) # don't forget to update NEWS file and AppStream metadata.
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
include(FeatureSummary)
|
include(FeatureSummary)
|
||||||
@@ -16,10 +16,11 @@ set (CMAKE_CXX_STANDARD 17)
|
|||||||
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set (CMAKE_AUTOMOC ON)
|
set (CMAKE_AUTOMOC ON)
|
||||||
set (CMAKE_AUTORCC ON)
|
set (CMAKE_AUTORCC ON)
|
||||||
|
set (CMAKE_AUTOUIC ON)
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
|
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
|
||||||
|
|
||||||
set (QT_MINIMUM_VERSION "6.4")
|
set (QT_MINIMUM_VERSION "6.5")
|
||||||
|
|
||||||
find_package(Qt${QT_VERSION_MAJOR} ${QT_MINIMUM_VERSION} REQUIRED
|
find_package(Qt${QT_VERSION_MAJOR} ${QT_MINIMUM_VERSION} REQUIRED
|
||||||
COMPONENTS Widgets Svg SvgWidgets LinguistTools
|
COMPONENTS Widgets Svg SvgWidgets LinguistTools
|
||||||
@@ -38,15 +39,12 @@ endif ()
|
|||||||
|
|
||||||
set (PPIC_CPP_FILES
|
set (PPIC_CPP_FILES
|
||||||
app/main.cpp
|
app/main.cpp
|
||||||
app/framelesswindow.cpp
|
|
||||||
app/mainwindow.cpp
|
app/mainwindow.cpp
|
||||||
app/actionmanager.cpp
|
app/actionmanager.cpp
|
||||||
app/graphicsview.cpp
|
app/graphicsview.cpp
|
||||||
app/graphicsscene.cpp
|
app/graphicsscene.cpp
|
||||||
app/bottombuttongroup.cpp
|
app/bottombuttongroup.cpp
|
||||||
app/navigatorview.cpp
|
app/navigatorview.cpp
|
||||||
app/opacityhelper.cpp
|
|
||||||
app/toolbutton.cpp
|
|
||||||
app/settings.cpp
|
app/settings.cpp
|
||||||
app/settingsdialog.cpp
|
app/settingsdialog.cpp
|
||||||
app/aboutdialog.cpp
|
app/aboutdialog.cpp
|
||||||
@@ -54,20 +52,19 @@ set (PPIC_CPP_FILES
|
|||||||
app/metadatadialog.cpp
|
app/metadatadialog.cpp
|
||||||
app/exiv2wrapper.cpp
|
app/exiv2wrapper.cpp
|
||||||
app/playlistmanager.cpp
|
app/playlistmanager.cpp
|
||||||
app/shortcutedit.cpp
|
|
||||||
app/fileopeneventhandler.cpp
|
app/fileopeneventhandler.cpp
|
||||||
|
app/playlistscout.cpp
|
||||||
|
app/playlistscouts/qtscout.cpp
|
||||||
|
app/playlistscouts/explorerscout.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set (PPIC_HEADER_FILES
|
set (PPIC_HEADER_FILES
|
||||||
app/framelesswindow.h
|
|
||||||
app/mainwindow.h
|
app/mainwindow.h
|
||||||
app/actionmanager.h
|
app/actionmanager.h
|
||||||
app/graphicsview.h
|
app/graphicsview.h
|
||||||
app/graphicsscene.h
|
app/graphicsscene.h
|
||||||
app/bottombuttongroup.h
|
app/bottombuttongroup.h
|
||||||
app/navigatorview.h
|
app/navigatorview.h
|
||||||
app/opacityhelper.h
|
|
||||||
app/toolbutton.h
|
|
||||||
app/settings.h
|
app/settings.h
|
||||||
app/settingsdialog.h
|
app/settingsdialog.h
|
||||||
app/aboutdialog.h
|
app/aboutdialog.h
|
||||||
@@ -75,8 +72,17 @@ set (PPIC_HEADER_FILES
|
|||||||
app/metadatadialog.h
|
app/metadatadialog.h
|
||||||
app/exiv2wrapper.h
|
app/exiv2wrapper.h
|
||||||
app/playlistmanager.h
|
app/playlistmanager.h
|
||||||
app/shortcutedit.h
|
|
||||||
app/fileopeneventhandler.h
|
app/fileopeneventhandler.h
|
||||||
|
app/playlistscout.h
|
||||||
|
app/playlistscouts/qtscout.h
|
||||||
|
app/playlistscouts/explorerscout.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set (PPIC_UI_FILES
|
||||||
|
app/settingsdialog.ui
|
||||||
|
app/aboutdialog.ui
|
||||||
|
app/metadatadialog.ui
|
||||||
|
app/mainwindow.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set (PPIC_QRC_FILES
|
set (PPIC_QRC_FILES
|
||||||
@@ -90,16 +96,36 @@ set (PPIC_RC_FILES
|
|||||||
set (EXE_NAME ppic)
|
set (EXE_NAME ppic)
|
||||||
|
|
||||||
# Translation
|
# Translation
|
||||||
file (GLOB PPIC_TS_FILES app/translations/*.ts)
|
file (GLOB PPIC_TS_FILES locales/app/*.ts)
|
||||||
set (PPIC_CPP_FILES_FOR_I18N ${PPIC_CPP_FILES})
|
set (PPIC_CPP_FILES_FOR_I18N ${PPIC_CPP_FILES})
|
||||||
|
|
||||||
|
find_program (UV_EXECUTABLE uv)
|
||||||
|
if (NOT UV_EXECUTABLE)
|
||||||
|
message (FATAL_ERROR "uv is required to run the metaglot tool, install it from https://docs.astral.sh/uv/")
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
list(APPEND PPIC_RC_FILES assets/pineapple-pictures.rc)
|
set (PPIC_RC_TEMPLATE_FILE ${CMAKE_CURRENT_BINARY_DIR}/pineapple-pictures.rc.in)
|
||||||
|
execute_process (
|
||||||
|
COMMAND ${UV_EXECUTABLE} tool run metaglot render rc
|
||||||
|
--manifest ${CMAKE_SOURCE_DIR}/dist/pineapple-pictures.rc.in.toml
|
||||||
|
--po ${CMAKE_SOURCE_DIR}/locales/winrc/*.po
|
||||||
|
--template ${CMAKE_SOURCE_DIR}/dist/pineapple-pictures.rc.in.liquid
|
||||||
|
--output ${PPIC_RC_TEMPLATE_FILE}
|
||||||
|
RESULT_VARIABLE METAGLOT_RESULT
|
||||||
|
)
|
||||||
|
if (NOT METAGLOT_RESULT EQUAL 0)
|
||||||
|
message (FATAL_ERROR "Failed to generate pineapple-pictures.rc.in via MetaGlot (exit code: ${METAGLOT_RESULT}). If it is not installed yet, run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
configure_file (${PPIC_RC_TEMPLATE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/pineapple-pictures.rc @ONLY)
|
||||||
|
list (APPEND PPIC_RC_FILES ${CMAKE_CURRENT_BINARY_DIR}/pineapple-pictures.rc)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_executable (${EXE_NAME}
|
add_executable (${EXE_NAME}
|
||||||
${PPIC_HEADER_FILES}
|
${PPIC_HEADER_FILES}
|
||||||
${PPIC_CPP_FILES}
|
${PPIC_CPP_FILES}
|
||||||
|
${PPIC_UI_FILES}
|
||||||
${PPIC_QRC_FILES}
|
${PPIC_QRC_FILES}
|
||||||
${PPIC_RC_FILES}
|
${PPIC_RC_FILES}
|
||||||
)
|
)
|
||||||
@@ -116,6 +142,11 @@ else()
|
|||||||
qt_add_translations(${EXE_NAME} ${ADD_TRANSLATIONS_ADDITIONAL_ARGS} TS_FILES ${PPIC_TS_FILES} QM_FILES_OUTPUT_VARIABLE PPIC_QM_FILES)
|
qt_add_translations(${EXE_NAME} ${ADD_TRANSLATIONS_ADDITIONAL_ARGS} TS_FILES ${PPIC_TS_FILES} QM_FILES_OUTPUT_VARIABLE PPIC_QM_FILES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# YYC MARK:
|
||||||
|
# This is essential, otherwise Qt UIC generated UI header file
|
||||||
|
# can not find our header files if there are custom widgets inside UI file.
|
||||||
|
target_include_directories(${EXE_NAME} PRIVATE app/)
|
||||||
|
|
||||||
target_sources(${EXE_NAME} PRIVATE ${PPIC_QM_FILES})
|
target_sources(${EXE_NAME} PRIVATE ${PPIC_QM_FILES})
|
||||||
|
|
||||||
target_link_libraries (${EXE_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::SvgWidgets)
|
target_link_libraries (${EXE_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::SvgWidgets)
|
||||||
@@ -198,17 +229,17 @@ if (WIN32)
|
|||||||
WIN32_EXECUTABLE TRUE
|
WIN32_EXECUTABLE TRUE
|
||||||
)
|
)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
set_source_files_properties(assets/icons/app-icon.icns PROPERTIES
|
set_source_files_properties(dist/sarasacw-picture.icns PROPERTIES
|
||||||
MACOSX_PACKAGE_LOCATION "Resources"
|
MACOSX_PACKAGE_LOCATION "Resources"
|
||||||
)
|
)
|
||||||
target_sources(${EXE_NAME} PUBLIC assets/icons/app-icon.icns)
|
target_sources(${EXE_NAME} PUBLIC dist/sarasacw-picture.icns)
|
||||||
# See https://cmake.org/cmake/help/v3.15/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
|
# See https://cmake.org/cmake/help/v3.15/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
|
||||||
set_target_properties(${EXE_NAME} PROPERTIES
|
set_target_properties(${EXE_NAME} PROPERTIES
|
||||||
MACOSX_BUNDLE TRUE
|
MACOSX_BUNDLE TRUE
|
||||||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/dist/MacOSXBundleInfo.plist.in
|
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/dist/MacOSXBundleInfo.plist.in
|
||||||
MACOSX_BUNDLE_BUNDLE_NAME "Pineapple Pictures"
|
MACOSX_BUNDLE_BUNDLE_NAME "Pineapple Pictures"
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER net.blumia.pineapple-pictures
|
MACOSX_BUNDLE_GUI_IDENTIFIER net.blumia.pineapple-pictures
|
||||||
MACOSX_BUNDLE_ICON_FILE app-icon.icns # contains the .icns file name, *without* the path.
|
MACOSX_BUNDLE_ICON_FILE sarasacw-picture.icns # contains the .icns file name, *without* the path.
|
||||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||||
)
|
)
|
||||||
@@ -219,20 +250,45 @@ elseif (UNIX)
|
|||||||
|
|
||||||
# install icon
|
# install icon
|
||||||
install (
|
install (
|
||||||
FILES assets/icons/app-icon.svg
|
DIRECTORY dist/freedesktop-icons/
|
||||||
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps"
|
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor"
|
||||||
RENAME net.blumia.pineapple-pictures.svg
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# install shortcut
|
# generate and install desktop entry file
|
||||||
|
set (PPIC_DESKTOP_FILE ${CMAKE_CURRENT_BINARY_DIR}/net.blumia.pineapple-pictures.desktop)
|
||||||
|
execute_process (
|
||||||
|
COMMAND ${UV_EXECUTABLE} tool run metaglot render desktop
|
||||||
|
--manifest ${CMAKE_SOURCE_DIR}/dist/net.blumia.pineapple-pictures.desktop.toml
|
||||||
|
--po ${CMAKE_SOURCE_DIR}/locales/desktop/*.po
|
||||||
|
--template ${CMAKE_SOURCE_DIR}/dist/net.blumia.pineapple-pictures.desktop.liquid
|
||||||
|
--output ${PPIC_DESKTOP_FILE}
|
||||||
|
RESULT_VARIABLE METAGLOT_DESKTOP_RESULT
|
||||||
|
)
|
||||||
|
if (NOT METAGLOT_DESKTOP_RESULT EQUAL 0)
|
||||||
|
message (FATAL_ERROR "Failed to generate net.blumia.pineapple-pictures.desktop via MetaGlot (exit code: ${METAGLOT_DESKTOP_RESULT}). If it is not installed yet, run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git")
|
||||||
|
endif ()
|
||||||
|
|
||||||
install (
|
install (
|
||||||
FILES dist/net.blumia.pineapple-pictures.desktop
|
FILES ${PPIC_DESKTOP_FILE}
|
||||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
|
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
|
||||||
)
|
)
|
||||||
|
|
||||||
# install app metadata file for appstream (and some other stuff using this metadata like snapcraft)
|
# generate and install app metadata file for appstream (and some other stuff using this metadata like snapcraft)
|
||||||
|
set (PPIC_METAINFO_FILE ${CMAKE_CURRENT_BINARY_DIR}/net.blumia.pineapple-pictures.metainfo.xml)
|
||||||
|
execute_process (
|
||||||
|
COMMAND ${UV_EXECUTABLE} tool run metaglot render appstream
|
||||||
|
--manifest ${CMAKE_SOURCE_DIR}/dist/net.blumia.pineapple-pictures.metainfo.xml.toml
|
||||||
|
--po ${CMAKE_SOURCE_DIR}/locales/appstream/*.po
|
||||||
|
--template ${CMAKE_SOURCE_DIR}/dist/net.blumia.pineapple-pictures.metainfo.xml.liquid
|
||||||
|
--output ${PPIC_METAINFO_FILE}
|
||||||
|
RESULT_VARIABLE METAGLOT_METAINFO_RESULT
|
||||||
|
)
|
||||||
|
if (NOT METAGLOT_METAINFO_RESULT EQUAL 0)
|
||||||
|
message (FATAL_ERROR "Failed to generate net.blumia.pineapple-pictures.metainfo.xml via MetaGlot (exit code: ${METAGLOT_METAINFO_RESULT}). If it is not installed yet, run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git")
|
||||||
|
endif ()
|
||||||
|
|
||||||
install (
|
install (
|
||||||
FILES dist/appstream/net.blumia.pineapple-pictures.metainfo.xml
|
FILES ${PPIC_METAINFO_FILE}
|
||||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
|
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
@@ -268,7 +324,6 @@ if (DEFINED QM_FILE_INSTALL_DIR)
|
|||||||
DESTINATION ${QM_FILE_INSTALL_DIR}
|
DESTINATION ${QM_FILE_INSTALL_DIR}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||||
|
|
||||||
# CPACK: General Settings
|
# CPACK: General Settings
|
||||||
@@ -284,7 +339,7 @@ elseif (APPLE)
|
|||||||
elseif (UNIX)
|
elseif (UNIX)
|
||||||
set (CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
set (CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||||
set (CPACK_DEBIAN_PACKAGE_RECOMMENDS "kimageformat-plugins")
|
set (CPACK_DEBIAN_PACKAGE_RECOMMENDS "kimageformat6-plugins")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2025 BLumia
|
Copyright (c) 2026 BLumia
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|||||||
@@ -1,3 +1,136 @@
|
|||||||
|
Version 1.6.0
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
Released: 2026-08-22
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Allow dragging window from titlebar to move window when maximized
|
||||||
|
* Add an option to show/hide bird-eye view
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* Maximize the window when the image size matches the screen size
|
||||||
|
* Fix window might stuck when drag move on some ill-formed window manager
|
||||||
|
* Make titlebar respect RTL layout
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
* Update translations
|
||||||
|
* Update Qt version to 6.11.2 for Windows and macOS pre-built binaries
|
||||||
|
|
||||||
|
Contributors:
|
||||||
|
Tech-Tac, Heimen Stoffels (vistaus), VenusGirl, Oğuz Ersen
|
||||||
|
|
||||||
|
Version 1.5.0
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
Released: 2026-07-04
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Introduced an optional titlebar that display file name and allows drag and double-click to move and toggle maximize state
|
||||||
|
* Windows: Now the application will use the system's built-in animation for open window animation
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* Show empty url list should also reset window title to blank
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
* Update translations
|
||||||
|
* Add vcs-browser link to AppStream metadata
|
||||||
|
|
||||||
|
Contributors:
|
||||||
|
Heimen Stoffels (vistaus), VenusGirl (VenusGirl)
|
||||||
|
|
||||||
|
Version 1.4.1
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
Released: 2026-04-05
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
* Update translations
|
||||||
|
* Update Qt version to 6.10.3 for Windows and macOS pre-built binaries
|
||||||
|
|
||||||
|
Contributors:
|
||||||
|
Heimen Stoffels (vistaus), Loc Huynh (hthienloc)
|
||||||
|
|
||||||
|
Version 1.4.0
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
Released: 2026-02-11
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Action to save image as new file with different format
|
||||||
|
* Add Vietnamese and Slovenian translation
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
* Update copyright year to 2026
|
||||||
|
* Update translations
|
||||||
|
* Update Qt version to 6.10.2 for Windows and macOS pre-built binaries
|
||||||
|
|
||||||
|
Contributors:
|
||||||
|
Loc Huynh, Sabri Ünal, VenusGirl, Andrej Poženel, Andrey
|
||||||
|
|
||||||
|
Version 1.3.0
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
Released: 2025-12-20
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* New option to limit SVG support to SVG Tiny 1.2 standard
|
||||||
|
* Windows: ship tools and configurations that help user associate image files to this program
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* Fix window not appear at the screen that the mouse cursor is at
|
||||||
|
* Fix Windows prebuilt binary having AVIF plugin included but not actually support it
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
* CPack DEB: will now recommend "kimageformat6-plugins" instead of the KF5 version
|
||||||
|
* Update translations
|
||||||
|
* Update exiv2 version for Windows binary build
|
||||||
|
|
||||||
|
Contributors:
|
||||||
|
VenusGirl, Andrey
|
||||||
|
|
||||||
|
Version 1.2.1
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
Released: 2025-11-22
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* Fix incorrect color when display some CMYK images.
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
* Now use Qt 6.10.1 for pre-built binary
|
||||||
|
* Update README description and AppStream metainfo
|
||||||
|
* Update translations
|
||||||
|
* Update libavif, AOM and expat version for Windows binary build
|
||||||
|
|
||||||
|
Contributors:
|
||||||
|
albanobattistella
|
||||||
|
|
||||||
|
Version 1.2.0
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
Released: 2025-09-21
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Long image mode that detect extra wide image and auto fit by its thin side
|
||||||
|
* Windows: Add product version to binary metadata / resource file
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
* Update translations
|
||||||
|
* Update libavif version for Windows binary build
|
||||||
|
|
||||||
|
Contributors:
|
||||||
|
Heimen Stoffels, albanobattistella, Sabri Ünal
|
||||||
|
|
||||||
|
Version 1.1.1
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
Released: 2025-08-02
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* Click dock icon should show window when it's hidden on macOS
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
* Ensure "Fit by Width" position the view to the beginning of the image
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
* Update translations
|
||||||
|
* Update Exiv2 version for Windows binary build
|
||||||
|
|
||||||
|
Contributors:
|
||||||
|
Heimen Stoffels, VenusGirl, தமிழ்நேரம்
|
||||||
|
|
||||||
Version 1.1.0
|
Version 1.1.0
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
Released: 2025-07-06
|
Released: 2025-07-06
|
||||||
@@ -166,4 +299,3 @@ Bugfixes:
|
|||||||
|
|
||||||
Contributors:
|
Contributors:
|
||||||
yyc12345
|
yyc12345
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,17 @@
|
|||||||
Yet another image viewer.
|
# Sarasas Chip Workshop Picture
|
||||||
|
|
||||||
|
Yet another legacy Windows Photo Viewer with cross-platform support.
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> SarasaCW Picture are still in refactoring. Please do not use it until this message removes.
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
Sarasas Chip Workshop Picture (abbr. SarasaCW Picture) is a lightweight image viewer that has cross-platform support and similar user interface about legacy Windows Photo Viewer. It allows you view JPEG, PNG, GIF, SVG, PSD, KRA, XCF, TGA, HDR, AVIF and some other frequently used image formats files quickly and easily without changing your long-term Windows usage experience.
|
||||||
|
|
||||||
|
SarasaCW Picture is the **hard fork** of [Pineapple Pictures](https://github.com/BLumia/pineapple-pictures) since Pineapple Pictures 1.4.1 version.
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|CI|Build Status|
|
|CI|Build Status|
|
||||||
|---|---|
|
|---|---|
|
||||||
@@ -8,10 +21,6 @@ Yet another image viewer.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
Pineapple Pictures is a lightweight image viewer that allows you view JPEG, PNG, GIF, SVG, PSD, KRA, XCF, TGA, HDR, AVIF and some other frequently used image formats files quickly and easily, and also provide a Stay-on-Top window setting that allows you pin the window so you can use it to pin a reference image at the top and then you can work with other software.
|
|
||||||
|
|
||||||
## Get it!
|
## Get it!
|
||||||
|
|
||||||
### Maintained by the original author
|
### Maintained by the original author
|
||||||
@@ -23,13 +32,22 @@ Pineapple Pictures is a lightweight image viewer that allows you view JPEG, PNG,
|
|||||||
|
|
||||||
### Maintained by contributors / certain distro's package maintainers
|
### Maintained by contributors / certain distro's package maintainers
|
||||||
|
|
||||||
- Debian (since bullseye) or Ubuntu (since 21.04): `sudo apt install pineapple-pictures`
|
[](https://repology.org/project/pineapple-pictures/versions)
|
||||||
- Nix / NixOS: [pineapple-pictures](https://search.nixos.org/packages?channel=unstable&show=pineapple-pictures&from=0&size=50&sort=relevance&type=packages&query=pineapple-pictures) (maintained by @wineee)
|
|
||||||
|
|
||||||
## Help Translation!
|
## Contribution
|
||||||
|
|
||||||
|
Beside feedback and code contribution, other contributions are also welcome!
|
||||||
|
|
||||||
|
### Help Translation!
|
||||||
|
|
||||||
[Translate this project on Weblate!](https://hosted.weblate.org/projects/pineapple-pictures/)
|
[Translate this project on Weblate!](https://hosted.weblate.org/projects/pineapple-pictures/)
|
||||||
|
|
||||||
|
### Funding
|
||||||
|
|
||||||
|
[](https://ko-fi.com/blumia)
|
||||||
|
|
||||||
|
[Afdian](https://afdian.com/a/BLumia)
|
||||||
|
|
||||||
## Build it manually:
|
## Build it manually:
|
||||||
|
|
||||||
Current state, we need:
|
Current state, we need:
|
||||||
@@ -62,3 +80,5 @@ It's possible to build it under Windows, Linux, macOS, and maybe other desktop p
|
|||||||
## License
|
## License
|
||||||
|
|
||||||
Pineapple Pictures as a whole is licensed under MIT license. Individual files may have a different, but compatible license.
|
Pineapple Pictures as a whole is licensed under MIT license. Individual files may have a different, but compatible license.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
|
# Sarasas Chip Workshop 照片查看器
|
||||||
|
|
||||||
|
简单轻量的、具有跨平台支持的、经典样式的 Windows 照片查看器。
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> SarasaCW 照片查看器还在重构中。在这条信息被移除之前请不要使用它。
|
||||||
|
|
||||||
|
## 简介
|
||||||
|
|
||||||
|
Sarasas Chip Workshop 照片查看器(简称 SarasaCW 照片查看器)是一个轻量级的图片查看器。支持跨平台。界面风格类似于经典的 Windows 照片查看器。它可以让你快速轻松地浏览 JPEG、PNG、GIF、SVG、PSD、KRA、XCF、TGA、HDR、AVIF 以及其他一些常用的图片格式,且无需改变你长期的 Windows 使用习惯。
|
||||||
|
|
||||||
|
SarasaCW 照片查看器是[菠萝看图](https://github.com/BLumia/pineapple-pictures)的**硬分叉**,该分叉自菠萝看图 1.4.1 版本开始。
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
简单轻量的跨平台看图工具。
|
简单轻量的跨平台看图工具。
|
||||||
|
|
||||||
|CI|构建状态|
|
|CI|构建状态|
|
||||||
@@ -8,15 +23,11 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 简介
|
|
||||||
|
|
||||||
菠萝看图是一个轻量图像查看器,允许你简单快捷的查看 JPEG, PNG, GIF, SVG, PSD, KRA, XCF, TGA, HDR, AVIF 等常用格式的图像文件,并提供了置顶窗口的选项以便你在使用其它软件时也可以将参考图片固定在顶端。
|
|
||||||
|
|
||||||
## 立即获取!
|
## 立即获取!
|
||||||
|
|
||||||
### 由原作者维护
|
### 由原作者维护
|
||||||
|
|
||||||
- [GitHub Release 页面](https://github.com/BLumia/pineapple-pictures/releases) | [gitee 发布页面](https://gitee.com/blumia/pineapple-pictures/releases)
|
- [GitHub Release 页面](https://github.com/BLumia/pineapple-pictures/releases)
|
||||||
- [SourceForge](https://sourceforge.net/projects/pineapple-pictures/)
|
- [SourceForge](https://sourceforge.net/projects/pineapple-pictures/)
|
||||||
- Archlinux AUR: [pineapple-pictures](https://aur.archlinux.org/packages/pineapple-pictures/) | [pineapple-pictures-git](https://aur.archlinux.org/packages/pineapple-pictures-git/)
|
- Archlinux AUR: [pineapple-pictures](https://aur.archlinux.org/packages/pineapple-pictures/) | [pineapple-pictures-git](https://aur.archlinux.org/packages/pineapple-pictures-git/)
|
||||||
- [Itch.io 商店](https://blumia.itch.io/pineapple-pictures)
|
- [Itch.io 商店](https://blumia.itch.io/pineapple-pictures)
|
||||||
@@ -24,13 +35,22 @@
|
|||||||
|
|
||||||
### 由贡献者/对应发行版的打包人员维护
|
### 由贡献者/对应发行版的打包人员维护
|
||||||
|
|
||||||
- Debian (自 bullseye 起) 或 Ubuntu (自 21.04 起): `sudo apt install pineapple-pictures`
|
[](https://repology.org/project/pineapple-pictures/versions)
|
||||||
- Nix / NixOS: [pineapple-pictures](https://search.nixos.org/packages?channel=unstable&show=pineapple-pictures&from=0&size=50&sort=relevance&type=packages&query=pineapple-pictures) (由 [@wineee](https://github.com/wineee) 维护)
|
|
||||||
|
|
||||||
## 帮助翻译!
|
## 参与贡献
|
||||||
|
|
||||||
|
除了参与反馈和代码贡献外,也欢迎各种类型的贡献!
|
||||||
|
|
||||||
|
### 帮助翻译!
|
||||||
|
|
||||||
[在 Weblate 上帮助此项目翻译到更多语言!](https://hosted.weblate.org/projects/pineapple-pictures/)
|
[在 Weblate 上帮助此项目翻译到更多语言!](https://hosted.weblate.org/projects/pineapple-pictures/)
|
||||||
|
|
||||||
|
### 打赏
|
||||||
|
|
||||||
|
[Afdian | 爱发电](https://afdian.com/a/BLumia)
|
||||||
|
|
||||||
|
[](https://ko-fi.com/blumia)
|
||||||
|
|
||||||
## 手动构建步骤:
|
## 手动构建步骤:
|
||||||
|
|
||||||
当前状态,我们需要先确保如下依赖可用:
|
当前状态,我们需要先确保如下依赖可用:
|
||||||
@@ -63,3 +83,5 @@ $ cmake --build . # 如果你使用 Makefile 作为 CMake 生成器,也可以
|
|||||||
## 许可协议
|
## 许可协议
|
||||||
|
|
||||||
菠萝看图整体使用 MIT 协议进行发布。项目所随的部分源文件可能具备不同但与之兼容的许可协议。
|
菠萝看图整体使用 MIT 协议进行发布。项目所随的部分源文件可能具备不同但与之兼容的许可协议。
|
||||||
|
|
||||||
|
-->
|
||||||
|
|||||||
@@ -1,33 +1,39 @@
|
|||||||
version = 1
|
version = 1
|
||||||
SPDX-PackageName = "Pineapple Pictures"
|
SPDX-PackageName = "Pineapple Pictures"
|
||||||
SPDX-PackageDownloadLocation = "https://github.com/BLumia/pineapple-pictures"
|
SPDX-PackageDownloadLocation = "https://github.com/BLumia/pineapple-pictures"
|
||||||
|
|
||||||
[[annotations]]
|
[[annotations]]
|
||||||
path = [".gitignore", "appveyor.yml", ".github/**"]
|
path = [".gitattributes", ".git-blame-ignore-revs", ".gitignore", "appveyor.yml", ".github/**"]
|
||||||
precedence = "aggregate"
|
precedence = "aggregate"
|
||||||
SPDX-FileCopyrightText = "None"
|
SPDX-FileCopyrightText = "None"
|
||||||
SPDX-License-Identifier = "CC0-1.0"
|
SPDX-License-Identifier = "CC0-1.0"
|
||||||
|
|
||||||
[[annotations]]
|
[[annotations]]
|
||||||
path = ["README**.md", "NEWS", "assets/**.rc", "assets/**.qrc", "dist/**"]
|
path = ["README**.md", "NEWS", "assets/**.rc.in", "assets/**.qrc", "dist/appstream/**", "dist/**.in", "dist/**.desktop", "dist/**.rc.in.toml", "dist/**.rc.in.liquid"]
|
||||||
precedence = "aggregate"
|
precedence = "aggregate"
|
||||||
SPDX-FileCopyrightText = "None"
|
SPDX-FileCopyrightText = "None"
|
||||||
SPDX-License-Identifier = "CC0-1.0"
|
SPDX-License-Identifier = "CC0-1.0"
|
||||||
|
|
||||||
[[annotations]]
|
[[annotations]]
|
||||||
path = ["app/translations/**.ts", "assets/plain/translators.html"]
|
path = ["locales/app/**.ts", "locales/winrc/**", "assets/plain/translators.html"]
|
||||||
precedence = "aggregate"
|
precedence = "aggregate"
|
||||||
SPDX-FileCopyrightText = "Translators from hosted.weblate.org"
|
SPDX-FileCopyrightText = "Translators from hosted.weblate.org"
|
||||||
SPDX-License-Identifier = "MIT"
|
SPDX-License-Identifier = "MIT"
|
||||||
|
|
||||||
[[annotations]]
|
[[annotations]]
|
||||||
path = "assets/icons/**.svg"
|
path = "tool/**"
|
||||||
precedence = "aggregate"
|
precedence = "aggregate"
|
||||||
SPDX-FileCopyrightText = "2022 Gary Wang"
|
SPDX-FileCopyrightText = "2026 yyc12345"
|
||||||
SPDX-License-Identifier = "MIT"
|
SPDX-License-Identifier = "MIT"
|
||||||
|
|
||||||
[[annotations]]
|
[[annotations]]
|
||||||
path = "assets/icons/app-icon.**"
|
path = "assets/icons/**.svg"
|
||||||
precedence = "aggregate"
|
precedence = "aggregate"
|
||||||
SPDX-FileCopyrightText = "2020 Lovelyblack"
|
SPDX-FileCopyrightText = "2022 Gary Wang"
|
||||||
SPDX-License-Identifier = "MIT"
|
SPDX-License-Identifier = "MIT"
|
||||||
|
|
||||||
|
[[annotations]]
|
||||||
|
path = "assets/icons/app-icon.**"
|
||||||
|
precedence = "aggregate"
|
||||||
|
SPDX-FileCopyrightText = "2020 Lovelyblack"
|
||||||
|
SPDX-License-Identifier = "MIT"
|
||||||
|
|||||||
@@ -1,181 +1,99 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "aboutdialog.h"
|
#include "aboutdialog.h"
|
||||||
|
#include "ui_aboutdialog.h"
|
||||||
#include <QAbstractButton>
|
|
||||||
#include <QDialogButtonBox>
|
#include <QApplication>
|
||||||
#include <QTextBrowser>
|
#include <QFile>
|
||||||
#include <QTabWidget>
|
|
||||||
#include <QVBoxLayout>
|
using namespace Qt::Literals::StringLiterals;
|
||||||
#include <QApplication>
|
|
||||||
#include <QLabel>
|
static QString loadEmbeddedHtml(QString&& path) {
|
||||||
#include <QPushButton>
|
QFile htmlFile(path);
|
||||||
#include <QFile>
|
bool canOpenFile = htmlFile.open(QIODevice::ReadOnly);
|
||||||
|
QByteArray htmlRawContent = canOpenFile ? htmlFile.readAll() : QByteArrayLiteral("");
|
||||||
using namespace Qt::Literals::StringLiterals;
|
return QString::fromUtf8(htmlRawContent);
|
||||||
|
}
|
||||||
AboutDialog::AboutDialog(QWidget *parent)
|
|
||||||
: QDialog(parent)
|
AboutDialog::AboutDialog(QWidget *parent)
|
||||||
, m_tabWidget(new QTabWidget)
|
: QDialog(parent), ui(new QT_PREPEND_NAMESPACE(Ui::AboutDialog))
|
||||||
, m_buttonBox(new QDialogButtonBox)
|
{
|
||||||
, m_helpTextEdit(new QTextBrowser)
|
ui->setupUi(this);
|
||||||
, m_aboutTextEdit(new QTextBrowser)
|
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||||
, m_specialThanksTextEdit(new QTextBrowser)
|
|
||||||
, m_licenseTextEdit(new QTextBrowser)
|
// blumia: Chain two arg() here since it seems lupdate will remove one of them if we use
|
||||||
, m_3rdPartyLibsTextEdit(new QTextBrowser)
|
// the old `arg(QCoreApp::translate(), tr())` way, but it's worth to mention
|
||||||
{
|
// `arg(QCoreApp::translate(), this->tr())` works, but lupdate will complain about the usage.
|
||||||
this->setWindowTitle(tr("About"));
|
const QString HELP_HTML = loadEmbeddedHtml(u":/htmls/help.html"_s)
|
||||||
|
.arg(tr("General Help"))
|
||||||
const QStringList helpStr {
|
.arg(tr("Launch application with image file path as argument to load the file."))
|
||||||
u"<p>%1</p>"_s.arg(tr("Launch application with image file path as argument to load the file.")),
|
.arg(tr("Passing in a single image file will load all the images in that directory and start viewing from that image."))
|
||||||
u"<p>%1</p>"_s.arg(tr("Drag and drop image file onto the window is also supported.")),
|
.arg(tr("Passing in multiple image files lets you view them one by one."))
|
||||||
u"<p>%1</p>"_s.arg(tr("None of the operations in this application will alter the pictures on disk.")),
|
.arg(tr("Drag and drop image file onto the window is also supported."))
|
||||||
u"<p>%1</p>"_s.arg(tr("Context menu option explanation:")),
|
.arg(tr("None of the operations in this application will alter the pictures on disk."))
|
||||||
u"<ul>"_s,
|
.arg(tr("Context Menu Help"))
|
||||||
// blumia: Chain two arg() here since it seems lupdate will remove one of them if we use
|
.arg(tr("Keep transformation", "The same meaning of MainWindow's Keep transformation."))
|
||||||
// the old `arg(QCoreApp::translate(), tr())` way, but it's worth to mention
|
.arg(tr("Avoid resetting the zoom/rotation/flip state that was applied to the image view when switching between images."))
|
||||||
// `arg(QCoreApp::translate(), this->tr())` works, but lupdate will complain about the usage.
|
.arg(tr("Checkerboard", "The same meaning of MainWindow's Checkerboard."))
|
||||||
u"<li><b>%1</b>:<br/>%2</li>"_s
|
.arg(tr("Checkerboard light and dark theme can be adjusted in the configuration window, or easily switch it by holding Shift and clicking the button."));
|
||||||
.arg(QCoreApplication::translate("MainWindow", "Stay on top"))
|
|
||||||
.arg(tr("Make window stay on top of all other windows.")),
|
const QString APP_NAME_ARG = qApp->applicationDisplayName();
|
||||||
u"<li><b>%1</b>:<br/>%2</li>"_s
|
const QString APP_VERSION_ARG =
|
||||||
.arg(QCoreApplication::translate("MainWindow", "Protected mode"))
|
#ifdef GIT_DESCRIBE_VERSION_STRING
|
||||||
.arg(tr("Avoid close window accidentally. (eg. by double clicking the window)")),
|
GIT_DESCRIBE_VERSION_STRING;
|
||||||
u"<li><b>%1</b>:<br/>%2</li>"_s
|
#else
|
||||||
.arg(QCoreApplication::translate("MainWindow", "Keep transformation", "The 'transformation' means the flip/rotation status that currently applied to the image view"))
|
qApp->applicationVersion();
|
||||||
.arg(tr("Avoid resetting the zoom/rotation/flip state that was applied to the image view when switching between images.")),
|
#endif // GIT_DESCRIBE_VERSION_STRING
|
||||||
u"</ul>"_s
|
const QString QT_VERSION_ARG = QT_VERSION_STR;
|
||||||
};
|
const QString QT_ARCH_ARG = QSysInfo::buildCpuArchitecture();
|
||||||
|
const QString ABOUT_HTML = loadEmbeddedHtml(u":/htmls/about.html"_s)
|
||||||
const QStringList aboutStr {
|
.arg(APP_NAME_ARG)
|
||||||
u"<center><img width='128' height='128' src=':/icons/app-icon.svg'/><br/>"_s,
|
.arg(tr("Version: %1").arg(APP_VERSION_ARG))
|
||||||
qApp->applicationDisplayName(),
|
.arg(tr("Upstream author"))
|
||||||
(u"<br/>"_s + tr("Version: %1").arg(
|
.arg(tr("Hard fork author"))
|
||||||
#ifdef GIT_DESCRIBE_VERSION_STRING
|
.arg(tr("Logo designer"))
|
||||||
GIT_DESCRIBE_VERSION_STRING
|
.arg(tr("Built with Qt %1 (%2)").arg(QT_VERSION_ARG).arg(QT_ARCH_ARG))
|
||||||
#else
|
.arg(tr("Source code"));
|
||||||
qApp->applicationVersion()
|
|
||||||
#endif // GIT_DESCRIBE_VERSION_STRING
|
const QString SPECIAL_THANKS_HTML = loadEmbeddedHtml(u":/htmls/special-thanks.html"_s)
|
||||||
)),
|
.arg(tr("Contributors"))
|
||||||
u"<hr/>"_s,
|
.arg(tr("List of contributors on GitHub"))
|
||||||
tr("Copyright (c) %1 %2", "%1 is year, %2 is the name of copyright holder(s)")
|
.arg(tr("Thanks to all people who contributed to this project."))
|
||||||
.arg(u"2025"_s, u"<a href='https://github.com/BLumia'>@BLumia</a>"_s),
|
.arg(tr("Translators"))
|
||||||
u"<br/>"_s,
|
.arg(tr("I would like to thank the following people who volunteered to translate this application."));
|
||||||
tr("Logo designed by %1").arg(u"<a href='https://github.com/Lovelyblack'>@Lovelyblack</a>"_s),
|
|
||||||
u"<hr/>"_s,
|
const QString LICENSE_HTML = loadEmbeddedHtml(u":/htmls/license.html"_s)
|
||||||
tr("Built with Qt %1 (%2)").arg(QT_VERSION_STR, QSysInfo::buildCpuArchitecture()),
|
.arg(tr("License"))
|
||||||
QStringLiteral("<br/><a href='%1'>%2</a>").arg("https://github.com/BLumia/pineapple-pictures", tr("Source code")),
|
.arg(tr("This application is released under the MIT License."))
|
||||||
u"</center>"_s
|
.arg(tr("License Verbatim Copy"));
|
||||||
};
|
|
||||||
|
const QString THIRD_PARTY_LIBS_HTML = loadEmbeddedHtml(u":/htmls/third-party-libs.html"_s)
|
||||||
QFile translaterHtml(u":/plain/translators.html"_s);
|
.arg(tr("Third-party Libraries"))
|
||||||
bool canOpenFile = translaterHtml.open(QIODevice::ReadOnly);
|
.arg(tr("This application is built on the following free software libraries.", "Free as in freedom"))
|
||||||
const QByteArray & translatorList = canOpenFile ? translaterHtml.readAll() : QByteArrayLiteral("");
|
.arg(tr("Some of them are optional and might not be included with this distribution depending on the build environment."));
|
||||||
|
|
||||||
const QStringList specialThanksStr {
|
ui->m_helpTextEdit->setHtml(HELP_HTML);
|
||||||
u"<h1 align='center'>%1</h1><a href='%2'>%3</a><p>%4</p>"_s.arg(
|
ui->m_aboutTextEdit->setHtml(ABOUT_HTML);
|
||||||
tr("Contributors"),
|
ui->m_specialThanksTextEdit->setHtml(SPECIAL_THANKS_HTML);
|
||||||
u"https://github.com/BLumia/pineapple-pictures/graphs/contributors"_s,
|
ui->m_licenseTextEdit->setHtml(LICENSE_HTML);
|
||||||
tr("List of contributors on GitHub"),
|
ui->m_3rdPartyLibsTextEdit->setHtml(THIRD_PARTY_LIBS_HTML);
|
||||||
tr("Thanks to all people who contributed to this project.")
|
|
||||||
),
|
connect(ui->m_buttonBox, QOverload<QAbstractButton *>::of(&QDialogButtonBox::clicked), this, [this](QAbstractButton * btn){
|
||||||
|
Q_UNUSED(btn)
|
||||||
u"<h1 align='center'>%1</h1><p>%2</p>%3"_s.arg(
|
this->close();
|
||||||
tr("Translators"),
|
});
|
||||||
tr("I would like to thank the following people who volunteered to translate this application."),
|
|
||||||
translatorList
|
setMinimumSize(361, 161); // not sure why it complain "Unable to set geometry"
|
||||||
)
|
}
|
||||||
};
|
|
||||||
|
AboutDialog::~AboutDialog()
|
||||||
const QStringList licenseStr {
|
{
|
||||||
u"<h1 align='center'><b>%1</b></h1>"_s.arg(tr("Your Rights")),
|
delete ui;
|
||||||
u"<p>%1</p><p>%2</p><ul><li>%3</li><li>%4</li><li>%5</li><li>%6</li></ul>"_s.arg(
|
}
|
||||||
tr("%1 is released under the MIT License."), // %1
|
|
||||||
tr("This license grants people a number of freedoms:"), // %2
|
QSize AboutDialog::sizeHint() const
|
||||||
tr("You are free to use %1, for any purpose"), // %3
|
{
|
||||||
tr("You are free to distribute %1"), // %4
|
return QSize(520, 350);
|
||||||
tr("You can study how %1 works and change it"), // %5
|
}
|
||||||
tr("You can distribute changed versions of %1") // %6
|
|
||||||
).arg(u"<i>%1</i>"_s),
|
|
||||||
u"<p>%1</p>"_s.arg(tr("The MIT license guarantees you this freedom. Nobody is ever permitted to take it away.")),
|
|
||||||
u"<hr/><pre>%2</pre>"_s
|
|
||||||
};
|
|
||||||
|
|
||||||
const QString mitLicense(QStringLiteral(R"(Expat/MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2025 BLumia
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
)"));
|
|
||||||
|
|
||||||
const QStringList thirdPartyLibsStr {
|
|
||||||
u"<h1 align='center'><b>%1</b></h1>"_s.arg(tr("Third-party Libraries used by %1")),
|
|
||||||
tr("%1 is built on the following free software libraries:", "Free as in freedom"),
|
|
||||||
u"<ul>"_s,
|
|
||||||
#ifdef HAVE_EXIV2_VERSION
|
|
||||||
u"<li><a href='%1'>%2</a>: %3</li>"_s.arg("https://www.exiv2.org/", "Exiv2", "GPLv2"),
|
|
||||||
#endif // EXIV2_VERSION
|
|
||||||
u"<li><a href='%1'>%2</a>: %3</li>"_s.arg("https://www.qt.io/", "Qt", "GPLv2 + GPLv3 + LGPLv2.1 + LGPLv3"),
|
|
||||||
u"</ul>"_s
|
|
||||||
};
|
|
||||||
|
|
||||||
m_helpTextEdit->setText(helpStr.join('\n'));
|
|
||||||
|
|
||||||
m_aboutTextEdit->setText(aboutStr.join('\n'));
|
|
||||||
m_aboutTextEdit->setOpenExternalLinks(true);
|
|
||||||
|
|
||||||
m_specialThanksTextEdit->setText(specialThanksStr.join('\n'));
|
|
||||||
m_specialThanksTextEdit->setOpenExternalLinks(true);
|
|
||||||
|
|
||||||
m_licenseTextEdit->setText(licenseStr.join('\n').arg(qApp->applicationDisplayName(), mitLicense));
|
|
||||||
|
|
||||||
m_3rdPartyLibsTextEdit->setText(thirdPartyLibsStr.join('\n').arg(u"<i>%1</i>"_s).arg(qApp->applicationDisplayName()));
|
|
||||||
m_3rdPartyLibsTextEdit->setOpenExternalLinks(true);
|
|
||||||
|
|
||||||
m_tabWidget->addTab(m_helpTextEdit, tr("&Help"));
|
|
||||||
m_tabWidget->addTab(m_aboutTextEdit, tr("&About"));
|
|
||||||
m_tabWidget->addTab(m_specialThanksTextEdit, tr("&Special Thanks"));
|
|
||||||
m_tabWidget->addTab(m_licenseTextEdit, tr("&License"));
|
|
||||||
m_tabWidget->addTab(m_3rdPartyLibsTextEdit, tr("&Third-party Libraries"));
|
|
||||||
|
|
||||||
m_buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
|
||||||
connect(m_buttonBox, QOverload<QAbstractButton *>::of(&QDialogButtonBox::clicked), this, [this](){
|
|
||||||
this->close();
|
|
||||||
});
|
|
||||||
|
|
||||||
setLayout(new QVBoxLayout);
|
|
||||||
|
|
||||||
layout()->addWidget(m_tabWidget);
|
|
||||||
layout()->addWidget(m_buttonBox);
|
|
||||||
|
|
||||||
setMinimumSize(361, 161); // not sure why it complain "Unable to set geometry"
|
|
||||||
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
AboutDialog::~AboutDialog()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize AboutDialog::sizeHint() const
|
|
||||||
{
|
|
||||||
return QSize(520, 350);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,36 +1,29 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef ABOUTDIALOG_H
|
#ifndef ABOUTDIALOG_H
|
||||||
#define ABOUTDIALOG_H
|
#define ABOUTDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QTextBrowser;
|
namespace Ui {
|
||||||
class QTabWidget;
|
class AboutDialog;
|
||||||
class QDialogButtonBox;
|
}
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class AboutDialog : public QDialog
|
class AboutDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AboutDialog(QWidget *parent = nullptr);
|
explicit AboutDialog(QWidget *parent = nullptr);
|
||||||
~AboutDialog() override;
|
~AboutDialog() override;
|
||||||
|
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTabWidget * m_tabWidget = nullptr;
|
QT_PREPEND_NAMESPACE(Ui::AboutDialog) *ui;
|
||||||
QDialogButtonBox * m_buttonBox = nullptr;
|
};
|
||||||
|
|
||||||
QTextBrowser * m_helpTextEdit = nullptr;
|
#endif // ABOUTDIALOG_H
|
||||||
QTextBrowser * m_aboutTextEdit = nullptr;
|
|
||||||
QTextBrowser * m_specialThanksTextEdit = nullptr;
|
|
||||||
QTextBrowser * m_licenseTextEdit = nullptr;
|
|
||||||
QTextBrowser * m_3rdPartyLibsTextEdit = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ABOUTDIALOG_H
|
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AboutDialog</class>
|
||||||
|
<widget class="QDialog" name="AboutDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::NonModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>About</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>361</width>
|
||||||
|
<height>161</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTabWidget" name="m_tabWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="helpTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>&Help</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="helpTabLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTextBrowser" name="m_helpTextEdit">
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="aboutTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>&About</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="aboutTabLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTextBrowser" name="m_aboutTextEdit">
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="specialThanksTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>&Special Thanks</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="specialThanksTabLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTextBrowser" name="m_specialThanksTextEdit">
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="licenseTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>&License</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="licenseTabLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTextBrowser" name="m_licenseTextEdit">
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="thirdPartyLibsTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>&Third-party Libraries</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="thirdPartyLibsTabLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTextBrowser" name="m_3rdPartyLibsTextEdit">
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -1,153 +1,208 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "actionmanager.h"
|
#include "actionmanager.h"
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "settings.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
#include <QGuiApplication>
|
#include "playlistmanager.h"
|
||||||
#include <QSvgRenderer>
|
#include "graphicsview.h"
|
||||||
#include <QPainter>
|
#include "graphicsscene.h"
|
||||||
|
|
||||||
#define ICON_NAME(name)\
|
#include <QGuiApplication>
|
||||||
QStringLiteral(":/icons/" #name ".svg")
|
#include <QSvgRenderer>
|
||||||
|
#include <QPainter>
|
||||||
#define ACTION_NAME(s) QStringLiteral(STRIFY(s))
|
|
||||||
#define STRIFY(s) #s
|
static QIcon loadHidpiIcon(const QString &resp, QSize sz = QSize(32, 32))
|
||||||
|
{
|
||||||
QIcon ActionManager::loadHidpiIcon(const QString &resp, QSize sz)
|
QPixmap pm = QPixmap(resp);
|
||||||
{
|
pm.scaled(sz * qApp->devicePixelRatio(), Qt::KeepAspectRatio);
|
||||||
QSvgRenderer r(resp);
|
pm.setDevicePixelRatio(qApp->devicePixelRatio());
|
||||||
QPixmap pm = QPixmap(sz * qApp->devicePixelRatio());
|
return QIcon(pm);
|
||||||
pm.fill(Qt::transparent);
|
}
|
||||||
QPainter p(&pm);
|
|
||||||
r.render(&p);
|
void ActionManager::setupAction(MainWindow *mainWindow)
|
||||||
pm.setDevicePixelRatio(qApp->devicePixelRatio());
|
{
|
||||||
return QIcon(pm);
|
// region: Action and Its Icon Creation
|
||||||
}
|
|
||||||
|
// Declare some convenient macros and lambdas.
|
||||||
void ActionManager::setupAction(MainWindow *mainWindow)
|
|
||||||
{
|
#define ICON_NAME(name)\
|
||||||
auto create_action = [] (QWidget *w, QAction **a, QString i, QString an, bool iconFromTheme = false) {
|
QStringLiteral(":/icons/" #name ".png")
|
||||||
*a = new QAction(w);
|
|
||||||
if (!i.isNull())
|
#define ACTION_NAME(s) QStringLiteral(STRIFY(s))
|
||||||
(*a)->setIcon(iconFromTheme ? QIcon::fromTheme(i) : ActionManager::loadHidpiIcon(i));
|
#define STRIFY(s) #s
|
||||||
(*a)->setObjectName(an);
|
|
||||||
w->addAction(*a);
|
auto create_action = [] (QWidget *w, QAction **a, QString i, QString an, bool iconFromTheme = false) {
|
||||||
};
|
*a = new QAction(w);
|
||||||
#define CREATE_NEW_ICON_ACTION(w, a, i) create_action(w, &a, ICON_NAME(i), ACTION_NAME(a))
|
if (!i.isNull())
|
||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionActualSize, zoom-original);
|
(*a)->setIcon(iconFromTheme ? QIcon::fromTheme(i) : loadHidpiIcon(i));
|
||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionToggleMaximize, view-fullscreen);
|
(*a)->setObjectName(an);
|
||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionZoomIn, zoom-in);
|
w->addAction(*a);
|
||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionZoomOut, zoom-out);
|
};
|
||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionToggleCheckerboard, view-background-checkerboard);
|
|
||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionRotateClockwise, object-rotate-right);
|
/// This macro for register normal action.
|
||||||
#undef CREATE_NEW_ICON_ACTION
|
#define CREATE_NEW_ACTION(w, a) create_action(w, &a, QString(), ACTION_NAME(a))
|
||||||
|
/// This macro for register Qt theme action.
|
||||||
#define CREATE_NEW_ACTION(w, a) create_action(w, &a, QString(), ACTION_NAME(a))
|
#define CREATE_NEW_THEMEICON_ACTION(w, a, i) create_action(w, &a, QLatin1String(STRIFY(i)), ACTION_NAME(a), true)
|
||||||
#define CREATE_NEW_THEMEICON_ACTION(w, a, i) create_action(w, &a, QLatin1String(STRIFY(i)), ACTION_NAME(a), true)
|
/// This macro for register action with our custom icon.
|
||||||
CREATE_NEW_ACTION(mainWindow, actionRotateCounterClockwise);
|
#define CREATE_NEW_ICON_ACTION(w, a, i) create_action(w, &a, ICON_NAME(i), ACTION_NAME(a), false)
|
||||||
CREATE_NEW_ACTION(mainWindow, actionPrevPicture);
|
|
||||||
CREATE_NEW_ACTION(mainWindow, actionNextPicture);
|
CREATE_NEW_ACTION(mainWindow, actionCopyPixmap);
|
||||||
|
CREATE_NEW_ACTION(mainWindow, actionCopyFilePath);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionTogglePauseAnimation);
|
|
||||||
CREATE_NEW_ACTION(mainWindow, actionAnimationNextFrame);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionPrevPicture, go-previous);
|
||||||
|
CREATE_NEW_ICON_ACTION(mainWindow, actionNextPicture, go-next);
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionOpen, document-open);
|
|
||||||
CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionActualSize, fit-to-size);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionFitInView);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionFitToScreen, fit-to-screen);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionFitByWidth);
|
CREATE_NEW_ACTION(mainWindow, actionFitByWidth);
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionCopyPixmap, edit-copy);
|
CREATE_NEW_ACTION(mainWindow, actionFitByHeight);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionCopyFilePath);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionZoomIn, zoom-in);
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionPaste, edit-paste);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionZoomOut, zoom-out);
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionTrash, edit-delete);
|
|
||||||
CREATE_NEW_ACTION(mainWindow, actionToggleStayOnTop);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionFlipHorizontal, flip-horizontal);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionToggleProtectMode);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionFlipVertical, flip-vertical);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionToggleAvoidResetTransform);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionRotateClockwise, rotate-right);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionSettings);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionRotateCounterClockwise, rotate-left);
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionHelp, system-help);
|
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionLocateInFileManager, system-file-manager);
|
CREATE_NEW_ACTION(mainWindow, actionToggleAvoidResetTransform);
|
||||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionProperties, document-properties);
|
CREATE_NEW_ACTION(mainWindow, actionToggleCheckerboard);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionQuitApp);
|
CREATE_NEW_ACTION(mainWindow, actionTogglePauseAnimation);
|
||||||
#undef CREATE_NEW_ACTION
|
CREATE_NEW_ACTION(mainWindow, actionAnimationNextFrame);
|
||||||
#undef CREATE_NEW_THEMEICON_ACTION
|
|
||||||
|
CREATE_NEW_ACTION(mainWindow, actionTrash/*, edit-delete*/);
|
||||||
retranslateUi(mainWindow);
|
CREATE_NEW_ACTION(mainWindow, actionLocateInFileManager/*, system-file-manager*/);
|
||||||
|
CREATE_NEW_ICON_ACTION(mainWindow, actionProperties, image-info);
|
||||||
QMetaObject::connectSlotsByName(mainWindow);
|
|
||||||
}
|
CREATE_NEW_ACTION(mainWindow, actionSettings);
|
||||||
|
CREATE_NEW_ACTION(mainWindow, actionHelp/*, system-help*/);
|
||||||
void ActionManager::retranslateUi(MainWindow *mainWindow)
|
|
||||||
{
|
// Remove convenient macros
|
||||||
Q_UNUSED(mainWindow);
|
|
||||||
|
#undef CREATE_NEW_ICON_ACTION
|
||||||
actionOpen->setText(QCoreApplication::translate("MainWindow", "&Open...", nullptr));
|
#undef CREATE_NEW_THEMEICON_ACTION
|
||||||
|
#undef CREATE_NEW_ACTION
|
||||||
actionActualSize->setText(QCoreApplication::translate("MainWindow", "Actual size", nullptr));
|
|
||||||
actionToggleMaximize->setText(QCoreApplication::translate("MainWindow", "Toggle maximize", nullptr));
|
#undef STRIFY
|
||||||
actionZoomIn->setText(QCoreApplication::translate("MainWindow", "Zoom in", nullptr));
|
#undef ACTION_NAME
|
||||||
actionZoomOut->setText(QCoreApplication::translate("MainWindow", "Zoom out", nullptr));
|
#undef ICON_NAME
|
||||||
actionToggleCheckerboard->setText(QCoreApplication::translate("MainWindow", "Toggle Checkerboard", nullptr));
|
|
||||||
actionRotateClockwise->setText(QCoreApplication::translate("MainWindow", "Rotate right", nullptr));
|
// endregion
|
||||||
actionRotateCounterClockwise->setText(QCoreApplication::translate("MainWindow", "Rotate left", nullptr));
|
|
||||||
|
// region: Setup Checkable Action
|
||||||
actionPrevPicture->setText(QCoreApplication::translate("MainWindow", "Previous image", nullptr));
|
|
||||||
actionNextPicture->setText(QCoreApplication::translate("MainWindow", "Next image", nullptr));
|
actionToggleAvoidResetTransform->setCheckable(true);
|
||||||
|
actionToggleCheckerboard->setCheckable(true);
|
||||||
actionTogglePauseAnimation->setText(QCoreApplication::translate("MainWindow", "Pause/Resume Animation", nullptr));
|
actionTogglePauseAnimation->setCheckable(true);
|
||||||
actionAnimationNextFrame->setText(QCoreApplication::translate("MainWindow", "Animation Go to Next Frame", nullptr));
|
|
||||||
|
// endregion
|
||||||
actionHorizontalFlip->setText(QCoreApplication::translate("MainWindow", "Flip &Horizontally", nullptr));
|
|
||||||
actionFitInView->setText(QCoreApplication::translate("MainWindow", "Fit to view", nullptr));
|
// region: Action Translatable Text Setup
|
||||||
actionFitByWidth->setText(QCoreApplication::translate("MainWindow", "Fit to width", nullptr));
|
|
||||||
actionCopyPixmap->setText(QCoreApplication::translate("MainWindow", "Copy P&ixmap", nullptr));
|
actionCopyPixmap->setText(QCoreApplication::translate("MainWindow", "Copy P&ixmap", nullptr));
|
||||||
actionCopyFilePath->setText(QCoreApplication::translate("MainWindow", "Copy &File Path", nullptr));
|
actionCopyFilePath->setText(QCoreApplication::translate("MainWindow", "Copy &File Path", nullptr));
|
||||||
actionPaste->setText(QCoreApplication::translate("MainWindow", "&Paste", nullptr));
|
|
||||||
actionTrash->setText(QCoreApplication::translate("MainWindow", "Move to Trash", nullptr));
|
actionPrevPicture->setText(QCoreApplication::translate("MainWindow", "Previous image", nullptr));
|
||||||
actionToggleStayOnTop->setText(QCoreApplication::translate("MainWindow", "Stay on top", nullptr));
|
actionNextPicture->setText(QCoreApplication::translate("MainWindow", "Next image", nullptr));
|
||||||
actionToggleProtectMode->setText(QCoreApplication::translate("MainWindow", "Protected mode", nullptr));
|
|
||||||
actionToggleAvoidResetTransform->setText(QCoreApplication::translate("MainWindow", "Keep transformation", "The 'transformation' means the flip/rotation status that currently applied to the image view"));
|
actionActualSize->setText(QCoreApplication::translate("MainWindow", "Actual size", nullptr));
|
||||||
actionSettings->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
|
actionFitToScreen->setText(QCoreApplication::translate("MainWindow", "Fit to screen", nullptr));
|
||||||
actionHelp->setText(QCoreApplication::translate("MainWindow", "Help", nullptr));
|
actionFitByWidth->setText(QCoreApplication::translate("MainWindow", "Fit by width", nullptr));
|
||||||
#ifdef Q_OS_WIN
|
actionFitByHeight->setText(QCoreApplication::translate("MainWindow", "Fit by height", nullptr));
|
||||||
actionLocateInFileManager->setText(
|
actionZoomIn->setText(QCoreApplication::translate("MainWindow", "Zoom in", nullptr));
|
||||||
QCoreApplication::translate(
|
actionZoomOut->setText(QCoreApplication::translate("MainWindow", "Zoom out", nullptr));
|
||||||
"MainWindow", "Show in File Explorer",
|
|
||||||
"File Explorer is the name of explorer.exe under Windows"
|
actionFlipHorizontal->setText(QCoreApplication::translate("MainWindow", "Flip &Horizontally", nullptr));
|
||||||
)
|
actionFlipVertical->setText(QCoreApplication::translate("MainWindow", "Flip &Vertically", nullptr));
|
||||||
);
|
actionRotateClockwise->setText(QCoreApplication::translate("MainWindow", "Rotate right", nullptr));
|
||||||
#else
|
actionRotateCounterClockwise->setText(QCoreApplication::translate("MainWindow", "Rotate left", nullptr));
|
||||||
actionLocateInFileManager->setText(QCoreApplication::translate("MainWindow", "Show in directory", nullptr));
|
|
||||||
#endif // Q_OS_WIN
|
actionToggleAvoidResetTransform->setText(QCoreApplication::translate("MainWindow", "Keep transformation", "The 'transformation' means the flip/rotation status that currently applied to the image view"));
|
||||||
actionProperties->setText(QCoreApplication::translate("MainWindow", "Properties", nullptr));
|
actionToggleCheckerboard->setText(QCoreApplication::translate("MainWindow", "Toggle Checkerboard", nullptr));
|
||||||
actionQuitApp->setText(QCoreApplication::translate("MainWindow", "Quit", nullptr));
|
actionTogglePauseAnimation->setText(QCoreApplication::translate("MainWindow", "Pause/Resume Animation", nullptr));
|
||||||
}
|
actionAnimationNextFrame->setText(QCoreApplication::translate("MainWindow", "Animation Go to Next Frame", nullptr));
|
||||||
|
|
||||||
void ActionManager::setupShortcuts()
|
actionTrash->setText(QCoreApplication::translate("MainWindow", "Move to Trash", nullptr));
|
||||||
{
|
#ifdef Q_OS_WIN
|
||||||
actionOpen->setShortcut(QKeySequence::Open);
|
actionLocateInFileManager->setText(
|
||||||
actionActualSize->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0));
|
QCoreApplication::translate(
|
||||||
actionZoomIn->setShortcut(QKeySequence::ZoomIn);
|
"MainWindow", "Show in File Explorer",
|
||||||
actionZoomOut->setShortcut(QKeySequence::ZoomOut);
|
"File Explorer is the name of explorer.exe under Windows"
|
||||||
actionPrevPicture->setShortcuts({
|
)
|
||||||
QKeySequence(Qt::Key_PageUp),
|
);
|
||||||
QKeySequence(Qt::Key_Left),
|
#else
|
||||||
});
|
actionLocateInFileManager->setText(QCoreApplication::translate("MainWindow", "Show in directory", nullptr));
|
||||||
actionNextPicture->setShortcuts({
|
#endif // Q_OS_WIN
|
||||||
QKeySequence(Qt::Key_PageDown),
|
actionProperties->setText(QCoreApplication::translate("MainWindow", "Properties", nullptr));
|
||||||
QKeySequence(Qt::Key_Right),
|
|
||||||
});
|
actionSettings->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
|
||||||
actionHorizontalFlip->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));
|
actionHelp->setText(QCoreApplication::translate("MainWindow", "Help", nullptr));
|
||||||
actionCopyPixmap->setShortcut(QKeySequence::Copy);
|
// endregion
|
||||||
actionPaste->setShortcut(QKeySequence::Paste);
|
|
||||||
actionTrash->setShortcut(QKeySequence::Delete);
|
QMetaObject::connectSlotsByName(mainWindow);
|
||||||
actionHelp->setShortcut(QKeySequence::HelpContents);
|
}
|
||||||
actionSettings->setShortcut(QKeySequence::Preferences);
|
|
||||||
actionProperties->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I));
|
void ActionManager::setupShortcuts()
|
||||||
actionQuitApp->setShortcuts({
|
{
|
||||||
QKeySequence(Qt::Key_Space),
|
actionCopyPixmap->setShortcut(QKeySequence::Copy);
|
||||||
QKeySequence(Qt::Key_Escape)
|
|
||||||
});
|
actionPrevPicture->setShortcuts({
|
||||||
}
|
QKeySequence(Qt::Key_Left),
|
||||||
|
QKeySequence(Qt::Key_PageUp),
|
||||||
|
});
|
||||||
|
actionNextPicture->setShortcuts({
|
||||||
|
QKeySequence(Qt::Key_Right),
|
||||||
|
QKeySequence(Qt::Key_PageDown),
|
||||||
|
});
|
||||||
|
|
||||||
|
actionActualSize->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0));
|
||||||
|
actionZoomIn->setShortcut(QKeySequence::ZoomIn);
|
||||||
|
actionZoomOut->setShortcut(QKeySequence::ZoomOut);
|
||||||
|
|
||||||
|
actionTrash->setShortcut(QKeySequence::Delete);
|
||||||
|
actionProperties->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I));
|
||||||
|
|
||||||
|
actionSettings->setShortcut(QKeySequence::Preferences);
|
||||||
|
actionHelp->setShortcut(QKeySequence::HelpContents);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionManager::updateActionState(PlaylistManager* pm, GraphicsView* gv)
|
||||||
|
{
|
||||||
|
const auto* gs = gv->scene();
|
||||||
|
const auto* settings = Settings::instance();
|
||||||
|
|
||||||
|
// Update copy actions
|
||||||
|
bool canCopy = pm->currentIndex().has_value();
|
||||||
|
actionCopyPixmap->setEnabled(canCopy);
|
||||||
|
actionCopyFilePath->setEnabled(canCopy);
|
||||||
|
|
||||||
|
// Update Prev/Next Picture State
|
||||||
|
const int galleryFileCount = pm->totalCount();
|
||||||
|
const bool loopGallery = settings->loopGallery();
|
||||||
|
actionPrevPicture->setEnabled(galleryFileCount > 1 && (loopGallery || !pm->isFirstIndex()));
|
||||||
|
actionNextPicture->setEnabled(galleryFileCount > 1 && (loopGallery || !pm->isLastIndex()));
|
||||||
|
|
||||||
|
// Update Avoid Reset Transform
|
||||||
|
actionToggleAvoidResetTransform->setChecked(gv->isAvoidResetTransform());
|
||||||
|
// Update Checkerboard
|
||||||
|
actionToggleCheckerboard->setChecked(gv->isCheckerboard());
|
||||||
|
// Update Animation Graphics Action
|
||||||
|
bool canPauseAnimation = gs->canPauseAnimation();
|
||||||
|
actionTogglePauseAnimation->setEnabled(canPauseAnimation);
|
||||||
|
if (canPauseAnimation) {
|
||||||
|
actionTogglePauseAnimation->setChecked(gs->isPauseAnimation());
|
||||||
|
} else {
|
||||||
|
actionTogglePauseAnimation->setChecked(false);
|
||||||
|
}
|
||||||
|
bool canSkipAnimation = gs->canSkipAnimationFrame();
|
||||||
|
actionAnimationNextFrame->setEnabled(canSkipAnimation);
|
||||||
|
|
||||||
|
// Update trash, located in explorer and properties.
|
||||||
|
bool hasLoadedFile = pm->currentIndex().has_value();
|
||||||
|
actionTrash->setEnabled(hasLoadedFile);
|
||||||
|
actionLocateInFileManager->setEnabled(hasLoadedFile);
|
||||||
|
actionProperties->setEnabled(hasLoadedFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,58 +1,60 @@
|
|||||||
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef ACTIONMANAGER_H
|
#ifndef ACTIONMANAGER_H
|
||||||
#define ACTIONMANAGER_H
|
#define ACTIONMANAGER_H
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
class PlaylistManager;
|
||||||
class ActionManager
|
class GraphicsView;
|
||||||
{
|
|
||||||
public:
|
/// Action Manager is separated from Main Window
|
||||||
explicit ActionManager() = default;
|
/// to manage all actions specifically.
|
||||||
~ActionManager() = default;
|
class ActionManager
|
||||||
|
{
|
||||||
void setupAction(MainWindow * mainWindow);
|
public:
|
||||||
void retranslateUi(MainWindow *MainWindow);
|
explicit ActionManager() = default;
|
||||||
void setupShortcuts();
|
~ActionManager() = default;
|
||||||
|
|
||||||
static QIcon loadHidpiIcon(const QString &resp, QSize sz = QSize(32, 32));
|
void setupAction(MainWindow * mainWindow);
|
||||||
|
void setupShortcuts();
|
||||||
public:
|
|
||||||
QAction *actionOpen;
|
public slots:
|
||||||
|
void updateActionState(PlaylistManager* pm, GraphicsView* gv);
|
||||||
QAction *actionActualSize;
|
|
||||||
QAction *actionToggleMaximize;
|
public:
|
||||||
QAction *actionZoomIn;
|
QAction *actionCopyPixmap;
|
||||||
QAction *actionZoomOut;
|
QAction *actionCopyFilePath;
|
||||||
QAction *actionToggleCheckerboard;
|
|
||||||
QAction *actionRotateClockwise;
|
QAction *actionPrevPicture;
|
||||||
QAction *actionRotateCounterClockwise;
|
QAction *actionNextPicture;
|
||||||
|
|
||||||
QAction *actionPrevPicture;
|
QAction *actionActualSize;
|
||||||
QAction *actionNextPicture;
|
QAction *actionFitToScreen;
|
||||||
|
QAction *actionFitByWidth;
|
||||||
QAction *actionTogglePauseAnimation;
|
QAction *actionFitByHeight;
|
||||||
QAction *actionAnimationNextFrame;
|
QAction *actionZoomIn;
|
||||||
|
QAction *actionZoomOut;
|
||||||
QAction *actionHorizontalFlip;
|
|
||||||
QAction *actionFitInView;
|
QAction *actionFlipHorizontal;
|
||||||
QAction *actionFitByWidth;
|
QAction *actionFlipVertical;
|
||||||
QAction *actionCopyPixmap;
|
QAction *actionRotateClockwise;
|
||||||
QAction *actionCopyFilePath;
|
QAction *actionRotateCounterClockwise;
|
||||||
QAction *actionPaste;
|
|
||||||
QAction *actionTrash;
|
QAction *actionToggleAvoidResetTransform;
|
||||||
QAction *actionToggleStayOnTop;
|
QAction *actionToggleCheckerboard;
|
||||||
QAction *actionToggleProtectMode;
|
QAction *actionTogglePauseAnimation;
|
||||||
QAction *actionToggleAvoidResetTransform;
|
QAction *actionAnimationNextFrame;
|
||||||
QAction *actionSettings;
|
|
||||||
QAction *actionHelp;
|
QAction *actionTrash;
|
||||||
QAction *actionLocateInFileManager;
|
QAction *actionLocateInFileManager;
|
||||||
QAction *actionProperties;
|
QAction *actionProperties;
|
||||||
QAction *actionQuitApp;
|
|
||||||
};
|
QAction *actionSettings;
|
||||||
|
QAction *actionHelp;
|
||||||
#endif // ACTIONMANAGER_H
|
};
|
||||||
|
|
||||||
|
#endif // ACTIONMANAGER_H
|
||||||
|
|||||||
@@ -1,57 +1,45 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "bottombuttongroup.h"
|
#include "bottombuttongroup.h"
|
||||||
|
|
||||||
#include "opacityhelper.h"
|
#include <QToolButton>
|
||||||
|
#include <QVBoxLayout>
|
||||||
#include <QToolButton>
|
#include <QDebug>
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QDebug>
|
BottomButtonGroup::BottomButtonGroup(QWidget *parent)
|
||||||
|
: QGroupBox (parent)
|
||||||
BottomButtonGroup::BottomButtonGroup(const std::vector<QAction *> &actionList, QWidget *parent)
|
{
|
||||||
: QGroupBox (parent)
|
QHBoxLayout * mainLayout = new QHBoxLayout(this);
|
||||||
, m_opacityHelper(new OpacityHelper(this))
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
{
|
this->setLayout(mainLayout);
|
||||||
QHBoxLayout * mainLayout = new QHBoxLayout(this);
|
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
this->setStyleSheet(R"#(
|
||||||
this->setLayout(mainLayout);
|
BottomButtonGroup {
|
||||||
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
border-style: none;
|
||||||
this->setStyleSheet("BottomButtonGroup {"
|
background: transparent;
|
||||||
"border: 1px solid gray;"
|
}
|
||||||
"border-top-left-radius: 10px;"
|
QToolButton {
|
||||||
"border-top-right-radius: 10px;"
|
background: transparent;
|
||||||
"border-style: none;"
|
border-style: none;
|
||||||
"background-color:rgba(0,0,0,120)"
|
}
|
||||||
"}"
|
)#");
|
||||||
"QToolButton {"
|
}
|
||||||
"background:transparent;"
|
|
||||||
"}"
|
void BottomButtonGroup::addActions(const std::vector<QAction *> & actionList) {
|
||||||
"QToolButton:!focus {"
|
for (QAction * action : actionList) {
|
||||||
"border-style: none;"
|
// Create button
|
||||||
"}");
|
QToolButton * btn = new QToolButton(this);
|
||||||
|
btn->setDefaultAction(action);
|
||||||
auto newActionBtn = [this](QAction * action) -> QToolButton * {
|
btn->setIconSize(QSize(32, 32));
|
||||||
QToolButton * btn = new QToolButton(this);
|
btn->setFixedSize(40, 40);
|
||||||
btn->setDefaultAction(action);
|
// Add button
|
||||||
btn->setIconSize(QSize(32, 32));
|
layout()->addWidget(btn);
|
||||||
btn->setFixedSize(40, 40);
|
}
|
||||||
return btn;
|
updateGeometry();
|
||||||
};
|
}
|
||||||
|
|
||||||
for (QAction * action : actionList) {
|
void BottomButtonGroup::addAction(QAction* action) {
|
||||||
addButton(newActionBtn(action));
|
addActions({action});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void BottomButtonGroup::setOpacity(qreal opacity, bool animated)
|
|
||||||
{
|
|
||||||
m_opacityHelper->setOpacity(opacity, animated);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BottomButtonGroup::addButton(QAbstractButton *button)
|
|
||||||
{
|
|
||||||
layout()->addWidget(button);
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,27 +1,23 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef BOTTOMBUTTONGROUP_H
|
#ifndef BOTTOMBUTTONGROUP_H
|
||||||
#define BOTTOMBUTTONGROUP_H
|
#define BOTTOMBUTTONGROUP_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
|
||||||
class OpacityHelper;
|
class BottomButtonGroup : public QGroupBox
|
||||||
class BottomButtonGroup : public QGroupBox
|
{
|
||||||
{
|
Q_OBJECT
|
||||||
Q_OBJECT
|
public:
|
||||||
public:
|
explicit BottomButtonGroup(QWidget *parent = nullptr);
|
||||||
explicit BottomButtonGroup(const std::vector<QAction *> & actionList, QWidget *parent = nullptr);
|
|
||||||
|
void addActions(const std::vector<QAction *> & actionList);
|
||||||
void setOpacity(qreal opacity, bool animated = true);
|
void addAction(QAction* action);
|
||||||
void addButton(QAbstractButton *button);
|
};
|
||||||
|
|
||||||
private:
|
#endif // BOTTOMBUTTONGROUP_H
|
||||||
OpacityHelper * m_opacityHelper;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // BOTTOMBUTTONGROUP_H
|
|
||||||
|
|||||||
@@ -1,138 +1,138 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "exiv2wrapper.h"
|
#include "exiv2wrapper.h"
|
||||||
|
|
||||||
#ifdef HAVE_EXIV2_VERSION
|
#ifdef HAVE_EXIV2_VERSION
|
||||||
#include <exiv2/exiv2.hpp>
|
#include <exiv2/exiv2.hpp>
|
||||||
#else // HAVE_EXIV2_VERSION
|
#else // HAVE_EXIV2_VERSION
|
||||||
namespace Exiv2 {
|
namespace Exiv2 {
|
||||||
class Image {};
|
class Image {};
|
||||||
}
|
}
|
||||||
#endif // HAVE_EXIV2_VERSION
|
#endif // HAVE_EXIV2_VERSION
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Exiv2Wrapper::Exiv2Wrapper()
|
Exiv2Wrapper::Exiv2Wrapper()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Exiv2Wrapper::~Exiv2Wrapper()
|
Exiv2Wrapper::~Exiv2Wrapper()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_EXIV2_VERSION // stupid AppleClang...
|
#ifdef HAVE_EXIV2_VERSION // stupid AppleClang...
|
||||||
template<typename Collection, typename Iterator>
|
template<typename Collection, typename Iterator>
|
||||||
void Exiv2Wrapper::cacheSection(Collection collection)
|
void Exiv2Wrapper::cacheSection(Collection collection)
|
||||||
{
|
{
|
||||||
const Collection& exifData = collection;
|
const Collection& exifData = collection;
|
||||||
Iterator it = exifData.begin(), end = exifData.end();
|
Iterator it = exifData.begin(), end = exifData.end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
QString key = QString::fromUtf8(it->key().c_str());
|
QString key = QString::fromUtf8(it->key().c_str());
|
||||||
if (it->tagName().substr(0, 2) == "0x") continue;
|
if (it->tagName().substr(0, 2) == "0x") continue;
|
||||||
// We might get exceptions like "No namespace info available for XMP prefix `Item'"
|
// We might get exceptions like "No namespace info available for XMP prefix `Item'"
|
||||||
// when trying to get tagLabel() data from a Xmpdatum if the tag is not common-used.
|
// when trying to get tagLabel() data from a Xmpdatum if the tag is not common-used.
|
||||||
// We don't care for those rare tags so let's just use a try-cache...
|
// We don't care for those rare tags so let's just use a try-cache...
|
||||||
try {
|
try {
|
||||||
QString label = QString::fromLocal8Bit(it->tagLabel().c_str());
|
QString label = QString::fromLocal8Bit(it->tagLabel().c_str());
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << *it;
|
stream << *it;
|
||||||
QString value = QString::fromUtf8(stream.str().c_str());
|
QString value = QString::fromUtf8(stream.str().c_str());
|
||||||
m_metadataValue.insert(key, value);
|
m_metadataValue.insert(key, value);
|
||||||
m_metadataLabel.insert(key, label);
|
m_metadataLabel.insert(key, label);
|
||||||
qDebug() << key << label << value;
|
qDebug() << key << label << value;
|
||||||
#if EXIV2_TEST_VERSION(0, 28, 0)
|
#if EXIV2_TEST_VERSION(0, 28, 0)
|
||||||
} catch (Exiv2::Error & err) {
|
} catch (Exiv2::Error & err) {
|
||||||
#else // 0.27.x
|
#else // 0.27.x
|
||||||
} catch (Exiv2::AnyError & err) {
|
} catch (Exiv2::AnyError & err) {
|
||||||
#endif // EXIV2_TEST_VERSION(0, 28, 0)
|
#endif // EXIV2_TEST_VERSION(0, 28, 0)
|
||||||
qWarning() << "Error loading key" << key << ":" << err.what();
|
qWarning() << "Error loading key" << key << ":" << err.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_EXIV2_VERSION
|
#endif // HAVE_EXIV2_VERSION
|
||||||
|
|
||||||
bool Exiv2Wrapper::load(const QString &filePath)
|
bool Exiv2Wrapper::load(const QString &filePath)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_EXIV2_VERSION
|
#ifdef HAVE_EXIV2_VERSION
|
||||||
QByteArray filePathByteArray = QFile::encodeName(filePath);
|
QByteArray filePathByteArray = QFile::encodeName(filePath);
|
||||||
try {
|
try {
|
||||||
m_exivImage.reset(Exiv2::ImageFactory::open(filePathByteArray.constData()).release());
|
m_exivImage.reset(Exiv2::ImageFactory::open(filePathByteArray.constData()).release());
|
||||||
m_exivImage->readMetadata();
|
m_exivImage->readMetadata();
|
||||||
} catch (const Exiv2::Error& error) {
|
} catch (const Exiv2::Error& error) {
|
||||||
m_errMsg = QString::fromUtf8(error.what());
|
m_errMsg = QString::fromUtf8(error.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
#else // HAVE_EXIV2_VERSION
|
#else // HAVE_EXIV2_VERSION
|
||||||
Q_UNUSED(filePath);
|
Q_UNUSED(filePath);
|
||||||
return false;
|
return false;
|
||||||
#endif // HAVE_EXIV2_VERSION
|
#endif // HAVE_EXIV2_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
void Exiv2Wrapper::cacheSections()
|
void Exiv2Wrapper::cacheSections()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_EXIV2_VERSION
|
#ifdef HAVE_EXIV2_VERSION
|
||||||
if (m_exivImage->checkMode(Exiv2::mdExif) & Exiv2::amRead) {
|
if (m_exivImage->checkMode(Exiv2::mdExif) & Exiv2::amRead) {
|
||||||
cacheSection<Exiv2::ExifData, Exiv2::ExifData::const_iterator>(m_exivImage->exifData());
|
cacheSection<Exiv2::ExifData, Exiv2::ExifData::const_iterator>(m_exivImage->exifData());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_exivImage->checkMode(Exiv2::mdIptc) & Exiv2::amRead) {
|
if (m_exivImage->checkMode(Exiv2::mdIptc) & Exiv2::amRead) {
|
||||||
cacheSection<Exiv2::IptcData, Exiv2::IptcData::const_iterator>(m_exivImage->iptcData());
|
cacheSection<Exiv2::IptcData, Exiv2::IptcData::const_iterator>(m_exivImage->iptcData());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_exivImage->checkMode(Exiv2::mdXmp) & Exiv2::amRead) {
|
if (m_exivImage->checkMode(Exiv2::mdXmp) & Exiv2::amRead) {
|
||||||
cacheSection<Exiv2::XmpData, Exiv2::XmpData::const_iterator>(m_exivImage->xmpData());
|
cacheSection<Exiv2::XmpData, Exiv2::XmpData::const_iterator>(m_exivImage->xmpData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// qDebug() << m_metadataValue;
|
// qDebug() << m_metadataValue;
|
||||||
// qDebug() << m_metadataLabel;
|
// qDebug() << m_metadataLabel;
|
||||||
#endif // HAVE_EXIV2_VERSION
|
#endif // HAVE_EXIV2_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Exiv2Wrapper::comment() const
|
QString Exiv2Wrapper::comment() const
|
||||||
{
|
{
|
||||||
#ifdef HAVE_EXIV2_VERSION
|
#ifdef HAVE_EXIV2_VERSION
|
||||||
return m_exivImage->comment().c_str();
|
return m_exivImage->comment().c_str();
|
||||||
#else // HAVE_EXIV2_VERSION
|
#else // HAVE_EXIV2_VERSION
|
||||||
return QString();
|
return QString();
|
||||||
#endif // HAVE_EXIV2_VERSION
|
#endif // HAVE_EXIV2_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Exiv2Wrapper::label(const QString &key) const
|
QString Exiv2Wrapper::label(const QString &key) const
|
||||||
{
|
{
|
||||||
return m_metadataLabel.value(key);
|
return m_metadataLabel.value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Exiv2Wrapper::value(const QString &key) const
|
QString Exiv2Wrapper::value(const QString &key) const
|
||||||
{
|
{
|
||||||
return m_metadataValue.value(key);
|
return m_metadataValue.value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Exiv2Wrapper::XmpValue(const QString &rawValue)
|
QString Exiv2Wrapper::XmpValue(const QString &rawValue)
|
||||||
{
|
{
|
||||||
QString ignored;
|
QString ignored;
|
||||||
return Exiv2Wrapper::XmpValue(rawValue, ignored);
|
return Exiv2Wrapper::XmpValue(rawValue, ignored);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Exiv2Wrapper::XmpValue(const QString &rawValue, QString &language)
|
QString Exiv2Wrapper::XmpValue(const QString &rawValue, QString &language)
|
||||||
{
|
{
|
||||||
if (rawValue.size() > 6 && rawValue.startsWith(QLatin1String("lang=\""))) {
|
if (rawValue.size() > 6 && rawValue.startsWith(QLatin1String("lang=\""))) {
|
||||||
int pos = rawValue.indexOf('"', 6);
|
int pos = rawValue.indexOf('"', 6);
|
||||||
|
|
||||||
if (pos != -1) {
|
if (pos != -1) {
|
||||||
language = rawValue.mid(6, pos - 6);
|
language = rawValue.mid(6, pos - 6);
|
||||||
return (rawValue.mid(pos + 2));
|
return (rawValue.mid(pos + 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
language.clear();
|
language.clear();
|
||||||
return rawValue;
|
return rawValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,43 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef EXIV2WRAPPER_H
|
#ifndef EXIV2WRAPPER_H
|
||||||
#define EXIV2WRAPPER_H
|
#define EXIV2WRAPPER_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
namespace Exiv2 {
|
namespace Exiv2 {
|
||||||
class Image;
|
class Image;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Exiv2Wrapper
|
class Exiv2Wrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Exiv2Wrapper();
|
Exiv2Wrapper();
|
||||||
~Exiv2Wrapper();
|
~Exiv2Wrapper();
|
||||||
|
|
||||||
bool load(const QString& filePath);
|
bool load(const QString& filePath);
|
||||||
void cacheSections();
|
void cacheSections();
|
||||||
|
|
||||||
QString comment() const;
|
QString comment() const;
|
||||||
QString label(const QString & key) const;
|
QString label(const QString & key) const;
|
||||||
QString value(const QString & key) const;
|
QString value(const QString & key) const;
|
||||||
|
|
||||||
static QString XmpValue(const QString &rawValue);
|
static QString XmpValue(const QString &rawValue);
|
||||||
static QString XmpValue(const QString &rawValue, QString & language);
|
static QString XmpValue(const QString &rawValue, QString & language);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Exiv2::Image> m_exivImage;
|
std::unique_ptr<Exiv2::Image> m_exivImage;
|
||||||
QMap<QString, QString> m_metadataValue;
|
QMap<QString, QString> m_metadataValue;
|
||||||
QMap<QString, QString> m_metadataLabel;
|
QMap<QString, QString> m_metadataLabel;
|
||||||
QString m_errMsg;
|
QString m_errMsg;
|
||||||
|
|
||||||
template<typename Collection, typename Iterator>
|
template<typename Collection, typename Iterator>
|
||||||
void cacheSection(Collection collection);
|
void cacheSection(Collection collection);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXIV2WRAPPER_H
|
#endif // EXIV2WRAPPER_H
|
||||||
|
|||||||
@@ -1,136 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
||||||
// SPDX-FileCopyrightText: 2023 Tad Young <yyc12321@outlook.com>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#include "framelesswindow.h"
|
|
||||||
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QHoverEvent>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QWindow>
|
|
||||||
|
|
||||||
FramelessWindow::FramelessWindow(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
, m_centralLayout(new QVBoxLayout(this))
|
|
||||||
, m_oldCursorShape(Qt::ArrowCursor)
|
|
||||||
, m_oldEdges()
|
|
||||||
{
|
|
||||||
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint);
|
|
||||||
this->setMouseTracking(true);
|
|
||||||
this->setAttribute(Qt::WA_Hover, true);
|
|
||||||
this->installEventFilter(this);
|
|
||||||
|
|
||||||
m_centralLayout->setContentsMargins(QMargins());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessWindow::setCentralWidget(QWidget *widget)
|
|
||||||
{
|
|
||||||
if (m_centralWidget) {
|
|
||||||
m_centralLayout->removeWidget(m_centralWidget);
|
|
||||||
m_centralWidget->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_centralLayout->addWidget(widget);
|
|
||||||
m_centralWidget = widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessWindow::installResizeCapture(QObject* widget)
|
|
||||||
{
|
|
||||||
widget->installEventFilter(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessWindow::eventFilter(QObject* o, QEvent* e)
|
|
||||||
{
|
|
||||||
switch (e->type()) {
|
|
||||||
case QEvent::HoverMove:
|
|
||||||
{
|
|
||||||
QWidget* wg = qobject_cast<QWidget*>(o);
|
|
||||||
if (wg != nullptr)
|
|
||||||
return mouseHover(static_cast<QHoverEvent*>(e), wg);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case QEvent::MouseButtonPress:
|
|
||||||
return mousePress(static_cast<QMouseEvent*>(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
return QWidget::eventFilter(o, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessWindow::mouseHover(QHoverEvent* event, QWidget* wg)
|
|
||||||
{
|
|
||||||
if (!isMaximized() && !isFullScreen()) {
|
|
||||||
QWindow* win = window()->windowHandle();
|
|
||||||
Qt::Edges edges = this->getEdgesByPos(wg->mapToGlobal(event->oldPos()), win->frameGeometry());
|
|
||||||
|
|
||||||
// backup & restore cursor shape
|
|
||||||
if (edges && !m_oldEdges)
|
|
||||||
// entering the edge. backup cursor shape
|
|
||||||
m_oldCursorShape = win->cursor().shape();
|
|
||||||
if (!edges && m_oldEdges)
|
|
||||||
// leaving the edge. restore cursor shape
|
|
||||||
win->setCursor(m_oldCursorShape);
|
|
||||||
|
|
||||||
// save the latest edges status
|
|
||||||
m_oldEdges = edges;
|
|
||||||
|
|
||||||
// show resize cursor shape if cursor is within border
|
|
||||||
if (edges) {
|
|
||||||
win->setCursor(this->getCursorByEdge(edges, Qt::ArrowCursor));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FramelessWindow::mousePress(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (event->buttons() & Qt::LeftButton && !isMaximized() && !isFullScreen()) {
|
|
||||||
QWindow* win = window()->windowHandle();
|
|
||||||
Qt::Edges edges = this->getEdgesByPos(event->globalPosition().toPoint(), win->frameGeometry());
|
|
||||||
if (edges) {
|
|
||||||
win->startSystemResize(edges);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::CursorShape FramelessWindow::getCursorByEdge(const Qt::Edges& edges, Qt::CursorShape default_cursor)
|
|
||||||
{
|
|
||||||
if ((edges == (Qt::TopEdge | Qt::LeftEdge)) || (edges == (Qt::RightEdge | Qt::BottomEdge)))
|
|
||||||
return Qt::SizeFDiagCursor;
|
|
||||||
else if ((edges == (Qt::TopEdge | Qt::RightEdge)) || (edges == (Qt::LeftEdge | Qt::BottomEdge)))
|
|
||||||
return Qt::SizeBDiagCursor;
|
|
||||||
else if (edges & (Qt::TopEdge | Qt::BottomEdge))
|
|
||||||
return Qt::SizeVerCursor;
|
|
||||||
else if (edges & (Qt::LeftEdge | Qt::RightEdge))
|
|
||||||
return Qt::SizeHorCursor;
|
|
||||||
else
|
|
||||||
return default_cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::Edges FramelessWindow::getEdgesByPos(const QPoint gpos, const QRect& winrect)
|
|
||||||
{
|
|
||||||
const int borderWidth = 8;
|
|
||||||
Qt::Edges edges;
|
|
||||||
|
|
||||||
int x = gpos.x() - winrect.x();
|
|
||||||
int y = gpos.y() - winrect.y();
|
|
||||||
|
|
||||||
if (x < borderWidth)
|
|
||||||
edges |= Qt::LeftEdge;
|
|
||||||
if (x > (winrect.width() - borderWidth))
|
|
||||||
edges |= Qt::RightEdge;
|
|
||||||
if (y < borderWidth)
|
|
||||||
edges |= Qt::TopEdge;
|
|
||||||
if (y > (winrect.height() - borderWidth))
|
|
||||||
edges |= Qt::BottomEdge;
|
|
||||||
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#ifndef FRAMELESSWINDOW_H
|
|
||||||
#define FRAMELESSWINDOW_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QVBoxLayout;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class FramelessWindow : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit FramelessWindow(QWidget *parent = nullptr);
|
|
||||||
|
|
||||||
void setCentralWidget(QWidget * widget);
|
|
||||||
void installResizeCapture(QObject* widget);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool eventFilter(QObject *o, QEvent *e) override;
|
|
||||||
bool mouseHover(QHoverEvent* event, QWidget* wg);
|
|
||||||
bool mousePress(QMouseEvent* event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Qt::Edges m_oldEdges;
|
|
||||||
Qt::CursorShape m_oldCursorShape;
|
|
||||||
|
|
||||||
Qt::CursorShape getCursorByEdge(const Qt::Edges& edges, Qt::CursorShape default_cursor);
|
|
||||||
Qt::Edges getEdgesByPos(const QPoint pos, const QRect& winrect);
|
|
||||||
|
|
||||||
QVBoxLayout * m_centralLayout = nullptr;
|
|
||||||
QWidget * m_centralWidget = nullptr; // just a pointer, doesn't take the ownership.
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // FRAMELESSWINDOW_H
|
|
||||||
@@ -4,6 +4,11 @@
|
|||||||
|
|
||||||
#include "graphicsscene.h"
|
#include "graphicsscene.h"
|
||||||
|
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include <QStyleHints>
|
||||||
|
#include <QOperatingSystemVersion>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -14,6 +19,33 @@
|
|||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
static const QColor& ColorSchemaToTextForeground(Qt::ColorScheme colorScheme) {
|
||||||
|
// YYC MARK:
|
||||||
|
// If we are using Windows 10 and lower system or Qt which do not support "Windows 11"
|
||||||
|
// theme (lower than Qt 6.7), we should only support light mode.
|
||||||
|
// Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11.
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
|
colorScheme = Qt::ColorScheme::Light;
|
||||||
|
#else
|
||||||
|
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) {
|
||||||
|
colorScheme = Qt::ColorScheme::Light;
|
||||||
|
}
|
||||||
|
#endif // QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
|
#endif // defined(Q_OS_WIN)
|
||||||
|
|
||||||
|
switch (colorScheme) {
|
||||||
|
case Qt::ColorScheme::Dark:
|
||||||
|
static QColor WHITE = QColor("White");
|
||||||
|
return WHITE;
|
||||||
|
case Qt::ColorScheme::Light:
|
||||||
|
case Qt::ColorScheme::Unknown:
|
||||||
|
default:
|
||||||
|
static QColor BLACK = QColor("Black");
|
||||||
|
return BLACK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PGraphicsPixmapItem : public QGraphicsPixmapItem
|
class PGraphicsPixmapItem : public QGraphicsPixmapItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -97,7 +129,8 @@ private:
|
|||||||
GraphicsScene::GraphicsScene(QObject *parent)
|
GraphicsScene::GraphicsScene(QObject *parent)
|
||||||
: QGraphicsScene(parent)
|
: QGraphicsScene(parent)
|
||||||
{
|
{
|
||||||
showText(tr("Drag image here"));
|
showText(tr("Drag image here", "The same meaning of MainWindow's hint."));
|
||||||
|
connect(qGuiApp->styleHints(), &QStyleHints::colorSchemeChanged, this, &GraphicsScene::updateStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsScene::~GraphicsScene()
|
GraphicsScene::~GraphicsScene()
|
||||||
@@ -119,7 +152,7 @@ void GraphicsScene::showText(const QString &text)
|
|||||||
{
|
{
|
||||||
this->clear();
|
this->clear();
|
||||||
QGraphicsTextItem * textItem = this->addText(text);
|
QGraphicsTextItem * textItem = this->addText(text);
|
||||||
textItem->setDefaultTextColor(QColor("White"));
|
textItem->setDefaultTextColor(ColorSchemaToTextForeground(qGuiApp->styleHints()->colorScheme()));
|
||||||
m_theThing = textItem;
|
m_theThing = textItem;
|
||||||
this->setSceneRect(m_theThing->boundingRect());
|
this->setSceneRect(m_theThing->boundingRect());
|
||||||
}
|
}
|
||||||
@@ -130,10 +163,9 @@ void GraphicsScene::showSvg(const QString &filepath)
|
|||||||
QGraphicsSvgItem * svgItem = new QGraphicsSvgItem();
|
QGraphicsSvgItem * svgItem = new QGraphicsSvgItem();
|
||||||
QSvgRenderer * render = new QSvgRenderer(svgItem);
|
QSvgRenderer * render = new QSvgRenderer(svgItem);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
||||||
// Qt 6.7.0's SVG support is terrible caused by huge memory usage, see QTBUG-124287
|
if (Settings::instance()->svgTiny12Only()) {
|
||||||
// Qt 6.7.1's is somewhat better, memory issue seems fixed, but still laggy when zoom in,
|
render->setOptions(QtSvg::Tiny12FeaturesOnly);
|
||||||
// see QTBUG-126771. Anyway let's disable it for now.
|
}
|
||||||
render->setOptions(QtSvg::Tiny12FeaturesOnly);
|
|
||||||
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
||||||
render->load(filepath);
|
render->load(filepath);
|
||||||
svgItem->setSharedRenderer(render);
|
svgItem->setSharedRenderer(render);
|
||||||
@@ -168,27 +200,57 @@ bool GraphicsScene::trySetTransformationMode(Qt::TransformationMode mode, float
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch graphics item as our custom animated item.
|
||||||
|
/// Return nullptr means this item is not animated item.
|
||||||
|
static PGraphicsMovieItem* fetchAnimatedItem(QGraphicsItem *item) {
|
||||||
|
return qgraphicsitem_cast<PGraphicsMovieItem *>(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GraphicsScene::canPauseAnimation() const {
|
||||||
|
return fetchAnimatedItem(m_theThing) != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GraphicsScene::isPauseAnimation() const {
|
||||||
|
auto* animatedItem = fetchAnimatedItem(m_theThing);
|
||||||
|
if (animatedItem != nullptr) {
|
||||||
|
return animatedItem->movie()->state() == QMovie::Paused;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GraphicsScene::togglePauseAnimation()
|
bool GraphicsScene::togglePauseAnimation()
|
||||||
{
|
{
|
||||||
PGraphicsMovieItem * animatedItem = qgraphicsitem_cast<PGraphicsMovieItem *>(m_theThing);
|
auto* animatedItem = fetchAnimatedItem(m_theThing);
|
||||||
if (animatedItem) {
|
if (animatedItem != nullptr) {
|
||||||
animatedItem->movie()->setPaused(animatedItem->movie()->state() != QMovie::Paused);
|
animatedItem->movie()->setPaused(animatedItem->movie()->state() != QMovie::Paused);
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
bool GraphicsScene::canSkipAnimationFrame() const {
|
||||||
|
return isPauseAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsScene::skipAnimationFrame(int delta)
|
bool GraphicsScene::skipAnimationFrame(int delta)
|
||||||
{
|
{
|
||||||
PGraphicsMovieItem * animatedItem = qgraphicsitem_cast<PGraphicsMovieItem *>(m_theThing);
|
auto* animatedItem = fetchAnimatedItem(m_theThing);
|
||||||
if (animatedItem) {
|
|
||||||
const int frameCount = animatedItem->movie()->frameCount();
|
// Only paused animated item can skip frame
|
||||||
const int currentFrame = animatedItem->movie()->currentFrameNumber();
|
if (animatedItem == nullptr) {
|
||||||
const int targetFrame = (currentFrame + delta) % frameCount;
|
return false;
|
||||||
animatedItem->movie()->setPaused(true);
|
|
||||||
return animatedItem->movie()->jumpToFrame(targetFrame);
|
|
||||||
}
|
}
|
||||||
return false;
|
if (animatedItem->movie()->state() != QMovie::Paused) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform skip
|
||||||
|
const int frameCount = animatedItem->movie()->frameCount();
|
||||||
|
const int currentFrame = animatedItem->movie()->currentFrameNumber();
|
||||||
|
const int targetFrame = (currentFrame + delta) % frameCount;
|
||||||
|
return animatedItem->movie()->jumpToFrame(targetFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap GraphicsScene::renderToPixmap()
|
QPixmap GraphicsScene::renderToPixmap()
|
||||||
@@ -205,3 +267,14 @@ QPixmap GraphicsScene::renderToPixmap()
|
|||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsScene::updateStyle(Qt::ColorScheme colorScheme) {
|
||||||
|
Q_UNUSED(colorScheme)
|
||||||
|
|
||||||
|
QGraphicsItem * item = this->m_theThing;
|
||||||
|
if (item == nullptr) return;
|
||||||
|
QGraphicsTextItem * textItem = qgraphicsitem_cast<QGraphicsTextItem*>(item);
|
||||||
|
if (textItem == nullptr) return;
|
||||||
|
|
||||||
|
textItem->setDefaultTextColor(ColorSchemaToTextForeground(colorScheme));
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,11 +21,26 @@ public:
|
|||||||
|
|
||||||
bool trySetTransformationMode(Qt::TransformationMode mode, float scaleHint);
|
bool trySetTransformationMode(Qt::TransformationMode mode, float scaleHint);
|
||||||
|
|
||||||
|
/// Check whether current thing is animation.
|
||||||
|
/// Only animation thing can be paused.
|
||||||
|
bool canPauseAnimation() const;
|
||||||
|
/// Check whether we are pasuing an animation graphics.
|
||||||
|
bool isPauseAnimation() const;
|
||||||
|
/// Toggle animation graphics pause state.
|
||||||
|
/// Return true for successfully toggle, otherwise false.
|
||||||
bool togglePauseAnimation();
|
bool togglePauseAnimation();
|
||||||
|
/// Check whether we can skip animation frame.
|
||||||
|
/// Only paused animation graphics can skip frame.
|
||||||
|
bool canSkipAnimationFrame() const;
|
||||||
|
/// Skip paused animation graphics with given frame.
|
||||||
|
/// Return true for successfully skip, otherwise false.
|
||||||
bool skipAnimationFrame(int delta = 1);
|
bool skipAnimationFrame(int delta = 1);
|
||||||
|
|
||||||
QPixmap renderToPixmap();
|
QPixmap renderToPixmap();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateStyle(Qt::ColorScheme colorScheme);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsItem * m_theThing = nullptr;
|
QGraphicsItem * m_theThing = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,371 +1,517 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "graphicsview.h"
|
#include "graphicsview.h"
|
||||||
|
|
||||||
#include "graphicsscene.h"
|
#include "graphicsscene.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QStyleHints>
|
||||||
#include <QMouseEvent>
|
#include <QOperatingSystemVersion>
|
||||||
#include <QScrollBar>
|
#include <QDebug>
|
||||||
#include <QMimeData>
|
#include <QColorSpace>
|
||||||
#include <QImageReader>
|
#include <QMouseEvent>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QScrollBar>
|
||||||
|
#include <QMimeData>
|
||||||
GraphicsView::GraphicsView(QWidget *parent)
|
#include <QImageReader>
|
||||||
: QGraphicsView (parent)
|
#include <QStyleOptionGraphicsItem>
|
||||||
{
|
|
||||||
setDragMode(QGraphicsView::ScrollHandDrag);
|
GraphicsView::GraphicsView(QWidget *parent)
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
: QGraphicsView (parent)
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
{
|
||||||
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
setDragMode(QGraphicsView::ScrollHandDrag);
|
||||||
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setStyleSheet("background-color: rgba(0, 0, 0, 220);"
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
"border-radius: 3px;");
|
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
setAcceptDrops(false);
|
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
setCheckerboardEnabled(false);
|
setAcceptDrops(false);
|
||||||
|
setCheckerboardEnabled(false);
|
||||||
connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, &GraphicsView::viewportRectChanged);
|
|
||||||
connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &GraphicsView::viewportRectChanged);
|
updateStyle(qGuiApp->styleHints()->colorScheme());
|
||||||
}
|
connect(qGuiApp->styleHints(), &QStyleHints::colorSchemeChanged, this, &GraphicsView::updateStyle);
|
||||||
|
|
||||||
void GraphicsView::showFileFromPath(const QString &filePath)
|
connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, &GraphicsView::viewportRectChanged);
|
||||||
{
|
connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &GraphicsView::viewportRectChanged);
|
||||||
emit navigatorViewRequired(false, transform());
|
}
|
||||||
|
|
||||||
if (filePath.endsWith(".svg")) {
|
void GraphicsView::showFileFromPath(const QString &filePath)
|
||||||
showSvg(filePath);
|
{
|
||||||
} else {
|
emit navigatorViewRequired(false, transform());
|
||||||
QImageReader imageReader(filePath);
|
|
||||||
imageReader.setAutoTransform(true);
|
if (filePath.endsWith(".svg")) {
|
||||||
imageReader.setDecideFormatFromContent(true);
|
showSvg(filePath);
|
||||||
imageReader.setAllocationLimit(0);
|
} else {
|
||||||
|
QImageReader imageReader(filePath);
|
||||||
// Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
|
imageReader.setAutoTransform(true);
|
||||||
// So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file.
|
imageReader.setDecideFormatFromContent(true);
|
||||||
// QImage::Format imageFormat = imageReader.imageFormat();
|
imageReader.setAllocationLimit(0);
|
||||||
if (imageReader.format().isEmpty()) {
|
|
||||||
showText(tr("File is not a valid image"));
|
// Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
|
||||||
} else if (imageReader.supportsAnimation() && imageReader.imageCount() > 1) {
|
// So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file.
|
||||||
showAnimated(filePath);
|
// QImage::Format imageFormat = imageReader.imageFormat();
|
||||||
} else if (!imageReader.canRead()) {
|
if (imageReader.format().isEmpty()) {
|
||||||
showText(tr("Image data is invalid or currently unsupported"));
|
showText(tr("File is not a valid image"));
|
||||||
} else {
|
} else if (imageReader.supportsAnimation() && imageReader.imageCount() > 1) {
|
||||||
QPixmap && pixmap = QPixmap::fromImageReader(&imageReader);
|
showAnimated(filePath);
|
||||||
if (pixmap.isNull()) {
|
} else if (!imageReader.canRead()) {
|
||||||
showText(tr("Image data is invalid or currently unsupported"));
|
showText(tr("Image data is invalid or currently unsupported"));
|
||||||
} else {
|
} else {
|
||||||
pixmap.setDevicePixelRatio(devicePixelRatioF());
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
showImage(pixmap);
|
QImage && img = imageReader.read();
|
||||||
}
|
if (img.isNull()) {
|
||||||
}
|
showText(tr("Image data is invalid or currently unsupported"));
|
||||||
}
|
} else {
|
||||||
}
|
if (img.format() == QImage::Format_CMYK8888) {
|
||||||
|
img.convertToColorSpace(QColorSpace::SRgb);
|
||||||
void GraphicsView::showImage(const QPixmap &pixmap)
|
}
|
||||||
{
|
img.setDevicePixelRatio(devicePixelRatioF());
|
||||||
resetTransform();
|
showImage(img);
|
||||||
scene()->showImage(pixmap);
|
}
|
||||||
displayScene();
|
#else
|
||||||
}
|
QPixmap && pixmap = QPixmap::fromImageReader(&imageReader);
|
||||||
|
if (pixmap.isNull()) {
|
||||||
void GraphicsView::showImage(const QImage &image)
|
showText(tr("Image data is invalid or currently unsupported"));
|
||||||
{
|
} else {
|
||||||
resetTransform();
|
pixmap.setDevicePixelRatio(devicePixelRatioF());
|
||||||
scene()->showImage(QPixmap::fromImage(image));
|
showImage(pixmap);
|
||||||
displayScene();
|
}
|
||||||
}
|
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||||
|
}
|
||||||
void GraphicsView::showText(const QString &text)
|
}
|
||||||
{
|
}
|
||||||
resetTransform();
|
|
||||||
scene()->showText(text);
|
void GraphicsView::showImage(const QPixmap &pixmap)
|
||||||
displayScene();
|
{
|
||||||
}
|
resetTransform();
|
||||||
|
scene()->showImage(pixmap);
|
||||||
void GraphicsView::showSvg(const QString &filepath)
|
displayScene();
|
||||||
{
|
}
|
||||||
resetTransform();
|
|
||||||
scene()->showSvg(filepath);
|
void GraphicsView::showImage(const QImage &image)
|
||||||
displayScene();
|
{
|
||||||
}
|
resetTransform();
|
||||||
|
scene()->showImage(QPixmap::fromImage(image));
|
||||||
void GraphicsView::showAnimated(const QString &filepath)
|
displayScene();
|
||||||
{
|
}
|
||||||
resetTransform();
|
|
||||||
scene()->showAnimated(filepath);
|
void GraphicsView::showText(const QString &text)
|
||||||
displayScene();
|
{
|
||||||
}
|
resetTransform();
|
||||||
|
scene()->showText(text);
|
||||||
GraphicsScene *GraphicsView::scene() const
|
displayScene();
|
||||||
{
|
}
|
||||||
return qobject_cast<GraphicsScene*>(QGraphicsView::scene());
|
|
||||||
}
|
void GraphicsView::showSvg(const QString &filepath)
|
||||||
|
{
|
||||||
void GraphicsView::setScene(GraphicsScene *scene)
|
resetTransform();
|
||||||
{
|
scene()->showSvg(filepath);
|
||||||
return QGraphicsView::setScene(scene);
|
displayScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal GraphicsView::scaleFactor() const
|
void GraphicsView::showAnimated(const QString &filepath)
|
||||||
{
|
{
|
||||||
return QStyleOptionGraphicsItem::levelOfDetailFromTransform(transform());
|
resetTransform();
|
||||||
}
|
scene()->showAnimated(filepath);
|
||||||
|
displayScene();
|
||||||
void GraphicsView::resetTransform()
|
}
|
||||||
{
|
|
||||||
if (!shouldAvoidTransform()) {
|
GraphicsScene *GraphicsView::scene() const
|
||||||
QGraphicsView::resetTransform();
|
{
|
||||||
}
|
return qobject_cast<GraphicsScene*>(QGraphicsView::scene());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsView::zoomView(qreal scaleFactor)
|
void GraphicsView::setScene(GraphicsScene *scene)
|
||||||
{
|
{
|
||||||
m_enableFitInView = false;
|
return QGraphicsView::setScene(scene);
|
||||||
scale(scaleFactor, scaleFactor);
|
}
|
||||||
applyTransformationModeByScaleFactor();
|
|
||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
qreal GraphicsView::scaleFactor() const
|
||||||
}
|
{
|
||||||
|
return QStyleOptionGraphicsItem::levelOfDetailFromTransform(transform());
|
||||||
// This is always according to user's view.
|
}
|
||||||
// the direction of the rotation will NOT be clockwise because the y-axis points downwards.
|
|
||||||
void GraphicsView::rotateView(bool clockwise)
|
void GraphicsView::resetTransform()
|
||||||
{
|
{
|
||||||
resetScale();
|
if (!shouldAvoidTransform()) {
|
||||||
|
QGraphicsView::resetTransform();
|
||||||
QTransform tf(0, clockwise ? 1 : -1, 0,
|
}
|
||||||
clockwise ? -1 : 1, 0, 0,
|
}
|
||||||
0, 0, 1);
|
|
||||||
tf = transform() * tf;
|
void GraphicsView::zoomView(qreal scaleFactor)
|
||||||
setTransform(tf);
|
{
|
||||||
}
|
m_enableFitToScreen = false;
|
||||||
|
scale(scaleFactor, scaleFactor);
|
||||||
void GraphicsView::flipView(bool horizontal)
|
applyTransformationModeByScaleFactor();
|
||||||
{
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
QTransform tf(horizontal ? -1 : 1, 0, 0,
|
}
|
||||||
0, horizontal ? 1 : -1, 0,
|
|
||||||
0, 0, 1);
|
// This is always according to user's view.
|
||||||
tf = transform() * tf;
|
// the direction of the rotation will NOT be clockwise because the y-axis points downwards.
|
||||||
setTransform(tf);
|
void GraphicsView::rotateView(bool clockwise)
|
||||||
|
{
|
||||||
// Ensure the navigation view is also flipped.
|
resetScale();
|
||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
|
||||||
}
|
QTransform tf(0, clockwise ? 1 : -1, 0,
|
||||||
|
clockwise ? -1 : 1, 0, 0,
|
||||||
void GraphicsView::resetScale()
|
0, 0, 1);
|
||||||
{
|
tf = transform() * tf;
|
||||||
setTransform(resetScale(transform()));
|
setTransform(tf);
|
||||||
applyTransformationModeByScaleFactor();
|
|
||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
// Apply transformation mode but don't emit navigator signal here
|
||||||
}
|
// Let displayScene() handle the navigator visibility correctly
|
||||||
|
applyTransformationModeByScaleFactor();
|
||||||
void GraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode)
|
}
|
||||||
{
|
|
||||||
QGraphicsView::fitInView(rect, aspectRadioMode);
|
void GraphicsView::flipView(bool horizontal)
|
||||||
applyTransformationModeByScaleFactor();
|
{
|
||||||
}
|
QTransform tf(horizontal ? -1 : 1, 0, 0,
|
||||||
|
0, horizontal ? 1 : -1, 0,
|
||||||
void GraphicsView::fitByOrientation(Qt::Orientation ori, bool scaleDownOnly)
|
0, 0, 1);
|
||||||
{
|
tf = transform() * tf;
|
||||||
resetScale();
|
setTransform(tf);
|
||||||
|
|
||||||
QRectF viewRect = this->viewport()->rect().adjusted(2, 2, -2, -2);
|
// Ensure the navigation view is also flipped.
|
||||||
QRectF imageRect = transform().mapRect(sceneRect());
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
|
}
|
||||||
qreal ratio;
|
|
||||||
|
void GraphicsView::resetScale()
|
||||||
if (ori == Qt::Horizontal) {
|
{
|
||||||
ratio = viewRect.width() / imageRect.width();
|
setTransform(resetScale(transform()));
|
||||||
} else {
|
applyTransformationModeByScaleFactor();
|
||||||
ratio = viewRect.height() / imageRect.height();
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scaleDownOnly && ratio > 1) ratio = 1;
|
void GraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode)
|
||||||
|
{
|
||||||
scale(ratio, ratio);
|
QGraphicsView::fitInView(rect, aspectRadioMode);
|
||||||
centerOn(imageRect.top(), 0);
|
applyTransformationModeByScaleFactor();
|
||||||
m_enableFitInView = false;
|
}
|
||||||
|
|
||||||
applyTransformationModeByScaleFactor();
|
void GraphicsView::fitByOrientation(Qt::Orientation ori, bool scaleDownOnly)
|
||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
{
|
||||||
}
|
resetScale();
|
||||||
|
|
||||||
void GraphicsView::displayScene()
|
QRectF viewRect = this->viewport()->rect();
|
||||||
{
|
QRectF imageRect = transform().mapRect(sceneRect());
|
||||||
if (shouldAvoidTransform()) {
|
QSize viewSize = viewRect.size().toSize();
|
||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
|
||||||
return;
|
qreal ratio;
|
||||||
}
|
|
||||||
|
if (ori == Qt::Horizontal) {
|
||||||
if (isSceneBiggerThanView()) {
|
// Horizontal fit means fit by width
|
||||||
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
if (scaleDownOnly && imageRect.width() <= viewSize.width()) {
|
||||||
}
|
// Image width already fits, no scaling needed
|
||||||
|
ratio = 1;
|
||||||
m_enableFitInView = true;
|
} else {
|
||||||
m_firstUserMediaLoaded = true;
|
ratio = viewRect.width() / imageRect.width();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
bool GraphicsView::isSceneBiggerThanView() const
|
// Vertical fit means fit by height
|
||||||
{
|
if (scaleDownOnly && imageRect.height() <= viewSize.height()) {
|
||||||
if (!isThingSmallerThanWindowWith(transform())) {
|
// Image height already fits, no scaling needed
|
||||||
return true;
|
ratio = 1;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
ratio = viewRect.height() / imageRect.height();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automately do fit in view when viewport(window) smaller than image original size.
|
if (ratio != 1) {
|
||||||
void GraphicsView::setEnableAutoFitInView(bool enable)
|
scale(ratio, ratio);
|
||||||
{
|
}
|
||||||
m_enableFitInView = enable;
|
|
||||||
}
|
// Position the image correctly based on orientation with rotation consideration
|
||||||
|
QRectF originalScene = sceneRect();
|
||||||
bool GraphicsView::avoidResetTransform() const
|
QTransform currentTransform = transform();
|
||||||
{
|
|
||||||
return m_avoidResetTransform;
|
// TODO:
|
||||||
}
|
// I guess following code may be optimized by matrix arithmetic operation.
|
||||||
|
// There is an AI given solution. But I didn't use it.
|
||||||
void GraphicsView::setAvoidResetTransform(bool avoidReset)
|
// Because I want to keep the same behavior of upstream.
|
||||||
{
|
|
||||||
m_avoidResetTransform = avoidReset;
|
// // Horizontal fit: Let the position of top center of viewport, (cx, 0), be inversely mapped to scene.
|
||||||
}
|
// // And compensate the behavior of `centerOn` which put given point to the center of viewport.
|
||||||
|
// QTransform inv = currentTransform.inverted();
|
||||||
inline double zeroOrOne(double number)
|
// QPointF viewCx = viewport()->rect().center().x();
|
||||||
{
|
// QPointF viewCy = viewport()->rect().center().y();
|
||||||
return qFuzzyIsNull(number) ? 0 : (number > 0 ? 1 : -1);
|
// // The target is viewport top center. Its y=0, so `centerOn` required scene point is (viewCx, -viewCy).
|
||||||
}
|
// centerOn(inv.map(QPointF(viewCx, -viewCy)));
|
||||||
|
|
||||||
// Note: this only works if we only have 90 degree based rotation
|
if (ori == Qt::Horizontal) {
|
||||||
// and no shear/translate.
|
// For horizontal fit (fit by width), position at top (for tall images)
|
||||||
QTransform GraphicsView::resetScale(const QTransform & orig)
|
// Find the scene point that corresponds to the top-center of the transformed image
|
||||||
{
|
QPointF sceneTopCenter;
|
||||||
return QTransform(zeroOrOne(orig.m11()), zeroOrOne(orig.m12()),
|
|
||||||
zeroOrOne(orig.m21()), zeroOrOne(orig.m22()),
|
if (qFuzzyIsNull(currentTransform.m12()) && qFuzzyIsNull(currentTransform.m21())) {
|
||||||
orig.dx(), orig.dy());
|
// 0° or 180° rotation
|
||||||
}
|
if (currentTransform.m11() > 0 && currentTransform.m22() > 0) {
|
||||||
|
// 0° rotation: use original top-center
|
||||||
void GraphicsView::toggleCheckerboard(bool invertCheckerboardColor)
|
sceneTopCenter = QPointF(originalScene.center().x(), originalScene.top());
|
||||||
{
|
} else {
|
||||||
setCheckerboardEnabled(!m_checkerboardEnabled, invertCheckerboardColor);
|
// 180° rotation: the visual "top" is now at the scene bottom
|
||||||
}
|
sceneTopCenter = QPointF(originalScene.center().x(), originalScene.bottom());
|
||||||
|
}
|
||||||
void GraphicsView::mousePressEvent(QMouseEvent *event)
|
} else {
|
||||||
{
|
// 90/270 degree rotation: the "top" in view corresponds to left/right in scene
|
||||||
if (shouldIgnoreMousePressMoveEvent(event)) {
|
if (currentTransform.m12() > 0) {
|
||||||
event->ignore();
|
// 90 degree: top in view = left in scene
|
||||||
// blumia: return here, or the QMouseEvent event transparency won't
|
sceneTopCenter = QPointF(originalScene.left(), originalScene.center().y());
|
||||||
// work if we set a QGraphicsView::ScrollHandDrag drag mode.
|
} else {
|
||||||
return;
|
// 270 degree: top in view = right in scene
|
||||||
}
|
sceneTopCenter = QPointF(originalScene.right(), originalScene.center().y());
|
||||||
|
}
|
||||||
return QGraphicsView::mousePressEvent(event);
|
}
|
||||||
}
|
centerOn(sceneTopCenter);
|
||||||
|
} else {
|
||||||
void GraphicsView::mouseMoveEvent(QMouseEvent *event)
|
// For vertical fit (fit by height), position at left (for wide images)
|
||||||
{
|
// Find the scene point that corresponds to the left-center of the transformed image
|
||||||
if (shouldIgnoreMousePressMoveEvent(event)) {
|
QPointF sceneLeftCenter;
|
||||||
event->ignore();
|
|
||||||
}
|
if (qFuzzyIsNull(currentTransform.m12()) && qFuzzyIsNull(currentTransform.m21())) {
|
||||||
|
// 0° or 180° rotation
|
||||||
return QGraphicsView::mouseMoveEvent(event);
|
if (currentTransform.m11() > 0 && currentTransform.m22() > 0) {
|
||||||
}
|
// 0° rotation: use original left-center
|
||||||
|
sceneLeftCenter = QPointF(originalScene.left(), originalScene.center().y());
|
||||||
void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
|
} else {
|
||||||
{
|
// 180° rotation: the visual "left" is now at the scene right
|
||||||
if (event->button() == Qt::ForwardButton || event->button() == Qt::BackButton) {
|
sceneLeftCenter = QPointF(originalScene.right(), originalScene.center().y());
|
||||||
event->ignore();
|
}
|
||||||
} else {
|
} else {
|
||||||
QGraphicsItem *item = itemAt(event->pos());
|
// 90/270 degree rotation: the "left" in view corresponds to top/bottom in scene
|
||||||
if (!item) {
|
if (currentTransform.m21() > 0) {
|
||||||
event->ignore();
|
// 90 degree: left in view = top in scene
|
||||||
}
|
sceneLeftCenter = QPointF(originalScene.center().x(), originalScene.top());
|
||||||
}
|
} else {
|
||||||
|
// 270 degree: left in view = bottom in scene
|
||||||
return QGraphicsView::mouseReleaseEvent(event);
|
sceneLeftCenter = QPointF(originalScene.center().x(), originalScene.bottom());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void GraphicsView::wheelEvent(QWheelEvent *event)
|
centerOn(sceneLeftCenter);
|
||||||
{
|
}
|
||||||
event->ignore();
|
|
||||||
// blumia: no need for calling parent method.
|
m_enableFitToScreen = false;
|
||||||
}
|
|
||||||
|
applyTransformationModeByScaleFactor();
|
||||||
void GraphicsView::resizeEvent(QResizeEvent *event)
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
{
|
}
|
||||||
if (m_enableFitInView) {
|
|
||||||
bool originalSizeSmallerThanWindow = isThingSmallerThanWindowWith(resetScale(transform()));
|
void GraphicsView::displayScene()
|
||||||
if (originalSizeSmallerThanWindow && scaleFactor() >= 1) {
|
{
|
||||||
// no longer need to do fitInView()
|
if (shouldAvoidTransform()) {
|
||||||
// but we leave the m_enableFitInView value unchanged in case
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
// user resize down the window again.
|
return;
|
||||||
} else if (originalSizeSmallerThanWindow && scaleFactor() < 1) {
|
}
|
||||||
resetScale();
|
|
||||||
} else {
|
if (isSceneBiggerThanView()) {
|
||||||
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
// Do fit-in-view
|
||||||
}
|
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
||||||
} else {
|
// After fitInView, the image should fit the window, so hide navigator
|
||||||
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
emit navigatorViewRequired(false, transform());
|
||||||
}
|
} else {
|
||||||
return QGraphicsView::resizeEvent(event);
|
// Image is already smaller than window, no navigator needed
|
||||||
}
|
emit navigatorViewRequired(false, transform());
|
||||||
|
}
|
||||||
bool GraphicsView::isThingSmallerThanWindowWith(const QTransform &transform) const
|
|
||||||
{
|
m_enableFitToScreen = true;
|
||||||
return rect().size().expandedTo(transform.mapRect(sceneRect()).size().toSize())
|
m_firstUserMediaLoaded = true;
|
||||||
== rect().size();
|
}
|
||||||
}
|
|
||||||
|
bool GraphicsView::isSceneBiggerThanView() const
|
||||||
bool GraphicsView::shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const
|
{
|
||||||
{
|
if (!isThingSmallerThanWindowWith(transform())) {
|
||||||
if (event->buttons() == Qt::NoButton) {
|
return true;
|
||||||
return true;
|
} else {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
QGraphicsItem *item = itemAt(event->pos());
|
}
|
||||||
if (!item) {
|
|
||||||
return true;
|
// Automately do fit in view when viewport(window) smaller than image original size.
|
||||||
}
|
void GraphicsView::setEnableAutoFitToScreen(bool enable)
|
||||||
|
{
|
||||||
if (isThingSmallerThanWindowWith(transform())) {
|
m_enableFitToScreen = enable;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
bool GraphicsView::isAvoidResetTransform() const
|
||||||
return false;
|
{
|
||||||
}
|
return m_avoidResetTransform;
|
||||||
|
}
|
||||||
void GraphicsView::setCheckerboardEnabled(bool enabled, bool invertColor)
|
|
||||||
{
|
void GraphicsView::setAvoidResetTransform(bool avoidReset)
|
||||||
m_checkerboardEnabled = enabled;
|
{
|
||||||
bool isLightCheckerboard = Settings::instance()->useLightCheckerboard() ^ invertColor;
|
m_avoidResetTransform = avoidReset;
|
||||||
if (m_checkerboardEnabled) {
|
}
|
||||||
// Prepare background check-board pattern
|
|
||||||
QPixmap tilePixmap(0x20, 0x20);
|
bool GraphicsView::isCheckerboard() const {
|
||||||
tilePixmap.fill(isLightCheckerboard ? QColor(220, 220, 220, 170) : QColor(35, 35, 35, 170));
|
return m_checkerboardEnabled;
|
||||||
QPainter tilePainter(&tilePixmap);
|
}
|
||||||
constexpr QColor color(45, 45, 45, 170);
|
|
||||||
constexpr QColor invertedColor(210, 210, 210, 170);
|
void GraphicsView::toggleCheckerboard(bool invertCheckerboardColor)
|
||||||
tilePainter.fillRect(0, 0, 0x10, 0x10, isLightCheckerboard ? invertedColor : color);
|
{
|
||||||
tilePainter.fillRect(0x10, 0x10, 0x10, 0x10, isLightCheckerboard ? invertedColor : color);
|
setCheckerboardEnabled(!m_checkerboardEnabled, invertCheckerboardColor);
|
||||||
tilePainter.end();
|
}
|
||||||
|
|
||||||
setBackgroundBrush(tilePixmap);
|
inline double zeroOrOne(double number)
|
||||||
} else {
|
{
|
||||||
setBackgroundBrush(Qt::transparent);
|
return qFuzzyIsNull(number) ? 0 : (number > 0 ? 1 : -1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Note: this only works if we only have 90 degree based rotation
|
||||||
void GraphicsView::applyTransformationModeByScaleFactor()
|
// and no shear/translate.
|
||||||
{
|
QTransform GraphicsView::resetScale(const QTransform & orig)
|
||||||
if (this->scaleFactor() < 1) {
|
{
|
||||||
scene()->trySetTransformationMode(Qt::SmoothTransformation, this->scaleFactor());
|
return QTransform(zeroOrOne(orig.m11()), zeroOrOne(orig.m12()),
|
||||||
} else {
|
zeroOrOne(orig.m21()), zeroOrOne(orig.m22()),
|
||||||
scene()->trySetTransformationMode(Qt::FastTransformation, this->scaleFactor());
|
orig.dx(), orig.dy());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
void GraphicsView::updateStyle(Qt::ColorScheme colorScheme) {
|
||||||
bool GraphicsView::shouldAvoidTransform() const
|
// YYC MARK:
|
||||||
{
|
// If we are using Windows 10 and lower system or Qt which do not support "Windows 11"
|
||||||
return m_firstUserMediaLoaded && m_avoidResetTransform;
|
// theme (lower than Qt 6.7), we should only support light mode.
|
||||||
}
|
// Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11.
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
|
colorScheme = Qt::ColorScheme::Light;
|
||||||
|
#else
|
||||||
|
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) {
|
||||||
|
colorScheme = Qt::ColorScheme::Light;
|
||||||
|
}
|
||||||
|
#endif // QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
|
#endif // defined(Q_OS_WIN)
|
||||||
|
|
||||||
|
switch (colorScheme) {
|
||||||
|
case Qt::ColorScheme::Dark:
|
||||||
|
setStyleSheet(R"#(
|
||||||
|
border-style: none;
|
||||||
|
background-color: black;
|
||||||
|
)#");
|
||||||
|
break;
|
||||||
|
case Qt::ColorScheme::Light:
|
||||||
|
case Qt::ColorScheme::Unknown:
|
||||||
|
default:
|
||||||
|
setStyleSheet(R"#(
|
||||||
|
border-style: none;
|
||||||
|
background-color: white;
|
||||||
|
)#");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsView::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (shouldIgnoreMousePressMoveEvent(event)) {
|
||||||
|
event->ignore();
|
||||||
|
// blumia: return here, or the QMouseEvent event transparency won't
|
||||||
|
// work if we set a QGraphicsView::ScrollHandDrag drag mode.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QGraphicsView::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsView::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (shouldIgnoreMousePressMoveEvent(event)) {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QGraphicsView::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::ForwardButton || event->button() == Qt::BackButton) {
|
||||||
|
event->ignore();
|
||||||
|
} else {
|
||||||
|
QGraphicsItem *item = itemAt(event->pos());
|
||||||
|
if (!item) {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QGraphicsView::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsView::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
// blumia: no need for calling parent method.
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsView::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
if (m_enableFitToScreen) {
|
||||||
|
bool originalSizeSmallerThanWindow = isThingSmallerThanWindowWith(resetScale(transform()));
|
||||||
|
if (originalSizeSmallerThanWindow && scaleFactor() >= 1) {
|
||||||
|
// no longer need to do fitInView()
|
||||||
|
// but we leave the m_enableToScreen value unchanged in case
|
||||||
|
// user resize down the window again.
|
||||||
|
} else if (originalSizeSmallerThanWindow && scaleFactor() < 1) {
|
||||||
|
resetScale();
|
||||||
|
} else {
|
||||||
|
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
|
||||||
|
}
|
||||||
|
return QGraphicsView::resizeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GraphicsView::isThingSmallerThanWindowWith(const QTransform &transform) const
|
||||||
|
{
|
||||||
|
return rect().size().expandedTo(transform.mapRect(sceneRect()).size().toSize())
|
||||||
|
== rect().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GraphicsView::shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const
|
||||||
|
{
|
||||||
|
if (event->buttons() == Qt::NoButton) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGraphicsItem *item = itemAt(event->pos());
|
||||||
|
if (!item) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isThingSmallerThanWindowWith(transform())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsView::setCheckerboardEnabled(bool enabled, bool invertColor)
|
||||||
|
{
|
||||||
|
m_checkerboardEnabled = enabled;
|
||||||
|
bool isLightCheckerboard = Settings::instance()->useLightCheckerboard() ^ invertColor;
|
||||||
|
if (m_checkerboardEnabled) {
|
||||||
|
// Prepare background check-board pattern
|
||||||
|
QPixmap tilePixmap(0x20, 0x20);
|
||||||
|
tilePixmap.fill(isLightCheckerboard ? QColor(220, 220, 220, 170) : QColor(35, 35, 35, 170));
|
||||||
|
QPainter tilePainter(&tilePixmap);
|
||||||
|
constexpr QColor color(45, 45, 45, 170);
|
||||||
|
constexpr QColor invertedColor(210, 210, 210, 170);
|
||||||
|
tilePainter.fillRect(0, 0, 0x10, 0x10, isLightCheckerboard ? invertedColor : color);
|
||||||
|
tilePainter.fillRect(0x10, 0x10, 0x10, 0x10, isLightCheckerboard ? invertedColor : color);
|
||||||
|
tilePainter.end();
|
||||||
|
|
||||||
|
setBackgroundBrush(tilePixmap);
|
||||||
|
} else {
|
||||||
|
setBackgroundBrush(Qt::transparent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsView::applyTransformationModeByScaleFactor()
|
||||||
|
{
|
||||||
|
if (this->scaleFactor() < 1) {
|
||||||
|
scene()->trySetTransformationMode(Qt::SmoothTransformation, this->scaleFactor());
|
||||||
|
} else {
|
||||||
|
scene()->trySetTransformationMode(Qt::FastTransformation, this->scaleFactor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GraphicsView::shouldAvoidTransform() const
|
||||||
|
{
|
||||||
|
return m_firstUserMediaLoaded && m_avoidResetTransform;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,79 +1,82 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef GRAPHICSVIEW_H
|
#ifndef GRAPHICSVIEW_H
|
||||||
#define GRAPHICSVIEW_H
|
#define GRAPHICSVIEW_H
|
||||||
|
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
class GraphicsScene;
|
class GraphicsScene;
|
||||||
class GraphicsView : public QGraphicsView
|
class GraphicsView : public QGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GraphicsView(QWidget *parent = nullptr);
|
GraphicsView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
void showFileFromPath(const QString &filePath);
|
void showFileFromPath(const QString &filePath);
|
||||||
|
|
||||||
void showImage(const QPixmap &pixmap);
|
void showImage(const QPixmap &pixmap);
|
||||||
void showImage(const QImage &image);
|
void showImage(const QImage &image);
|
||||||
void showText(const QString &text);
|
void showText(const QString &text);
|
||||||
void showSvg(const QString &filepath);
|
void showSvg(const QString &filepath);
|
||||||
void showAnimated(const QString &filepath);
|
void showAnimated(const QString &filepath);
|
||||||
|
|
||||||
GraphicsScene * scene() const;
|
GraphicsScene * scene() const;
|
||||||
void setScene(GraphicsScene *scene);
|
void setScene(GraphicsScene *scene);
|
||||||
|
|
||||||
qreal scaleFactor() const;
|
qreal scaleFactor() const;
|
||||||
|
|
||||||
void resetTransform();
|
void resetTransform();
|
||||||
void zoomView(qreal scaleFactor);
|
void zoomView(qreal scaleFactor);
|
||||||
void rotateView(bool clockwise = true);
|
void rotateView(bool clockwise = true);
|
||||||
void flipView(bool horizontal = true);
|
void flipView(bool horizontal = true);
|
||||||
void resetScale();
|
void resetScale();
|
||||||
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
|
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
|
||||||
void fitByOrientation(Qt::Orientation ori = Qt::Horizontal, bool scaleDownOnly = false);
|
void fitByOrientation(Qt::Orientation ori = Qt::Horizontal, bool scaleDownOnly = false);
|
||||||
|
|
||||||
void displayScene();
|
void displayScene();
|
||||||
bool isSceneBiggerThanView() const;
|
bool isSceneBiggerThanView() const;
|
||||||
void setEnableAutoFitInView(bool enable = true);
|
void setEnableAutoFitToScreen(bool enable = true);
|
||||||
|
|
||||||
bool avoidResetTransform() const;
|
bool isAvoidResetTransform() const;
|
||||||
void setAvoidResetTransform(bool avoidReset);
|
void setAvoidResetTransform(bool avoidReset);
|
||||||
|
|
||||||
static QTransform resetScale(const QTransform & orig);
|
bool isCheckerboard() const;
|
||||||
|
void toggleCheckerboard(bool invertCheckerboardColor = false);
|
||||||
signals:
|
|
||||||
void navigatorViewRequired(bool required, QTransform transform);
|
static QTransform resetScale(const QTransform & orig);
|
||||||
void viewportRectChanged();
|
|
||||||
|
signals:
|
||||||
public slots:
|
void navigatorViewRequired(bool required, QTransform transform);
|
||||||
void toggleCheckerboard(bool invertCheckerboardColor = false);
|
void viewportRectChanged();
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
void mousePressEvent(QMouseEvent * event) override;
|
void updateStyle(Qt::ColorScheme colorScheme);
|
||||||
void mouseMoveEvent(QMouseEvent * event) override;
|
|
||||||
void mouseReleaseEvent(QMouseEvent * event) override;
|
private:
|
||||||
void wheelEvent(QWheelEvent *event) override;
|
void mousePressEvent(QMouseEvent * event) override;
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void mouseMoveEvent(QMouseEvent * event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent * event) override;
|
||||||
bool isThingSmallerThanWindowWith(const QTransform &transform) const;
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
bool shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
void setCheckerboardEnabled(bool enabled, bool invertColor = false);
|
|
||||||
void applyTransformationModeByScaleFactor();
|
bool isThingSmallerThanWindowWith(const QTransform &transform) const;
|
||||||
|
bool shouldIgnoreMousePressMoveEvent(const QMouseEvent *event) const;
|
||||||
inline bool shouldAvoidTransform() const;
|
void setCheckerboardEnabled(bool enabled, bool invertColor = false);
|
||||||
|
void applyTransformationModeByScaleFactor();
|
||||||
// Consider switch to 3 state for "no fit", "always fit" and "fit when view is smaller"?
|
|
||||||
// ... or even more? e.g. "fit/snap width" things...
|
inline bool shouldAvoidTransform() const;
|
||||||
// Currently it's "no fit" when it's false and "fit when view is smaller" when it's true.
|
|
||||||
bool m_enableFitInView = false;
|
// Consider switch to 3 state for "no fit", "always fit" and "fit when view is smaller"?
|
||||||
bool m_avoidResetTransform = false;
|
// ... or even more? e.g. "fit/snap width" things...
|
||||||
bool m_checkerboardEnabled = false;
|
// Currently it's "no fit" when it's false and "fit when view is smaller" when it's true.
|
||||||
bool m_useLightCheckerboard = false;
|
bool m_enableFitToScreen = false;
|
||||||
bool m_firstUserMediaLoaded = false;
|
bool m_avoidResetTransform = false;
|
||||||
};
|
bool m_checkerboardEnabled = false;
|
||||||
|
bool m_useLightCheckerboard = false;
|
||||||
#endif // GRAPHICSVIEW_H
|
bool m_firstUserMediaLoaded = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRAPHICSVIEW_H
|
||||||
|
|||||||
@@ -1,91 +1,96 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include "playlistmanager.h"
|
#include "settings.h"
|
||||||
#include "settings.h"
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
#ifdef Q_OS_MACOS
|
#include "fileopeneventhandler.h"
|
||||||
#include "fileopeneventhandler.h"
|
#endif // Q_OS_MACOS
|
||||||
#endif // Q_OS_MACOS
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QApplication>
|
#include <QCommandLineParser>
|
||||||
#include <QCommandLineParser>
|
#include <QDir>
|
||||||
#include <QDir>
|
#include <QTranslator>
|
||||||
#include <QTranslator>
|
#include <QUrl>
|
||||||
#include <QUrl>
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
using namespace Qt::Literals::StringLiterals;
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
int main(int argc, char *argv[])
|
{
|
||||||
{
|
QCoreApplication::setApplicationName(u"Pineapple Pictures"_s);
|
||||||
QCoreApplication::setApplicationName(u"Pineapple Pictures"_s);
|
QCoreApplication::setApplicationVersion(PPIC_VERSION_STRING);
|
||||||
QCoreApplication::setApplicationVersion(PPIC_VERSION_STRING);
|
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Settings::instance()->hiDpiScaleFactorBehavior());
|
||||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Settings::instance()->hiDpiScaleFactorBehavior());
|
|
||||||
|
QApplication a(argc, argv);
|
||||||
QApplication a(argc, argv);
|
|
||||||
|
QTranslator translator;
|
||||||
QTranslator translator;
|
#if defined(TRANSLATION_RESOURCE_EMBEDDING)
|
||||||
#if defined(TRANSLATION_RESOURCE_EMBEDDING)
|
const QString qmDir = u":/i18n/"_s;
|
||||||
const QString qmDir = u":/i18n/"_s;
|
#elif defined(QM_FILE_INSTALL_ABSOLUTE_DIR)
|
||||||
#elif defined(QM_FILE_INSTALL_ABSOLUTE_DIR)
|
const QString qmDir = QT_STRINGIFY(QM_FILE_INSTALL_ABSOLUTE_DIR);
|
||||||
const QString qmDir = QT_STRINGIFY(QM_FILE_INSTALL_ABSOLUTE_DIR);
|
#else
|
||||||
#else
|
const QString qmDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("translations");
|
||||||
const QString qmDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("translations");
|
#endif
|
||||||
#endif
|
if (translator.load(QLocale(), u"PineapplePictures"_s, u"_"_s, qmDir)) {
|
||||||
if (translator.load(QLocale(), u"PineapplePictures"_s, u"_"_s, qmDir)) {
|
QCoreApplication::installTranslator(&translator);
|
||||||
QCoreApplication::installTranslator(&translator);
|
}
|
||||||
}
|
|
||||||
|
QGuiApplication::setApplicationDisplayName(QCoreApplication::translate("main", "Pineapple Pictures"));
|
||||||
QGuiApplication::setApplicationDisplayName(QCoreApplication::translate("main", "Pineapple Pictures"));
|
|
||||||
|
// commandline options
|
||||||
// commandline options
|
QCommandLineOption supportedImageFormats(u"supported-image-formats"_s, QCoreApplication::translate("main", "List supported image format suffixes, and quit program."));
|
||||||
QCommandLineOption supportedImageFormats(u"supported-image-formats"_s, QCoreApplication::translate("main", "List supported image format suffixes, and quit program."));
|
// parse commandline arguments
|
||||||
// parse commandline arguments
|
QCommandLineParser parser;
|
||||||
QCommandLineParser parser;
|
parser.addOption(supportedImageFormats);
|
||||||
parser.addOption(supportedImageFormats);
|
parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));
|
||||||
parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));
|
parser.addHelpOption();
|
||||||
parser.addHelpOption();
|
parser.process(a);
|
||||||
parser.process(a);
|
|
||||||
|
if (parser.isSet(supportedImageFormats)) {
|
||||||
if (parser.isSet(supportedImageFormats)) {
|
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
fputs(qPrintable(MainWindow::supportedImageFormats().join(QChar('\n'))), stdout);
|
||||||
fputs(qPrintable(MainWindow::supportedImageFormats().join(QChar('\n'))), stdout);
|
::exit(EXIT_SUCCESS);
|
||||||
::exit(EXIT_SUCCESS);
|
#else
|
||||||
#else
|
QCommandLineParser::showMessageAndExit(QCommandLineParser::MessageType::Information,
|
||||||
QCommandLineParser::showMessageAndExit(QCommandLineParser::MessageType::Information,
|
MainWindow::supportedImageFormats().join(QChar('\n')));
|
||||||
MainWindow::supportedImageFormats().join(QChar('\n')));
|
#endif
|
||||||
#endif
|
}
|
||||||
}
|
|
||||||
|
MainWindow w;
|
||||||
MainWindow w;
|
w.show();
|
||||||
w.show();
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
#ifdef Q_OS_MACOS
|
FileOpenEventHandler * fileOpenEventHandler = new FileOpenEventHandler(&a);
|
||||||
FileOpenEventHandler * fileOpenEventHandler = new FileOpenEventHandler(&a);
|
a.installEventFilter(fileOpenEventHandler);
|
||||||
a.installEventFilter(fileOpenEventHandler);
|
a.connect(fileOpenEventHandler, &FileOpenEventHandler::fileOpen, [&w](const QUrl & url){
|
||||||
a.connect(fileOpenEventHandler, &FileOpenEventHandler::fileOpen, [&w](const QUrl & url){
|
if (w.isHidden()) {
|
||||||
if (w.isHidden()) {
|
w.showNormal();
|
||||||
w.setWindowOpacity(1);
|
} else {
|
||||||
w.showNormal();
|
w.activateWindow();
|
||||||
} else {
|
}
|
||||||
w.activateWindow();
|
w.showFiles({url});
|
||||||
}
|
w.initWindowSize();
|
||||||
w.showUrls({url});
|
});
|
||||||
w.initWindowSize();
|
|
||||||
});
|
// Handle dock icon clicks to show hidden window
|
||||||
#endif // Q_OS_MACOS
|
a.connect(&a, &QApplication::applicationStateChanged, [&w](Qt::ApplicationState state) {
|
||||||
|
if (state == Qt::ApplicationActive && w.isHidden()) {
|
||||||
QStringList urlStrList = parser.positionalArguments();
|
w.showFiles({});
|
||||||
QList<QUrl> && urlList = PlaylistManager::convertToUrlList(urlStrList);
|
w.galleryCurrent(false);
|
||||||
|
w.showNormal();
|
||||||
if (!urlList.isEmpty()) {
|
w.raise();
|
||||||
w.showUrls(urlList);
|
w.activateWindow();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
w.initWindowSize();
|
#endif // Q_OS_MACOS
|
||||||
|
|
||||||
return QApplication::exec();
|
QStringList fileList = parser.positionalArguments();
|
||||||
}
|
w.showFiles(fileList);
|
||||||
|
|
||||||
|
w.initWindowSize();
|
||||||
|
|
||||||
|
return QApplication::exec();
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,134 +1,97 @@
|
|||||||
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "framelesswindow.h"
|
#include <QWidget>
|
||||||
|
|
||||||
#include <QParallelAnimationGroup>
|
QT_BEGIN_NAMESPACE
|
||||||
#include <QPropertyAnimation>
|
class QFileSystemWatcher;
|
||||||
#include <QPushButton>
|
namespace Ui {
|
||||||
|
class MainWindow;
|
||||||
QT_BEGIN_NAMESPACE
|
}
|
||||||
class QGraphicsOpacityEffect;
|
QT_END_NAMESPACE
|
||||||
class QGraphicsView;
|
|
||||||
class QFileSystemWatcher;
|
class ActionManager;
|
||||||
QT_END_NAMESPACE
|
class PlaylistManager;
|
||||||
|
|
||||||
class ActionManager;
|
class MainWindow : public QWidget
|
||||||
class PlaylistManager;
|
{
|
||||||
class ToolButton;
|
Q_OBJECT
|
||||||
class GraphicsView;
|
|
||||||
class NavigatorView;
|
public:
|
||||||
class BottomButtonGroup;
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
class MainWindow : public FramelessWindow
|
~MainWindow() override;
|
||||||
{
|
|
||||||
Q_OBJECT
|
void showFiles(const QStringList& files);
|
||||||
|
void showFiles(const QList<QUrl>& urls);
|
||||||
public:
|
void initWindowSize();
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
|
||||||
~MainWindow() override;
|
void clearGallery();
|
||||||
|
void galleryPrev();
|
||||||
void showUrls(const QList<QUrl> &urls);
|
void galleryNext();
|
||||||
void initWindowSize();
|
void galleryCurrent(bool fromFileWatcher);
|
||||||
void adjustWindowSizeBySceneRect();
|
|
||||||
QUrl currentImageFileUrl() const;
|
static QStringList supportedImageFormats();
|
||||||
|
|
||||||
void clearGallery();
|
protected slots:
|
||||||
void galleryPrev();
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
void galleryNext();
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
void galleryCurrent(bool showLoadImageHintWhenEmpty, bool reloadImage);
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
|
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||||
static QStringList supportedImageFormats();
|
void dropEvent(QDropEvent *event) override;
|
||||||
|
|
||||||
protected slots:
|
void centerWindow();
|
||||||
void showEvent(QShowEvent *event) override;
|
void toggleAvoidResetTransform();
|
||||||
void enterEvent(QEnterEvent *event) override;
|
void toggleFullscreen();
|
||||||
void leaveEvent(QEvent *event) override;
|
void toggleMaximize();
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
protected:
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
QSize sizeHint() const override;
|
||||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
|
||||||
void wheelEvent(QWheelEvent *event) override;
|
private slots:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void on_actionCopyPixmap_triggered();
|
||||||
void contextMenuEvent(QContextMenuEvent *event) override;
|
void on_actionCopyFilePath_triggered();
|
||||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
|
||||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
void on_actionPrevPicture_triggered();
|
||||||
void dropEvent(QDropEvent *event) override;
|
void on_actionNextPicture_triggered();
|
||||||
|
|
||||||
void centerWindow();
|
void on_actionActualSize_triggered();
|
||||||
void closeWindow();
|
void on_actionFitToScreen_triggered();
|
||||||
void updateWidgetsPosition();
|
void on_actionFitByWidth_triggered();
|
||||||
void toggleProtectedMode();
|
void on_actionFitByHeight_triggered();
|
||||||
void toggleStayOnTop();
|
void on_actionZoomIn_triggered();
|
||||||
void toggleAvoidResetTransform();
|
void on_actionZoomOut_triggered();
|
||||||
bool stayOnTop() const;
|
|
||||||
bool canPaste() const;
|
void on_actionFlipHorizontal_triggered();
|
||||||
void quitAppAction(bool force = false);
|
void on_actionFlipVertical_triggered();
|
||||||
void toggleFullscreen();
|
void on_actionRotateClockwise_triggered();
|
||||||
void toggleMaximize();
|
void on_actionRotateCounterClockwise_triggered();
|
||||||
|
|
||||||
protected:
|
void on_actionToggleAvoidResetTransform_triggered();
|
||||||
QSize sizeHint() const override;
|
void on_actionToggleCheckerboard_triggered();
|
||||||
|
void on_actionTogglePauseAnimation_triggered();
|
||||||
private slots:
|
void on_actionAnimationNextFrame_triggered();
|
||||||
void on_actionOpen_triggered();
|
|
||||||
|
void on_actionTrash_triggered();
|
||||||
void on_actionActualSize_triggered();
|
void on_actionLocateInFileManager_triggered();
|
||||||
void on_actionToggleMaximize_triggered();
|
void on_actionProperties_triggered();
|
||||||
void on_actionZoomIn_triggered();
|
|
||||||
void on_actionZoomOut_triggered();
|
void on_actionSettings_triggered();
|
||||||
void on_actionToggleCheckerboard_triggered();
|
void on_actionHelp_triggered();
|
||||||
void on_actionRotateClockwise_triggered();
|
|
||||||
void on_actionRotateCounterClockwise_triggered();
|
private:
|
||||||
|
bool updateFileWatcher(const QString & basePath = QString());
|
||||||
void on_actionPrevPicture_triggered();
|
void updateActionState();
|
||||||
void on_actionNextPicture_triggered();
|
|
||||||
|
private:
|
||||||
void on_actionTogglePauseAnimation_triggered();
|
QT_PREPEND_NAMESPACE(Ui::MainWindow) *ui;
|
||||||
void on_actionAnimationNextFrame_triggered();
|
|
||||||
|
ActionManager *m_am;
|
||||||
void on_actionHorizontalFlip_triggered();
|
PlaylistManager *m_pm;
|
||||||
void on_actionFitInView_triggered();
|
QFileSystemWatcher *m_fileSystemWatcher;
|
||||||
void on_actionFitByWidth_triggered();
|
};
|
||||||
void on_actionCopyPixmap_triggered();
|
|
||||||
void on_actionCopyFilePath_triggered();
|
#endif // MAINWINDOW_H
|
||||||
void on_actionPaste_triggered();
|
|
||||||
void on_actionTrash_triggered();
|
|
||||||
void on_actionToggleStayOnTop_triggered();
|
|
||||||
void on_actionToggleProtectMode_triggered();
|
|
||||||
void on_actionToggleAvoidResetTransform_triggered();
|
|
||||||
void on_actionSettings_triggered();
|
|
||||||
void on_actionHelp_triggered();
|
|
||||||
void on_actionProperties_triggered();
|
|
||||||
void on_actionLocateInFileManager_triggered();
|
|
||||||
void on_actionQuitApp_triggered();
|
|
||||||
|
|
||||||
void doCloseWindow();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool updateFileWatcher(const QString & basePath = QString());
|
|
||||||
void updateGalleryButtonsVisibility();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ActionManager *m_am;
|
|
||||||
PlaylistManager *m_pm;
|
|
||||||
|
|
||||||
QPoint m_oldMousePos;
|
|
||||||
QPropertyAnimation *m_fadeOutAnimation;
|
|
||||||
QPropertyAnimation *m_floatUpAnimation;
|
|
||||||
QParallelAnimationGroup *m_exitAnimationGroup;
|
|
||||||
QFileSystemWatcher *m_fileSystemWatcher;
|
|
||||||
ToolButton *m_closeButton;
|
|
||||||
ToolButton *m_prevButton;
|
|
||||||
ToolButton *m_nextButton;
|
|
||||||
GraphicsView *m_graphicsView;
|
|
||||||
NavigatorView *m_gv;
|
|
||||||
BottomButtonGroup *m_bottomButtonGroup;
|
|
||||||
bool m_protectedMode = false;
|
|
||||||
bool m_clickedOnWindow = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QWidget" name="MainWindow">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::NonModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>640</width>
|
||||||
|
<height>480</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="m_centralLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="GraphicsView" name="m_gv">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="bottomBar" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>72</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>72</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="bottomBarLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="m_navPH" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>99</width>
|
||||||
|
<height>72</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>99</width>
|
||||||
|
<height>72</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="leftSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="BottomButtonGroup" name="m_bottomButtonGroup"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="rightSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="NavigatorView" name="m_nav">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>99</width>
|
||||||
|
<height>72</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>99</width>
|
||||||
|
<height>72</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
<widget class="QMenu" name="m_subMenuCopy">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Copy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="m_subMenuTransform">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Transform</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="m_menu"/>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>GraphicsView</class>
|
||||||
|
<extends>QGraphicsView</extends>
|
||||||
|
<header>graphicsview.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>NavigatorView</class>
|
||||||
|
<extends>QGraphicsView</extends>
|
||||||
|
<header>navigatorview.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>BottomButtonGroup</class>
|
||||||
|
<extends>QGroupBox</extends>
|
||||||
|
<header>bottombuttongroup.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -1,110 +1,113 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "metadatadialog.h"
|
#include "metadatadialog.h"
|
||||||
|
#include "ui_metadatadialog.h"
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QPainter>
|
#include <QDialogButtonBox>
|
||||||
#include <QStyledItemDelegate>
|
#include <QPainter>
|
||||||
#include <QTreeView>
|
#include <QStyledItemDelegate>
|
||||||
#include <QVBoxLayout>
|
#include <QTreeView>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
|
||||||
#include "metadatamodel.h"
|
#include "metadatamodel.h"
|
||||||
|
|
||||||
class PropertyTreeView : public QTreeView
|
class PropertyTreeView : public QTreeView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PropertyTreeView(QWidget* parent) : QTreeView(parent) {}
|
explicit PropertyTreeView(QWidget* parent) : QTreeView(parent) {}
|
||||||
~PropertyTreeView() {}
|
~PropertyTreeView() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void rowsInserted(const QModelIndex& parent, int start, int end) override
|
void rowsInserted(const QModelIndex& parent, int start, int end) override
|
||||||
{
|
{
|
||||||
QTreeView::rowsInserted(parent, start, end);
|
QTreeView::rowsInserted(parent, start, end);
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
// we are inserting a section group
|
// we are inserting a section group
|
||||||
for (int row = start; row <= end; ++row) {
|
for (int row = start; row <= end; ++row) {
|
||||||
setupSection(row);
|
setupSection(row);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we are inserting a property
|
// we are inserting a property
|
||||||
setRowHidden(parent.row(), QModelIndex(), false);
|
setRowHidden(parent.row(), QModelIndex(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() override
|
void reset() override
|
||||||
{
|
{
|
||||||
QTreeView::reset();
|
QTreeView::reset();
|
||||||
if (model()) {
|
if (model()) {
|
||||||
for (int row = 0; row < model()->rowCount(); ++row) {
|
for (int row = 0; row < model()->rowCount(); ++row) {
|
||||||
setupSection(row);
|
setupSection(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupSection(int row)
|
void setupSection(int row)
|
||||||
{
|
{
|
||||||
expand(model()->index(row, 0));
|
expand(model()->index(row, 0));
|
||||||
setFirstColumnSpanned(row, QModelIndex(), true);
|
setFirstColumnSpanned(row, QModelIndex(), true);
|
||||||
setRowHidden(row, QModelIndex(), !model()->hasChildren(model()->index(row, 0)));
|
setRowHidden(row, QModelIndex(), !model()->hasChildren(model()->index(row, 0)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PropertyTreeItemDelegate : public QStyledItemDelegate
|
class PropertyTreeItemDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PropertyTreeItemDelegate(QObject* parent)
|
PropertyTreeItemDelegate(QObject* parent)
|
||||||
: QStyledItemDelegate(parent)
|
: QStyledItemDelegate(parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override
|
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override
|
||||||
{
|
{
|
||||||
QStyleOptionViewItem opt = option;
|
QStyleOptionViewItem opt = option;
|
||||||
if (!index.parent().isValid()) {
|
if (!index.parent().isValid()) {
|
||||||
opt.font.setBold(true);
|
opt.font.setBold(true);
|
||||||
opt.features.setFlag(QStyleOptionViewItem::Alternate);
|
opt.features.setFlag(QStyleOptionViewItem::Alternate);
|
||||||
}
|
}
|
||||||
QStyledItemDelegate::paint(painter, opt, index);
|
QStyledItemDelegate::paint(painter, opt, index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MetadataDialog::MetadataDialog(QWidget *parent)
|
MetadataDialog::MetadataDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent), ui(new QT_PREPEND_NAMESPACE(Ui::MetadataDialog))
|
||||||
, m_treeView(new PropertyTreeView(this))
|
{
|
||||||
{
|
ui->setupUi(this);
|
||||||
m_treeView->setRootIsDecorated(false);
|
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||||
m_treeView->setIndentation(0);
|
|
||||||
m_treeView->setItemDelegate(new PropertyTreeItemDelegate(m_treeView));
|
// YYC MARK:
|
||||||
m_treeView->header()->resizeSection(0, sizeHint().width() / 2);
|
// Because we use custom QTreeView and we do not want to expose it to public domain.
|
||||||
|
// So I have to use this way as the compromise.
|
||||||
setWindowTitle(tr("Image Metadata"));
|
|
||||||
|
// Create our custom QTreeView and insert them
|
||||||
QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
m_treeView = new PropertyTreeView(this);
|
||||||
|
auto* layout = ui->verticalLayout;
|
||||||
setLayout(new QVBoxLayout);
|
const int index = layout->indexOf(ui->m_buttonBox);
|
||||||
layout()->addWidget(m_treeView);
|
layout->insertWidget(index, m_treeView);
|
||||||
layout()->addWidget(buttonBox);
|
|
||||||
|
// Setup our custom QTreeView
|
||||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::close);
|
m_treeView->setRootIsDecorated(false);
|
||||||
|
m_treeView->setIndentation(0);
|
||||||
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
m_treeView->setItemDelegate(new PropertyTreeItemDelegate(m_treeView));
|
||||||
}
|
m_treeView->header()->resizeSection(0, sizeHint().width() / 2);
|
||||||
|
|
||||||
MetadataDialog::~MetadataDialog()
|
connect(ui->m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::close);
|
||||||
{
|
}
|
||||||
|
|
||||||
}
|
MetadataDialog::~MetadataDialog()
|
||||||
|
{
|
||||||
void MetadataDialog::setMetadataModel(MetadataModel * model)
|
delete ui;
|
||||||
{
|
}
|
||||||
m_treeView->setModel(model);
|
|
||||||
}
|
void MetadataDialog::setMetadataModel(MetadataModel * model)
|
||||||
|
{
|
||||||
QSize MetadataDialog::sizeHint() const
|
m_treeView->setModel(model);
|
||||||
{
|
}
|
||||||
return QSize(520, 350);
|
|
||||||
}
|
QSize MetadataDialog::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(520, 350);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,30 +1,37 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef METADATADIALOG_H
|
#ifndef METADATADIALOG_H
|
||||||
#define METADATADIALOG_H
|
#define METADATADIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class MetadataModel;
|
QT_BEGIN_NAMESPACE
|
||||||
class MetadataDialog : public QDialog
|
namespace Ui {
|
||||||
{
|
class MetadataDialog;
|
||||||
Q_OBJECT
|
}
|
||||||
public:
|
QT_END_NAMESPACE
|
||||||
explicit MetadataDialog(QWidget * parent);
|
|
||||||
~MetadataDialog() override;
|
class MetadataModel;
|
||||||
|
class MetadataDialog : public QDialog
|
||||||
void setMetadataModel(MetadataModel * model);
|
{
|
||||||
|
Q_OBJECT
|
||||||
QSize sizeHint() const override;
|
public:
|
||||||
|
explicit MetadataDialog(QWidget * parent);
|
||||||
private:
|
~MetadataDialog() override;
|
||||||
QTreeView * m_treeView = nullptr;
|
|
||||||
};
|
void setMetadataModel(MetadataModel * model);
|
||||||
|
|
||||||
#endif // METADATADIALOG_H
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTreeView * m_treeView = nullptr;
|
||||||
|
QT_PREPEND_NAMESPACE(Ui::MetadataDialog) *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // METADATADIALOG_H
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MetadataDialog</class>
|
||||||
|
<widget class="QDialog" name="MetadataDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::NonModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Image Metadata</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -1,320 +1,320 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "metadatamodel.h"
|
#include "metadatamodel.h"
|
||||||
#include "exiv2wrapper.h"
|
#include "exiv2wrapper.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
|
|
||||||
using namespace Qt::Literals::StringLiterals;
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
|
||||||
MetadataModel::MetadataModel(QObject *parent)
|
MetadataModel::MetadataModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MetadataModel::~MetadataModel()
|
MetadataModel::~MetadataModel()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetadataModel::setFile(const QString &imageFilePath)
|
void MetadataModel::setFile(const QString &imageFilePath)
|
||||||
{
|
{
|
||||||
QFileInfo fileInfo(imageFilePath);
|
QFileInfo fileInfo(imageFilePath);
|
||||||
// It'll be fine if we don't re-use the image reader we pass to the graphics scene for now.
|
// It'll be fine if we don't re-use the image reader we pass to the graphics scene for now.
|
||||||
QImageReader imgReader(imageFilePath);
|
QImageReader imgReader(imageFilePath);
|
||||||
imgReader.setAutoTransform(true);
|
imgReader.setAutoTransform(true);
|
||||||
imgReader.setDecideFormatFromContent(true);
|
imgReader.setDecideFormatFromContent(true);
|
||||||
|
|
||||||
const QString & itemTypeString = tr("%1 File").arg(QString(imgReader.format().toUpper()));
|
const QString & itemTypeString = tr("%1 File").arg(QString(imgReader.format().toUpper()));
|
||||||
const QString & sizeString = QLocale().formattedDataSize(fileInfo.size());
|
const QString & sizeString = QLocale().formattedDataSize(fileInfo.size());
|
||||||
const QString & birthTimeString = QLocale().toString(fileInfo.birthTime(), QLocale::LongFormat);
|
const QString & birthTimeString = QLocale().toString(fileInfo.birthTime(), QLocale::LongFormat);
|
||||||
const QString & lastModifiedTimeString = QLocale().toString(fileInfo.lastModified(), QLocale::LongFormat);
|
const QString & lastModifiedTimeString = QLocale().toString(fileInfo.lastModified(), QLocale::LongFormat);
|
||||||
const QString & imageDimensionsString = imageSize(imgReader.size());
|
const QString & imageDimensionsString = imageSize(imgReader.size());
|
||||||
const QString & imageRatioString = imageSizeRatio(imgReader.size());
|
const QString & imageRatioString = imageSizeRatio(imgReader.size());
|
||||||
|
|
||||||
appendSection(u"Description"_s, tr("Description", "Section name."));
|
appendSection(u"Description"_s, tr("Description", "Section name."));
|
||||||
appendSection(u"Origin"_s, tr("Origin", "Section name."));
|
appendSection(u"Origin"_s, tr("Origin", "Section name."));
|
||||||
appendSection(u"Image"_s, tr("Image", "Section name."));
|
appendSection(u"Image"_s, tr("Image", "Section name."));
|
||||||
appendSection(u"Camera"_s, tr("Camera", "Section name."));
|
appendSection(u"Camera"_s, tr("Camera", "Section name."));
|
||||||
appendSection(u"AdvancedPhoto"_s, tr("Advanced photo", "Section name."));
|
appendSection(u"AdvancedPhoto"_s, tr("Advanced photo", "Section name."));
|
||||||
appendSection(u"GPS"_s, tr("GPS", "Section name."));
|
appendSection(u"GPS"_s, tr("GPS", "Section name."));
|
||||||
appendSection(u"File"_s, tr("File", "Section name."));
|
appendSection(u"File"_s, tr("File", "Section name."));
|
||||||
|
|
||||||
if (imgReader.supportsOption(QImageIOHandler::Size)) {
|
if (imgReader.supportsOption(QImageIOHandler::Size)) {
|
||||||
appendProperty(u"Image"_s, u"Image.Dimensions"_s,
|
appendProperty(u"Image"_s, u"Image.Dimensions"_s,
|
||||||
tr("Dimensions"), imageDimensionsString);
|
tr("Dimensions"), imageDimensionsString);
|
||||||
appendProperty(u"Image"_s, u"Image.SizeRatio"_s,
|
appendProperty(u"Image"_s, u"Image.SizeRatio"_s,
|
||||||
tr("Aspect ratio"), imageRatioString);
|
tr("Aspect ratio"), imageRatioString);
|
||||||
}
|
}
|
||||||
if (imgReader.supportsAnimation() && imgReader.imageCount() > 1) {
|
if (imgReader.supportsAnimation() && imgReader.imageCount() > 1) {
|
||||||
appendProperty(u"Image"_s, u"Image.FrameCount"_s,
|
appendProperty(u"Image"_s, u"Image.FrameCount"_s,
|
||||||
tr("Frame count"), QString::number(imgReader.imageCount()));
|
tr("Frame count"), QString::number(imgReader.imageCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
appendProperty(u"File"_s, u"File.Name"_s,
|
appendProperty(u"File"_s, u"File.Name"_s,
|
||||||
tr("Name"), fileInfo.fileName());
|
tr("Name"), fileInfo.fileName());
|
||||||
appendProperty(u"File"_s, u"File.ItemType"_s,
|
appendProperty(u"File"_s, u"File.ItemType"_s,
|
||||||
tr("Item type"), itemTypeString);
|
tr("Item type"), itemTypeString);
|
||||||
appendProperty(u"File"_s, u"File.Path"_s,
|
appendProperty(u"File"_s, u"File.Path"_s,
|
||||||
tr("Folder path"), QDir::toNativeSeparators(fileInfo.path()));
|
tr("Folder path"), QDir::toNativeSeparators(fileInfo.path()));
|
||||||
appendProperty(u"File"_s, u"File.Size"_s,
|
appendProperty(u"File"_s, u"File.Size"_s,
|
||||||
tr("Size"), sizeString);
|
tr("Size"), sizeString);
|
||||||
appendProperty(u"File"_s, u"File.CreatedTime"_s,
|
appendProperty(u"File"_s, u"File.CreatedTime"_s,
|
||||||
tr("Date created"), birthTimeString);
|
tr("Date created"), birthTimeString);
|
||||||
appendProperty(u"File"_s, u"File.LastModified"_s,
|
appendProperty(u"File"_s, u"File.LastModified"_s,
|
||||||
tr("Date modified"), lastModifiedTimeString);
|
tr("Date modified"), lastModifiedTimeString);
|
||||||
|
|
||||||
Exiv2Wrapper wrapper;
|
Exiv2Wrapper wrapper;
|
||||||
if (wrapper.load(imageFilePath)) {
|
if (wrapper.load(imageFilePath)) {
|
||||||
wrapper.cacheSections();
|
wrapper.cacheSections();
|
||||||
|
|
||||||
appendExivPropertyIfExist(wrapper, u"Description"_s,
|
appendExivPropertyIfExist(wrapper, u"Description"_s,
|
||||||
u"Xmp.dc.title"_s, tr("Title"), true);
|
u"Xmp.dc.title"_s, tr("Title"), true);
|
||||||
appendExivPropertyIfExist(wrapper, u"Description"_s,
|
appendExivPropertyIfExist(wrapper, u"Description"_s,
|
||||||
u"Exif.Image.ImageDescription"_s, tr("Subject"), true);
|
u"Exif.Image.ImageDescription"_s, tr("Subject"), true);
|
||||||
appendExivPropertyIfExist(wrapper, u"Description"_s,
|
appendExivPropertyIfExist(wrapper, u"Description"_s,
|
||||||
u"Exif.Image.Rating"_s, tr("Rating"));
|
u"Exif.Image.Rating"_s, tr("Rating"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Description"_s,
|
appendExivPropertyIfExist(wrapper, u"Description"_s,
|
||||||
u"Xmp.dc.subject"_s, tr("Tags"));
|
u"Xmp.dc.subject"_s, tr("Tags"));
|
||||||
appendPropertyIfNotEmpty(u"Description"_s, u"Description.Comments"_s,
|
appendPropertyIfNotEmpty(u"Description"_s, u"Description.Comments"_s,
|
||||||
tr("Comments"), wrapper.comment());
|
tr("Comments"), wrapper.comment());
|
||||||
|
|
||||||
appendExivPropertyIfExist(wrapper, u"Origin"_s,
|
appendExivPropertyIfExist(wrapper, u"Origin"_s,
|
||||||
u"Exif.Image.Artist"_s, tr("Authors"));
|
u"Exif.Image.Artist"_s, tr("Authors"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Origin"_s,
|
appendExivPropertyIfExist(wrapper, u"Origin"_s,
|
||||||
u"Exif.Photo.DateTimeOriginal"_s, tr("Date taken"));
|
u"Exif.Photo.DateTimeOriginal"_s, tr("Date taken"));
|
||||||
// FIXME: We may fetch the same type of metadata from different metadata collection.
|
// FIXME: We may fetch the same type of metadata from different metadata collection.
|
||||||
// Current implementation is not pretty and may need to do a rework...
|
// Current implementation is not pretty and may need to do a rework...
|
||||||
// appendExivPropertyIfExist(wrapper, QStringLiteral("Origin"),
|
// appendExivPropertyIfExist(wrapper, QStringLiteral("Origin"),
|
||||||
// QStringLiteral("Xmp.xmp.CreatorTool"), tr("Program name"));
|
// QStringLiteral("Xmp.xmp.CreatorTool"), tr("Program name"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Origin"_s,
|
appendExivPropertyIfExist(wrapper, u"Origin"_s,
|
||||||
u"Exif.Image.Software"_s, tr("Program name"));
|
u"Exif.Image.Software"_s, tr("Program name"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Origin"_s,
|
appendExivPropertyIfExist(wrapper, u"Origin"_s,
|
||||||
u"Exif.Image.Copyright"_s, tr("Copyright"));
|
u"Exif.Image.Copyright"_s, tr("Copyright"));
|
||||||
|
|
||||||
appendExivPropertyIfExist(wrapper, u"Image"_s,
|
appendExivPropertyIfExist(wrapper, u"Image"_s,
|
||||||
u"Exif.Image.XResolution"_s, tr("Horizontal resolution"));
|
u"Exif.Image.XResolution"_s, tr("Horizontal resolution"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Image"_s,
|
appendExivPropertyIfExist(wrapper, u"Image"_s,
|
||||||
u"Exif.Image.YResolution"_s, tr("Vertical resolution"));
|
u"Exif.Image.YResolution"_s, tr("Vertical resolution"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Image"_s,
|
appendExivPropertyIfExist(wrapper, u"Image"_s,
|
||||||
u"Exif.Image.ResolutionUnit"_s, tr("Resolution unit"));
|
u"Exif.Image.ResolutionUnit"_s, tr("Resolution unit"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Image"_s,
|
appendExivPropertyIfExist(wrapper, u"Image"_s,
|
||||||
u"Exif.Photo.ColorSpace"_s, tr("Colour representation"));
|
u"Exif.Photo.ColorSpace"_s, tr("Colour representation"));
|
||||||
|
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Image.Make"_s, tr("Camera maker"));
|
u"Exif.Image.Make"_s, tr("Camera maker"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Image.Model"_s, tr("Camera model"));
|
u"Exif.Image.Model"_s, tr("Camera model"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.FNumber"_s, tr("F-stop"));
|
u"Exif.Photo.FNumber"_s, tr("F-stop"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.ExposureTime"_s, tr("Exposure time"));
|
u"Exif.Photo.ExposureTime"_s, tr("Exposure time"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.ISOSpeedRatings"_s, tr("ISO speed"));
|
u"Exif.Photo.ISOSpeedRatings"_s, tr("ISO speed"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.ExposureBiasValue"_s, tr("Exposure bias"));
|
u"Exif.Photo.ExposureBiasValue"_s, tr("Exposure bias"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.FocalLength"_s, tr("Focal length"));
|
u"Exif.Photo.FocalLength"_s, tr("Focal length"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.MaxApertureValue"_s, tr("Max aperture"));
|
u"Exif.Photo.MaxApertureValue"_s, tr("Max aperture"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.MeteringMode"_s, tr("Metering mode"));
|
u"Exif.Photo.MeteringMode"_s, tr("Metering mode"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.SubjectDistance"_s, tr("Subject distance"));
|
u"Exif.Photo.SubjectDistance"_s, tr("Subject distance"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.Flash"_s, tr("Flash mode"));
|
u"Exif.Photo.Flash"_s, tr("Flash mode"));
|
||||||
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
appendExivPropertyIfExist(wrapper, u"Camera"_s,
|
||||||
u"Exif.Photo.FocalLengthIn35mmFilm"_s, tr("35mm focal length"));
|
u"Exif.Photo.FocalLengthIn35mmFilm"_s, tr("35mm focal length"));
|
||||||
|
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.LensModel"_s, tr("Lens model"));
|
u"Exif.Photo.LensModel"_s, tr("Lens model"));
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.Contrast"_s, tr("Contrast"));
|
u"Exif.Photo.Contrast"_s, tr("Contrast"));
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.BrightnessValue"_s, tr("Brightness"));
|
u"Exif.Photo.BrightnessValue"_s, tr("Brightness"));
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.ExposureProgram"_s, tr("Exposure program"));
|
u"Exif.Photo.ExposureProgram"_s, tr("Exposure program"));
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.Saturation"_s, tr("Saturation"));
|
u"Exif.Photo.Saturation"_s, tr("Saturation"));
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.Sharpness"_s, tr("Sharpness"));
|
u"Exif.Photo.Sharpness"_s, tr("Sharpness"));
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.WhiteBalance"_s, tr("White balance"));
|
u"Exif.Photo.WhiteBalance"_s, tr("White balance"));
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.DigitalZoomRatio"_s, tr("Digital zoom"));
|
u"Exif.Photo.DigitalZoomRatio"_s, tr("Digital zoom"));
|
||||||
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
appendExivPropertyIfExist(wrapper, u"AdvancedPhoto"_s,
|
||||||
u"Exif.Photo.ExifVersion"_s, tr("EXIF version"));
|
u"Exif.Photo.ExifVersion"_s, tr("EXIF version"));
|
||||||
|
|
||||||
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
||||||
u"Exif.GPSInfo.GPSLatitudeRef"_s, tr("Latitude reference"));
|
u"Exif.GPSInfo.GPSLatitudeRef"_s, tr("Latitude reference"));
|
||||||
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
||||||
u"Exif.GPSInfo.GPSLatitude"_s, tr("Latitude"));
|
u"Exif.GPSInfo.GPSLatitude"_s, tr("Latitude"));
|
||||||
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
||||||
u"Exif.GPSInfo.GPSLongitudeRef"_s, tr("Longitude reference"));
|
u"Exif.GPSInfo.GPSLongitudeRef"_s, tr("Longitude reference"));
|
||||||
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
||||||
u"Exif.GPSInfo.GPSLongitude"_s, tr("Longitude"));
|
u"Exif.GPSInfo.GPSLongitude"_s, tr("Longitude"));
|
||||||
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
||||||
u"Exif.GPSInfo.GPSAltitudeRef"_s, tr("Altitude reference"));
|
u"Exif.GPSInfo.GPSAltitudeRef"_s, tr("Altitude reference"));
|
||||||
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
appendExivPropertyIfExist(wrapper, u"GPS"_s,
|
||||||
u"Exif.GPSInfo.GPSAltitude"_s, tr("Altitude"));
|
u"Exif.GPSInfo.GPSAltitude"_s, tr("Altitude"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MetadataModel::imageSize(const QSize &size)
|
QString MetadataModel::imageSize(const QSize &size)
|
||||||
{
|
{
|
||||||
QString imageSize;
|
QString imageSize;
|
||||||
|
|
||||||
if (size.isValid()) {
|
if (size.isValid()) {
|
||||||
imageSize = tr("%1 x %2").arg(QString::number(size.width()), QString::number(size.height()));
|
imageSize = tr("%1 x %2").arg(QString::number(size.width()), QString::number(size.height()));
|
||||||
} else {
|
} else {
|
||||||
imageSize = QLatin1Char('-');
|
imageSize = QLatin1Char('-');
|
||||||
}
|
}
|
||||||
|
|
||||||
return imageSize;
|
return imageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int simplegcd(int a, int b) {
|
int simplegcd(int a, int b) {
|
||||||
return b == 0 ? a : simplegcd(b, a % b);
|
return b == 0 ? a : simplegcd(b, a % b);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MetadataModel::imageSizeRatio(const QSize &size)
|
QString MetadataModel::imageSizeRatio(const QSize &size)
|
||||||
{
|
{
|
||||||
if (!size.isValid()) {
|
if (!size.isValid()) {
|
||||||
return QStringLiteral("-");
|
return QStringLiteral("-");
|
||||||
}
|
}
|
||||||
int gcd = simplegcd(size.width(), size.height());
|
int gcd = simplegcd(size.width(), size.height());
|
||||||
return tr("%1 : %2").arg(QString::number(size.width() / gcd), QString::number(size.height() / gcd));
|
return tr("%1 : %2").arg(QString::number(size.width() / gcd), QString::number(size.height() / gcd));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MetadataModel::appendSection(const QString §ionKey, QStringView sectionDisplayName)
|
bool MetadataModel::appendSection(const QString §ionKey, QStringView sectionDisplayName)
|
||||||
{
|
{
|
||||||
if (m_sections.contains(sectionKey)) {
|
if (m_sections.contains(sectionKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sections.append(sectionKey);
|
m_sections.append(sectionKey);
|
||||||
m_sectionProperties[sectionKey] = qMakePair<QString, QList<QString> >(sectionDisplayName.toString(), {});
|
m_sectionProperties[sectionKey] = qMakePair<QString, QList<QString> >(sectionDisplayName.toString(), {});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MetadataModel::appendPropertyIfNotEmpty(const QString §ionKey, const QString &propertyKey, const QString &propertyDisplayName, const QString &propertyValue)
|
bool MetadataModel::appendPropertyIfNotEmpty(const QString §ionKey, const QString &propertyKey, const QString &propertyDisplayName, const QString &propertyValue)
|
||||||
{
|
{
|
||||||
if (propertyValue.isEmpty()) return false;
|
if (propertyValue.isEmpty()) return false;
|
||||||
|
|
||||||
return appendProperty(sectionKey, propertyKey, propertyDisplayName, propertyValue);
|
return appendProperty(sectionKey, propertyKey, propertyDisplayName, propertyValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MetadataModel::appendProperty(const QString §ionKey, const QString &propertyKey, QStringView propertyDisplayName, QStringView propertyValue)
|
bool MetadataModel::appendProperty(const QString §ionKey, const QString &propertyKey, QStringView propertyDisplayName, QStringView propertyValue)
|
||||||
{
|
{
|
||||||
if (!m_sections.contains(sectionKey)) {
|
if (!m_sections.contains(sectionKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> & propertyList = m_sectionProperties[sectionKey].second;
|
QList<QString> & propertyList = m_sectionProperties[sectionKey].second;
|
||||||
if (!propertyList.contains(propertyKey)) {
|
if (!propertyList.contains(propertyKey)) {
|
||||||
propertyList.append(propertyKey);
|
propertyList.append(propertyKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_properties[propertyKey] = qMakePair<QString, QString>(propertyDisplayName.toString(), propertyValue.toString());
|
m_properties[propertyKey] = qMakePair<QString, QString>(propertyDisplayName.toString(), propertyValue.toString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MetadataModel::appendExivPropertyIfExist(const Exiv2Wrapper &wrapper, const QString §ionKey, const QString &exiv2propertyKey, const QString &propertyDisplayName, bool isXmpString)
|
bool MetadataModel::appendExivPropertyIfExist(const Exiv2Wrapper &wrapper, const QString §ionKey, const QString &exiv2propertyKey, const QString &propertyDisplayName, bool isXmpString)
|
||||||
{
|
{
|
||||||
const QString & value = wrapper.value(exiv2propertyKey);
|
const QString & value = wrapper.value(exiv2propertyKey);
|
||||||
if (!value.isEmpty()) {
|
if (!value.isEmpty()) {
|
||||||
appendProperty(sectionKey, exiv2propertyKey,
|
appendProperty(sectionKey, exiv2propertyKey,
|
||||||
propertyDisplayName.isEmpty() ? wrapper.label(exiv2propertyKey) : propertyDisplayName,
|
propertyDisplayName.isEmpty() ? wrapper.label(exiv2propertyKey) : propertyDisplayName,
|
||||||
isXmpString ? Exiv2Wrapper::XmpValue(value) : value);
|
isXmpString ? Exiv2Wrapper::XmpValue(value) : value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex MetadataModel::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex MetadataModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (!hasIndex(row, column, parent)) {
|
if (!hasIndex(row, column, parent)) {
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
return createIndex(row, column, RowType::SectionRow);
|
return createIndex(row, column, RowType::SectionRow);
|
||||||
} else {
|
} else {
|
||||||
// internalid param: row means nth section it belongs to.
|
// internalid param: row means nth section it belongs to.
|
||||||
return createIndex(row, column, RowType::PropertyRow + parent.row());
|
return createIndex(row, column, RowType::PropertyRow + parent.row());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex MetadataModel::parent(const QModelIndex &child) const
|
QModelIndex MetadataModel::parent(const QModelIndex &child) const
|
||||||
{
|
{
|
||||||
if (!child.isValid()) {
|
if (!child.isValid()) {
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (child.internalId() == RowType::SectionRow) {
|
if (child.internalId() == RowType::SectionRow) {
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
} else {
|
} else {
|
||||||
return createIndex(child.internalId() - RowType::PropertyRow, 0, SectionRow);
|
return createIndex(child.internalId() - RowType::PropertyRow, 0, SectionRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MetadataModel::rowCount(const QModelIndex &parent) const
|
int MetadataModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
return m_sections.count();
|
return m_sections.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent.internalId() == RowType::SectionRow) {
|
if (parent.internalId() == RowType::SectionRow) {
|
||||||
const QString & sectionKey = m_sections[parent.row()];
|
const QString & sectionKey = m_sections[parent.row()];
|
||||||
return m_sectionProperties[sectionKey].second.count();
|
return m_sectionProperties[sectionKey].second.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MetadataModel::columnCount(const QModelIndex &) const
|
int MetadataModel::columnCount(const QModelIndex &) const
|
||||||
{
|
{
|
||||||
// Always key(display name) and value.
|
// Always key(display name) and value.
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MetadataModel::data(const QModelIndex &index, int role) const
|
QVariant MetadataModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role != Qt::DisplayRole) {
|
if (role != Qt::DisplayRole) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.internalId() == RowType::SectionRow) {
|
if (index.internalId() == RowType::SectionRow) {
|
||||||
return (index.column() == 0) ? m_sectionProperties[m_sections[index.row()]].first
|
return (index.column() == 0) ? m_sectionProperties[m_sections[index.row()]].first
|
||||||
: QVariant();
|
: QVariant();
|
||||||
} else {
|
} else {
|
||||||
int sectionIndex = index.internalId() - RowType::PropertyRow;
|
int sectionIndex = index.internalId() - RowType::PropertyRow;
|
||||||
const QString & sectionKey = m_sections[sectionIndex];
|
const QString & sectionKey = m_sections[sectionIndex];
|
||||||
const QList<QString> & propertyList = m_sectionProperties[sectionKey].second;
|
const QList<QString> & propertyList = m_sectionProperties[sectionKey].second;
|
||||||
return (index.column() == 0) ? m_properties[propertyList[index.row()]].first
|
return (index.column() == 0) ? m_properties[propertyList[index.row()]].first
|
||||||
: m_properties[propertyList[index.row()]].second;
|
: m_properties[propertyList[index.row()]].second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MetadataModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant MetadataModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Vertical || role != Qt::DisplayRole) {
|
if (orientation == Qt::Vertical || role != Qt::DisplayRole) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
return section == 0 ? tr("Property") : tr("Value");
|
return section == 0 ? tr("Property") : tr("Value");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +1,52 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef METADATAMODEL_H
|
#ifndef METADATAMODEL_H
|
||||||
#define METADATAMODEL_H
|
#define METADATAMODEL_H
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
class Exiv2Wrapper;
|
class Exiv2Wrapper;
|
||||||
class MetadataModel : public QAbstractItemModel
|
class MetadataModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MetadataModel(QObject *parent = nullptr);
|
explicit MetadataModel(QObject *parent = nullptr);
|
||||||
~MetadataModel();
|
~MetadataModel();
|
||||||
|
|
||||||
void setFile(const QString & imageFilePath);
|
void setFile(const QString & imageFilePath);
|
||||||
static QString imageSize(const QSize &size);
|
static QString imageSize(const QSize &size);
|
||||||
static QString imageSizeRatio(const QSize &size);
|
static QString imageSizeRatio(const QSize &size);
|
||||||
bool appendSection(const QString & sectionKey, QStringView sectionDisplayName);
|
bool appendSection(const QString & sectionKey, QStringView sectionDisplayName);
|
||||||
bool appendPropertyIfNotEmpty(const QString & sectionKey, const QString & propertyKey,
|
bool appendPropertyIfNotEmpty(const QString & sectionKey, const QString & propertyKey,
|
||||||
const QString & propertyDisplayName, const QString & propertyValue = QString());
|
const QString & propertyDisplayName, const QString & propertyValue = QString());
|
||||||
bool appendProperty(const QString & sectionKey, const QString & propertyKey,
|
bool appendProperty(const QString & sectionKey, const QString & propertyKey,
|
||||||
QStringView propertyDisplayName, QStringView propertyValue = QString());
|
QStringView propertyDisplayName, QStringView propertyValue = QString());
|
||||||
bool appendExivPropertyIfExist(const Exiv2Wrapper & wrapper, const QString & sectionKey,
|
bool appendExivPropertyIfExist(const Exiv2Wrapper & wrapper, const QString & sectionKey,
|
||||||
const QString & exiv2propertyKey, const QString & propertyDisplayName = QString(),
|
const QString & exiv2propertyKey, const QString & propertyDisplayName = QString(),
|
||||||
bool isXmpString = false);
|
bool isXmpString = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum RowType : quintptr {
|
enum RowType : quintptr {
|
||||||
SectionRow,
|
SectionRow,
|
||||||
PropertyRow,
|
PropertyRow,
|
||||||
};
|
};
|
||||||
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QModelIndex parent(const QModelIndex &child) const override;
|
QModelIndex parent(const QModelIndex &child) const override;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
int columnCount(const QModelIndex & = QModelIndex()) const override;
|
int columnCount(const QModelIndex & = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
// [SECTION_KEY]
|
// [SECTION_KEY]
|
||||||
QList<QString> m_sections;
|
QList<QString> m_sections;
|
||||||
// {SECTION_KEY: (SECTION_DISPLAY_NAME, [PROPERTY_KEY])}
|
// {SECTION_KEY: (SECTION_DISPLAY_NAME, [PROPERTY_KEY])}
|
||||||
QMap<QString, QPair<QString, QList<QString> > > m_sectionProperties;
|
QMap<QString, QPair<QString, QList<QString> > > m_sectionProperties;
|
||||||
// {PROPERTY_KEY: (PROPERTY_DISPLAY_NAME, PROPERTY_VALUE)}
|
// {PROPERTY_KEY: (PROPERTY_DISPLAY_NAME, PROPERTY_VALUE)}
|
||||||
QMap<QString, QPair<QString, QString> > m_properties;
|
QMap<QString, QPair<QString, QString> > m_properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // METADATAMODEL_H
|
#endif // METADATAMODEL_H
|
||||||
|
|||||||
@@ -1,86 +1,120 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "navigatorview.h"
|
#include "navigatorview.h"
|
||||||
|
|
||||||
#include "graphicsview.h"
|
#include "graphicsview.h"
|
||||||
#include "opacityhelper.h"
|
|
||||||
|
#include <QStyleHints>
|
||||||
#include <QMouseEvent>
|
#include <QOperatingSystemVersion>
|
||||||
#include <QDebug>
|
#include <QMouseEvent>
|
||||||
|
#include <QDebug>
|
||||||
NavigatorView::NavigatorView(QWidget *parent)
|
#include <QTimer>
|
||||||
: QGraphicsView (parent)
|
|
||||||
, m_viewportRegion(this->rect())
|
NavigatorView::NavigatorView(QWidget *parent)
|
||||||
, m_opacityHelper(new OpacityHelper(this))
|
: QGraphicsView (parent)
|
||||||
{
|
, m_viewportRegion(this->rect())
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
{
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setStyleSheet("background-color: rgba(0, 0, 0, 120);"
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
"border-radius: 3px;");
|
|
||||||
}
|
updateStyle(qGuiApp->styleHints()->colorScheme());
|
||||||
|
connect(qGuiApp->styleHints(), &QStyleHints::colorSchemeChanged, this, &NavigatorView::updateStyle);
|
||||||
// doesn't take or manage its ownership
|
}
|
||||||
void NavigatorView::setMainView(GraphicsView *mainView)
|
|
||||||
{
|
// doesn't take or manage its ownership
|
||||||
m_mainView = mainView;
|
void NavigatorView::setMainView(GraphicsView *mainView)
|
||||||
}
|
{
|
||||||
|
m_mainView = mainView;
|
||||||
void NavigatorView::setOpacity(qreal opacity, bool animated)
|
}
|
||||||
{
|
|
||||||
m_opacityHelper->setOpacity(opacity, animated);
|
void NavigatorView::updateMainViewportRegion()
|
||||||
}
|
{
|
||||||
|
// Use QTimer::singleShot with lambda to delay the update
|
||||||
void NavigatorView::updateMainViewportRegion()
|
// This ensures all geometry updates are complete before calculating viewport region
|
||||||
{
|
QTimer::singleShot(0, [this]() {
|
||||||
if (m_mainView != nullptr) {
|
if (m_mainView != nullptr) {
|
||||||
m_viewportRegion = mapFromScene(m_mainView->mapToScene(m_mainView->rect()));
|
m_viewportRegion = mapFromScene(m_mainView->mapToScene(m_mainView->rect()));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
void NavigatorView::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
void NavigatorView::updateStyle(Qt::ColorScheme colorScheme) {
|
||||||
m_mouseDown = true;
|
// YYC MARK:
|
||||||
|
// If we are using Windows 10 and lower system or Qt which do not support "Windows 11"
|
||||||
if (m_mainView) {
|
// theme (lower than Qt 6.7), we should only support light mode.
|
||||||
m_mainView->centerOn(mapToScene(event->pos()));
|
// Because Qt's dark-mode-aware "Windows 11" theme is only well-supported on Windows 11.
|
||||||
update();
|
#if defined(Q_OS_WIN)
|
||||||
}
|
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
|
colorScheme = Qt::ColorScheme::Light;
|
||||||
event->accept();
|
#else
|
||||||
}
|
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) {
|
||||||
|
colorScheme = Qt::ColorScheme::Light;
|
||||||
void NavigatorView::mouseMoveEvent(QMouseEvent *event)
|
}
|
||||||
{
|
#endif // QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
if (m_mouseDown && m_mainView) {
|
#endif // defined(Q_OS_WIN)
|
||||||
m_mainView->centerOn(mapToScene(event->pos()));
|
|
||||||
update();
|
switch (colorScheme) {
|
||||||
event->accept();
|
case Qt::ColorScheme::Dark:
|
||||||
} else {
|
setStyleSheet(R"#(
|
||||||
event->ignore();
|
border-style: none;
|
||||||
}
|
background-color: rgba(255, 255, 255, 70);
|
||||||
}
|
)#");
|
||||||
|
break;
|
||||||
void NavigatorView::mouseReleaseEvent(QMouseEvent *event)
|
case Qt::ColorScheme::Light:
|
||||||
{
|
case Qt::ColorScheme::Unknown:
|
||||||
m_mouseDown = false;
|
default:
|
||||||
|
setStyleSheet(R"#(
|
||||||
event->accept();
|
border-style: none;
|
||||||
}
|
background-color: rgba(0, 0, 0, 70);
|
||||||
|
)#");
|
||||||
void NavigatorView::wheelEvent(QWheelEvent *event)
|
break;
|
||||||
{
|
}
|
||||||
event->ignore();
|
}
|
||||||
return QGraphicsView::wheelEvent(event);
|
|
||||||
}
|
void NavigatorView::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
void NavigatorView::paintEvent(QPaintEvent *event)
|
m_mouseDown = true;
|
||||||
{
|
|
||||||
QGraphicsView::paintEvent(event);
|
if (m_mainView) {
|
||||||
|
m_mainView->centerOn(mapToScene(event->pos()));
|
||||||
QPainter painter(viewport());
|
update();
|
||||||
painter.setPen(QPen(Qt::gray, 2));
|
}
|
||||||
painter.drawRect(m_viewportRegion.boundingRect());
|
|
||||||
}
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigatorView::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (m_mouseDown && m_mainView) {
|
||||||
|
m_mainView->centerOn(mapToScene(event->pos()));
|
||||||
|
update();
|
||||||
|
event->accept();
|
||||||
|
} else {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigatorView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
m_mouseDown = false;
|
||||||
|
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigatorView::wheelEvent(QWheelEvent *event)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
return QGraphicsView::wheelEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigatorView::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QGraphicsView::paintEvent(event);
|
||||||
|
|
||||||
|
QPainter painter(viewport());
|
||||||
|
painter.setPen(QPen(Qt::gray, 2));
|
||||||
|
painter.drawRect(m_viewportRegion.boundingRect());
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,38 +1,38 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef NAVIGATORVIEW_H
|
#ifndef NAVIGATORVIEW_H
|
||||||
#define NAVIGATORVIEW_H
|
#define NAVIGATORVIEW_H
|
||||||
|
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
||||||
class OpacityHelper;
|
class GraphicsView;
|
||||||
class GraphicsView;
|
class NavigatorView : public QGraphicsView
|
||||||
class NavigatorView : public QGraphicsView
|
{
|
||||||
{
|
Q_OBJECT
|
||||||
Q_OBJECT
|
public:
|
||||||
public:
|
NavigatorView(QWidget *parent = nullptr);
|
||||||
NavigatorView(QWidget *parent = nullptr);
|
|
||||||
|
void setMainView(GraphicsView *mainView);
|
||||||
void setMainView(GraphicsView *mainView);
|
|
||||||
void setOpacity(qreal opacity, bool animated = true);
|
public slots:
|
||||||
|
void updateMainViewportRegion();
|
||||||
public slots:
|
|
||||||
void updateMainViewportRegion();
|
private slots:
|
||||||
|
void updateStyle(Qt::ColorScheme colorScheme);
|
||||||
private:
|
|
||||||
void mousePressEvent(QMouseEvent * event) override;
|
private:
|
||||||
void mouseMoveEvent(QMouseEvent * event) override;
|
void mousePressEvent(QMouseEvent * event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent * event) override;
|
void mouseMoveEvent(QMouseEvent * event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent * event) override;
|
||||||
void wheelEvent(QWheelEvent *event) override;
|
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
|
void paintEvent(QPaintEvent *event) override;
|
||||||
bool m_mouseDown = false;
|
|
||||||
QPolygon m_viewportRegion;
|
bool m_mouseDown = false;
|
||||||
QGraphicsView *m_mainView = nullptr;
|
QPolygon m_viewportRegion;
|
||||||
OpacityHelper *m_opacityHelper = nullptr;
|
QGraphicsView *m_mainView = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NAVIGATORVIEW_H
|
#endif // NAVIGATORVIEW_H
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#include "opacityhelper.h"
|
|
||||||
|
|
||||||
#include <QGraphicsOpacityEffect>
|
|
||||||
#include <QPropertyAnimation>
|
|
||||||
|
|
||||||
OpacityHelper::OpacityHelper(QWidget *parent)
|
|
||||||
: QObject(parent)
|
|
||||||
, m_opacityFx(new QGraphicsOpacityEffect(parent))
|
|
||||||
, m_opacityAnimation(new QPropertyAnimation(m_opacityFx, "opacity"))
|
|
||||||
{
|
|
||||||
parent->setGraphicsEffect(m_opacityFx);
|
|
||||||
|
|
||||||
m_opacityAnimation->setDuration(300);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpacityHelper::setOpacity(qreal opacity, bool animated)
|
|
||||||
{
|
|
||||||
if (!animated) {
|
|
||||||
m_opacityFx->setOpacity(opacity);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_opacityAnimation->stop();
|
|
||||||
m_opacityAnimation->setStartValue(m_opacityFx->opacity());
|
|
||||||
m_opacityAnimation->setEndValue(opacity);
|
|
||||||
m_opacityAnimation->start();
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#ifndef OPACITYHELPER_H
|
|
||||||
#define OPACITYHELPER_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QGraphicsOpacityEffect;
|
|
||||||
class QPropertyAnimation;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class OpacityHelper : QObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OpacityHelper(QWidget * parent);
|
|
||||||
|
|
||||||
void setOpacity(qreal opacity, bool animated = true);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QGraphicsOpacityEffect * m_opacityFx;
|
|
||||||
QPropertyAnimation * m_opacityAnimation;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // OPACITYHELPER_H
|
|
||||||
@@ -1,283 +1,295 @@
|
|||||||
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "playlistmanager.h"
|
#include "playlistmanager.h"
|
||||||
|
#include "playlistscout.h"
|
||||||
#include <QCollator>
|
|
||||||
#include <QDir>
|
#include <QCollator>
|
||||||
#include <QFileInfo>
|
#include <QDir>
|
||||||
#include <QUrl>
|
#include <QFileInfo>
|
||||||
|
#include <QUrl>
|
||||||
PlaylistModel::PlaylistModel(QObject *parent)
|
|
||||||
: QAbstractListModel(parent)
|
PlaylistManager::PlaylistManager(QObject *parent)
|
||||||
{
|
: QObject(parent)
|
||||||
|
, m_currentIndex(std::nullopt)
|
||||||
}
|
, m_playlist()
|
||||||
|
, m_allowedSuffixes()
|
||||||
PlaylistModel::~PlaylistModel()
|
{
|
||||||
= default;
|
|
||||||
|
}
|
||||||
void PlaylistModel::setPlaylist(const QList<QUrl> &urls)
|
|
||||||
{
|
PlaylistManager::~PlaylistManager()
|
||||||
beginResetModel();
|
{
|
||||||
m_playlist = urls;
|
|
||||||
endResetModel();
|
}
|
||||||
}
|
|
||||||
|
// region: Allowed Suffixes Operations
|
||||||
QModelIndex PlaylistModel::loadPlaylist(const QList<QUrl> & urls)
|
|
||||||
{
|
const QStringList& PlaylistManager::allowedSuffixes() const {
|
||||||
if (urls.isEmpty()) return {};
|
return m_allowedSuffixes;
|
||||||
if (urls.count() == 1) {
|
}
|
||||||
return loadPlaylist(urls.constFirst());
|
|
||||||
} else {
|
void PlaylistManager::setAllowedSuffixes(const QStringList& nameFilters) {
|
||||||
setPlaylist(urls);
|
m_allowedSuffixes = nameFilters;
|
||||||
return index(0);
|
emit allowedSuffixesChanged(m_allowedSuffixes);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// endregion
|
||||||
QModelIndex PlaylistModel::loadPlaylist(const QUrl &url)
|
|
||||||
{
|
// region: Playlist Loader and Reset
|
||||||
QFileInfo info(url.toLocalFile());
|
|
||||||
QDir dir(info.path());
|
bool PlaylistManager::loadPlaylist(const QStringList& files) {
|
||||||
QString && currentFileName = info.fileName();
|
// Convert string list to url list first
|
||||||
|
QList<QUrl> urls;
|
||||||
if (dir.path() == m_currentDir) {
|
for (const QString & file : std::as_const(files)) {
|
||||||
int idx = indexOf(url);
|
urls.append(urlFromString(file));
|
||||||
return idx == -1 ? appendToPlaylist(url) : index(idx);
|
}
|
||||||
}
|
|
||||||
|
return loadPlaylist(urls);
|
||||||
QStringList entryList = dir.entryList(
|
}
|
||||||
m_autoLoadSuffixes,
|
|
||||||
QDir::Files | QDir::NoSymLinks, QDir::NoSort);
|
bool PlaylistManager::loadPlaylist(const QList<QUrl>& urls) {
|
||||||
|
// Check its count, and check M3U8 playlist for single file case.
|
||||||
QCollator collator;
|
if (urls.isEmpty()) {
|
||||||
collator.setNumericMode(true);
|
clearPlaylist();
|
||||||
|
return true;
|
||||||
std::sort(entryList.begin(), entryList.end(), collator);
|
} else if (urls.count() == 1) {
|
||||||
|
const QUrl& firstUrl = urls.first();
|
||||||
QList<QUrl> playlist;
|
const QString lowerCaseUrlPath(firstUrl.path().toLower());
|
||||||
|
if (lowerCaseUrlPath.endsWith(".m3u8") || lowerCaseUrlPath.endsWith(".m3u")) {
|
||||||
int idx = -1;
|
return loadM3U8Playlist(firstUrl);
|
||||||
for (int i = 0; i < entryList.count(); i++) {
|
} else {
|
||||||
const QString & fileName = entryList.at(i);
|
return loadSingleFilePlaylist(firstUrl);
|
||||||
const QString & oneEntry = dir.absoluteFilePath(fileName);
|
}
|
||||||
const QUrl & url = QUrl::fromLocalFile(oneEntry);
|
} else {
|
||||||
playlist.append(url);
|
return loadMultipleFilesPlaylist(std::move(urls));
|
||||||
if (fileName == currentFileName) {
|
}
|
||||||
idx = i;
|
}
|
||||||
}
|
|
||||||
}
|
bool PlaylistManager::loadSingleFilePlaylist(const QUrl& url) {
|
||||||
if (idx == -1) {
|
// Check URL at first
|
||||||
idx = playlist.count();
|
if (!checkUrl(url))
|
||||||
playlist.append(url);
|
return false;
|
||||||
}
|
|
||||||
m_currentDir = dir.path();
|
// Scout playlist by given file
|
||||||
|
auto scoutResult = PlaylistScout::scout(url, m_allowedSuffixes);
|
||||||
setPlaylist(playlist);
|
if (!scoutResult.has_value()) {
|
||||||
|
return false;
|
||||||
return index(idx);
|
}
|
||||||
}
|
|
||||||
|
// Setup playlist with index
|
||||||
QModelIndex PlaylistModel::appendToPlaylist(const QUrl &url)
|
setPlaylist(std::move(scoutResult->playlist), scoutResult->indexHint);
|
||||||
{
|
return true;
|
||||||
const int lastIndex = rowCount();
|
}
|
||||||
beginInsertRows(QModelIndex(), lastIndex, lastIndex);
|
|
||||||
m_playlist.append(url);
|
bool PlaylistManager::loadMultipleFilesPlaylist(const QList<QUrl>&& urls) {
|
||||||
endInsertRows();
|
// Check all of them are valid
|
||||||
return index(lastIndex);
|
for (const auto& url : std::as_const(urls)) {
|
||||||
}
|
if (!checkUrl(url)) {
|
||||||
|
return false;
|
||||||
bool PlaylistModel::removeAt(int index)
|
}
|
||||||
{
|
}
|
||||||
if (index < 0 || index >= rowCount()) return false;
|
|
||||||
beginRemoveRows(QModelIndex(), index, index);
|
// Set playlist and return
|
||||||
m_playlist.removeAt(index);
|
setPlaylist(std::move(urls));
|
||||||
endRemoveRows();
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
bool PlaylistManager::loadM3U8Playlist(const QUrl& url) {
|
||||||
int PlaylistModel::indexOf(const QUrl &url) const
|
// Check URL at first
|
||||||
{
|
if (!checkUrl(url))
|
||||||
return m_playlist.indexOf(url);
|
return false;
|
||||||
}
|
|
||||||
|
QList<QUrl> urls;
|
||||||
QUrl PlaylistModel::urlByIndex(int index) const
|
QFile file(url.toLocalFile());
|
||||||
{
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
return m_playlist.value(index);
|
while (!file.atEnd()) {
|
||||||
}
|
QString line = file.readLine();
|
||||||
|
if (line.startsWith('#')) {
|
||||||
QStringList PlaylistModel::autoLoadFilterSuffixes() const
|
continue;
|
||||||
{
|
}
|
||||||
return m_autoLoadSuffixes;
|
QFileInfo fileInfo(file);
|
||||||
}
|
QUrl item = QUrl::fromUserInput(line, fileInfo.absolutePath());
|
||||||
|
if (!checkUrl(item)) {
|
||||||
QHash<int, QByteArray> PlaylistModel::roleNames() const
|
return false;
|
||||||
{
|
}
|
||||||
QHash<int, QByteArray> result = QAbstractListModel::roleNames();
|
urls.append(item);
|
||||||
result.insert(UrlRole, "url");
|
}
|
||||||
return result;
|
} else {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
int PlaylistModel::rowCount(const QModelIndex &parent) const
|
|
||||||
{
|
setPlaylist(std::move(urls));
|
||||||
return m_playlist.count();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant PlaylistModel::data(const QModelIndex &index, int role) const
|
void PlaylistManager::setPlaylist(const QList<QUrl>&& urls, std::optional<qsizetype> indexHint) {
|
||||||
{
|
// Setup playlist
|
||||||
if (!index.isValid()) return {};
|
m_playlist = std::move(urls);
|
||||||
|
|
||||||
switch (role) {
|
// Set index with hint
|
||||||
case Qt::DisplayRole:
|
if (indexHint.has_value()) {
|
||||||
return m_playlist.at(index.row()).fileName();
|
m_currentIndex = *indexHint;
|
||||||
case UrlRole:
|
}
|
||||||
return m_playlist.at(index.row());
|
sanitizeIndex();
|
||||||
}
|
|
||||||
|
// Raise signal
|
||||||
return {};
|
emit playlistChanged(totalCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistManager::PlaylistManager(QObject *parent)
|
void PlaylistManager::clearPlaylist() {
|
||||||
: QObject(parent)
|
m_playlist.clear();
|
||||||
{
|
sanitizeIndex();
|
||||||
connect(&m_model, &PlaylistModel::rowsRemoved, this,
|
emit playlistChanged(this->totalCount());
|
||||||
[this](const QModelIndex &, int, int) {
|
}
|
||||||
if (m_model.rowCount() <= m_currentIndex) {
|
|
||||||
setProperty("currentIndex", m_currentIndex - 1);
|
// endregion
|
||||||
}
|
|
||||||
});
|
// region: Playlist Operations
|
||||||
|
|
||||||
auto onRowCountChanged = [this](){
|
void PlaylistManager::appendToPlaylist(const QString &file)
|
||||||
emit totalCountChanged(m_model.rowCount());
|
{
|
||||||
};
|
return appendToPlaylist(urlFromString(file));
|
||||||
|
}
|
||||||
connect(&m_model, &PlaylistModel::rowsInserted, this, onRowCountChanged);
|
|
||||||
connect(&m_model, &PlaylistModel::rowsRemoved, this, onRowCountChanged);
|
void PlaylistManager::appendToPlaylist(const QUrl &url)
|
||||||
connect(&m_model, &PlaylistModel::modelReset, this, onRowCountChanged);
|
{
|
||||||
}
|
m_playlist.append(url);
|
||||||
|
sanitizeIndex();
|
||||||
PlaylistManager::~PlaylistManager()
|
emit playlistChanged(totalCount());
|
||||||
{
|
}
|
||||||
|
|
||||||
}
|
bool PlaylistManager::insertIntoPlaylist(qsizetype index, const QString &file)
|
||||||
|
{
|
||||||
PlaylistModel *PlaylistManager::model()
|
return insertIntoPlaylist(index, urlFromString(file));
|
||||||
{
|
}
|
||||||
return &m_model;
|
|
||||||
}
|
bool PlaylistManager::insertIntoPlaylist(qsizetype index, const QUrl &url)
|
||||||
|
{
|
||||||
void PlaylistManager::setPlaylist(const QList<QUrl> &urls)
|
if (index < 0 || index > totalCount()) {
|
||||||
{
|
return false;
|
||||||
m_model.setPlaylist(urls);
|
} else {
|
||||||
}
|
m_playlist.insert(index, url);
|
||||||
|
sanitizeIndex();
|
||||||
QModelIndex PlaylistManager::loadPlaylist(const QList<QUrl> &urls)
|
emit playlistChanged(totalCount());
|
||||||
{
|
return true;
|
||||||
QModelIndex idx = m_model.loadPlaylist(urls);
|
}
|
||||||
setProperty("currentIndex", idx.row());
|
}
|
||||||
return idx;
|
|
||||||
}
|
bool PlaylistManager::removeFromPlaylist(qsizetype index)
|
||||||
|
{
|
||||||
QModelIndex PlaylistManager::loadPlaylist(const QUrl &url)
|
if (index < 0 || index >= totalCount()) {
|
||||||
{
|
return false;
|
||||||
QModelIndex idx = m_model.loadPlaylist(url);
|
} else {
|
||||||
setProperty("currentIndex", idx.row());
|
m_playlist.removeAt(index);
|
||||||
return idx;
|
sanitizeIndex();
|
||||||
}
|
emit playlistChanged(totalCount());
|
||||||
|
return true;
|
||||||
QModelIndex PlaylistManager::loadM3U8Playlist(const QUrl &url)
|
}
|
||||||
{
|
}
|
||||||
QFile file(url.toLocalFile());
|
|
||||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
// endregion
|
||||||
QList<QUrl> urls;
|
|
||||||
while (!file.atEnd()) {
|
// region: Index Operations
|
||||||
QString line = file.readLine();
|
|
||||||
if (line.startsWith('#')) {
|
qsizetype PlaylistManager::totalCount() const
|
||||||
continue;
|
{
|
||||||
}
|
return m_playlist.count();
|
||||||
QFileInfo fileInfo(file);
|
}
|
||||||
QUrl item = QUrl::fromUserInput(line, fileInfo.absolutePath());
|
|
||||||
urls.append(item);
|
std::optional<qsizetype> PlaylistManager::previousIndex() const
|
||||||
}
|
{
|
||||||
return loadPlaylist(urls);
|
if (!m_currentIndex.has_value() || totalCount() <= 0) return std::nullopt;
|
||||||
} else {
|
return (isFirstIndex() ? totalCount() - 1 : *m_currentIndex - 1);
|
||||||
return {};
|
}
|
||||||
}
|
|
||||||
}
|
std::optional<qsizetype> PlaylistManager::nextIndex() const
|
||||||
|
{
|
||||||
int PlaylistManager::totalCount() const
|
if (!m_currentIndex.has_value() || totalCount() <= 0) return std::nullopt;
|
||||||
{
|
return (isLastIndex() ? 0 : *m_currentIndex + 1);
|
||||||
return m_model.rowCount();
|
}
|
||||||
}
|
|
||||||
|
bool PlaylistManager::isFirstIndex() const
|
||||||
QModelIndex PlaylistManager::previousIndex() const
|
{
|
||||||
{
|
return m_currentIndex.has_value() && *m_currentIndex == 0;
|
||||||
int count = totalCount();
|
}
|
||||||
if (count == 0) return {};
|
|
||||||
|
bool PlaylistManager::isLastIndex() const
|
||||||
return m_model.index(isFirstIndex() ? count - 1 : m_currentIndex - 1);
|
{
|
||||||
}
|
return m_currentIndex.has_value() && *m_currentIndex + 1 == totalCount();
|
||||||
|
}
|
||||||
QModelIndex PlaylistManager::nextIndex() const
|
|
||||||
{
|
std::optional<qsizetype> PlaylistManager::currentIndex() const
|
||||||
int count = totalCount();
|
{
|
||||||
if (count == 0) return {};
|
return m_currentIndex;
|
||||||
|
}
|
||||||
return m_model.index(isLastIndex() ? 0 : m_currentIndex + 1);
|
|
||||||
}
|
bool PlaylistManager::setCurrentIndex(qsizetype index)
|
||||||
|
{
|
||||||
QModelIndex PlaylistManager::curIndex() const
|
if (!m_currentIndex.has_value()) {
|
||||||
{
|
return false;
|
||||||
return m_model.index(m_currentIndex);
|
}
|
||||||
}
|
if (index < 0 || index >= totalCount()) {
|
||||||
|
return false;
|
||||||
bool PlaylistManager::isFirstIndex() const
|
}
|
||||||
{
|
if (*m_currentIndex == index) {
|
||||||
return m_currentIndex == 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlaylistManager::isLastIndex() const
|
m_currentIndex = index;
|
||||||
{
|
emit currentIndexChanged(index);
|
||||||
return m_currentIndex + 1 == totalCount();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistManager::setCurrentIndex(const QModelIndex &index)
|
QUrl PlaylistManager::urlByIndex(qsizetype index) const
|
||||||
{
|
{
|
||||||
if (index.isValid() && index.row() >= 0 && index.row() < totalCount()) {
|
return m_playlist.value(index);
|
||||||
setProperty("currentIndex", index.row());
|
}
|
||||||
}
|
|
||||||
}
|
QString PlaylistManager::localFileByIndex(qsizetype index) const
|
||||||
|
{
|
||||||
QUrl PlaylistManager::urlByIndex(const QModelIndex &index)
|
return urlByIndex(index).toLocalFile();
|
||||||
{
|
}
|
||||||
return m_model.urlByIndex(index.row());
|
|
||||||
}
|
// endregion
|
||||||
|
|
||||||
QString PlaylistManager::localFileByIndex(const QModelIndex &index)
|
// region: Misc
|
||||||
{
|
|
||||||
return urlByIndex(index).toLocalFile();
|
void PlaylistManager::sanitizeIndex()
|
||||||
}
|
{
|
||||||
|
auto cnt = totalCount();
|
||||||
bool PlaylistManager::removeAt(const QModelIndex &index)
|
if (cnt == 0) {
|
||||||
{
|
// If playlist is empty, current index should be invalid.
|
||||||
return m_model.removeAt(index.row());
|
m_currentIndex = std::nullopt;
|
||||||
}
|
} else {
|
||||||
|
if (m_currentIndex.has_value()) {
|
||||||
void PlaylistManager::setAutoLoadFilterSuffixes(const QStringList &nameFilters)
|
// Clamp current index in playlist range.
|
||||||
{
|
// If it is already in range, not change was done.
|
||||||
m_model.setProperty("autoLoadFilterSuffixes", nameFilters);
|
auto currentIndex = *m_currentIndex;
|
||||||
}
|
if (currentIndex < 0) {
|
||||||
|
m_currentIndex = 0;
|
||||||
QList<QUrl> PlaylistManager::convertToUrlList(const QStringList &files)
|
} else if (currentIndex >= cnt) {
|
||||||
{
|
m_currentIndex = cnt - 1;
|
||||||
QList<QUrl> urlList;
|
} else {
|
||||||
for (const QString & str : std::as_const(files)) {
|
; // No change.
|
||||||
QUrl url = QUrl::fromLocalFile(str);
|
}
|
||||||
if (url.isValid()) {
|
} else {
|
||||||
urlList.append(url);
|
// If there is no set value for current index,
|
||||||
}
|
// set it at the beginning of playlist.
|
||||||
}
|
m_currentIndex = 0;
|
||||||
|
}
|
||||||
return urlList;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlaylistManager::checkUrl(const QUrl& url)
|
||||||
|
{
|
||||||
|
return url.isValid() && url.isLocalFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl PlaylistManager::urlFromString(const QString& file)
|
||||||
|
{
|
||||||
|
return QUrl::fromLocalFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|||||||
@@ -1,88 +1,130 @@
|
|||||||
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QAbstractListModel>
|
#include <QObject>
|
||||||
|
#include <optional>
|
||||||
class PlaylistModel : public QAbstractListModel
|
|
||||||
{
|
/// The manager of playlist.
|
||||||
Q_OBJECT
|
class PlaylistManager : public QObject
|
||||||
public:
|
{
|
||||||
enum PlaylistRole {
|
Q_OBJECT
|
||||||
UrlRole = Qt::UserRole
|
public:
|
||||||
};
|
/// Constructs a PlaylistManager with an optional parent QObject.
|
||||||
Q_ENUM(PlaylistRole)
|
explicit PlaylistManager(QObject* parent = nullptr);
|
||||||
Q_PROPERTY(QStringList autoLoadFilterSuffixes MEMBER m_autoLoadSuffixes NOTIFY autoLoadFilterSuffixesChanged)
|
/// Destructor.
|
||||||
|
~PlaylistManager();
|
||||||
explicit PlaylistModel(QObject *parent = nullptr);
|
|
||||||
~PlaylistModel() override;
|
/// Get the allowed file suffixes of this playlist.
|
||||||
|
/// @return The current list of allowed suffixes.
|
||||||
void setPlaylist(const QList<QUrl> & urls);
|
const QStringList& allowedSuffixes() const;
|
||||||
QModelIndex loadPlaylist(const QList<QUrl> & urls);
|
/// Set the allowed file suffixes of this playlist.
|
||||||
QModelIndex loadPlaylist(const QUrl & url);
|
/// @remark This only works for "load the whole directory by one file" case.
|
||||||
QModelIndex appendToPlaylist(const QUrl & url);
|
/// @param[in] nameFilters The new list of allowed suffixes.
|
||||||
bool removeAt(int index);
|
void setAllowedSuffixes(const QStringList& nameFilters);
|
||||||
int indexOf(const QUrl & url) const;
|
|
||||||
QUrl urlByIndex(int index) const;
|
/// Load user specified files as playlist.
|
||||||
QStringList autoLoadFilterSuffixes() const;
|
/// @remark The wrapper for another overload.
|
||||||
|
/// @return True for successful load, otherwise false.
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
bool loadPlaylist(const QStringList& files);
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
/// Load user specified URLs as playlist.
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
/// @remark This function automatically dispatch these files into correct sub-load functions.
|
||||||
|
/// @return True for successful load, otherwise false.
|
||||||
signals:
|
bool loadPlaylist(const QList<QUrl>& urls);
|
||||||
void autoLoadFilterSuffixesChanged(QStringList suffixes);
|
/// Clear the entire playlist and reset current index.
|
||||||
|
void clearPlaylist();
|
||||||
private:
|
|
||||||
// model data
|
/// Append a local file path to the playlist.
|
||||||
QList<QUrl> m_playlist;
|
void appendToPlaylist(const QString& file);
|
||||||
// properties
|
/// Append a URL to the playlist.
|
||||||
QStringList m_autoLoadSuffixes = {};
|
void appendToPlaylist(const QUrl& url);
|
||||||
// internal
|
/// Insert a local file path at the given index.
|
||||||
QString m_currentDir;
|
/// @return True if inserted successfully, false if index is out of range.
|
||||||
};
|
bool insertIntoPlaylist(qsizetype index, const QString& file);
|
||||||
|
/// Insert a URL at the given index.
|
||||||
class PlaylistManager : public QObject
|
/// @return True if inserted successfully, false if index is out of range.
|
||||||
{
|
bool insertIntoPlaylist(qsizetype index, const QUrl& url);
|
||||||
Q_OBJECT
|
/// Remove the entry at the given index.
|
||||||
public:
|
/// @return True if removed successfully, false if index is out of range.
|
||||||
Q_PROPERTY(int currentIndex MEMBER m_currentIndex NOTIFY currentIndexChanged)
|
bool removeFromPlaylist(qsizetype index);
|
||||||
Q_PROPERTY(QStringList autoLoadFilterSuffixes WRITE setAutoLoadFilterSuffixes)
|
|
||||||
Q_PROPERTY(PlaylistModel * model READ model CONSTANT)
|
/// Returns the total number of items in the playlist.
|
||||||
|
/// @return Total count of entries in the playlist.
|
||||||
explicit PlaylistManager(QObject *parent = nullptr);
|
qsizetype totalCount() const;
|
||||||
~PlaylistManager();
|
/// Try fetching previous index.
|
||||||
|
/// @details This previous index is gallery-loop-aware.
|
||||||
PlaylistModel * model();
|
/// @return std::nullopt if playlist is empty, otherwise the previous index considering gallery loop.
|
||||||
|
std::optional<qsizetype> previousIndex() const;
|
||||||
void setPlaylist(const QList<QUrl> & url);
|
/// Try fetching next index.
|
||||||
Q_INVOKABLE QModelIndex loadPlaylist(const QList<QUrl> & urls);
|
/// @details This next index is gallery-loop-aware.
|
||||||
Q_INVOKABLE QModelIndex loadPlaylist(const QUrl & url);
|
/// @return std::nullopt if playlist is empty, otherwise the next index considering gallery loop.
|
||||||
Q_INVOKABLE QModelIndex loadM3U8Playlist(const QUrl & url);
|
std::optional<qsizetype> nextIndex() const;
|
||||||
|
/// Check whether current index is the first index.
|
||||||
int totalCount() const;
|
/// @return False if current index is not the first index or playlist is empty, otherwise true.
|
||||||
QModelIndex previousIndex() const;
|
bool isFirstIndex() const;
|
||||||
QModelIndex nextIndex() const;
|
/// Check whether current index is the last index.
|
||||||
QModelIndex curIndex() const;
|
/// @return False if current index is not the last index or playlist is empty, otherwise true.
|
||||||
bool isFirstIndex() const;
|
bool isLastIndex() const;
|
||||||
bool isLastIndex() const;
|
/// Returns the current index.
|
||||||
void setCurrentIndex(const QModelIndex & index);
|
/// @return std::nullopt if the playlist is empty, otherwise the current index.
|
||||||
QUrl urlByIndex(const QModelIndex & index);
|
std::optional<qsizetype> currentIndex() const;
|
||||||
QString localFileByIndex(const QModelIndex & index);
|
/// Set the current index.
|
||||||
bool removeAt(const QModelIndex & index);
|
/// @remark Index only can be set when playlist is not empty.
|
||||||
|
/// @return True if successful set, including "not changed" set, otherwise false.
|
||||||
void setAutoLoadFilterSuffixes(const QStringList &nameFilters);
|
/// This return value only indicates whether we can set index and given index is valid for setting.
|
||||||
|
/// If "no changed" set occurs, this function returns true, but doesn't raise current index changed signal.
|
||||||
static QList<QUrl> convertToUrlList(const QStringList & files);
|
bool setCurrentIndex(qsizetype index);
|
||||||
|
/// Returns the URL at the given index.
|
||||||
signals:
|
/// @return The URL if index is valid.
|
||||||
void currentIndexChanged(int index);
|
/// This class guarantee that this QUrl is pointing to a local file.
|
||||||
void totalCountChanged(int count);
|
QUrl urlByIndex(qsizetype index) const;
|
||||||
|
/// Returns the local file path at the given index.
|
||||||
private:
|
/// @return The local file path if index is valid.
|
||||||
int m_currentIndex = -1;
|
/// This class guarantee that local file path always is valid.
|
||||||
PlaylistModel m_model;
|
QString localFileByIndex(qsizetype index) const;
|
||||||
};
|
|
||||||
|
signals:
|
||||||
|
void allowedSuffixesChanged(const QStringList& suffixes);
|
||||||
|
/// Raised when index was changed bu setter.
|
||||||
|
/// The argument holds the new current index.
|
||||||
|
/// Please note that this signal will NOT be raised by the whole playlist change caused index change.
|
||||||
|
void currentIndexChanged(qsizetype index);
|
||||||
|
/// The whole playlist was changed, involving loading, editing and deleting some or full entries.
|
||||||
|
/// The argument holds the total count of new play list.
|
||||||
|
void playlistChanged(qsizetype count);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// The fundamental playlist setter.
|
||||||
|
/// @details All playlist load functions will call this function to set playlist at last.
|
||||||
|
/// @param[in] urls ALl urls in this list should be checked by checkUrl() function.
|
||||||
|
/// @param[in] indexHint Try to set current index to this index if possible.
|
||||||
|
void setPlaylist(const QList<QUrl>&& urls, std::optional<qsizetype> indexHint = std::nullopt);
|
||||||
|
/// Load playlist from a single file.
|
||||||
|
/// @details This function scans the same directory for siblings matching allowed suffixes, sorted naturally.
|
||||||
|
/// @return True if the playlist was loaded successfully, false otherwise.
|
||||||
|
bool loadSingleFilePlaylist(const QUrl& url);
|
||||||
|
/// Load playlist from multiple URLs directly.
|
||||||
|
/// @return True if all URLs are valid, false otherwise.
|
||||||
|
bool loadMultipleFilesPlaylist(const QList<QUrl>&& urls);
|
||||||
|
/// Load playlist from an M3U/M3U8 playlist file.
|
||||||
|
/// @return True if loaded successfully, false otherwise.
|
||||||
|
bool loadM3U8Playlist(const QUrl& url);
|
||||||
|
|
||||||
|
/// Make sure that current index is valid.
|
||||||
|
/// @details This function usually is used by those functions manipulating playlist.
|
||||||
|
void sanitizeIndex();
|
||||||
|
|
||||||
|
/// Check whether given QUrl is proper to be put into playlist.
|
||||||
|
/// @details Only the url pointing to local file can be put into playlist.
|
||||||
|
static bool checkUrl(const QUrl& url);
|
||||||
|
/// Convert a string to local file into a QUrl.
|
||||||
|
/// @param[in] file The string pointing to local file.
|
||||||
|
static QUrl urlFromString(const QString& file);
|
||||||
|
|
||||||
|
std::optional<qsizetype> m_currentIndex;
|
||||||
|
QList<QUrl> m_playlist;
|
||||||
|
QStringList m_allowedSuffixes;
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2026 yyc12345 <yyc12321@outlook.com>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#include "playlistscout.h"
|
||||||
|
|
||||||
|
#include "playlistscouts/qtscout.h"
|
||||||
|
#include "playlistscouts/explorerscout.h"
|
||||||
|
|
||||||
|
std::optional<PlaylistScout::ScoutResult> PlaylistScout::scout(
|
||||||
|
const QUrl &url, const QStringList &allowedSuffixes) {
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// In Windows, Qt approach can not aware Windows Explorer custom sort order.
|
||||||
|
// So we need to try using Win32 functions for fetching it at first.
|
||||||
|
if (auto rv = PlaylistScout::Explorer::scout(url, allowedSuffixes); rv.has_value()) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
|
// TODO: We may add macOS Finder, KDE Dolphin and etc supports in future.
|
||||||
|
|
||||||
|
// Qt way is the last fallback.
|
||||||
|
return PlaylistScout::Qt::scout(url, allowedSuffixes);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2026 yyc12345 <yyc12321@outlook.com>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QList>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
namespace PlaylistScout {
|
||||||
|
/// The result of scout
|
||||||
|
struct ScoutResult {
|
||||||
|
/// The final fetched playlist (it can be empty).
|
||||||
|
/// Each item must be a QUrl pointing to a local file.
|
||||||
|
QList<QUrl> playlist;
|
||||||
|
/// The index of given file located in playlist.
|
||||||
|
/// Nullopt if it is not presented in playlist.
|
||||||
|
std::optional<qsizetype> indexHint;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @brief Scout available image files in given file's parent dir with given allowed suffixes.
|
||||||
|
/// @param[in] url The path to file whose parent dir is our target dir for finding image files.
|
||||||
|
/// @param[in] allowedSuffixes
|
||||||
|
/// Each items in this list is a wildcard pattern for matching allowed file name, like \c *.png .
|
||||||
|
/// The fetched item will be preserved if its name matching any of them.
|
||||||
|
/// If this list is empty, there is no restrictions for finding files.
|
||||||
|
/// @return Scout result if success, otherwise nullopt.
|
||||||
|
std::optional<ScoutResult> scout(const QUrl &url, const QStringList &allowedSuffixes);
|
||||||
|
}
|
||||||
@@ -0,0 +1,332 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2026 yyc12345 <yyc12321@outlook.com>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#include "explorerscout.h"
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include <exdisp.h> // IShellWindows, CLSID_ShellWindows
|
||||||
|
#include <servprov.h> // IServiceProvider
|
||||||
|
#include <shlguid.h> // SID_STopLevelBrowser
|
||||||
|
#include <shlobj.h>
|
||||||
|
|
||||||
|
// YYC MARK:
|
||||||
|
// We use custom RAII wrappers instead of existing COM smart pointers because the
|
||||||
|
// project may be built with MinGW, which does not have good compatibility with
|
||||||
|
// CComPtr and Microsoft's WRL ComPtr (<wrl/client.h>).
|
||||||
|
// Furthermore, PIDLs are not COM objects (they are freed via ILFree, not Release),
|
||||||
|
// so no standard smart pointer covers them regardless of compiler.
|
||||||
|
|
||||||
|
/// RAII wrapper for COM initialization (CoInitialize / CoUninitialize).
|
||||||
|
/// Must be declared before any COM objects (e.g., ComPtr, UniquePidl) so that
|
||||||
|
/// CoUninitialize runs after all COM objects are released during scope exit.
|
||||||
|
class ComGuard {
|
||||||
|
public:
|
||||||
|
ComGuard() : m_hr(CoInitialize(nullptr)) {}
|
||||||
|
~ComGuard() { if (SUCCEEDED(m_hr)) CoUninitialize(); }
|
||||||
|
ComGuard(const ComGuard&) = delete;
|
||||||
|
ComGuard& operator=(const ComGuard&) = delete;
|
||||||
|
|
||||||
|
bool IsInitialized() const { return SUCCEEDED(m_hr); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
HRESULT m_hr;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// RAII wrapper for COM interface pointers.
|
||||||
|
template <typename T>
|
||||||
|
class ComPtr {
|
||||||
|
public:
|
||||||
|
ComPtr() = default;
|
||||||
|
ComPtr(std::nullptr_t) {}
|
||||||
|
~ComPtr() { Reset(); }
|
||||||
|
ComPtr(const ComPtr&) = delete;
|
||||||
|
ComPtr& operator=(const ComPtr&) = delete;
|
||||||
|
ComPtr(ComPtr&& other) noexcept : m_ptr(other.m_ptr) { other.m_ptr = nullptr; }
|
||||||
|
ComPtr& operator=(ComPtr&& other) noexcept {
|
||||||
|
if (this != &other) {
|
||||||
|
Reset();
|
||||||
|
m_ptr = other.m_ptr;
|
||||||
|
other.m_ptr = nullptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* operator->() const { return m_ptr; }
|
||||||
|
T* Get() const { return m_ptr; }
|
||||||
|
T** GetAddressOf() { return &m_ptr; }
|
||||||
|
explicit operator bool() const { return m_ptr != nullptr; }
|
||||||
|
void Reset() { if (m_ptr) { m_ptr->Release(); m_ptr = nullptr; } }
|
||||||
|
|
||||||
|
private:
|
||||||
|
T* m_ptr = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// RAII wrapper for PIDL (Item ID List).
|
||||||
|
class UniquePidl {
|
||||||
|
public:
|
||||||
|
UniquePidl() = default;
|
||||||
|
explicit UniquePidl(LPITEMIDLIST pidl) : m_pidl(pidl) {}
|
||||||
|
~UniquePidl() { Reset(); }
|
||||||
|
UniquePidl(const UniquePidl&) = delete;
|
||||||
|
UniquePidl& operator=(const UniquePidl&) = delete;
|
||||||
|
UniquePidl(UniquePidl&& other) noexcept : m_pidl(other.m_pidl) { other.m_pidl = nullptr; }
|
||||||
|
UniquePidl& operator=(UniquePidl&& other) noexcept {
|
||||||
|
if (this != &other) {
|
||||||
|
Reset();
|
||||||
|
m_pidl = other.m_pidl;
|
||||||
|
other.m_pidl = nullptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPCITEMIDLIST Get() const { return m_pidl; }
|
||||||
|
LPITEMIDLIST* GetAddressOf() { return &m_pidl; }
|
||||||
|
explicit operator bool() const { return m_pidl != nullptr; }
|
||||||
|
void Reset() { if (m_pidl) { ILFree(m_pidl); m_pidl = nullptr; } }
|
||||||
|
|
||||||
|
private:
|
||||||
|
LPITEMIDLIST m_pidl = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Outputs a diagnostic warning for debugging Windows Explorer integration failures.
|
||||||
|
static void ReportError(const QString& detail)
|
||||||
|
{
|
||||||
|
qWarning("Windows Explorer file list fetch error: %s",
|
||||||
|
qPrintable(detail));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Normalizes a Windows directory path for case-insensitive comparison:
|
||||||
|
/// converts to native separators, lowercases, and ensures a trailing backslash.
|
||||||
|
static QString NormalizePath(const QString& path)
|
||||||
|
{
|
||||||
|
QString result = QDir::toNativeSeparators(path).toLower();
|
||||||
|
if (!result.endsWith(QChar('\\'))) {
|
||||||
|
result += QChar('\\');
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Checks whether the Explorer window represented by the given IDispatch is
|
||||||
|
/// displaying the target folder. Returns its IFolderView2 on match, or null.
|
||||||
|
static ComPtr<IFolderView2> TryMatchWindow(IDispatch* dispatch, const QString& normalizedTarget)
|
||||||
|
{
|
||||||
|
// Navigate: IDispatch -> IServiceProvider -> IShellBrowser.
|
||||||
|
ComPtr<IServiceProvider> serviceProvider;
|
||||||
|
if (FAILED(dispatch->QueryInterface(IID_PPV_ARGS(serviceProvider.GetAddressOf())))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ComPtr<IShellBrowser> shellBrowser;
|
||||||
|
if (FAILED(serviceProvider->QueryService(SID_STopLevelBrowser,
|
||||||
|
IID_PPV_ARGS(shellBrowser.GetAddressOf())))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IShellBrowser -> active IShellView.
|
||||||
|
ComPtr<IShellView> shellView;
|
||||||
|
if (FAILED(shellBrowser->QueryActiveShellView(shellView.GetAddressOf()))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the folder's path via IPersistIDList.
|
||||||
|
ComPtr<IPersistIDList> persistIdList;
|
||||||
|
if (FAILED(shellView->QueryInterface(IID_PPV_ARGS(persistIdList.GetAddressOf())))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
UniquePidl folderPidl;
|
||||||
|
if (FAILED(persistIdList->GetIDList(folderPidl.GetAddressOf()))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
PWSTR pathStr = nullptr;
|
||||||
|
if (FAILED(SHGetNameFromIDList(folderPidl.Get(), SIGDN_DESKTOPABSOLUTEPARSING, &pathStr))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString windowPath = NormalizePath(QString::fromWCharArray(pathStr));
|
||||||
|
CoTaskMemFree(pathStr);
|
||||||
|
|
||||||
|
if (windowPath != normalizedTarget) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Path matches — query IFolderView2 from the ShellView.
|
||||||
|
ComPtr<IFolderView2> folderView2;
|
||||||
|
if (FAILED(shellView->QueryInterface(IID_PPV_ARGS(folderView2.GetAddressOf())))) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return folderView2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tries to find a live Explorer window that is currently displaying the given
|
||||||
|
/// folder path. Returns the IFolderView2 from that window, or an empty ComPtr.
|
||||||
|
///
|
||||||
|
/// Explorer's sort order is stored only in the running Explorer process's memory.
|
||||||
|
/// Creating a new shell view via IShellFolder::CreateViewObject yields a default
|
||||||
|
/// sort (always by name), so we must find the actual live IFolderView2 instead.
|
||||||
|
///
|
||||||
|
/// Reference:
|
||||||
|
/// - https://www.stephenli.ca/getting-windows-explorers-current-directory-sort-order
|
||||||
|
/// - https://github.com/d2phap/ImageGlass/blob/75a296287f338edcf409eee3917531b25ff5d927/v9/Components/ImageGlass.Base/FileSystem/FileFinder.cs
|
||||||
|
/// - NuGet Package: D2Phap.EggShell
|
||||||
|
static ComPtr<IFolderView2> FindLiveFolderView(const QString& targetFolderPath)
|
||||||
|
{
|
||||||
|
// Create the Shell windows collection (all open Explorer windows).
|
||||||
|
ComPtr<IShellWindows> shellWindows;
|
||||||
|
if (FAILED(CoCreateInstance(CLSID_ShellWindows, nullptr, CLSCTX_ALL,
|
||||||
|
IID_PPV_ARGS(shellWindows.GetAddressOf())))) {
|
||||||
|
ReportError("Failed to create IShellWindows instance");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString normalizedTarget = NormalizePath(targetFolderPath);
|
||||||
|
|
||||||
|
// 1. Try the Desktop window first — it may contain the file the user opened.
|
||||||
|
{
|
||||||
|
VARIANT varLoc;
|
||||||
|
VariantInit(&varLoc);
|
||||||
|
varLoc.vt = VT_I4;
|
||||||
|
varLoc.lVal = 0;
|
||||||
|
|
||||||
|
VARIANT varLocRoot;
|
||||||
|
VariantInit(&varLocRoot);
|
||||||
|
|
||||||
|
long desktopHwnd = 0;
|
||||||
|
ComPtr<IDispatch> desktopDispatch;
|
||||||
|
HRESULT findHr = shellWindows->FindWindowSW(
|
||||||
|
&varLoc, &varLocRoot, SWC_DESKTOP,
|
||||||
|
&desktopHwnd, SWFO_NEEDDISPATCH,
|
||||||
|
desktopDispatch.GetAddressOf());
|
||||||
|
|
||||||
|
VariantClear(&varLoc);
|
||||||
|
VariantClear(&varLocRoot);
|
||||||
|
|
||||||
|
if (SUCCEEDED(findHr) && desktopDispatch) {
|
||||||
|
ComPtr<IFolderView2> result = TryMatchWindow(desktopDispatch.Get(), normalizedTarget);
|
||||||
|
if (result) return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Iterate regular Explorer windows.
|
||||||
|
LONG count = 0;
|
||||||
|
shellWindows->get_Count(&count);
|
||||||
|
|
||||||
|
for (LONG i = 0; i < count; i++) {
|
||||||
|
VARIANT varIndex;
|
||||||
|
VariantInit(&varIndex);
|
||||||
|
varIndex.vt = VT_I4;
|
||||||
|
varIndex.lVal = i;
|
||||||
|
|
||||||
|
ComPtr<IDispatch> dispatch;
|
||||||
|
HRESULT itemHr = shellWindows->Item(varIndex, dispatch.GetAddressOf());
|
||||||
|
VariantClear(&varIndex);
|
||||||
|
|
||||||
|
if (FAILED(itemHr) || !dispatch) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ComPtr<IFolderView2> result = TryMatchWindow(dispatch.Get(), normalizedTarget);
|
||||||
|
if (result) return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<PlaylistScout::ScoutResult> PlaylistScout::Explorer::scout(
|
||||||
|
const QUrl &url, const QStringList &allowedSuffixes) {
|
||||||
|
PlaylistScout::ScoutResult rv;
|
||||||
|
|
||||||
|
QFileInfo info(url.toLocalFile());
|
||||||
|
QString folderPath = info.path();
|
||||||
|
QString currentFileName = info.fileName();
|
||||||
|
|
||||||
|
// Pre-compile wildcard suffix filters into regular expressions for performance.
|
||||||
|
QList<QRegularExpression> nameRegexps;
|
||||||
|
for (const QString &pattern : allowedSuffixes) {
|
||||||
|
nameRegexps.append(QRegularExpression(
|
||||||
|
QRegularExpression::wildcardToRegularExpression(pattern),
|
||||||
|
QRegularExpression::CaseInsensitiveOption));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize COM. The ComGuard must be declared before any COM objects
|
||||||
|
// below so that CoUninitialize runs after all of them are released.
|
||||||
|
ComGuard comGuard;
|
||||||
|
if (!comGuard.IsInitialized()) {
|
||||||
|
ReportError("COM initialization failed");
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find a live Explorer window that is currently displaying the target folder.
|
||||||
|
ComPtr<IFolderView2> folderView2 = FindLiveFolderView(folderPath);
|
||||||
|
if (!folderView2) {
|
||||||
|
ReportError("No open Explorer window matches the folder: " + folderPath);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get items already sorted in Explorer's view order, as an IShellItemArray.
|
||||||
|
// SVGIO_ALLVIEW returns all items; SVGIO_FLAG_VIEWORDER respects the view's sort.
|
||||||
|
ComPtr<IShellItemArray> itemArray;
|
||||||
|
if (FAILED(folderView2->Items(SVGIO_ALLVIEW | SVGIO_FLAG_VIEWORDER,
|
||||||
|
IID_PPV_ARGS(itemArray.GetAddressOf())))) {
|
||||||
|
ReportError("IFolderView2::Items(SVGIO_ALLVIEW | SVGIO_FLAG_VIEWORDER) failed");
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD itemCount = 0;
|
||||||
|
itemArray->GetCount(&itemCount);
|
||||||
|
|
||||||
|
// Enumerate sorted items, filter by pattern, and build the playlist.
|
||||||
|
for (DWORD i = 0; i < itemCount; i++) {
|
||||||
|
ComPtr<IShellItem> shellItem;
|
||||||
|
if (FAILED(itemArray->GetItemAt(i, shellItem.GetAddressOf()))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the full parsing path of the item.
|
||||||
|
PWSTR pathStr = nullptr;
|
||||||
|
if (FAILED(shellItem->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pathStr)) || !pathStr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QString filePath = QString::fromWCharArray(pathStr);
|
||||||
|
CoTaskMemFree(pathStr);
|
||||||
|
|
||||||
|
// Skip directories — the view may include folders alongside files.
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
if (!fileInfo.isFile()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString fileName = fileInfo.fileName();
|
||||||
|
|
||||||
|
// Match against compiled wildcard patterns.
|
||||||
|
bool matches = nameRegexps.isEmpty();
|
||||||
|
for (const QRegularExpression &re : std::as_const(nameRegexps)) {
|
||||||
|
if (re.match(fileName).hasMatch()) {
|
||||||
|
matches = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!matches) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv.playlist.append(QUrl::fromLocalFile(filePath));
|
||||||
|
if (fileName == currentFileName) {
|
||||||
|
rv.indexHint = rv.playlist.size() - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Q_OS_WIN
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2026 yyc12345 <yyc12321@outlook.com>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../playlistscout.h"
|
||||||
|
#include <QtSystemDetection>
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
|
namespace PlaylistScout::Explorer {
|
||||||
|
std::optional<ScoutResult> scout(const QUrl &url, const QStringList &allowedSuffixes);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Q_OS_WIN
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2025 Gary Wang <git@blumia.net>
|
||||||
|
// SPDX-FileCopyrightText: 2026 yyc12345 <yyc12321@outlook.com>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#include "qtscout.h"
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QCollator>
|
||||||
|
|
||||||
|
std::optional<PlaylistScout::ScoutResult> PlaylistScout::Qt::scout(
|
||||||
|
const QUrl &url, const QStringList &allowedSuffixes) {
|
||||||
|
PlaylistScout::ScoutResult rv;
|
||||||
|
|
||||||
|
QFileInfo info(url.toLocalFile());
|
||||||
|
QDir dir(info.path());
|
||||||
|
QString currentFileName = info.fileName();
|
||||||
|
|
||||||
|
QStringList entryList = dir.entryList(
|
||||||
|
allowedSuffixes, QDir::Files | QDir::NoSymLinks, QDir::NoSort);
|
||||||
|
|
||||||
|
QCollator collator;
|
||||||
|
collator.setNumericMode(true);
|
||||||
|
|
||||||
|
std::sort(entryList.begin(), entryList.end(), collator);
|
||||||
|
|
||||||
|
for (qsizetype i = 0; i < entryList.count(); i++) {
|
||||||
|
const QString &fileName = entryList.at(i);
|
||||||
|
const QString &oneEntry = dir.absoluteFilePath(fileName);
|
||||||
|
const QUrl &url = QUrl::fromLocalFile(oneEntry);
|
||||||
|
|
||||||
|
rv.playlist.append(url);
|
||||||
|
if (fileName == currentFileName) {
|
||||||
|
rv.indexHint = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2026 yyc12345 <yyc12321@outlook.com>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../playlistscout.h"
|
||||||
|
|
||||||
|
namespace PlaylistScout::Qt {
|
||||||
|
std::optional<ScoutResult> scout(const QUrl &url, const QStringList &allowedSuffixes);
|
||||||
|
}
|
||||||
@@ -1,226 +1,174 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
namespace QEnumHelper
|
Settings *Settings::instance()
|
||||||
{
|
{
|
||||||
template <typename E>
|
// SAFETY:
|
||||||
E fromString(const QString &text, const E defaultValue)
|
// This is a global singleton and it is leaked by design.
|
||||||
{
|
static Settings* INSTANCE = new Settings(nullptr);
|
||||||
bool ok;
|
return INSTANCE;
|
||||||
E result = static_cast<E>(QMetaEnum::fromType<E>().keyToValue(text.toUtf8(), &ok));
|
}
|
||||||
if (!ok) {
|
|
||||||
return defaultValue;
|
namespace QEnumHelper
|
||||||
}
|
{
|
||||||
return result;
|
template <typename E>
|
||||||
}
|
E fromString(const QString &text, const E defaultValue)
|
||||||
|
{
|
||||||
template <typename E>
|
bool ok;
|
||||||
QString toString(E value)
|
E result = static_cast<E>(QMetaEnum::fromType<E>().keyToValue(text.toUtf8(), &ok));
|
||||||
{
|
if (!ok) {
|
||||||
const int intValue = static_cast<int>(value);
|
return defaultValue;
|
||||||
return QString::fromUtf8(QMetaEnum::fromType<E>().valueToKey(intValue));
|
}
|
||||||
}
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings *Settings::m_settings_instance = nullptr;
|
template <typename E>
|
||||||
|
QString toString(E value)
|
||||||
Settings *Settings::instance()
|
{
|
||||||
{
|
const int intValue = static_cast<int>(value);
|
||||||
if (!m_settings_instance) {
|
return QString::fromUtf8(QMetaEnum::fromType<E>().valueToKey(intValue));
|
||||||
m_settings_instance = new Settings;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_settings_instance;
|
bool Settings::showNavigatorView() const
|
||||||
}
|
{
|
||||||
|
return m_qsettings->value("show_navigator_view", true).toBool();
|
||||||
bool Settings::stayOnTop() const
|
}
|
||||||
{
|
|
||||||
return m_qsettings->value("stay_on_top", true).toBool();
|
bool Settings::useLightCheckerboard() const
|
||||||
}
|
{
|
||||||
|
return m_qsettings->value("use_light_checkerboard", false).toBool();
|
||||||
bool Settings::useBuiltInCloseAnimation() const
|
}
|
||||||
{
|
|
||||||
return m_qsettings->value("use_built_in_close_animation", true).toBool();
|
bool Settings::loopGallery() const
|
||||||
}
|
{
|
||||||
|
return m_qsettings->value("loop_gallery", true).toBool();
|
||||||
bool Settings::useLightCheckerboard() const
|
}
|
||||||
{
|
|
||||||
return m_qsettings->value("use_light_checkerboard", false).toBool();
|
bool Settings::svgTiny12Only() const
|
||||||
}
|
{
|
||||||
|
// Qt 6.7.0's SVG support is terrible caused by huge memory usage, see QTBUG-124287
|
||||||
bool Settings::loopGallery() const
|
// Qt 6.7.1's is somewhat better, memory issue seems fixed, but still laggy when zoom in, see QTBUG-126771.
|
||||||
{
|
// Qt 6.9.3 and Qt 6.10.1 seems no longer have the laggy issue, so let's make the default value different
|
||||||
return m_qsettings->value("loop_gallery", true).toBool();
|
// based on Qt version.
|
||||||
}
|
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 3)
|
||||||
|
return m_qsettings->value("svg_tiny12_only", true).toBool();
|
||||||
Settings::DoubleClickBehavior Settings::doubleClickBehavior() const
|
#else
|
||||||
{
|
return m_qsettings->value("svg_tiny12_only", false).toBool();
|
||||||
QString result = m_qsettings->value("double_click_behavior", "Close").toString();
|
#endif // QT_VERSION < QT_VERSION_CHECK(6, 9, 3)
|
||||||
|
}
|
||||||
return QEnumHelper::fromString<DoubleClickBehavior>(result, DoubleClickBehavior::Close);
|
|
||||||
}
|
Settings::MouseWheelBehavior Settings::mouseWheelBehavior() const
|
||||||
|
{
|
||||||
Settings::MouseWheelBehavior Settings::mouseWheelBehavior() const
|
QString result = m_qsettings->value("mouse_wheel_behavior", "").toString();
|
||||||
{
|
return QEnumHelper::fromString<MouseWheelBehavior>(result, MouseWheelBehavior::Zoom);
|
||||||
QString result = m_qsettings->value("mouse_wheel_behavior", "Zoom").toString();
|
}
|
||||||
|
|
||||||
return QEnumHelper::fromString<MouseWheelBehavior>(result, MouseWheelBehavior::Zoom);
|
Settings::WindowSizeBehavior Settings::initWindowSizeBehavior() const
|
||||||
}
|
{
|
||||||
|
QString result = m_qsettings->value("init_window_size_behavior", "").toString();
|
||||||
Settings::WindowSizeBehavior Settings::initWindowSizeBehavior() const
|
return QEnumHelper::fromString<WindowSizeBehavior>(result, WindowSizeBehavior::Windowed);
|
||||||
{
|
}
|
||||||
QString result = m_qsettings->value("init_window_size_behavior", "Auto").toString();
|
|
||||||
|
Qt::HighDpiScaleFactorRoundingPolicy Settings::hiDpiScaleFactorBehavior() const
|
||||||
return QEnumHelper::fromString<WindowSizeBehavior>(result, WindowSizeBehavior::Auto);
|
{
|
||||||
}
|
QString result = m_qsettings->value("hidpi_scale_factor_behavior", "").toString();
|
||||||
|
return QEnumHelper::fromString<Qt::HighDpiScaleFactorRoundingPolicy>(result, Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
Qt::HighDpiScaleFactorRoundingPolicy Settings::hiDpiScaleFactorBehavior() const
|
}
|
||||||
{
|
|
||||||
QString result = m_qsettings->value("hidpi_scale_factor_behavior", "PassThrough").toString();
|
void Settings::setShowNavigatorView(bool on)
|
||||||
|
{
|
||||||
return QEnumHelper::fromString<Qt::HighDpiScaleFactorRoundingPolicy>(result, Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
m_qsettings->setValue("show_navigator_view", on);
|
||||||
}
|
m_qsettings->sync();
|
||||||
|
}
|
||||||
void Settings::setStayOnTop(bool on)
|
|
||||||
{
|
void Settings::setUseLightCheckerboard(bool light)
|
||||||
m_qsettings->setValue("stay_on_top", on);
|
{
|
||||||
m_qsettings->sync();
|
m_qsettings->setValue("use_light_checkerboard", light);
|
||||||
}
|
m_qsettings->sync();
|
||||||
|
}
|
||||||
void Settings::setUseBuiltInCloseAnimation(bool on)
|
|
||||||
{
|
void Settings::setLoopGallery(bool on)
|
||||||
m_qsettings->setValue("use_built_in_close_animation", on);
|
{
|
||||||
m_qsettings->sync();
|
m_qsettings->setValue("loop_gallery", on);
|
||||||
}
|
m_qsettings->sync();
|
||||||
|
}
|
||||||
void Settings::setUseLightCheckerboard(bool light)
|
|
||||||
{
|
void Settings::setSvgTiny12Only(bool on)
|
||||||
m_qsettings->setValue("use_light_checkerboard", light);
|
{
|
||||||
m_qsettings->sync();
|
m_qsettings->setValue("svg_tiny12_only", on);
|
||||||
}
|
m_qsettings->sync();
|
||||||
|
}
|
||||||
void Settings::setLoopGallery(bool on)
|
|
||||||
{
|
void Settings::setMouseWheelBehavior(MouseWheelBehavior mwb)
|
||||||
m_qsettings->setValue("loop_gallery", on);
|
{
|
||||||
m_qsettings->sync();
|
m_qsettings->setValue("mouse_wheel_behavior", QEnumHelper::toString(mwb));
|
||||||
}
|
m_qsettings->sync();
|
||||||
|
}
|
||||||
void Settings::setDoubleClickBehavior(DoubleClickBehavior dcb)
|
|
||||||
{
|
void Settings::setInitWindowSizeBehavior(WindowSizeBehavior wsb)
|
||||||
m_qsettings->setValue("double_click_behavior", QEnumHelper::toString(dcb));
|
{
|
||||||
m_qsettings->sync();
|
m_qsettings->setValue("init_window_size_behavior", QEnumHelper::toString(wsb));
|
||||||
}
|
m_qsettings->sync();
|
||||||
|
}
|
||||||
void Settings::setMouseWheelBehavior(MouseWheelBehavior mwb)
|
|
||||||
{
|
void Settings::setHiDpiScaleFactorBehavior(Qt::HighDpiScaleFactorRoundingPolicy hidpi)
|
||||||
m_qsettings->setValue("mouse_wheel_behavior", QEnumHelper::toString(mwb));
|
{
|
||||||
m_qsettings->sync();
|
m_qsettings->setValue("hidpi_scale_factor_behavior", QEnumHelper::toString(hidpi));
|
||||||
}
|
m_qsettings->sync();
|
||||||
|
}
|
||||||
void Settings::setInitWindowSizeBehavior(WindowSizeBehavior wsb)
|
|
||||||
{
|
#if defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN)
|
||||||
m_qsettings->setValue("init_window_size_behavior", QEnumHelper::toString(wsb));
|
#include <windows.h>
|
||||||
m_qsettings->sync();
|
// QCoreApplication::applicationDirPath() parses the "applicationDirPath" from arg0, which...
|
||||||
}
|
// 1. rely on a QApplication object instance
|
||||||
|
// but we need to call QGuiApplication::setHighDpiScaleFactorRoundingPolicy() before QApplication get created
|
||||||
void Settings::setHiDpiScaleFactorBehavior(Qt::HighDpiScaleFactorRoundingPolicy hidpi)
|
// 2. arg0 is NOT garanteed to be the path of execution
|
||||||
{
|
// see also: https://stackoverflow.com/questions/383973/is-args0-guaranteed-to-be-the-path-of-execution
|
||||||
m_qsettings->setValue("hidpi_scale_factor_behavior", QEnumHelper::toString(hidpi));
|
// This function is here mainly for #1.
|
||||||
m_qsettings->sync();
|
QString getApplicationDirPath()
|
||||||
}
|
{
|
||||||
|
WCHAR buffer[MAX_PATH];
|
||||||
void Settings::applyUserShortcuts(QWidget *widget)
|
GetModuleFileNameW(NULL, buffer, MAX_PATH);
|
||||||
{
|
QString appPath = QString::fromWCharArray(buffer);
|
||||||
m_qsettings->beginGroup("shortcuts");
|
|
||||||
const QStringList shortcutNames = m_qsettings->allKeys();
|
return appPath.left(appPath.lastIndexOf('\\'));
|
||||||
for (const QString & name : shortcutNames) {
|
}
|
||||||
QList<QKeySequence> shortcuts = m_qsettings->value(name).value<QList<QKeySequence>>();
|
#endif // defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN)
|
||||||
setShortcutsForAction(widget, name, shortcuts, false);
|
|
||||||
}
|
Settings::Settings(QObject *parent)
|
||||||
m_qsettings->endGroup();
|
: QObject(parent)
|
||||||
}
|
{
|
||||||
|
QString configPath;
|
||||||
bool Settings::setShortcutsForAction(QWidget *widget, const QString &objectName,
|
|
||||||
QList<QKeySequence> shortcuts, bool writeConfig)
|
#if defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN)
|
||||||
{
|
QString portableConfigDirPath = QDir(getApplicationDirPath()).absoluteFilePath("data");
|
||||||
QAction * targetAction = nullptr;
|
QFileInfo portableConfigDirInfo(portableConfigDirPath);
|
||||||
for (QAction * action : widget->actions()) {
|
if (portableConfigDirInfo.exists() && portableConfigDirInfo.isDir() && portableConfigDirInfo.isWritable()) {
|
||||||
if (action->objectName() == objectName) {
|
// we can use it.
|
||||||
targetAction = action;
|
configPath = portableConfigDirPath;
|
||||||
} else {
|
}
|
||||||
for (const QKeySequence & shortcut : std::as_const(shortcuts)) {
|
#endif // defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN)
|
||||||
if (action->shortcuts().contains(shortcut)) {
|
|
||||||
return false;
|
if (configPath.isEmpty()) {
|
||||||
}
|
// Should be %LOCALAPPDATA%\<APPNAME> under Windows, ~/.config/<APPNAME> under Linux.
|
||||||
}
|
configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
m_qsettings = new QSettings(QDir(configPath).absoluteFilePath("config.ini"), QSettings::IniFormat, this);
|
||||||
if (targetAction) {
|
|
||||||
targetAction->setShortcuts(shortcuts);
|
qRegisterMetaType<QList<QKeySequence>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetAction && writeConfig) {
|
|
||||||
m_qsettings->beginGroup("shortcuts");
|
|
||||||
m_qsettings->setValue(objectName, QVariant::fromValue(shortcuts));
|
|
||||||
m_qsettings->endGroup();
|
|
||||||
m_qsettings->sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN)
|
|
||||||
#include <windows.h>
|
|
||||||
// QCoreApplication::applicationDirPath() parses the "applicationDirPath" from arg0, which...
|
|
||||||
// 1. rely on a QApplication object instance
|
|
||||||
// but we need to call QGuiApplication::setHighDpiScaleFactorRoundingPolicy() before QApplication get created
|
|
||||||
// 2. arg0 is NOT garanteed to be the path of execution
|
|
||||||
// see also: https://stackoverflow.com/questions/383973/is-args0-guaranteed-to-be-the-path-of-execution
|
|
||||||
// This function is here mainly for #1.
|
|
||||||
QString getApplicationDirPath()
|
|
||||||
{
|
|
||||||
WCHAR buffer[MAX_PATH];
|
|
||||||
GetModuleFileNameW(NULL, buffer, MAX_PATH);
|
|
||||||
QString appPath = QString::fromWCharArray(buffer);
|
|
||||||
|
|
||||||
return appPath.left(appPath.lastIndexOf('\\'));
|
|
||||||
}
|
|
||||||
#endif // defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN)
|
|
||||||
|
|
||||||
Settings::Settings()
|
|
||||||
: QObject(qApp)
|
|
||||||
{
|
|
||||||
QString configPath;
|
|
||||||
|
|
||||||
#if defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN)
|
|
||||||
QString portableConfigDirPath = QDir(getApplicationDirPath()).absoluteFilePath("data");
|
|
||||||
QFileInfo portableConfigDirInfo(portableConfigDirPath);
|
|
||||||
if (portableConfigDirInfo.exists() && portableConfigDirInfo.isDir() && portableConfigDirInfo.isWritable()) {
|
|
||||||
// we can use it.
|
|
||||||
configPath = portableConfigDirPath;
|
|
||||||
}
|
|
||||||
#endif // defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN)
|
|
||||||
|
|
||||||
if (configPath.isEmpty()) {
|
|
||||||
// Should be %LOCALAPPDATA%\<APPNAME> under Windows, ~/.config/<APPNAME> under Linux.
|
|
||||||
configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_qsettings = new QSettings(QDir(configPath).absoluteFilePath("config.ini"), QSettings::IniFormat, this);
|
|
||||||
|
|
||||||
qRegisterMetaType<QList<QKeySequence>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,69 +1,52 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
class Settings : public QObject
|
class Settings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum DoubleClickBehavior {
|
enum MouseWheelBehavior {
|
||||||
Ignore,
|
Zoom,
|
||||||
Close,
|
Switch,
|
||||||
Maximize,
|
};
|
||||||
FullScreen,
|
Q_ENUM(MouseWheelBehavior)
|
||||||
};
|
|
||||||
Q_ENUM(DoubleClickBehavior)
|
enum WindowSizeBehavior {
|
||||||
|
Maximized,
|
||||||
enum MouseWheelBehavior {
|
Windowed,
|
||||||
Zoom,
|
};
|
||||||
Switch,
|
Q_ENUM(WindowSizeBehavior)
|
||||||
};
|
|
||||||
Q_ENUM(MouseWheelBehavior)
|
static Settings *instance();
|
||||||
|
|
||||||
enum WindowSizeBehavior {
|
bool showNavigatorView() const;
|
||||||
Auto,
|
bool useLightCheckerboard() const;
|
||||||
Maximized,
|
bool loopGallery() const;
|
||||||
Windowed,
|
bool svgTiny12Only() const;
|
||||||
};
|
MouseWheelBehavior mouseWheelBehavior() const;
|
||||||
Q_ENUM(WindowSizeBehavior)
|
WindowSizeBehavior initWindowSizeBehavior() const;
|
||||||
|
Qt::HighDpiScaleFactorRoundingPolicy hiDpiScaleFactorBehavior() const;
|
||||||
static Settings *instance();
|
|
||||||
|
void setShowNavigatorView(bool on);
|
||||||
bool stayOnTop() const;
|
void setUseLightCheckerboard(bool light);
|
||||||
bool useBuiltInCloseAnimation() const;
|
void setLoopGallery(bool on);
|
||||||
bool useLightCheckerboard() const;
|
void setSvgTiny12Only(bool on);
|
||||||
bool loopGallery() const;
|
void setMouseWheelBehavior(MouseWheelBehavior mwb);
|
||||||
DoubleClickBehavior doubleClickBehavior() const;
|
void setInitWindowSizeBehavior(WindowSizeBehavior wsb);
|
||||||
MouseWheelBehavior mouseWheelBehavior() const;
|
void setHiDpiScaleFactorBehavior(Qt::HighDpiScaleFactorRoundingPolicy hidpi);
|
||||||
WindowSizeBehavior initWindowSizeBehavior() const;
|
|
||||||
Qt::HighDpiScaleFactorRoundingPolicy hiDpiScaleFactorBehavior() const;
|
private:
|
||||||
|
Settings(QObject *parent = nullptr);
|
||||||
void setStayOnTop(bool on);
|
|
||||||
void setUseBuiltInCloseAnimation(bool on);
|
QSettings *m_qsettings;
|
||||||
void setUseLightCheckerboard(bool light);
|
|
||||||
void setLoopGallery(bool on);
|
signals:
|
||||||
void setDoubleClickBehavior(DoubleClickBehavior dcb);
|
|
||||||
void setMouseWheelBehavior(MouseWheelBehavior mwb);
|
public slots:
|
||||||
void setInitWindowSizeBehavior(WindowSizeBehavior wsb);
|
};
|
||||||
void setHiDpiScaleFactorBehavior(Qt::HighDpiScaleFactorRoundingPolicy hidpi);
|
|
||||||
|
|
||||||
void applyUserShortcuts(QWidget * widget);
|
|
||||||
bool setShortcutsForAction(QWidget * widget, const QString & objectName,
|
|
||||||
QList<QKeySequence> shortcuts, bool writeConfig = true);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Settings();
|
|
||||||
|
|
||||||
static Settings *m_settings_instance;
|
|
||||||
|
|
||||||
QSettings *m_qsettings;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,200 +1,145 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
#include "ui_settingsdialog.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "shortcutedit.h"
|
#include "settings.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QApplication>
|
||||||
#include <QCheckBox>
|
#include <QTimer>
|
||||||
#include <QComboBox>
|
#include <QStringListModel>
|
||||||
#include <QFormLayout>
|
#include <type_traits>
|
||||||
#include <QKeySequenceEdit>
|
|
||||||
#include <QScrollArea>
|
template <typename E, typename = std::enable_if_t<std::is_enum_v<E>>>
|
||||||
#include <QSplitter>
|
class EnumComboBoxTransformer {
|
||||||
#include <QStringListModel>
|
public:
|
||||||
#include <QMessageBox>
|
using Pair = QPair<E, QString>;
|
||||||
|
using Pairs = QList<QPair<E, QString>>;
|
||||||
SettingsDialog::SettingsDialog(QWidget *parent)
|
|
||||||
: QDialog(parent)
|
EnumComboBoxTransformer(Pairs &&pairs) : pairs(std::move(pairs)) {}
|
||||||
, m_stayOnTop(new QCheckBox)
|
~EnumComboBoxTransformer() = default;
|
||||||
, m_useBuiltInCloseAnimation(new QCheckBox)
|
Q_DISABLE_COPY_MOVE(EnumComboBoxTransformer)
|
||||||
, m_useLightCheckerboard(new QCheckBox)
|
|
||||||
, m_loopGallery(new QCheckBox)
|
/// Build Qt model used for QComboBox
|
||||||
, m_doubleClickBehavior(new QComboBox)
|
QStringListModel* buildComboBoxModel(QObject *parent = nullptr) const {
|
||||||
, m_mouseWheelBehavior(new QComboBox)
|
QStringList dropDownEntries;
|
||||||
, m_initWindowSizeBehavior(new QComboBox)
|
for (const auto& pair : std::as_const(this->pairs)) {
|
||||||
, m_hiDpiRoundingPolicyBehavior(new QComboBox)
|
dropDownEntries.append(pair.second);
|
||||||
{
|
}
|
||||||
this->setWindowTitle(tr("Settings"));
|
return new QStringListModel(dropDownEntries, parent);
|
||||||
|
}
|
||||||
QHBoxLayout * mainLayout = new QHBoxLayout(this);
|
/// Convert QComboBox index to enum value.
|
||||||
QTabWidget * settingsTabs = new QTabWidget(this);
|
E to_value(int index) const {
|
||||||
mainLayout->addWidget(settingsTabs);
|
return this->pairs.at(static_cast<qsizetype>(index)).first;
|
||||||
|
}
|
||||||
QWidget * settingsFormHolder = new QWidget;
|
/// Convert enum value to QComboBox index.
|
||||||
QFormLayout * settingsForm = new QFormLayout(settingsFormHolder);
|
int to_index(E value) const {
|
||||||
settingsTabs->addTab(settingsFormHolder, tr("Options"));
|
for (qsizetype i = 0; i < pairs.size(); ++i) {
|
||||||
|
if (pairs.at(i).first == value) {
|
||||||
QSplitter * shortcutEditorSplitter = new QSplitter;
|
return static_cast<int>(i);
|
||||||
shortcutEditorSplitter->setOrientation(Qt::Vertical);
|
}
|
||||||
shortcutEditorSplitter->setChildrenCollapsible(false);
|
}
|
||||||
QScrollArea * shortcutScrollArea = new QScrollArea;
|
// Value not found
|
||||||
shortcutEditorSplitter->addWidget(shortcutScrollArea);
|
throw std::invalid_argument("invalid enum value for finding index");
|
||||||
shortcutScrollArea->setWidgetResizable(true);
|
}
|
||||||
shortcutScrollArea->setMinimumHeight(200);
|
|
||||||
QWidget * shortcutsFormHolder = new QWidget;
|
private:
|
||||||
QFormLayout * shortcutsForm = new QFormLayout(shortcutsFormHolder);
|
Pairs pairs;
|
||||||
shortcutScrollArea->setWidget(shortcutsFormHolder);
|
};
|
||||||
settingsTabs->addTab(shortcutEditorSplitter, tr("Shortcuts"));
|
|
||||||
|
static EnumComboBoxTransformer<Settings::MouseWheelBehavior, QString> MW_OPTIONS {
|
||||||
for (const QAction * action : parent->actions()) {
|
{
|
||||||
ShortcutEdit * shortcutEdit = new ShortcutEdit;
|
{ Settings::MouseWheelBehavior::Zoom, QCoreApplication::translate("SettingsDialog", "Zoom in and out") },
|
||||||
shortcutEdit->setObjectName(QLatin1String("shortcut_") + action->objectName());
|
{ Settings::MouseWheelBehavior::Switch, QCoreApplication::translate("SettingsDialog", "View next or previous item") }
|
||||||
shortcutEdit->setShortcuts(action->shortcuts());
|
}
|
||||||
shortcutsForm->addRow(action->text(), shortcutEdit);
|
};
|
||||||
connect(shortcutEdit, &ShortcutEdit::editButtonClicked, this, [=](){
|
|
||||||
if (shortcutEditorSplitter->count() == 1) shortcutEditorSplitter->addWidget(new QWidget);
|
static EnumComboBoxTransformer<Settings::WindowSizeBehavior, QString> IWS_OPTIONS {
|
||||||
ShortcutEditor * shortcutEditor = new ShortcutEditor(shortcutEdit);
|
{
|
||||||
shortcutEditor->setDescription(tr("Editing shortcuts for action \"%1\":").arg(action->text()));
|
{ Settings::WindowSizeBehavior::Maximized, QCoreApplication::translate("SettingsDialog", "Maximized") },
|
||||||
QWidget * oldEditor = shortcutEditorSplitter->replaceWidget(1, shortcutEditor);
|
{ Settings::WindowSizeBehavior::Windowed, QCoreApplication::translate("SettingsDialog", "Windowed") }
|
||||||
shortcutEditorSplitter->setSizes({shortcutEditorSplitter->height(), 1});
|
}
|
||||||
oldEditor->deleteLater();
|
};
|
||||||
});
|
|
||||||
connect(shortcutEdit, &ShortcutEdit::applyShortcutsRequested, this, [=](QList<QKeySequence> newShortcuts){
|
static EnumComboBoxTransformer<Qt::HighDpiScaleFactorRoundingPolicy, QString> HIDPI_OPTIONS {
|
||||||
bool succ = Settings::instance()->setShortcutsForAction(parent, shortcutEdit->objectName().mid(9),
|
{
|
||||||
newShortcuts);
|
{ Qt::HighDpiScaleFactorRoundingPolicy::Round, QCoreApplication::translate("SettingsDialog", "Round (Integer scaling)", "This option means round up for .5 and above") },
|
||||||
if (!succ) {
|
{ Qt::HighDpiScaleFactorRoundingPolicy::Ceil, QCoreApplication::translate("SettingsDialog", "Ceil (Integer scaling)", "This option means always round up") },
|
||||||
QMessageBox::warning(this, tr("Failed to set shortcuts"),
|
{ Qt::HighDpiScaleFactorRoundingPolicy::Floor, QCoreApplication::translate("SettingsDialog", "Floor (Integer scaling)", "This option means always round down") },
|
||||||
tr("Please check if shortcuts are duplicated with existing shortcuts."));
|
{ Qt::HighDpiScaleFactorRoundingPolicy::PassThrough, QCoreApplication::translate("SettingsDialog", "Follow system (Fractional scaling)", "This option means don't round") }
|
||||||
}
|
}
|
||||||
shortcutEdit->setShortcuts(action->shortcuts());
|
};
|
||||||
});
|
|
||||||
}
|
SettingsDialog::SettingsDialog(QWidget *parent)
|
||||||
|
: QDialog(parent), ui(new QT_PREPEND_NAMESPACE(Ui::SettingsDialog))
|
||||||
static QList< QPair<Settings::DoubleClickBehavior, QString> > _dc_options {
|
{
|
||||||
{ Settings::DoubleClickBehavior::Ignore, tr("Do nothing") },
|
ui->setupUi(this);
|
||||||
{ Settings::DoubleClickBehavior::Close, tr("Close the window") },
|
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||||
{ Settings::DoubleClickBehavior::Maximize, tr("Toggle maximize") },
|
|
||||||
{ Settings::DoubleClickBehavior::FullScreen, tr("Toggle fullscreen") }
|
auto* settings = Settings::instance();
|
||||||
};
|
ui->m_showNavigatorView->setChecked(Settings::instance()->showNavigatorView());
|
||||||
|
ui->m_useLightCheckerboard->setChecked(settings->useLightCheckerboard());
|
||||||
static QList< QPair<Settings::MouseWheelBehavior, QString> > _mw_options {
|
ui->m_loopGallery->setChecked(settings->loopGallery());
|
||||||
{ Settings::MouseWheelBehavior::Zoom, tr("Zoom in and out") },
|
ui->m_svgTiny12Only->setChecked(settings->svgTiny12Only());
|
||||||
{ Settings::MouseWheelBehavior::Switch, tr("View next or previous item") }
|
ui->m_mouseWheelBehavior->setModel(MW_OPTIONS.buildComboBoxModel(this));
|
||||||
};
|
Settings::MouseWheelBehavior mwb = settings->mouseWheelBehavior();
|
||||||
|
ui->m_mouseWheelBehavior->setCurrentIndex(MW_OPTIONS.to_index(mwb));
|
||||||
static QList< QPair<Settings::WindowSizeBehavior, QString> > _iws_options {
|
ui->m_initWindowSizeBehavior->setModel(IWS_OPTIONS.buildComboBoxModel(this));
|
||||||
{ Settings::WindowSizeBehavior::Auto, tr("Auto size") },
|
Settings::WindowSizeBehavior iwsb = settings->initWindowSizeBehavior();
|
||||||
{ Settings::WindowSizeBehavior::Maximized, tr("Maximized") },
|
ui->m_initWindowSizeBehavior->setCurrentIndex(IWS_OPTIONS.to_index(iwsb));
|
||||||
{ Settings::WindowSizeBehavior::Windowed, tr("Windowed") }
|
ui->m_hiDpiRoundingPolicyBehavior->setModel(HIDPI_OPTIONS.buildComboBoxModel(this));
|
||||||
};
|
Qt::HighDpiScaleFactorRoundingPolicy hidpi = settings->hiDpiScaleFactorBehavior();
|
||||||
|
ui->m_hiDpiRoundingPolicyBehavior->setCurrentIndex(HIDPI_OPTIONS.to_index(hidpi));
|
||||||
static QList< QPair<Qt::HighDpiScaleFactorRoundingPolicy, QString> > _hidpi_options {
|
|
||||||
{ Qt::HighDpiScaleFactorRoundingPolicy::Round, tr("Round (Integer scaling)", "This option means round up for .5 and above") },
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
||||||
{ Qt::HighDpiScaleFactorRoundingPolicy::Ceil, tr("Ceil (Integer scaling)", "This option means always round up") },
|
# define QCHECKBOX_CHECKSTATECHANGED QCheckBox::checkStateChanged
|
||||||
{ Qt::HighDpiScaleFactorRoundingPolicy::Floor, tr("Floor (Integer scaling)", "This option means always round down") },
|
# define QT_CHECKSTATE Qt::CheckState
|
||||||
{ Qt::HighDpiScaleFactorRoundingPolicy::PassThrough, tr("Follow system (Fractional scaling)", "This option means don't round") }
|
#else
|
||||||
};
|
# define QCHECKBOX_CHECKSTATECHANGED QCheckBox::stateChanged
|
||||||
|
# define QT_CHECKSTATE int
|
||||||
QStringList dcbDropDown;
|
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
||||||
for (const QPair<Settings::DoubleClickBehavior, QString> & dcOption : _dc_options) {
|
|
||||||
dcbDropDown.append(dcOption.second);
|
connect(ui->m_showNavigatorView, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
||||||
}
|
Settings::instance()->setShowNavigatorView(state == Qt::Checked);
|
||||||
|
});
|
||||||
QStringList mwbDropDown;
|
|
||||||
for (const QPair<Settings::MouseWheelBehavior, QString> & mwOption : _mw_options) {
|
connect(ui->m_useLightCheckerboard, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
||||||
mwbDropDown.append(mwOption.second);
|
Settings::instance()->setUseLightCheckerboard(state == Qt::Checked);
|
||||||
}
|
});
|
||||||
|
|
||||||
QStringList iwsbDropDown;
|
connect(ui->m_loopGallery, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
||||||
for (const QPair<Settings::WindowSizeBehavior, QString> & iwsOption : _iws_options) {
|
Settings::instance()->setLoopGallery(state == Qt::Checked);
|
||||||
iwsbDropDown.append(iwsOption.second);
|
});
|
||||||
}
|
|
||||||
|
connect(ui->m_svgTiny12Only, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
||||||
QStringList hidpiDropDown;
|
Settings::instance()->setSvgTiny12Only(state == Qt::Checked);
|
||||||
for (const QPair<Qt::HighDpiScaleFactorRoundingPolicy, QString> & hidpiOption : _hidpi_options) {
|
});
|
||||||
hidpiDropDown.append(hidpiOption.second);
|
|
||||||
}
|
connect(ui->m_mouseWheelBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
|
||||||
|
Settings::instance()->setMouseWheelBehavior(MW_OPTIONS.to_value(index));
|
||||||
settingsForm->addRow(tr("Stay on top when start-up"), m_stayOnTop);
|
});
|
||||||
settingsForm->addRow(tr("Use built-in close window animation"), m_useBuiltInCloseAnimation);
|
|
||||||
settingsForm->addRow(tr("Use light-color checkerboard"), m_useLightCheckerboard);
|
connect(ui->m_initWindowSizeBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
|
||||||
settingsForm->addRow(tr("Loop the loaded gallery"), m_loopGallery);
|
Settings::instance()->setInitWindowSizeBehavior(IWS_OPTIONS.to_value(index));
|
||||||
settingsForm->addRow(tr("Double-click behavior"), m_doubleClickBehavior);
|
});
|
||||||
settingsForm->addRow(tr("Mouse wheel behavior"), m_mouseWheelBehavior);
|
|
||||||
settingsForm->addRow(tr("Default window size"), m_initWindowSizeBehavior);
|
connect(ui->m_hiDpiRoundingPolicyBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
|
||||||
settingsForm->addRow(tr("HiDPI scale factor rounding policy"), m_hiDpiRoundingPolicyBehavior);
|
Settings::instance()->setHiDpiScaleFactorBehavior(HIDPI_OPTIONS.to_value(index));
|
||||||
|
});
|
||||||
m_stayOnTop->setChecked(Settings::instance()->stayOnTop());
|
|
||||||
m_useBuiltInCloseAnimation->setChecked(Settings::instance()->useBuiltInCloseAnimation());
|
// YYC MARK:
|
||||||
m_useLightCheckerboard->setChecked(Settings::instance()->useLightCheckerboard());
|
// Use adjustSize() to make sure all ComboBox are expanded by its items.
|
||||||
m_loopGallery->setChecked(Settings::instance()->loopGallery());
|
// Because items are added after inserting them into layout.
|
||||||
m_doubleClickBehavior->setModel(new QStringListModel(dcbDropDown));
|
// It is inviable to call this function in ctor because this relys on Qt event system.
|
||||||
Settings::DoubleClickBehavior dcb = Settings::instance()->doubleClickBehavior();
|
// It only can be done by QTimer::singleShot().
|
||||||
m_doubleClickBehavior->setCurrentIndex(static_cast<int>(dcb));
|
QTimer::singleShot(0, this, [this](){
|
||||||
m_mouseWheelBehavior->setModel(new QStringListModel(mwbDropDown));
|
this->adjustSize();
|
||||||
Settings::MouseWheelBehavior mwb = Settings::instance()->mouseWheelBehavior();
|
});
|
||||||
m_mouseWheelBehavior->setCurrentIndex(static_cast<int>(mwb));
|
}
|
||||||
m_initWindowSizeBehavior->setModel(new QStringListModel(iwsbDropDown));
|
|
||||||
Settings::WindowSizeBehavior iwsb = Settings::instance()->initWindowSizeBehavior();
|
SettingsDialog::~SettingsDialog()
|
||||||
m_initWindowSizeBehavior->setCurrentIndex(static_cast<int>(iwsb));
|
{
|
||||||
m_hiDpiRoundingPolicyBehavior->setModel(new QStringListModel(hidpiDropDown));
|
delete ui;
|
||||||
Qt::HighDpiScaleFactorRoundingPolicy hidpi = Settings::instance()->hiDpiScaleFactorBehavior();
|
}
|
||||||
for (int i = 0; i < _hidpi_options.count(); i++) {
|
|
||||||
if (_hidpi_options.at(i).first == hidpi) {
|
|
||||||
m_hiDpiRoundingPolicyBehavior->setCurrentIndex(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
|
||||||
# define QCHECKBOX_CHECKSTATECHANGED QCheckBox::checkStateChanged
|
|
||||||
# define QT_CHECKSTATE Qt::CheckState
|
|
||||||
#else
|
|
||||||
# define QCHECKBOX_CHECKSTATECHANGED QCheckBox::stateChanged
|
|
||||||
# define QT_CHECKSTATE int
|
|
||||||
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
|
||||||
|
|
||||||
connect(m_stayOnTop, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
|
||||||
Settings::instance()->setStayOnTop(state == Qt::Checked);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_useBuiltInCloseAnimation, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
|
||||||
Settings::instance()->setUseBuiltInCloseAnimation(state == Qt::Checked);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_useLightCheckerboard, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
|
||||||
Settings::instance()->setUseLightCheckerboard(state == Qt::Checked);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_loopGallery, &QCHECKBOX_CHECKSTATECHANGED, this, [ = ](QT_CHECKSTATE state){
|
|
||||||
Settings::instance()->setLoopGallery(state == Qt::Checked);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_doubleClickBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
|
|
||||||
Settings::instance()->setDoubleClickBehavior(_dc_options.at(index).first);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_mouseWheelBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
|
|
||||||
Settings::instance()->setMouseWheelBehavior(_mw_options.at(index).first);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_initWindowSizeBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
|
|
||||||
Settings::instance()->setInitWindowSizeBehavior(_iws_options.at(index).first);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_hiDpiRoundingPolicyBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
|
|
||||||
Settings::instance()->setHiDpiScaleFactorBehavior(_hidpi_options.at(index).first);
|
|
||||||
});
|
|
||||||
|
|
||||||
adjustSize();
|
|
||||||
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsDialog::~SettingsDialog()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,35 +1,27 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#ifndef SETTINGSDIALOG_H
|
#ifndef SETTINGSDIALOG_H
|
||||||
#define SETTINGSDIALOG_H
|
#define SETTINGSDIALOG_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QDialog>
|
||||||
#include <QDialog>
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
class QCheckBox;
|
namespace Ui {
|
||||||
class QComboBox;
|
class SettingsDialog;
|
||||||
class SettingsDialog : public QDialog
|
}
|
||||||
{
|
QT_END_NAMESPACE
|
||||||
Q_OBJECT
|
|
||||||
public:
|
class SettingsDialog : public QDialog
|
||||||
explicit SettingsDialog(QWidget *parent = nullptr);
|
{
|
||||||
~SettingsDialog();
|
Q_OBJECT
|
||||||
|
public:
|
||||||
signals:
|
explicit SettingsDialog(QWidget *parent = nullptr);
|
||||||
|
~SettingsDialog();
|
||||||
public slots:
|
|
||||||
|
private:
|
||||||
private:
|
QT_PREPEND_NAMESPACE(Ui::SettingsDialog) *ui;
|
||||||
QCheckBox * m_stayOnTop = nullptr;
|
};
|
||||||
QCheckBox * m_useBuiltInCloseAnimation = nullptr;
|
|
||||||
QCheckBox * m_useLightCheckerboard = nullptr;
|
#endif // SETTINGSDIALOG_H
|
||||||
QCheckBox * m_loopGallery = nullptr;
|
|
||||||
QComboBox * m_doubleClickBehavior = nullptr;
|
|
||||||
QComboBox * m_mouseWheelBehavior = nullptr;
|
|
||||||
QComboBox * m_initWindowSizeBehavior = nullptr;
|
|
||||||
QComboBox * m_hiDpiRoundingPolicyBehavior = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SETTINGSDIALOG_H
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SettingsDialog</class>
|
||||||
|
<widget class="QDialog" name="SettingsDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::NonModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="mainLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTabWidget" name="settingsTabs">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="optionsTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Options</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QFormLayout" name="settingsForm">
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="m_showNavigatorView">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show navigation view</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="m_useLightCheckerboard">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use light-color checkerboard</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="m_loopGallery">
|
||||||
|
<property name="text">
|
||||||
|
<string>Loop the loaded gallery</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="m_svgTiny12Only">
|
||||||
|
<property name="text">
|
||||||
|
<string>Limit SVG support to SVG Tiny 1.2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="m_mouseWheelBehaviorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Mouse wheel behavior</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="m_mouseWheelBehavior"/>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="m_initWindowSizeBehaviorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Default window size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QComboBox" name="m_initWindowSizeBehavior"/>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="m_hiDpiRoundingPolicyBehaviorLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>HiDPI scale factor rounding policy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QComboBox" name="m_hiDpiRoundingPolicyBehavior"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2024 Gary Wang <opensource@blumia.net>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#include "shortcutedit.h"
|
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QFormLayout>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QKeySequenceEdit>
|
|
||||||
|
|
||||||
ShortcutEditor::ShortcutEditor(ShortcutEdit * shortcutEdit, QWidget * parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
, m_descriptionLabel(new QLabel)
|
|
||||||
, m_shortcutEdit(shortcutEdit)
|
|
||||||
, m_shortcutLayout(new QFormLayout)
|
|
||||||
{
|
|
||||||
Q_CHECK_PTR(m_shortcutEdit);
|
|
||||||
|
|
||||||
QDialogButtonBox * buttons = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Discard);
|
|
||||||
|
|
||||||
QVBoxLayout * layout = new QVBoxLayout(this);
|
|
||||||
layout->addWidget(m_descriptionLabel);
|
|
||||||
layout->addLayout(m_shortcutLayout);
|
|
||||||
layout->addWidget(buttons);
|
|
||||||
|
|
||||||
connect(buttons, &QDialogButtonBox::clicked, this, [=](QAbstractButton *button){
|
|
||||||
if ((QPushButton *)button == buttons->button(QDialogButtonBox::Apply)) {
|
|
||||||
applyShortcuts();
|
|
||||||
} else {
|
|
||||||
reloadShortcuts();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(shortcutEdit, &ShortcutEdit::shortcutsChanged, this, &ShortcutEditor::reloadShortcuts);
|
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
|
||||||
|
|
||||||
reloadShortcuts();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShortcutEditor::setDescription(const QString &desc)
|
|
||||||
{
|
|
||||||
m_descriptionLabel->setText(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShortcutEditor::reloadShortcuts()
|
|
||||||
{
|
|
||||||
if (!m_keySequenceEdits.isEmpty()) {
|
|
||||||
for (QKeySequenceEdit * keyseqEdit : m_keySequenceEdits) {
|
|
||||||
m_shortcutLayout->removeRow(keyseqEdit);
|
|
||||||
}
|
|
||||||
m_keySequenceEdits.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QKeySequence> shortcuts = m_shortcutEdit->shortcuts();
|
|
||||||
shortcuts.append(QKeySequence());
|
|
||||||
for (const QKeySequence & shortcut : shortcuts) {
|
|
||||||
QKeySequenceEdit * keyseqEdit = new QKeySequenceEdit(this);
|
|
||||||
keyseqEdit->setClearButtonEnabled(true);
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
|
||||||
keyseqEdit->setMaximumSequenceLength(1);
|
|
||||||
#endif // QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
|
||||||
keyseqEdit->setKeySequence(shortcut);
|
|
||||||
m_keySequenceEdits.append(keyseqEdit);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_keySequenceEdits.count(); i++) {
|
|
||||||
m_shortcutLayout->addRow(tr("Shortcut #%1").arg(i + 1), m_keySequenceEdits.at(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShortcutEditor::applyShortcuts()
|
|
||||||
{
|
|
||||||
QList<QKeySequence> shortcuts;
|
|
||||||
for (const QKeySequenceEdit * keyseqEdit : m_keySequenceEdits) {
|
|
||||||
if (!keyseqEdit->keySequence().isEmpty() && !shortcuts.contains(keyseqEdit->keySequence())) {
|
|
||||||
shortcuts.append(keyseqEdit->keySequence());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit m_shortcutEdit->applyShortcutsRequested(shortcuts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------
|
|
||||||
|
|
||||||
ShortcutEdit::ShortcutEdit(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
, m_shortcutsLabel(new QLabel(this))
|
|
||||||
, m_setShortcutButton(new QToolButton(this))
|
|
||||||
{
|
|
||||||
m_setShortcutButton->setText("...");
|
|
||||||
|
|
||||||
QHBoxLayout * layout = new QHBoxLayout(this);
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
layout->addWidget(m_shortcutsLabel, 1);
|
|
||||||
layout->addWidget(m_setShortcutButton);
|
|
||||||
|
|
||||||
connect(this, &ShortcutEdit::shortcutsChanged, this, [=](){
|
|
||||||
QStringList shortcutTexts;
|
|
||||||
for (const QKeySequence & shortcut : std::as_const(m_shortcuts)) {
|
|
||||||
shortcutTexts.append(shortcut.toString(QKeySequence::NativeText));
|
|
||||||
}
|
|
||||||
m_shortcutsLabel->setText(shortcutTexts.isEmpty() ? tr("No shortcuts") : shortcutTexts.join(", "));
|
|
||||||
m_shortcutsLabel->setDisabled(shortcutTexts.isEmpty());
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_setShortcutButton, &QToolButton::clicked, this, &ShortcutEdit::editButtonClicked);
|
|
||||||
|
|
||||||
adjustSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
ShortcutEdit::~ShortcutEdit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QKeySequence> ShortcutEdit::shortcuts() const
|
|
||||||
{
|
|
||||||
return m_shortcuts;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShortcutEdit::setShortcuts(const QList<QKeySequence> &shortcuts)
|
|
||||||
{
|
|
||||||
m_shortcuts = shortcuts;
|
|
||||||
emit shortcutsChanged();
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2024 Gary Wang <opensource@blumia.net>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QList>
|
|
||||||
#include <QKeySequence>
|
|
||||||
|
|
||||||
class QLabel;
|
|
||||||
class QFormLayout;
|
|
||||||
class QToolButton;
|
|
||||||
class QKeySequenceEdit;
|
|
||||||
class ShortcutEdit;
|
|
||||||
class ShortcutEditor : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit ShortcutEditor(ShortcutEdit * shortcutEdit, QWidget * parent = nullptr);
|
|
||||||
~ShortcutEditor() = default;
|
|
||||||
|
|
||||||
void setDescription(const QString & desc);
|
|
||||||
|
|
||||||
void reloadShortcuts();
|
|
||||||
void applyShortcuts();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QLabel * m_descriptionLabel;
|
|
||||||
ShortcutEdit * m_shortcutEdit;
|
|
||||||
QFormLayout * m_shortcutLayout;
|
|
||||||
QList<QKeySequenceEdit *> m_keySequenceEdits;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ShortcutEdit : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QList<QKeySequence> shortcuts MEMBER m_shortcuts WRITE setShortcuts NOTIFY shortcutsChanged)
|
|
||||||
public:
|
|
||||||
explicit ShortcutEdit(QWidget * parent = nullptr);
|
|
||||||
~ShortcutEdit();
|
|
||||||
|
|
||||||
QList<QKeySequence> shortcuts() const;
|
|
||||||
void setShortcuts(const QList<QKeySequence> &shortcuts);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void shortcutsChanged();
|
|
||||||
void editButtonClicked();
|
|
||||||
void applyShortcutsRequested(QList<QKeySequence> newShortcuts);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QList<QKeySequence> m_shortcuts;
|
|
||||||
QLabel * m_shortcutsLabel;
|
|
||||||
QToolButton * m_setShortcutButton;
|
|
||||||
};
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#include "toolbutton.h"
|
|
||||||
|
|
||||||
#include "actionmanager.h"
|
|
||||||
#include "opacityhelper.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QGraphicsOpacityEffect>
|
|
||||||
#include <QPropertyAnimation>
|
|
||||||
|
|
||||||
ToolButton::ToolButton(bool hoverColor, QWidget *parent)
|
|
||||||
: QPushButton(parent)
|
|
||||||
, m_opacityHelper(new OpacityHelper(this))
|
|
||||||
{
|
|
||||||
setFlat(true);
|
|
||||||
QString qss = "QPushButton {"
|
|
||||||
"background: transparent;"
|
|
||||||
"}";
|
|
||||||
if (hoverColor) {
|
|
||||||
qss += "QPushButton:hover {"
|
|
||||||
"background: red;"
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
setStyleSheet(qss);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolButton::setIconResourcePath(const QString &iconp)
|
|
||||||
{
|
|
||||||
this->setIcon(ActionManager::loadHidpiIcon(iconp, this->iconSize()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolButton::setOpacity(qreal opacity, bool animated)
|
|
||||||
{
|
|
||||||
m_opacityHelper->setOpacity(opacity, animated);
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
#ifndef TOOLBUTTON_H
|
|
||||||
#define TOOLBUTTON_H
|
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
class OpacityHelper;
|
|
||||||
class ToolButton : public QPushButton
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ToolButton(bool hoverColor = false, QWidget * parent = nullptr);
|
|
||||||
void setIconResourcePath(const QString &iconp);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setOpacity(qreal opacity, bool animated = true);
|
|
||||||
|
|
||||||
private:
|
|
||||||
OpacityHelper * m_opacityHelper;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TOOLBUTTON_H
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
image:
|
|
||||||
- Visual Studio 2022
|
|
||||||
environment:
|
|
||||||
CMAKE_INSTALL_PREFIX: C:\projects\cmake
|
|
||||||
LIBZ: C:\projects\zlib
|
|
||||||
LIBEXPAT: C:\projects\libexpat
|
|
||||||
LIBAVIF: C:\projects\libavif
|
|
||||||
LIBEXIV2: C:\projects\exiv2
|
|
||||||
PPKG: C:\projects\ppkg
|
|
||||||
matrix:
|
|
||||||
- job_name: mingw_64_qt6_8
|
|
||||||
QTDIR: C:\Qt\6.8\mingw_64
|
|
||||||
MINGW64: C:\Qt\Tools\mingw1310_64
|
|
||||||
KF_BRANCH: master
|
|
||||||
EXIV2_VERSION: "0.28.5"
|
|
||||||
EXIV2_CMAKE_OPTIONS: "-DEXIV2_ENABLE_BROTLI=OFF -DEXIV2_ENABLE_INIH=OFF -DEXIV2_BUILD_EXIV2_COMMAND=OFF"
|
|
||||||
PPIC_CMAKE_OPTIONS: "-DPREFER_QT_5=OFF"
|
|
||||||
WINDEPLOYQT_ARGS: "--verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-system-d3d-compiler --skip-plugin-types tls,networkinformation"
|
|
||||||
|
|
||||||
install:
|
|
||||||
- mkdir %CMAKE_INSTALL_PREFIX%
|
|
||||||
- mkdir %LIBZ%
|
|
||||||
- mkdir %LIBEXPAT%
|
|
||||||
- mkdir %LIBAVIF%
|
|
||||||
- mkdir %LIBEXIV2%
|
|
||||||
- mkdir %PPKG%
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
- git submodule update --init --recursive
|
|
||||||
- set PATH=%PATH%;%CMAKE_INSTALL_PREFIX%;%QTDIR%\bin;%MINGW64%\bin;%PPKG%
|
|
||||||
- set CC=%MINGW64%\bin\gcc.exe
|
|
||||||
- set CXX=%MINGW64%\bin\g++.exe
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
# prepare
|
|
||||||
- mkdir 3rdparty
|
|
||||||
- choco install ninja
|
|
||||||
- cd %PPKG%
|
|
||||||
- curl -fsSL -o ppkg.exe https://github.com/BLumia/pineapple-package-manager/releases/latest/download/ppkg.exe
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# download and install zlib for KArchive
|
|
||||||
- cd %LIBZ%
|
|
||||||
- curl -fsSL -o zlib131.zip https://zlib.net/zlib131.zip
|
|
||||||
- 7z x zlib131.zip -y
|
|
||||||
- cd zlib-1.3.1
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX%
|
|
||||||
- cmake --build . --config Release
|
|
||||||
- cmake --build . --config Release --target install/strip
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# install ECM so we can build KImageFormats
|
|
||||||
- cd 3rdparty
|
|
||||||
- git clone -b %KF_BRANCH% -q https://invent.kde.org/frameworks/extra-cmake-modules.git
|
|
||||||
- git rev-parse HEAD
|
|
||||||
- cd extra-cmake-modules
|
|
||||||
- cmake -G "Ninja" . -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX% -DBUILD_TESTING=OFF
|
|
||||||
- cmake --build .
|
|
||||||
- cmake --build . --target install
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# install AOM for libavif AV1 decoding support...
|
|
||||||
- cd 3rdparty
|
|
||||||
#- git clone -b v3.9.1 --depth 1 https://aomedia.googlesource.com/aom
|
|
||||||
#- cd aom
|
|
||||||
#- mkdir build.aom
|
|
||||||
#- cd build.aom
|
|
||||||
#- cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX% -DENABLE_DOCS=OFF -DBUILD_SHARED_LIBS=ON -DAOM_TARGET_CPU=generic -DENABLE_TESTS=OFF -DENABLE_TESTDATA=OFF -DENABLE_TOOLS=OFF -DENABLE_EXAMPLES=0
|
|
||||||
#- cmake --build . --config Release
|
|
||||||
#- cmake --build . --config Release --target install/strip
|
|
||||||
- mkdir aom
|
|
||||||
- cd aom
|
|
||||||
- curl -fsSL -o ppkg-aom.zip https://sourceforge.net/projects/pineapple-package-manager/files/packages/mingw-w64-x86_64-windows/aom-3.9.1-2.zip
|
|
||||||
- ppkg ppkg-aom.zip
|
|
||||||
- 7z x ppkg-aom.zip LICENSE -y
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# install libavif for avif format support of KImageFormats
|
|
||||||
- cd %LIBAVIF%
|
|
||||||
- curl -fsSL -o libavif-v1_1_1.zip https://github.com/AOMediaCodec/libavif/archive/v1.1.1.zip
|
|
||||||
- 7z x libavif-v1_1_1.zip -y
|
|
||||||
- cd libavif-1.1.1
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX% -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_LIBYUV=ON
|
|
||||||
- cmake --build . --config Release
|
|
||||||
- cmake --build . --config Release --target install/strip
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# install KArchive for kra format support of KImageFormats
|
|
||||||
- cd 3rdparty
|
|
||||||
- git clone -b %KF_BRANCH% -q https://invent.kde.org/frameworks/karchive.git
|
|
||||||
- git rev-parse HEAD
|
|
||||||
- cd karchive
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake .. -G "Ninja" -DWITH_LIBZSTD=OFF -DWITH_BZIP2=OFF -DWITH_LIBLZMA=OFF -DWITH_OPENSSL=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX%
|
|
||||||
- cmake --build . --config Release
|
|
||||||
- cmake --build . --config Release --target install/strip
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# build libexpat for libexiv2
|
|
||||||
- cd %LIBEXPAT%
|
|
||||||
- curl -fsSL -o R_2_6_2.zip https://github.com/libexpat/libexpat/archive/R_2_6_2.zip
|
|
||||||
- 7z x R_2_6_2.zip -y
|
|
||||||
- cd libexpat-R_2_6_2/expat/
|
|
||||||
- cmake -G "Ninja" . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX% -DEXPAT_BUILD_EXAMPLES=OFF -DEXPAT_BUILD_TESTS=OFF -DEXPAT_BUILD_TOOLS=OFF
|
|
||||||
- cmake --build . --target install/strip
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# build libexiv2
|
|
||||||
- cd %LIBEXIV2%
|
|
||||||
- curl -fsSL -o v%EXIV2_VERSION%.zip https://github.com/Exiv2/exiv2/archive/v%EXIV2_VERSION%.zip
|
|
||||||
- 7z x v%EXIV2_VERSION%.zip -y
|
|
||||||
- cd exiv2-%EXIV2_VERSION%
|
|
||||||
- cmake -G "Ninja" . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX% %EXIV2_CMAKE_OPTIONS%
|
|
||||||
- cmake --build . --target install/strip
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# install KImageFormats
|
|
||||||
- cd 3rdparty
|
|
||||||
- git clone -b %KF_BRANCH% -q https://invent.kde.org/frameworks/kimageformats.git
|
|
||||||
- git rev-parse HEAD
|
|
||||||
- cd kimageformats
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake .. -G "Ninja" -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DKDE_INSTALL_QTPLUGINDIR=%QTDIR%\plugins
|
|
||||||
- cmake --build . --config Release
|
|
||||||
- cmake --build . --config Release --target install/strip
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
# finally...
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake .. -G "Ninja" %PPIC_CMAKE_OPTIONS% -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=%CMAKE_INSTALL_PREFIX% -DCMAKE_INSTALL_PREFIX='%cd%'
|
|
||||||
- cmake --build . --config Release
|
|
||||||
- cmake --build . --config Release --target install/strip
|
|
||||||
# fixme: I don't know how to NOT make the binary installed to the ./bin/ folder...
|
|
||||||
- cd bin
|
|
||||||
- copy %APPVEYOR_BUILD_FOLDER%\LICENSE
|
|
||||||
- copy %CMAKE_INSTALL_PREFIX%\bin\libaom.dll
|
|
||||||
- copy %CMAKE_INSTALL_PREFIX%\bin\libexpat-1.dll
|
|
||||||
- copy %CMAKE_INSTALL_PREFIX%\bin\libexiv2.dll
|
|
||||||
- copy %CMAKE_INSTALL_PREFIX%\bin\libavif.dll
|
|
||||||
- copy %CMAKE_INSTALL_PREFIX%\bin\libzlib.dll
|
|
||||||
- copy %CMAKE_INSTALL_PREFIX%\bin\libKF?Archive.dll
|
|
||||||
- windeployqt %WINDEPLOYQT_ARGS% .\ppic.exe
|
|
||||||
# copy 3rdparty licenses for the libs we vendored for windows...
|
|
||||||
- mkdir licenses
|
|
||||||
- cd licenses
|
|
||||||
- copy %APPVEYOR_BUILD_FOLDER%\3rdparty\aom\LICENSE License.aom.txt
|
|
||||||
- copy %APPVEYOR_BUILD_FOLDER%\3rdparty\karchive\LICENSES\LGPL-2.0-or-later.txt License.KArchive.txt
|
|
||||||
- copy %APPVEYOR_BUILD_FOLDER%\3rdparty\kimageformats\LICENSES\LGPL-2.1-or-later.txt License.kimageformats.txt
|
|
||||||
- copy %LIBEXPAT%\libexpat-R_2_6_2\expat\COPYING License.expat.txt
|
|
||||||
- copy %LIBAVIF%\libavif-1.1.1\LICENSE License.libavif.txt
|
|
||||||
- copy %LIBEXIV2%\exiv2-%EXIV2_VERSION%\COPYING License.exiv2.txt
|
|
||||||
# TODO: Qt, zlib
|
|
||||||
- cd ..
|
|
||||||
# for debug..
|
|
||||||
- tree /f
|
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%
|
|
||||||
- xcopy %CMAKE_INSTALL_PREFIX% .\cmake-prefix-copy /E /H /C /I
|
|
||||||
|
|
||||||
artifacts:
|
|
||||||
- path: build\bin
|
|
||||||
- path: cmake-prefix-copy
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<center>
|
||||||
|
<p>
|
||||||
|
<img width='128' height='128' src=':/icons/app-icon.png'/>
|
||||||
|
<br/>
|
||||||
|
<!-- Application name -->
|
||||||
|
<span>%1</span>
|
||||||
|
<br/>
|
||||||
|
<!-- Version info -->
|
||||||
|
<span>%2</span>
|
||||||
|
</p>
|
||||||
|
<hr/>
|
||||||
|
<p>
|
||||||
|
<!-- Upstream author and fork author -->
|
||||||
|
<span>%3</span><span>: </span><a href='https://github.com/BLumia'>@BLumia</a>
|
||||||
|
<br/>
|
||||||
|
<span>%4</span><span>: </span><a href='https://github.com/yyc12345'>@yyc12345</a>
|
||||||
|
<br/>
|
||||||
|
<!-- Icon author -->
|
||||||
|
<span>%5</span><span>: </span><a href='https://github.com/Lovelyblack'>@Lovelyblack</a>
|
||||||
|
</p>
|
||||||
|
<hr/>
|
||||||
|
<p>
|
||||||
|
<!-- Built Qt version info -->
|
||||||
|
<span>%6</span>
|
||||||
|
<br/>
|
||||||
|
<!-- Source code -->
|
||||||
|
<span>%7</span><span>: </span><a href='https://github.com/BLumia/pineapple-pictures'>GitHub</a>
|
||||||
|
</p>
|
||||||
|
</center>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<!-- General help -->
|
||||||
|
<h1 align='center'>%1</h1>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<span>%2</span>
|
||||||
|
<ul>
|
||||||
|
<li>%3</li>
|
||||||
|
<li>%4</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>%5</li>
|
||||||
|
<li>%6</li>
|
||||||
|
</ul>
|
||||||
|
<hr/>
|
||||||
|
<!-- Context menu option help -->
|
||||||
|
<h1 align='center'>%7</h1>
|
||||||
|
<!-- Context menu option list -->
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<b>%8</b><span>:</span>
|
||||||
|
<br/>
|
||||||
|
<span>%9</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>%10</b><span>:</span>
|
||||||
|
<br/>
|
||||||
|
<span>%11</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<!-- License -->
|
||||||
|
<h1 align='center'><b>%1</b></h1>
|
||||||
|
<p>%2</p>
|
||||||
|
<hr/>
|
||||||
|
<!-- VErbatime license -->
|
||||||
|
<h1 align='center'><b>%3</b></h1>
|
||||||
|
<pre>
|
||||||
|
Expat/MIT License
|
||||||
|
|
||||||
|
Copyright © 2026 BLumia
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
</pre>
|
||||||
@@ -1,3 +1,14 @@
|
|||||||
|
<!-- Contributor title -->
|
||||||
|
<h1 align='center'>%1</h1>
|
||||||
|
<!-- Contributor list -->
|
||||||
|
<a href='https://github.com/BLumia/pineapple-pictures/graphs/contributors'>%2</a>
|
||||||
|
<!-- The message to thank these contributors -->
|
||||||
|
<p>%3</p>
|
||||||
|
|
||||||
|
<!-- Translator title -->
|
||||||
|
<h1 align='center'>%4</h1>
|
||||||
|
<!-- The message to thank these translators -->
|
||||||
|
<p>%5</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><u>Catalan</u>: Toni Estévez</li>
|
<li><u>Catalan</u>: Toni Estévez</li>
|
||||||
<li><u>Chinese (Simplified)</u>: Percy Hong</li>
|
<li><u>Chinese (Simplified)</u>: Percy Hong</li>
|
||||||
@@ -12,8 +23,10 @@
|
|||||||
<li><u>Punjabi (Pakistan)</u>: bgo-eiu</li>
|
<li><u>Punjabi (Pakistan)</u>: bgo-eiu</li>
|
||||||
<li><u>Russian</u>: Sergey Shornikov, Artem, Andrey</li>
|
<li><u>Russian</u>: Sergey Shornikov, Artem, Andrey</li>
|
||||||
<li><u>Sinhala</u>: HelaBasa</li>
|
<li><u>Sinhala</u>: HelaBasa</li>
|
||||||
|
<li><u>Slovenian</u>: Andrej Poženel - SDT</li>
|
||||||
<li><u>Spanish</u>: Toni Estévez, Génesis Toxical, William(ѕ)ⁿ, gallegonovato</li>
|
<li><u>Spanish</u>: Toni Estévez, Génesis Toxical, William(ѕ)ⁿ, gallegonovato</li>
|
||||||
<li><u>Tamil</u>: தமிழ்நேரம் (TamilNeram)</li>
|
<li><u>Tamil</u>: தமிழ்நேரம் (TamilNeram)</li>
|
||||||
<li><u>Turkish</u>: E-Akcaer, Oğuz Ersen, Sabri Ünal</li>
|
<li><u>Turkish</u>: E-Akcaer, Oğuz Ersen, Sabri Ünal</li>
|
||||||
<li><u>Ukrainian</u>: Dan, volkov, Сергій</li>
|
<li><u>Ukrainian</u>: Dan, volkov, Сергій</li>
|
||||||
|
<li><u>Vietnamese</u>: Loc Huynh</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<!-- Title -->
|
||||||
|
<h1 align='center'><b>%1</b></h1>
|
||||||
|
<!-- List intro message -->
|
||||||
|
<p>%2</p>
|
||||||
|
<p>%3</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href='https://www.qt.io/'>Qt</a><span>: </span>
|
||||||
|
<span>GPLv2 + GPLv3 + LGPLv2.1 + LGPLv3</span>
|
||||||
|
</li>
|
||||||
|
<li style="display: none;">
|
||||||
|
<a href='https://www.exiv2.org/'>Exiv2</a><span>: </span>
|
||||||
|
<span>GPLv2</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
Before Width: | Height: | Size: 212 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 75 75" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
|
|
||||||
<g transform="matrix(1,0,0,1,-119,-102)">
|
|
||||||
<g id="go-next" transform="matrix(1.25,0,0,1.44231,119,-7.61538)">
|
|
||||||
<rect x="0" y="76" width="60" height="52" style="fill:none;"/>
|
|
||||||
<g transform="matrix(0.8,0,0,0.693333,0.260244,25.056)">
|
|
||||||
<circle cx="37.175" cy="110.977" r="33.175" style="fill-opacity:0.15;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g id="path867" transform="matrix(0.8,0,0,0.693333,1.80436,76.0055)">
|
|
||||||
<path d="M31.578,26.175L42.911,37.508L31.578,48.809" style="fill:none;fill-rule:nonzero;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 75 75" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;">
|
|
||||||
<g transform="matrix(1,0,0,1,-39,-102)">
|
|
||||||
<g id="go-previous" transform="matrix(1.25,0,0,1.44231,39,-7.61538)">
|
|
||||||
<rect x="0" y="76" width="60" height="52" style="fill:none;"/>
|
|
||||||
<g transform="matrix(0.8,0,0,0.693333,0.260244,25.056)">
|
|
||||||
<circle cx="37.175" cy="110.977" r="33.175" style="fill-opacity:0.15;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g id="path867" transform="matrix(0.8,0,0,0.693333,-1.8205,76.0055)">
|
|
||||||
<path d="M43.442,26.175L32.109,37.508L43.442,48.809" style="fill:none;fill-rule:nonzero;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
|
||||||
<g transform="matrix(1,0,0,1,-74,-7.10543e-15)">
|
|
||||||
<g id="object-rotate-right" transform="matrix(1,0,0,1,74,7.10543e-15)">
|
|
||||||
<rect x="0" y="0" width="32" height="32" style="fill:none;"/>
|
|
||||||
<g transform="matrix(1,0,0,1,-1,-0.275147)">
|
|
||||||
<g transform="matrix(1,0,0,1,-74,-7.10543e-15)">
|
|
||||||
<path d="M100,18C100,22.967 95.967,27 91,27C86.033,27 82,22.967 82,18C82,13.033 86.033,9 91,9" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(0.984136,-0.177418,0.177418,0.984136,-74.2676,16.4198)">
|
|
||||||
<path d="M89,13L93,9L89,5" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
|
||||||
<g transform="matrix(1,0,0,1,0,-37)">
|
|
||||||
<g id="view-background-checkerboard" transform="matrix(1,0,0,1,0,37)">
|
|
||||||
<rect x="0" y="0" width="32" height="32" style="fill:none;"/>
|
|
||||||
<g id="rect814" transform="matrix(0.964431,0,0,0.907545,0.187581,-988.266)">
|
|
||||||
<rect x="6.027" y="1095.56" width="10.369" height="11.019" style="fill:white;fill-opacity:0.87;"/>
|
|
||||||
</g>
|
|
||||||
<g id="rect814-4" transform="matrix(0.984615,0,0,0.898704,-0.143354,-978.502)">
|
|
||||||
<rect x="16.396" y="1106.6" width="10.156" height="11.127" style="fill:white;fill-opacity:0.87;"/>
|
|
||||||
</g>
|
|
||||||
<g id="rect814-2" transform="matrix(0.963684,0,0,0.898697,0.199828,-978.495)">
|
|
||||||
<rect x="6.019" y="1106.6" width="10.377" height="11.127" style="fill:white;fill-opacity:0.07;"/>
|
|
||||||
</g>
|
|
||||||
<g id="rect814-2-6" transform="matrix(0.980558,0,0,0.898693,-0.0768322,-978.47)">
|
|
||||||
<rect x="16.396" y="1095.45" width="10.198" height="11.127" style="fill:white;fill-opacity:0.07;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1,0,0,0.952381,-74,-34)">
|
|
||||||
<rect x="80" y="42" width="20" height="21" style="fill:none;stroke:white;stroke-width:2.05px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.7 KiB |
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
|
||||||
<g transform="matrix(1,0,0,1,-37,-37)">
|
|
||||||
<g id="view-fullscreen" transform="matrix(1,0,0,1,37,37)">
|
|
||||||
<rect x="0" y="0" width="32" height="32" style="fill:none;"/>
|
|
||||||
<g transform="matrix(1,0,0,1,-36,-37)">
|
|
||||||
<path d="M42,49L42,43L48,43" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(-1,1.22465e-16,1.22465e-16,1,68,-37)">
|
|
||||||
<path d="M42,49L42,43L48,43" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1,-2.46519e-32,-2.46519e-32,-1,-36,69)">
|
|
||||||
<path d="M42,49L42,43L48,43" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1.11111,0,0,1.14286,-42.3333,-42.8571)">
|
|
||||||
<rect x="48" y="48" width="9" height="7" style="fill:none;stroke:white;stroke-width:1.77px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(-1,-1.22465e-16,1.22465e-16,-1,68,69)">
|
|
||||||
<path d="M42,49L42,43L48,43" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,71 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
width="32"
|
|
||||||
height="32"
|
|
||||||
viewBox="0 0 8.4666665 8.4666669"
|
|
||||||
version="1.1"
|
|
||||||
id="svg8"
|
|
||||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
|
||||||
sodipodi:docname="window-close.svg">
|
|
||||||
<defs
|
|
||||||
id="defs2" />
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="base"
|
|
||||||
pagecolor="#000000"
|
|
||||||
bordercolor="#666666"
|
|
||||||
borderopacity="1.0"
|
|
||||||
inkscape:pageopacity="0.69803922"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:zoom="22.627417"
|
|
||||||
inkscape:cx="19.29838"
|
|
||||||
inkscape:cy="15.79404"
|
|
||||||
inkscape:document-units="px"
|
|
||||||
inkscape:current-layer="layer1"
|
|
||||||
showgrid="false"
|
|
||||||
units="px"
|
|
||||||
inkscape:pagecheckerboard="true"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1001"
|
|
||||||
inkscape:window-x="-9"
|
|
||||||
inkscape:window-y="-9"
|
|
||||||
inkscape:window-maximized="1" />
|
|
||||||
<metadata
|
|
||||||
id="metadata5">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<dc:title />
|
|
||||||
</cc:Work>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1"
|
|
||||||
transform="translate(0,-288.5333)">
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#ffffff;stroke-width:0.396875;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
|
||||||
d="m 2.100237,290.55098 4.3234589,4.22265"
|
|
||||||
id="path817"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="cc" />
|
|
||||||
<path
|
|
||||||
style="fill:none;stroke:#ffffff;stroke-width:0.396875;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
|
||||||
d="m 2.099406,294.78651 4.3414732,-4.24185"
|
|
||||||
id="path819"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="cc" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
|
||||||
<rect id="zoom-in" x="0" y="0" width="32" height="32" style="fill:none;"/>
|
|
||||||
<g id="zoom-in1" serif:id="zoom-in">
|
|
||||||
<g>
|
|
||||||
<g transform="matrix(1,0,0,1,-1,0)">
|
|
||||||
<circle cx="16" cy="15" r="9" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(0.8,0.8,-0.8,0.8,27.6,-17.2)">
|
|
||||||
<path d="M21,28L26,28" style="fill:none;stroke:white;stroke-width:2.65px;"/>
|
|
||||||
</g>
|
|
||||||
<path d="M11,15L19,15" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
<path d="M15,11L15,19" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:square;stroke-miterlimit:1.5;">
|
|
||||||
<g transform="matrix(1,0,0,1,-74,-37)">
|
|
||||||
<g id="zoom-original" transform="matrix(1,0,0,1,74,37)">
|
|
||||||
<rect x="0" y="0" width="32" height="32" style="fill:none;"/>
|
|
||||||
<g transform="matrix(1,0,0,1,-73,-37)">
|
|
||||||
<path d="M85,57L85,49L84,49" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1,0,0,1,-74,-37)">
|
|
||||||
<rect x="89" y="50" width="2" height="2" style="fill:white;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1,0,0,1,-74,-33)">
|
|
||||||
<rect x="89" y="50" width="2" height="2" style="fill:white;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1,0,0,1,-64,-37)">
|
|
||||||
<path d="M85,57L85,49L84,49" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1,0,0,0.952381,-74,-34)">
|
|
||||||
<rect x="80" y="42" width="20" height="21" style="fill:none;stroke:white;stroke-width:2.05px;stroke-linecap:round;stroke-linejoin:round;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
@@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
|
||||||
<g transform="matrix(1,0,0,1,-74,0)">
|
|
||||||
<g id="zoom-out" transform="matrix(1,0,0,1,74,0)">
|
|
||||||
<rect x="0" y="0" width="32" height="32" style="fill:none;"/>
|
|
||||||
<g>
|
|
||||||
<g transform="matrix(1,0,0,1,-1,0)">
|
|
||||||
<circle cx="16" cy="15" r="9" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(0.8,0.8,-0.8,0.8,27.6,-17.2)">
|
|
||||||
<path d="M21,28L26,28" style="fill:none;stroke:white;stroke-width:2.65px;"/>
|
|
||||||
</g>
|
|
||||||
<path d="M11,15L19,15" style="fill:none;stroke:white;stroke-width:2px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,17 +0,0 @@
|
|||||||
IDI_ICON1 ICON DISCARDABLE "icons/app-icon.ico"
|
|
||||||
1 VERSIONINFO
|
|
||||||
BEGIN
|
|
||||||
BLOCK "StringFileInfo"
|
|
||||||
BEGIN
|
|
||||||
BLOCK "040904E4"
|
|
||||||
BEGIN
|
|
||||||
VALUE "FileDescription", "Pineapple Pictures - Image Viewer"
|
|
||||||
VALUE "LegalCopyright", "MIT/Expat License - Copyright (C) 2024 Gary Wang"
|
|
||||||
VALUE "ProductName", "Pineapple Pictures"
|
|
||||||
END
|
|
||||||
END
|
|
||||||
BLOCK "VarFileInfo"
|
|
||||||
BEGIN
|
|
||||||
VALUE "Translation", 0x409, 1200
|
|
||||||
END
|
|
||||||
END
|
|
||||||
@@ -1,15 +1,23 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>icons/zoom-in.svg</file>
|
<!-- In-app icon resources -->
|
||||||
<file>icons/zoom-out.svg</file>
|
<file>icons/app-icon.png</file>
|
||||||
<file>icons/view-fullscreen.svg</file>
|
<file>icons/image-info.png</file>
|
||||||
<file>icons/zoom-original.svg</file>
|
<file>icons/fit-to-screen.png</file>
|
||||||
<file>icons/object-rotate-right.svg</file>
|
<file>icons/fit-to-size.png</file>
|
||||||
<file>icons/view-background-checkerboard.svg</file>
|
<file>icons/zoom-in.png</file>
|
||||||
<file>icons/app-icon.svg</file>
|
<file>icons/zoom-out.png</file>
|
||||||
<file>icons/window-close.svg</file>
|
<file>icons/rotate-left.png</file>
|
||||||
<file>icons/go-next.svg</file>
|
<file>icons/rotate-right.png</file>
|
||||||
<file>icons/go-previous.svg</file>
|
<file>icons/go-next.png</file>
|
||||||
<file>plain/translators.html</file>
|
<file>icons/go-previous.png</file>
|
||||||
|
<file>icons/flip-horizontal.png</file>
|
||||||
|
<file>icons/flip-vertical.png</file>
|
||||||
|
<!-- HTML resources -->
|
||||||
|
<file>htmls/help.html</file>
|
||||||
|
<file>htmls/about.html</file>
|
||||||
|
<file>htmls/special-thanks.html</file>
|
||||||
|
<file>htmls/license.html</file>
|
||||||
|
<file>htmls/third-party-libs.html</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -1,136 +1,136 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>English</string>
|
<string>English</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
|
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleLongVersionString</key>
|
<key>CFBundleLongVersionString</key>
|
||||||
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
|
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
|
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||||
<!-- FIXME: this list can't be automatically generated by Qt's CMake API, don't know why. -->
|
<!-- FIXME: this list can't be automatically generated by Qt's CMake API, don't know why. -->
|
||||||
<key>CFBundleLocalizations</key>
|
<key>CFBundleLocalizations</key>
|
||||||
<array>
|
<array>
|
||||||
<string>en</string>
|
<string>en</string>
|
||||||
<string>ca</string>
|
<string>ca</string>
|
||||||
<string>de</string>
|
<string>de</string>
|
||||||
<string>es</string>
|
<string>es</string>
|
||||||
<string>fr</string>
|
<string>fr</string>
|
||||||
<string>id</string>
|
<string>id</string>
|
||||||
<string>it</string>
|
<string>it</string>
|
||||||
<string>ja</string>
|
<string>ja</string>
|
||||||
<string>ko</string>
|
<string>ko</string>
|
||||||
<string>nb_NO</string>
|
<string>nb_NO</string>
|
||||||
<string>nl</string>
|
<string>nl</string>
|
||||||
<string>pa_PK</string>
|
<string>pa_PK</string>
|
||||||
<string>ru</string>
|
<string>ru</string>
|
||||||
<string>si</string>
|
<string>si</string>
|
||||||
<string>ta</string>
|
<string>ta</string>
|
||||||
<string>tr</string>
|
<string>tr</string>
|
||||||
<string>uk</string>
|
<string>uk</string>
|
||||||
<string>zh_CN</string>
|
<string>zh_CN</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleDocumentTypes</key>
|
<key>CFBundleDocumentTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<!-- JPEG -->
|
<!-- JPEG -->
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeName</key>
|
<key>CFBundleTypeName</key>
|
||||||
<string>JPEG Image</string>
|
<string>JPEG Image</string>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
<array>
|
<array>
|
||||||
<string>jpg</string>
|
<string>jpg</string>
|
||||||
<string>jpeg</string>
|
<string>jpeg</string>
|
||||||
<string>jfif</string>
|
<string>jfif</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeMIMETypes</key>
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>image/jpeg</string>
|
<string>image/jpeg</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Viewer</string>
|
<string>Viewer</string>
|
||||||
</dict>
|
</dict>
|
||||||
<!-- PNG -->
|
<!-- PNG -->
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeName</key>
|
<key>CFBundleTypeName</key>
|
||||||
<string>PNG Image</string>
|
<string>PNG Image</string>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
<array>
|
<array>
|
||||||
<string>png</string>
|
<string>png</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeMIMETypes</key>
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>image/png</string>
|
<string>image/png</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Viewer</string>
|
<string>Viewer</string>
|
||||||
</dict>
|
</dict>
|
||||||
<!-- WebP -->
|
<!-- WebP -->
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeName</key>
|
<key>CFBundleTypeName</key>
|
||||||
<string>WebP Image</string>
|
<string>WebP Image</string>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
<array>
|
<array>
|
||||||
<string>webp</string>
|
<string>webp</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeMIMETypes</key>
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>image/webp</string>
|
<string>image/webp</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Viewer</string>
|
<string>Viewer</string>
|
||||||
</dict>
|
</dict>
|
||||||
<!-- GIF -->
|
<!-- GIF -->
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeName</key>
|
<key>CFBundleTypeName</key>
|
||||||
<string>GIF Image</string>
|
<string>GIF Image</string>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
<array>
|
<array>
|
||||||
<string>gif</string>
|
<string>gif</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeMIMETypes</key>
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>image/gif</string>
|
<string>image/gif</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Viewer</string>
|
<string>Viewer</string>
|
||||||
</dict>
|
</dict>
|
||||||
<!-- SVG -->
|
<!-- SVG -->
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeName</key>
|
<key>CFBundleTypeName</key>
|
||||||
<string>SVG Image</string>
|
<string>SVG Image</string>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
<array>
|
<array>
|
||||||
<string>svg</string>
|
<string>svg</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeMIMETypes</key>
|
<key>CFBundleTypeMIMETypes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>image/svg+xml</string>
|
<string>image/svg+xml</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Viewer</string>
|
<string>Viewer</string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
msgid ""
|
|
||||||
msgstr ""
|
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
|
||||||
"POT-Creation-Date: 2023-08-22 18:49中国标准时间\n"
|
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
||||||
"MIME-Version: 1.0\n"
|
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
|
||||||
|
|
||||||
#. (itstool) path: component/name
|
|
||||||
#: net.blumia.pineapple-pictures.metainfo.xml:7
|
|
||||||
msgid "Pineapple Pictures"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. (itstool) path: component/summary
|
|
||||||
#: net.blumia.pineapple-pictures.metainfo.xml:9
|
|
||||||
msgid "Image Viewer"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. (itstool) path: description/p
|
|
||||||
#: net.blumia.pineapple-pictures.metainfo.xml:12
|
|
||||||
msgid "Pineapple Pictures is a lightweight and easy-to-use image viewer that comes with a handy navigation thumbnail when zoom-in, and doesn't contain any image management support."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. (itstool) path: screenshot/caption
|
|
||||||
#: net.blumia.pineapple-pictures.metainfo.xml:17
|
|
||||||
msgid "Main window when an image file is loaded"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. (itstool) path: screenshot/caption
|
|
||||||
#: net.blumia.pineapple-pictures.metainfo.xml:22
|
|
||||||
msgid "Zooming in a raster image"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. (itstool) path: screenshot/caption
|
|
||||||
#: net.blumia.pineapple-pictures.metainfo.xml:27
|
|
||||||
msgid "Zooming in a vector image"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. (itstool) path: component/developer_name
|
|
||||||
#: net.blumia.pineapple-pictures.metainfo.xml:34
|
|
||||||
msgid "Gary (BLumia) Wang et al."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 787 B |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 2.2 KiB |