Compare commits

..

69 Commits

Author SHA1 Message Date
Travis Abendshien
a0bb5f44e0 chore: merge main into pyright-alchemy 2025-09-06 03:25:23 -07:00
Travis Abendshien
7a8d34e190 feat(ui): add thumb cache size setting to settings panel (#1088)
* feat: add thumb cache size setting to settings panel

* refactor: change names in cache_manager.py to be less ambiguous, more descriptive

* refactor: store cache size in MiB instead of bytes
2025-09-05 16:04:06 -07:00
Travis Abendshien
3374f6b07f fix: add option to use old Windows 'start' command (#1084) 2025-09-05 13:44:52 -07:00
Travis Abendshien
eecb4d3e38 fix: account for leading slash pattern in wcmatch (#1092) 2025-09-05 13:38:02 -07:00
Travis Abendshien
583d107cb8 fix: reorder renderer types to fix early false positives (#1093) 2025-09-05 12:44:51 -07:00
Travis Abendshien
2db8bed304 translations: add Czech, Portuguese (Portugal), and Romanian in UI 2025-09-04 15:18:07 -07:00
Travis Abendshien
01680cab34 fix: update SQL_FILENAME to import from new constant (#1094) 2025-09-04 13:30:45 -07:00
Travis Abendshien
bbb17285e7 chore: merge main into pyright-alchemy 2025-09-03 16:09:58 -07:00
Travis Abendshien
ccd7ce136e Revert "fix: reorder renderer types to fix early false positives"
This reverts commit 25f85bf443.
2025-09-03 02:26:20 -07:00
Travis Abendshien
25f85bf443 fix: reorder renderer types to fix early false positives 2025-09-03 02:23:14 -07:00
Travis Abendshien
ce095385a8 chore: bump version to v9.5.4 2025-09-01 15:43:10 -07:00
Jann Stute
54f9c93285 refactor: auto mnemonics (#1083) 2025-09-01 15:38:34 -07:00
Weblate (bot)
1132026aff translations: update Hungarian (#1079)
Currently translated at 100.0% (355 of 355 strings)

Translated using Weblate (Hungarian)

Currently translated at 99.7% (354 of 355 strings)

Translated using Weblate (Hungarian)

Currently translated at 99.4% (353 of 355 strings)



Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/hu/
Translation: TagStudio/Strings

Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
2025-09-01 15:19:21 -07:00
Jann Stute
c16445f47e feat: auto generation of mnemonics (#1082) 2025-09-01 15:14:37 -07:00
Travis Abendshien
781aca27ae fix: don't flush entire changes when adding tags in bulk (#1081)
* fix: don't flush entire changes when adding tags in bulk

* fix: remove bumped version

* fix: remove bumped version, again
2025-09-01 15:14:09 -07:00
Weblate (bot)
4f9d805cac translations: update from Hosted Weblate (#1078)
* Translated using Weblate (Turkish)

Currently translated at 80.5% (281 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/tr/
Translation: TagStudio/Strings

* Translated using Weblate (Filipino)

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: searinminecraft <kitakita@disroot.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/fil/
Translation: TagStudio/Strings

* Translated using Weblate (Tamil)

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ta/
Translation: TagStudio/Strings

* Translated using Weblate (Portuguese (Brazil))

Currently translated at 71.3% (249 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pt_BR/
Translation: TagStudio/Strings

* Translated using Weblate (German)

Currently translated at 100.0% (349 of 349 strings)

Translated using Weblate (German)

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Liveside <livesi5e@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/de/
Translation: TagStudio/Strings

* Translated using Weblate (Russian)

Currently translated at 89.6% (313 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ru/
Translation: TagStudio/Strings

* Translated using Weblate (Japanese)

Currently translated at 89.6% (313 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: wany-oh <wany-oh@users.noreply.hosted.weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ja/
Translation: TagStudio/Strings

* Translated using Weblate (Portuguese)

Currently translated at 73.6% (257 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: ssantos <ssantos@web.de>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pt/
Translation: TagStudio/Strings

* Translated using Weblate (Hungarian)

Currently translated at 100.0% (349 of 349 strings)

Translated using Weblate (Hungarian)

Currently translated at 92.8% (324 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/hu/
Translation: TagStudio/Strings

* Translated using Weblate (Polish)

Currently translated at 84.8% (296 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pl/
Translation: TagStudio/Strings

* Translated using Weblate (Spanish)

Currently translated at 90.2% (315 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/es/
Translation: TagStudio/Strings

* Translated using Weblate (French)

Currently translated at 100.0% (349 of 349 strings)

Translated using Weblate (French)

Currently translated at 92.8% (324 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Med <45147847+kitsumed@users.noreply.github.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/fr/
Translation: TagStudio/Strings

* Translated using Weblate (Chinese (Traditional Han script))

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/zh_Hant/
Translation: TagStudio/Strings

* Translated using Weblate (Chinese (Simplified Han script))

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Luoyu <tkiuvvv2333@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/zh_Hans/
Translation: TagStudio/Strings

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Neemek <sindodeg@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/nb_NO/
Translation: TagStudio/Strings

* Translated using Weblate (Toki Pona)

Currently translated at 84.8% (296 of 349 strings)

Co-authored-by: Bee Crankson <ProfB.crankson@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/tok/
Translation: TagStudio/Strings

* Translated using Weblate (Viossa)

Currently translated at 82.8% (289 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Nginearing <142851004+Nginearing@users.noreply.github.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/qpv/
Translation: TagStudio/Strings

---------

Co-authored-by: searinminecraft <kitakita@disroot.org>
Co-authored-by: Liveside <livesi5e@gmail.com>
Co-authored-by: wany-oh <wany-oh@users.noreply.hosted.weblate.org>
Co-authored-by: ssantos <ssantos@web.de>
Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
Co-authored-by: Med <45147847+kitsumed@users.noreply.github.com>
Co-authored-by: Luoyu <tkiuvvv2333@gmail.com>
Co-authored-by: Neemek <sindodeg@gmail.com>
Co-authored-by: Bee Crankson <ProfB.crankson@gmail.com>
Co-authored-by: Nginearing <142851004+Nginearing@users.noreply.github.com>
Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
2025-09-01 13:01:39 -07:00
Weblate (bot)
bb10baf892 translations: update from Hosted Weblate (#1076)
* Translated using Weblate (Turkish)

Currently translated at 80.5% (281 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/tr/
Translation: TagStudio/Strings

* Translated using Weblate (Filipino)

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: searinminecraft <kitakita@disroot.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/fil/
Translation: TagStudio/Strings

* Translated using Weblate (Tamil)

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ta/
Translation: TagStudio/Strings

* Translated using Weblate (Portuguese (Brazil))

Currently translated at 71.3% (249 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pt_BR/
Translation: TagStudio/Strings

* Translated using Weblate (German)

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/de/
Translation: TagStudio/Strings

* Translated using Weblate (Russian)

Currently translated at 89.6% (313 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ru/
Translation: TagStudio/Strings

* Translated using Weblate (Japanese)

Currently translated at 89.6% (313 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: wany-oh <wany-oh@users.noreply.hosted.weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ja/
Translation: TagStudio/Strings

* Translated using Weblate (Portuguese)

Currently translated at 73.6% (257 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: ssantos <ssantos@web.de>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pt/
Translation: TagStudio/Strings

* Translated using Weblate (Hungarian)

Currently translated at 92.8% (324 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/hu/
Translation: TagStudio/Strings

* Translated using Weblate (Polish)

Currently translated at 84.8% (296 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pl/
Translation: TagStudio/Strings

* Translated using Weblate (Spanish)

Currently translated at 90.2% (315 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/es/
Translation: TagStudio/Strings

* Translated using Weblate (French)

Currently translated at 92.8% (324 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/fr/
Translation: TagStudio/Strings

* Translated using Weblate (Chinese (Traditional Han script))

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/zh_Hant/
Translation: TagStudio/Strings

* Translated using Weblate (Chinese (Simplified Han script))

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Luoyu <tkiuvvv2333@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/zh_Hans/
Translation: TagStudio/Strings

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 89.1% (311 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Neemek <sindodeg@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/nb_NO/
Translation: TagStudio/Strings

* Translated using Weblate (Toki Pona)

Currently translated at 84.8% (296 of 349 strings)

Co-authored-by: Bee Crankson <ProfB.crankson@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/tok/
Translation: TagStudio/Strings

* Translated using Weblate (Viossa)

Currently translated at 82.8% (289 of 349 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Nginearing <142851004+Nginearing@users.noreply.github.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/qpv/
Translation: TagStudio/Strings

---------

Co-authored-by: searinminecraft <kitakita@disroot.org>
Co-authored-by: wany-oh <wany-oh@users.noreply.hosted.weblate.org>
Co-authored-by: ssantos <ssantos@web.de>
Co-authored-by: Luoyu <tkiuvvv2333@gmail.com>
Co-authored-by: Neemek <sindodeg@gmail.com>
Co-authored-by: Bee Crankson <ProfB.crankson@gmail.com>
Co-authored-by: Nginearing <142851004+Nginearing@users.noreply.github.com>
2025-09-01 12:04:11 -07:00
Travis Abendshien
1ae92a3661 feat: add setting to select splash screen (#1077)
* feat: add setting to select splash screen

* feat: add random setting to splash screens
2025-09-01 12:01:32 -07:00
Travis Abendshien
2f4b72fd4d feat: add library cleanup screen and 'fix ignored files' window (#1070)
* feat(ui): add LibraryInfoWindow with statistics

* feat: add library cleanup screen

* fix: missing resource

* tests: add basic test for resource_manager.py

* feat: remove ignored files in bulk

* feat: open backups folder from library info window

* refactor: rename unlinked+ignored modal files

* refactor: sort en.json
2025-08-31 16:53:56 -07:00
Weblate (bot)
7a7e1cc4bd translations: update from Hosted Weblate (#1071)
* Translated using Weblate (Hungarian)

Currently translated at 100.0% (330 of 330 strings)

Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/hu/
Translation: TagStudio/Strings

* Translated using Weblate (French)

Currently translated at 100.0% (330 of 330 strings)

Co-authored-by: Med <45147847+kitsumed@users.noreply.github.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/fr/
Translation: TagStudio/Strings

---------

Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
Co-authored-by: Med <45147847+kitsumed@users.noreply.github.com>
2025-08-31 16:49:53 -07:00
purpletennisball
a9a1470a08 fix: parent tags in tag editor are uneditable (#1073) 2025-08-31 16:38:01 -07:00
Travis Abendshien
dcf564e8c3 fix: add loop cutoff to get_tag_categories() (#1075) 2025-08-31 14:00:39 -07:00
Travis Abendshien
9891caca35 fix: set generate_thumbs default to true 2025-08-30 15:34:52 -07:00
Xarvex
131c5df86b fix(nix/package): ignore mutating test files, add new problematic tests 2025-08-30 12:16:50 -05:00
Travis Abendshien
d8b058ac5a docs: update launch arguments 2025-08-29 17:40:32 -07:00
Travis Abendshien
a9bdd93c64 docs: update roadmap 2025-08-29 17:29:13 -07:00
Xarvex
2926b91980 chore(thumbs): prepare for pillow_heif removing AVIF support (#1065)
* fix(thumb_renderer): prepare for pillow_heif removing AVIF support

* fix(nix/package): add pillow-avif-plugin
2025-08-29 17:05:40 -07:00
Travis Abendshien
46f7edf6e8 chore: fix tests 2025-08-29 16:26:09 -07:00
Travis Abendshien
745fea6b85 refactor: addresss type hints in query_lang 2025-08-29 16:22:31 -07:00
Travis Abendshien
668ac23a86 chore: add json library files to pyright ignore 2025-08-29 16:22:31 -07:00
Travis Abendshien
8e8f416246 refactor: fix type hints in db.py 2025-08-29 16:22:31 -07:00
Travis Abendshien
218aa9e0d1 refactor: merge cyclicly imported files into library.py 2025-08-29 16:22:28 -07:00
Travis Abendshien
8e1ae81ec9 feat: replace extension exclusion system with .ts_ignore (#1046)
* feat: replace extension exclusion with ts_ignore
2025-08-29 14:25:54 -07:00
Weblate (bot)
44c7d223ff fix(translations): update Portuguese keys (#1069)
Currently translated at 80.5% (270 of 335 strings)

Update translation files

Updated by "Cleanup translation files" add-on in Weblate.



Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pt/
Translation: TagStudio/Strings

Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
2025-08-29 14:03:03 -07:00
Travis Abendshien
3f9aa87ab6 feat(ui): add LibraryInfoWindow with statistics (#1056) 2025-08-29 13:54:42 -07:00
Weblate (bot)
2583a76f56 translations: update from Hosted Weblate (#1066)
* Translated using Weblate (Hungarian)

Currently translated at 100.0% (329 of 329 strings)

Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/hu/
Translation: TagStudio/Strings

* Translated using Weblate (Spanish)

Currently translated at 99.6% (327 of 328 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Joan <joancanalscrehuet@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/es/
Translation: TagStudio/Strings

* Translated using Weblate (French)

Currently translated at 100.0% (329 of 329 strings)

Translated using Weblate (French)

Currently translated at 100.0% (328 of 328 strings)

Co-authored-by: Bamowen <mathieu.monsauret@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Med <45147847+kitsumed@users.noreply.github.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/fr/
Translation: TagStudio/Strings

---------

Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
Co-authored-by: Joan <joancanalscrehuet@gmail.com>
Co-authored-by: Bamowen <mathieu.monsauret@gmail.com>
Co-authored-by: Med <45147847+kitsumed@users.noreply.github.com>
2025-08-29 13:51:53 -07:00
TheBobBobs
d8919ab283 perf: optimize db queries for preview panel (#942)
* perf: optimize mapping of category->tags

* perf: one less db call for Library.tag_display_name

* fix: include joins in Library.get_tag_hierarchy

* fix: remove category if empty in preview panel

* fix: add missing imports and remove unneeded dict

* fix: add tags that are categories to their own category

* fix: flip parent_id/child_id in get_tag_hierarchy

* fix: prevent trying to save duplicate TagParents
2025-08-29 13:42:15 -07:00
TheBobBobs
08d0ba4eee perf: optimize sql for or queries (#948) 2025-08-28 16:57:10 -07:00
Jann Stute
e551359845 refactor: unwrap instead of assert not None (#1068)
* refactor: unwrap instead of assert not None

* fix: address review feedback
2025-08-28 13:27:49 -07:00
Travis Abendshien
12e074b71d refactor: store DB version inside versions table (#1058)
* refactor: store DB version inside `versions` table

* tests: update search_library db file

* chore: add copyright info to library constants.py

* fix: only backup db if loaded version is lower

* chore: mark Preferences as @deprecated
2025-08-28 12:58:51 -07:00
Travis Abendshien
4704b92804 ci(tests): fix broken tests and add type hints (#1062)
* ci: expand pyright ignore rules to vendored and tests

* tests: comment out unused Mocks for further evaluation

* tests: fix broken tests, add type hints

* chore: address type feedback

* chore: remove unused qtbot parameter
2025-08-27 04:33:38 -07:00
Travis Abendshien
3a0da4699a fix: swap parent and child logic for TAG_CHILDREN_QUERY (#1064) 2025-08-27 03:19:19 -07:00
TheBobBobs
3125a995a7 refactor: make cache_manager thread safe (#1039)
* refactor: make cache_manager thread safe

* fix: move CacheManager to ts_qt

* fix: handle unexpected files in thumbnail cache

* perf(cache): reduce folder checks by tracking recently used folders

---------

Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
2025-08-26 19:10:50 -07:00
Eric
5dfcc36d70 feat: add thumbnail generation toggle (#1057) 2025-08-26 18:51:36 -07:00
Xarvex
eb2887e871 fix(pyproject): remove extraPaths intended for external libraries
This also resolves issues in editors using the wrong paths for
completion and reporting missing type stubs.
2025-08-25 22:55:49 -05:00
HeikoWasTaken
02a56892e6 feat: add version argument (#1060)
Co-authored-by: heiko <heiko_was_taken@protonmail.com>
2025-08-25 22:32:51 -05:00
Travis Abendshien
3489e159a5 docs: update roadmap 2025-08-25 12:01:59 -07:00
purpletennisball
6c257f9671 fix: folders with names of unlinked entries are linked (#1027)
* fix: render folder entries as unlinked

* fix: hide file size for linked folders

* fix: linked folders can be revealed in explorer

* fix: linked folders can be opened

* fix: linked folders can be deleted

* fix: skip rendering thumbnails in `ThumbRenderer._render`

* fix: skip getting image metadata for folders

* fix: conflicts

* style: ruff
2025-08-25 11:39:21 -07:00
Weblate (bot)
acba9c3c33 translations: update from Hosted Weblate (#1026)
* Translated using Weblate (Russian)

Currently translated at 100.0% (325 of 325 strings)

Co-authored-by: Dott-rus <antonamelin8@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ru/
Translation: TagStudio/Strings

* Translated using Weblate (Romanian)

Currently translated at 10.7% (35 of 327 strings)

Added translation using Weblate (Romanian)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: VLTNO <gfree6311@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ro/
Translation: TagStudio/Strings

* Translated using Weblate (Japanese)

Currently translated at 100.0% (325 of 325 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: wany-oh <wany-oh@users.noreply.hosted.weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/ja/
Translation: TagStudio/Strings

* Translated using Weblate (Portuguese)

Currently translated at 83.0% (270 of 325 strings)

Translated using Weblate (Portuguese)

Currently translated at 83.0% (270 of 325 strings)

Translated using Weblate (Portuguese)

Currently translated at 83.0% (270 of 325 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
Co-authored-by: ssantos <ssantos@web.de>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pt/
Translation: TagStudio/Strings

* Translated using Weblate (Hungarian)

Currently translated at 100.0% (328 of 328 strings)

Translated using Weblate (Hungarian)

Currently translated at 100.0% (325 of 325 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/hu/
Translation: TagStudio/Strings

* Translated using Weblate (Polish)

Currently translated at 93.4% (302 of 323 strings)

Co-authored-by: Feather <featherprinceyt@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/pl/
Translation: TagStudio/Strings

* Translated using Weblate (French)

Currently translated at 100.0% (328 of 328 strings)

Translated using Weblate (French)

Currently translated at 100.0% (325 of 325 strings)

Translated using Weblate (French)

Currently translated at 100.0% (325 of 325 strings)

Co-authored-by: Bamowen <mathieu.monsauret@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Med <45147847+kitsumed@users.noreply.github.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/fr/
Translation: TagStudio/Strings

* Translated using Weblate (Swedish)

Currently translated at 29.5% (96 of 325 strings)

Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: skrap konto <skrap.kontot.4@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/sv/
Translation: TagStudio/Strings

* Update translation files

Updated by "Squash Git commits" add-on in Weblate.

Translation: TagStudio/Strings
Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/

---------

Co-authored-by: Dott-rus <antonamelin8@gmail.com>
Co-authored-by: VLTNO <gfree6311@gmail.com>
Co-authored-by: wany-oh <wany-oh@users.noreply.hosted.weblate.org>
Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
Co-authored-by: ssantos <ssantos@web.de>
Co-authored-by: Szíjártó Levente Pál <szijartoleventepal@gmail.com>
Co-authored-by: Feather <featherprinceyt@gmail.com>
Co-authored-by: Bamowen <mathieu.monsauret@gmail.com>
Co-authored-by: Med <45147847+kitsumed@users.noreply.github.com>
Co-authored-by: skrap konto <skrap.kontot.4@gmail.com>
2025-08-25 11:20:52 -07:00
Xarvex
899c534467 fix(nix): fixup and rework, always use nixpkgs PySide/Qt (#1048) 2025-08-24 18:08:14 -05:00
Travis Abendshien
74383e3c3c feat: swap IDs in tag_parents table; bump DB to v100
commit c1346e7df36b137cf88be284a96329fee9605a6a
Author: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
Date:   Sat Aug 23 18:04:58 2025 -0700

    docs: update DB v100 with tag_parents flip

commit 7e5d9381759b000533c809df9d9bc4f9d984e363
Author: HeikoWasTaken <heikowastaken@protonmail.com>
Date:   Sun Aug 24 00:31:21 2025 +0100

    fix: swap IDs in parent_tags DB table (#998)

    * fix: reorder child and parent IDs in TagParent constructor call

    * feat: add db10 migration

    * fix: SQL query returning parent IDs instead of children IDs

    * fix: stop assigning child tags as parents

    * fix: select and remove parent tags, instead of child tags

    * test/fix: correctly reorder child/parent args in broken test

    * fix: migrate json subtags as parent tags, instead of child tags (I see where it went wrong now lol)

    * fix: query parent tags instead of children

    * refactor: scooching this down below db9 migrations

    * test: add DB10 migration test

    ---------

    Co-authored-by: heiko <heiko_was_taken@protonmail.com>

commit 1ce02699ad9798800f9d98832b2a6377e3d79ed4
Author: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
Date:   Sat Aug 23 14:47:39 2025 -0700

    feat: add db minor versioning, bump to 100
2025-08-23 18:17:19 -07:00
TheBobBobs
660a87bb94 feat: add random sorting (#1029)
* feat: add random sorting

* fix: improve randomness of random sort
2025-08-23 13:42:36 -07:00
Travis Abendshien
89cf2b22e4 fix(ui): fix vector previews not rendering 2025-08-22 15:33:58 -07:00
Travis Abendshien
133092cd05 fix(ui): fix clear square behind ignored icon 2025-08-21 17:31:26 -07:00
Travis Abendshien
94ac83768a docs: add sidebar icon for ignore page 2025-08-21 16:13:20 -07:00
Travis Abendshien
61ca3cb32a feat(ui): add exr thumbnail support (#1035) 2025-08-21 15:51:30 -07:00
Travis Abendshien
0e7a2dfd3d feat: add .ts_ignore pattern ignoring system (#897)
* feat: add `.ts_ignore` pattern ignoring system

* fix: add wcmatch dependency

* search: add ".TemporaryItems" to GLOBAL_IGNORE

* add `desktop.ini` and `.localized` to global ignore

* add ".fhdx" and ".ts" filetypes

* chore: remove logging statement

* chore: format with ruff

* feat: use ripgrep for scanning if available

* docs: add ignore.md

* search: remove ts_ignore filtering on queries

* feat: detect if files are added but ignored

* fix: render edges on all unlinked thumbs

* perf: don't search for cached unlinked thumbs

* fix(ui): ensure newlines in file stats

* fix: use ignore_to_glob for wcmatch

* fix(tests): remove inconsistent test

The test hinged on the timing of refresh_dir()'s yield's rather than actual values

* ui: change ignored icon and color
2025-08-21 15:50:59 -07:00
Travis Abendshien
d00546d5fe docs(roadmap): add infinite scrolling to roadmap 2025-08-19 17:33:44 -07:00
Travis Abendshien
969b1674f0 fix(search): pass current BrowsingState to from_tag_id() (#1038)
* fix(search): pass current BrowsingState to from_tag_id()

* chore: fix docstring

* fix: use existing query to build tag_id query

Co-authored-by: Jann Stute <46534683+Computerdores@users.noreply.github.com>

---------

Co-authored-by: Jann Stute <46534683+Computerdores@users.noreply.github.com>
2025-08-19 12:58:09 -07:00
Travis Abendshien
00001bbf0b docs: update header style for mobile 2025-08-18 08:26:41 -07:00
Travis Abendshien
df064ad104 feat: add missing raw image, text, and audio types 2025-08-17 16:57:20 -07:00
Travis Abendshien
31d205a869 docs: update home page 2025-08-17 16:55:06 -07:00
Travis Abendshien
a55d9a6a67 docs: add preview support section to library page 2025-08-17 16:54:10 -07:00
Travis Abendshien
2c5c98c86c docs: update formatting of schema_changes page 2025-08-16 09:37:21 -07:00
Travis Abendshien
8cef5e5749 docs: change accent color to "purple" 2025-08-16 09:04:17 -07:00
Travis Abendshien
32a2b47c4c docs: remove minimal/unfinished pages 2025-08-15 20:45:04 -07:00
Travis Abendshien
7a44ef156d docs: add icons to sidebar and titles 2025-08-15 20:33:32 -07:00
Travis Abendshien
f2454c4a9a docs: rework roadmap (#1023)
* docs: rework core features

* docs: rework tag features

* docs: rework library features

* docs: rework search features

* docs: rework application features

* docs: rework macro features

* refactor(docs): remove card formatting for roadmap

* docs: roadmap tweaks
2025-08-12 11:53:26 -07:00
Jann Stute
537ecb2a55 fix: add tag to selected entries in bulk not individually (#1028) 2025-08-11 12:08:52 -07:00
167 changed files with 6885 additions and 3866 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
docs/assets/tag_bubbles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

View File

@@ -1,4 +1,8 @@
# Developing
---
icon: material/code-braces
---
# :material-code-braces: Developing
If you wish to develop for TagStudio, you'll need to create a development environment by installing the required dependencies. You have a number of options depending on your level of experience and familiarity with existing Python toolchains.

View File

@@ -1,4 +1,8 @@
# FFmpeg
---
icon: material/movie-open-cog
---
# :material-movie-open-cog: FFmpeg
FFmpeg is required for thumbnail previews and playback features on audio and video files. FFmpeg is a free Open Source project dedicated to the handling of multimedia (video, audio, etc) files. For more information, see their official website at [ffmpeg.org](https://www.ffmpeg.org/).

View File

@@ -1,52 +1,110 @@
---
title: Home
hide:
- toc
---
# Welcome to the TagStudio Documentation!
#
![TagStudio Alpha](./assets/github_header.png)
TagStudio is a photo & file organization application with an underlying tag-based system that focuses on giving freedom and flexibility to the user. No proprietary programs or formats, no sea of sidecar files, and no complete upheaval of your filesystem structure.
<figure width="60%" markdown="span">
![TagStudio screenshot](./assets/screenshot.png)
<figcaption>TagStudio Alpha v9.5.0 running on macOS Sequoia.</figcaption>
<link rel="stylesheet" href="stylesheets/home.css">
<figure markdown="span">
![TagStudio](./assets/ts-9-3_logo_text.png){ width=80% }<h2>A User-Focused Photo & File Management System</h2>
</figure>
## Feature Roadmap
<br>
The [Feature Roadmap](./updates/roadmap.md) lists all of the planned core features for TagStudio to be considered "feature complete" along with estimated release milestones. The development and testing of these features takes priority over all other requested or submitted features unless they are later added to this roadmap. This helps ensure that TagStudio eventually sees a full release and becomes more usable by more people more quickly.
<figure markdown="span">
![TagStudio screenshot](./assets/screenshot.png){ width=80% }
<figcaption>TagStudio Alpha v9.5.0 running on macOS Sequoia.</figcaption>
</figure>
## Current Features
<div class="grid" markdown>
### Libraries
![TagStudio screenshot](./assets/tag_bubbles.png)
- Create [libraries](./library/index.md) centered around a system directory. Libraries contain a series of entries: the representations of your files combined with metadata fields. Each entry represents a file in your librarys directory, and is linked to its location.
- Address moved, deleted, or otherwise "unlinked" files by using the "Fix Unlinked Entries" option in the Tools menu.
**TagStudio** is a photo & file organization application with an underlying tag-based system that focuses on giving freedom and flexibility to the user. No proprietary programs or formats, no sea of sidecar files, and no complete upheaval of your filesystem structure.
### Tagging + Metadata Fields
</div>
- Add custom powerful [tags](./library/tag.md) to your library entries
- Add [metadata fields](./library/field.md) to your library entries, including:
- Name, Author, Artist (Single-Line Text Fields)
- Description, Notes (Multi-Line Text Fields)
- Create rich tags composed of a name, color, a list of aliases, and a list of "parent tags" - these being tags in which these tags inherit values from.
- Copy and paste tags and fields across file entries
- Automatically organize tags into groups based on parent tags marked as "categories"
- Generate tags from your existing folder structure with the "Folders to Tags" macro (NOTE: these tags do NOT sync with folders after they are created)
<figure markdown="span">
[:material-download: Download Latest Release](https://github.com/TagStudioDev/TagStudio/releases){ .md-button .md-button--primary }
</figure>
### Search
## :material-star: Core Features
- [Search](./library/library_search.md) for file entries based on tags, file path (`path:`), file types (`filetype:`), and even media types! (`mediatype:`)
- Use and combine Boolean operators (`AND`, `OR`, `NOT`) along with parentheses groups, quotation escaping, and underscore substitution to create detailed search queries
- Use special search conditions (`special:untagged`) to find file entries without tags or fields, respectively
<div class="grid cards" markdown>
### File Entries
- :material-file-multiple:{ .lg .middle } **[All Files](./library/entry.md) Welcome**
- Nearly all [file](./library/entry.md) types are supported in TagStudio libraries - just not all have dedicated thumbnail support.
- Preview most image file types, animated GIFs, videos, plain text documents, audio files, Blender projects, and more!
- Open files or file locations by right-clicking on thumbnails and previews and selecting the respective context menu options. You can also click on the preview panel image to open the file, and click the file path label to open its location.
- Delete files from both your library and drive by right-clicking the thumbnail(s) and selecting the "Move to Trash"/"Move to Recycle Bin" option.
***
TagStudio works with photos, videos, music, documents, and more! **All file types** are recognized by TagStudio, with most common ones having built-in preview support.
[:material-arrow-right: See Full Preview Support](./library/index.md#preview-support)
- :material-tag-text:{ .lg .middle } **Create [Tags](./library/tag.md) Your Way**
***
- :material-format-font: No character restrictions
- :material-form-textbox: Add aliases/alternate names
- :material-palette: Customize colors and styles
- :material-tag-multiple: Tags can be tagged with other tags!
- :material-star-four-points: And more!
- :material-magnify:{ .lg .middle } **Powerful [Search](./library/library_search.md)**
***
- Full [Boolean operator](./library/library_search.md) support
- Filenames, paths, and extensions with [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) syntax
- General media types (e.g. "Photo", "Video", "Document")
- Special searches (e.g. "Untagged")
- "[Smartcase](./library/library_search.md#case-sensitivity)" case sensitivity
- :material-text-box:{ .lg .middle } **Text and Date [Fields](./library/field.md)**
***
Along with tags, add custom metadata fields such as text and dates to your files!
This is useful for adding notes and descriptions, titling files, and keeping track of extra dates and times.
</div>
## :material-toolbox: Built Different
<div class="grid cards" markdown>
- :material-scale-balance:{ .lg .middle } **Open Source**
***
TagStudio is licensed under the GPL-3.0 license with the source code and executable releases available on [GitHub](https://github.com/TagStudioDev/TagStudio).
[:material-arrow-right: View License](https://github.com/TagStudioDev/TagStudio/blob/main/LICENSE)
[:material-arrow-right: Roadmap to MIT Core Library License](./updates/roadmap.md#core-library-api)
- :material-database:{ .lg .middle } **Central Save File**
***
Apposed to filling your drives with [sidecar files](https://en.wikipedia.org/wiki/Sidecar_file), TagStudio uses a project-like [library](./library/index.md) system that stores your tags and metadata inside a single save file per-library.
[:material-arrow-right: Learn About the Format](./library/index.md)
</div>
---
## :material-layers-triple: More Than an Application
TagStudio aims to create an **open** and **robust** format for file tagging that isn't burdened by the limitations of traditional tagging and file metadata systems. **TagStudio** is the first proof-of-concept implementation of this system.
<div class="grid cards" markdown>
- :material-map-check:{ .lg .middle } See the [**Roadmap**](./updates/roadmap.md) for future features and updates
</div>

View File

@@ -1,4 +1,8 @@
# Installation
---
icon: material/download
---
# :material-download: Installation
TagStudio provides [releases](https://github.com/TagStudioDev/TagStudio/releases) as well as full access to its [source code](https://github.com/TagStudioDev/TagStudio) under the [GPLv3](https://github.com/TagStudioDev/TagStudio/blob/main/LICENSE) license.
@@ -207,6 +211,14 @@ Don't forget to rebuild!
## Third-Party Dependencies
<!-- prettier-ignore -->
!!! tip
You can check to see if any of these dependencies are correctly located by launching TagStudio and going to "About TagStudio" in the menu bar.
### FFmpeg/FFprobe
For audio/video thumbnails and playback you'll need [FFmpeg](https://ffmpeg.org/download.html) installed on your system. If you encounter any issues with this, please reference our [FFmpeg Help](./help/ffmpeg.md) guide.
You can check to see if FFmpeg and FFprobe are correctly located by launching TagStudio and going to "About TagStudio" in the menu bar.
### ripgrep
A recommended tool to improve the performance of directory scanning is [`ripgrep`](https://github.com/BurntSushi/ripgrep), a Rust-based directory walker that natively integrates with our [`.ts_ignore`](./utilities/ignore.md) (`.gitignore`-style) pattern matching system for excluding files and directories. Ripgrep is already pre-installed on some Linux distributions and also available from several package managers.

View File

@@ -1,6 +1,10 @@
# File Entries
---
icon: material/file
---
File entries are the individual representations of your files inside a TagStudio [library](./index.md). Each one corresponds one-to-one to a file on disk, and tracks all of the additional [tags](tag.md) and metadata that you attach to it inside TagStudio.
# :material-file: Entries
Entries are the individual representations of your files inside a TagStudio [library](./index.md). Each one corresponds one-to-one to a file on disk, and tracks all of the additional [tags](tag.md) and metadata that you attach to it inside TagStudio.
## Storage
@@ -10,7 +14,7 @@ File entry data is stored within the `ts_library.sqlite` file inside each librar
File entries appear as thumbnails inside the grid display. The preview panel shows a more detailed preview of the file, along with extra file stats and all attached TagStudio tags and fields.
## Unlinked File Entries
## Unlinked Entries
If the file that an entry is referencing has been moved, renamed, or deleted on disk, then TagStudio will display its unlinked status with a red chain-link icon instead of its thumbnail image. Certain uncached stats such as the file size and image dimensions will also be unavailable to see in the preview panel.

View File

@@ -1,8 +0,0 @@
---
tags:
- Upcoming Feature
---
# Entry Groups
Entries can be grouped via tags marked as "groups" which when applied to different entries will signal TagStudio to treat those entries as a single group inside of searches and browsing.

View File

@@ -1,4 +1,8 @@
# Fields
---
icon: material/text-box
---
# :material-text-box: Fields
Fields are additional types of metadata that you can attach to [file entries](./entry.md). Like [tags](./tag.md), fields are not stored inside files themselves nor in sidecar files, but rather inside the respective TagStudio [library](./index.md) save file.

View File

@@ -1,5 +1,155 @@
# Library
# :material-database: Library
<!-- prettier-ignore -->
!!! info
This page is a work in progress and needs to be updated with additional information.
The library is how TagStudio represents your chosen directory, with every file inside being represented by a [file entry](./entry.md). You can have as many or few libraries as you wish, since each libraries' data is stored within a `.TagStudio` folder at its root. From there the library save file itself is stored as `ts_library.sqlite`, with TagStudio versions 9.4 and below using a the legacy `ts_library.json` format.
Note that this means [tags](./tag.md) you create only exist _per-library_.
Note that this means [tags](./tag.md) you create only exist _per-library_. Global tags along with other library structure updates are planned for future releases on the [roadmap](../updates/roadmap.md#library).
---
## Preview Support
TagStudio offers built-in preview and thumbnail support for a wide variety of file types. Files that don't have explicit support can still be added to your library like normal, they will just show a default icon for thumbnails and previews. TagStudio also references the file's [MIME](https://en.wikipedia.org/wiki/Media_type) type in an attempt to render previews for file types that haven't gained explicit support yet.
### :material-image-outline: Images
Images will generate thumbnails the first time they are viewed or since the last time they were modified. Thumbnails are used in the grid view, but not in the Preview Panel. Animated images will play in the Preview Panel.
| Filetype | Extensions | Animation |
| -------------------- | -------------------------------------------------- | :---------------------------------: |
| Animated PNG | `.apng` | :material-check-circle:{.lg .green} |
| Apple Icon Image | `.icns` | :material-minus-circle:{.lg .gray} |
| AVIF | `.avif` | :material-minus-circle:{.lg .gray} |
| Bitmap | `.bmp` | :material-minus-circle:{.lg .gray} |
| GIF | `.gif` | :material-check-circle:{.lg .green} |
| HEIF | `.heif`, `.heic` | :material-minus-circle:{.lg .gray} |
| JPEG | `.jpeg`, `.jpg`, `.jfif`, `.jif`, `.jpg_large`[^1] | :material-minus-circle:{.lg .gray} |
| JPEG-XL | `.jxl` | :material-close-circle:{.lg .red} |
| OpenEXR | `.exr` | :material-minus-circle:{.lg .gray} |
| OpenRaster | `.ora` | :material-minus-circle:{.lg .gray} |
| PNG | `.png` | :material-minus-circle:{.lg .gray} |
| SVG | `.svg` | :material-minus-circle:{.lg .gray} |
| TIFF | `.tiff`, `.tif` | :material-minus-circle:{.lg .gray} |
| Valve Texture Format | `.vtf` | :material-close-circle:{.lg .red} |
| WebP | `.webp` | :material-check-circle:{.lg .green} |
| Windows Icon | `.ico` | :material-minus-circle:{.lg .gray} |
#### :material-image-outline: RAW Images
| Filetype | Extensions |
| -------------------------------- | ---------------------- |
| Camera Image File Format (Canon) | `.crw`, `.cr2`, `.cr3` |
| Digital Negative | `.dng` |
| Fuji RAW | `.raf` |
| Nikon RAW | `.nef`, `.nrw` |
| Olympus RAW | `.orf` |
| Panasonic RAW | `.raw`, `.rw2` |
| Sony RAW | `.arw` |
### :material-movie-open: Videos
Video thumbnails will default to the closest viable frame from the middle of the video. Both thumbnail generation and video playback in the Preview Panel requires [FFmpeg](../install.md#third-party-dependencies) installed on your system.
| Filetype | Extensions | Dependencies |
| --------------------- | ----------------------- | :----------: |
| 3GP | `.3gp` | FFmpeg |
| AVI | `.avi` | FFmpeg |
| AVIF | `.avif` | FFmpeg |
| FLV | `.flv` | FFmpeg |
| HEVC | `.hevc` | FFmpeg |
| Matroska | `.mkv` | FFmpeg |
| MP4 | `.mp4` , `.m4p` | FFmpeg |
| MPEG Transport Stream | `.ts` | FFmpeg |
| QuickTime | `.mov`, `.movie`, `.qt` | FFmpeg |
| WebM | `.webm` | FFmpeg |
| WMV | `.wmv` | FFmpeg |
### :material-sine-wave: Audio
Audio thumbnails will default to embedded cover art (if any) andfallback to generated waveform thumbnails. Audio file playback is supported in the Preview Panel if you have [FFmpeg](../install.md#third-party-dependencies) installed on your system. Audio waveforms are currently not cached.
| Filetype | Extensions | Dependencies |
| ------------------- | ------------------------ | :----------: |
| AAC | `.aac`, `.m4a` | FFmpeg |
| AIFF | `.aiff`, `.aif`, `.aifc` | FFmpeg |
| Apple Lossless[^2] | `.alac`, `.aac` | FFmpeg |
| FLAC | `.flac` | FFmpeg |
| MP3 | `.mp3`, | FFmpeg |
| Ogg | `.ogg` | FFmpeg |
| WAVE | `.wav`, `.wave` | FFmpeg |
| Windows Media Audio | `.wma` | FFmpeg |
### :material-file-chart: Documents
Preview support for office documents or well-known project file formats varies by the format and whether or not embedded thumbnails are available to be read from. OpenDocument-based files are typically supported.
| Filetype | Extensions | Preview Type |
| ----------------------------- | --------------------- | -------------------------------------------------------------------------- |
| Blender | `.blend`, `.blend<#>` | Embedded thumbnail :material-alert-circle:{ title="If available in file" } |
| Keynote (Apple iWork) | `.key` | Embedded thumbnail |
| Krita[^3] | `.kra`, `.krz` | Embedded thumbnail :material-alert-circle:{ title="If available in file" } |
| MuseScore | `.mscz` | Embedded thumbnail :material-alert-circle:{ title="If available in file" } |
| Numbers (Apple iWork) | `.numbers` | Embedded thumbnail |
| OpenDocument Presentation | `.odp`, `.fodp` | Embedded thumbnail |
| OpenDocument Spreadsheet | `.ods`, `.fods` | Embedded thumbnail |
| OpenDocument Text | `.odt`, `.fodt` | Embedded thumbnail |
| Pages (Apple iWork) | `.pages` | Embedded thumbnail |
| PDF | `.pdf` | First page render |
| Photoshop | `.psd` | Flattened image render |
| PowerPoint (Microsoft Office) | `.pptx`, `.ppt` | Embedded thumbnail :material-alert-circle:{ title="If available in file" } |
### 3D Models
<!-- prettier-ignore -->
!!! failure "3D Model Support"
TagStudio does not currently support previews for 3D model files *(outside of Blender project embedded thumbnails)*. This is on our [roadmap](../updates/roadmap.md#uiux) for future features.
### :material-format-font: Fonts
Font thumbnails will use a "Aa" example preview of the font, with a full alphanumeric of the font available in the Preview Panel.
| Filetype | Extensions |
| -------------------- | ----------------- |
| OpenType Font | `.otf`, `.otc` |
| TrueType Font | `.ttf`, `.ttc` |
| Web Open Font Format | `.woff`, `.woff2` |
### :material-text-box: Text
<!-- prettier-ignore -->
!!! info "Plain Text Support"
TagStudio supports the *vast* majority of files considered to be "[plain text](https://en.wikipedia.org/wiki/Plain_text)". If an extension or format is not listed here, odds are it's still supported anyway.
Text files render the first 256 bytes of text information to an image preview for thumbnails and the Preview Panel. Improved thumbnails, full scrollable text, and syntax highlighting are on our [roadmap](../updates/roadmap.md#uiux) for future features.
| Filetype | Extensions | Syntax Highlighting |
| ---------- | --------------------------------------------- | :--------------------------------: |
| CSV | `.csv` | :material-close-circle:{.lg .red} |
| HTML | `.html`, `.htm`, `.xhtml`, `.shtml`, `.dhtml` | :material-close-circle:{.lg .red} |
| JSON | `.json`, `.jsonc`, `.json5` | :material-close-circle:{.lg .red} |
| Markdown | `.md`, `.markdown`, `.mkd`, `.rmd` | :material-close-circle:{.lg .red} |
| Plain Text | `.txt`, `.text` | :material-minus-circle:{.lg .gray} |
| TOML | `.toml` | :material-close-circle:{.lg .red} |
| XML | `.xml`, `.xul` | :material-close-circle:{.lg .red} |
| YAML | `.yaml`, `.yml` | :material-close-circle:{.lg .red} |
### :material-file: Other
| Filetype | Extensions | Preview Type |
| -------- | ---------- | -------------------- |
| EPUB | `.epub` | Embedded ebook cover |
<!-- prettier-ignore-start -->
[^1]:
The `.jpg_large` extension is unofficial and instead the byproduct of how [Google Chrome used to download images from Twitter](https://fileinfo.com/extension/jpg_large). Since this mangled extension is still in circulation, TagStudio supports it.
[^2]:
Apple Lossless traditionally uses `.m4a` and `.caf` containers, but may unofficially use the `.alac` extension. The `.m4a` container is also used for separate compressed audio codecs.
[^3]:
Krita also supports saving projects as OpenRaster `.ora` files. Support for these is listed in the "[Images](#images)" section.
<!-- prettier-ignore-end -->

View File

@@ -1,4 +1,8 @@
# Library Search
---
icon: material/magnify
---
# :material-magnify: Search
TagStudio provides various methods to search your library, ranging from TagStudio data such as tags to inherent file data such as paths or media types.
@@ -74,7 +78,7 @@ TagStudio uses a "[smartcase](https://neovim.io/doc/user/options.html#'smartcase
#### Glob Syntax
Optionally, you may use [glob](https://en.wikipedia.org/wiki/Glob_(programming)) syntax to search filepaths.
Optionally, you may use [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) syntax to search filepaths.
#### Examples

View File

@@ -1,4 +1,8 @@
# Tags
---
icon: material/tag-text
---
# :material-tag-text: Tags
Tags are discrete objects that represent some attribute. This could be a person, place, object, concept, and more. Unlike most tagging systems, TagStudio tags are not solely represented by a line of text or a hashtag. Tags in TagStudio consist of several properties and relationships that give extra customization, searching power, and ease of tagging that cannot be achieved by string-based tags alone. TagStudio tags are designed to be as simple or as complex as you'd like, giving options to users of all skill levels and use cases.
@@ -60,9 +64,9 @@ Lastly, when searching your files with broader categories such as `Character` or
### Component Tags
**_[Coming in version 9.6](../updates/roadmap.md#v96)_**
**_Coming in version 9.6_**
Component tags will be built from a composition-based, or "HAS" type relationship between tags. This takes care of instances where an attribute may "have" another attribute, but doesn't inherit from it. Shrek may be an `Ogre`, he may be a `Character`, but he is NOT a `Leather Vest` - even if he's commonly seen _with_ it. Component tags, along with the upcoming [Tag Override](./tag_overrides.md) feature, are built to handle these cases in a way that still simplifies the tagging process without adding too much undue complexity for the user.
Component tags will be built from a composition-based, or "HAS" type relationship between tags. This takes care of instances where an attribute may "have" another attribute, but doesn't inherit from it. Shrek may be an `Ogre`, he may be a `Character`, but he is NOT a `Leather Vest` - even if he's commonly seen _with_ it. Component tags, along with the upcoming "Tag Override" feature, are built to handle these cases in a way that still simplifies the tagging process without adding too much undue complexity for the user.
## Tag Appearance
@@ -80,7 +84,7 @@ Custom palettes and colors can be created via the [Tag Color Manager](./tag_colo
### Icon
**_[Coming in version 9.6](../updates/roadmap.md#v96)_**
**_Coming in version 9.6_**
## Tag Properties
@@ -94,7 +98,7 @@ When the "Is Category" property is checked, this tag now acts as a category sepa
#### Is Hidden
**_[Coming in version 9.6](../updates/roadmap.md#v96)_**
**_Coming in version 9.6_**
When the "Is Hidden" property is checked, any file entries tagged with this tag will not show up in searches by default. This property comes by default with the built-in "Archived" tag.

View File

@@ -1,8 +1,8 @@
---
tags:
icon: material/shape-plus
---
# Tag Categories
# :material-shape-plus: Tag Categories
The "Is Category" property of tags determines if a tag should be treated as a category itself when being organized inside the preview panel. Tags marked as categories will show themselves and all tags inheriting from it (including recursively) underneath a field-like section with the tag's name. This means that duplicates of tags can appear on entries if the tag inherits from multiple parent categories, however this is by design and reflects the nature of multiple inheritance. Any tags not inheriting from a category tag will simply show under a default "Tag" section.

View File

@@ -1,4 +1,8 @@
# Tag Colors
---
icon: material/palette
---
# :material-palette: Tag Colors
TagStudio features a variety of built-in tag colors, alongside the ability for users to create their own custom tag color palettes.

View File

@@ -1,20 +0,0 @@
---
tags:
- Upcoming Feature
---
# Tag Overrides
Tag overrides are the ability to add or remove [parent tags](./tag.md#parent-tags) from a [tag](./tag.md) on a per-[entry](./entry.md) basis.
## Examples
<figure markdown="span">
![Example 1](../assets/tag_override_ex-1.png){ height="300" }
<figcaption>Ex. 1 - Comparing standard tag composition vs additive and subtractive inheritance overrides.</figcaption>
</figure>
<figure markdown="span">
![Example 2](../assets/tag_override_ex-2.png){ height="300" }
<figcaption>Ex. 2 - Parent tag swap using tag overrides.</figcaption>
</figure>

View File

@@ -26,6 +26,18 @@
);
}
/* Mobile Nav Header */
.md-nav__source {
background: linear-gradient(
60deg,
rgb(205, 78, 255) 0%,
rgb(116, 123, 255) 100%
);
border-style: solid;
border-width: 0 0 2px 0;
border-color: #ffffff33;
}
th,
td {
padding: 0.5em 1em 0.5em 1em !important;
@@ -68,6 +80,10 @@ h2,
margin-right: -0.8rem;
}
figcaption {
margin-top: 0 !important;
}
.md-search__form {
height: 1.5rem;
background-color: #00004444;
@@ -81,8 +97,12 @@ h2,
margin-top: -0.2rem;
}
.twemoji {
margin-top: 0.05rem;
h1 > .twemoji {
margin-top: 0.14rem;
}
h2 > .twemoji {
margin-top: 0.08rem;
}
/* Matches the palette used by mkdocs-material */
@@ -97,3 +117,39 @@ h2,
.priority-low {
color: #28afff;
}
.red {
color: rgb(245, 0, 87);
}
.amber {
color: rgb(255, 145, 0);
}
.green {
color: rgb(0, 191, 165);
}
.gray {
color: rgb(158, 158, 158);
}
@media screen and (max-width: 76.234375em) {
/* Always show image logo on mobile */
.md-header__button.md-logo {
display: block;
}
label[for="__drawer"].md-header__button.md-icon {
order: -1;
}
.md-header {
background: linear-gradient(
60deg,
rgb(205, 78, 255) 10%,
rgb(116, 123, 255) 70%,
rgb(72, 179, 255) 100%
);
}
}

14
docs/stylesheets/home.css Normal file
View File

@@ -0,0 +1,14 @@
h2 {
margin: 1rem 0 0 0 !important;
}
.md-content .md-typeset h1 {
/* display: none; */
font-size: 0;
}
.grid > p {
align-content: center;
font-size: 1rem !important;
line-height: 1.25rem;
}

View File

@@ -1,4 +1,6 @@
---
title: Changelog
icon: material/list-status
---
--8<-- "CHANGELOG.md"
--8<-- "CHANGELOG.md"

View File

@@ -1,217 +1,283 @@
# Feature Roadmap
---
icon: material/map-check
---
This checklist details the current and remaining features required at a minimum for TagStudio to be considered "Feature Complete". This list is _not_ a definitive list for additional feature requests and PRs as they come in, but rather an outline of my personal core feature set intended for TagStudio.
# :material-map-check: Roadmap
## Priorities
This page outlines the current and planned features required for TagStudio to be considered "feature complete" (v10.0.0). Features and changes are broken up by group in order to better assess the overall state of those features. [Priority levels](#priority-levels) and [version estimates](#version-estimates) are provided in order to give a rough idea of what's planned and when it may release.
Features are broken up into the following priority levels, with nested priorities referencing their relative priority for the overall feature (i.e. A [LOW] priority feature can have a [HIGH] priority element but it otherwise still a [LOW] priority item overall):
This roadmap will update as new features are planned or completed. If there's a feature you'd like to see but is not listed on this page, please check the GitHub [Issues](https://github.com/TagStudioDev/TagStudio/issues) page and submit a feature request if one does not already exist!
- [HIGH] - Core feature
- [MEDIUM] - Important but not necessary
- [LOW] - Just nice to have
## Priority Levels
## Version Milestones
Planned features and changes are assigned **priority levels** to signify how important they are to the feature-complete version of TagStudio and to serve as a general guide for what should be worked on first, along with [version estimates](#version-estimates). When features are completed, their priority level icons are removed.
These version milestones are rough estimations for when the previous core features will be added. For a more definitive idea for when features are coming, please reference the current GitHub [milestones](https://github.com/TagStudioDev/TagStudio/milestones).
<!-- prettier-ignore -->
!!! info "Priority Level Icons"
- :material-chevron-triple-up:{ .priority-high title="High Priority" } **High Priority** - Core features
- :material-chevron-double-up:{ .priority-med title="Medium Priority" } **Medium Priority** - Important, but not necessary
- :material-chevron-up:{ .priority-low title="Low Priority" } **Low Priority** - Just nice to have
## Version Estimates
Features are given rough estimations for which version they will be completed in, and are listed next to their names (e.g. Feature **[v9.0.0]**). They are eventually replaced with links to the version changelog in which they were completed in, if applicable.
<!-- prettier-ignore -->
!!! tip
For a more definitive and up-to-date list of features planned for near-future updates, please reference the current GitHub [Milestones](https://github.com/TagStudioDev/TagStudio/milestones)!
---
## Core
### :material-database: SQL Library Database
An improved SQLite-based library save file format in which legacy JSON libraries are be migrated to.
Must be finalized or deemed "feature complete" before other core features are developed or finalized.
<!-- prettier-ignore -->
!!! note
This list was created after the release of version 9.4
See the "[Library](#library)" section for features related to the library database rather than the underlying schema.
### v9.5
- [x] A SQLite-based library save file format **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [ ] Cached File Properties Table :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [x] Date Entry Added to Library :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Date File Created :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Date File Modified :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Date Photo Taken :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Media Duration :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Media Dimensions :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Word Count :material-chevron-up:{ .priority-low title="Low Priority" }
#### Core
### :material-database-cog: Core Library + API
- [x] SQL backend [HIGH]
A separated, UI agnostic core library that would be used to interface with the TagStudio library format. Would host an API for communication from outside the program. This would be licensed under the more permissive [MIT](https://en.wikipedia.org/wiki/MIT_License) license to foster wider adoption compared to the TagStudio application source code.
#### Tags
- [ ] Core Library :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v10.0.0]**
- [ ] Core Library API :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v10.0.0]**
- [ ] MIT License :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v10.0.0]**
- [x] Deleting Tags [HIGH]
- [ ] User-defined tag colors [HIGH]
- [x] ID based, not string or hex [HIGH]
- [x] Color name [HIGH]
- [x] Color value (hex) [HIGH]
- [x] Existing colors are now a set of base colors [HIGH]
- [x] [Tag Categories](../library/tag_categories.md) [HIGH]
- [x] Property available for tags that allow the tag and any inheriting from it to be displayed separately in the preview panel under a title [HIGH]
### :material-clipboard-text: Format Specification
#### Search
A detailed written specification for the TagStudio tag and/or library format. Intended for used by third-parties to build alternative cores or protocols that can remain interoperable.
- [x] Boolean operators [HIGH]
- [x] Filename search [HIGH]
- [x] File type search [HIGH]
- [x] Search by extension (e.g. ".jpg", ".png") [HIGH]
- [x] Optional consolidation of extension synonyms (i.e. ".jpg" can equal ".jpeg") [LOW]
- [x] Search by media type (e.g. "image", "video", "document") [MEDIUM]
- [x] Sort by date added [HIGH]
- [ ] Format Specification Established :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v10.0.0]**
#### UI
---
- [x] Translations _(Any applicable)_ [MEDIUM]
- [x] Unified Media Player [HIGH]
- [x] Auto-hiding player controls
- [x] Play/Pause [HIGH]
- [x] Loop [HIGH]
- [x] Toggle Autoplay [MEDIUM]
- [x] Volume Control [HIGH]
- [x] Toggle Mute [HIGH]
- [x] Timeline scrubber [HIGH]
- [ ] Fullscreen [MEDIUM]
- [x] Configurable page size [HIGH]
## Application
#### Performance
### :material-button-cursor: UI/UX
- [x] Thumbnail caching [HIGH]
- [x] Library Grid View
- [ ] Explore Filesystem in Grid View :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Infinite Scrolling (No Pagination) :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Library List View :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Explore Filesystem in List View :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Lightbox View :material-chevron-triple-up:{ .priority-high title="High Priority" }
- Similar to List View in concept, but displays one large preview that can cycle back/forth between entries.
- [ ] Smaller thumbnails of immediate adjacent entries below :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [x] Library Statistics Screen :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.5.4]**
- [ ] Unified Library Health/Cleanup Screen :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.5.4]**
- [x] Fix Unlinked Entries
- [x] Fix Duplicate Files
- [x] ~~Fix Duplicate Entries~~
- [ ] Remove Ignored Entries :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.4]**
- [ ] Delete Old Backups :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.5.5]**
- [ ] Delete Legacy JSON File :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.5.5]**
- [x] Translations
- [ ] Search Bar Rework :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.7.0]**
- [ ] Improved Tag Autocomplete :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Tags appear as widgets in search bar :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Unified Media Player
- [x] Auto-Hiding Player Controls
- [x] Play/Pause
- [x] Loop
- [x] Toggle Autoplay
- [x] Volume Control
- [x] Toggle Mute
- [x] Timeline scrubber
- [ ] Fullscreen :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Fine-Tuned UI/UX :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6]**
- [ ] 3D Model Thumbnails/Previews :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] STL File Support
- [ ] OBJ File Support
- [ ] Plaintext Thumbnails/Previews :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Basic Support
- [ ] Full File Preview :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Syntax Highlighting :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Toggleable Persistent Tagging Panel :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Top Tags
- [ ] Recent Tags
- [ ] Tag Search
- [ ] Pinned Tags
- [ ] New Tabbed Tag Building UI to Support New Tag Features :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Custom Thumbnail Overrides :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Media Duration Labels :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Word/Line Count Labels :material-chevron-up:{ .priority-low title="Low Priority" }
- [ ] Custom Tag Badges :material-chevron-up:{ .priority-low title="Low Priority" }
- Would serve as an addition/alternative to the Favorite and Archived badges.
### v9.6
### :material-cog: Settings
#### Core
- [x] Application Settings
- [x] Stored in System User Folder/Designated Folder
- [x] Language
- [x] Date and Time Format
- [x] Theme
- [x] Thumbnail Generation :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.5.4]**
- [x] Configurable Page Size
- [ ] Library Settings :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Stored in `.TagStudio` folder :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Toggle File Extension Label :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Toggle Duration Label :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Cached file property table (media duration, word count, dimensions, etc.) [MEDIUM]
### :material-puzzle: Plugin Support
#### Library
Some form of official plugin support for TagStudio, likely with its own API that may connect to or encapsulate part of the the [core library API](#core-library-api).
- [ ] Multiple Root Directories per Library [HIGH]
- [ ] `.ts_ignore` (`.gitignore`-style glob ignoring) [HIGH]
- [ ] Sharable Color Packs [MEDIUM]
- [ ] Human-readable (TOML) files containing tag data [HIGH]
- [ ] Importable [HIGH]
- [ ] Exportable [HIGH]
- [ ] Plugin Support :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v10.0.0]**
#### Tags
---
- [ ] Merging Tags [HIGH]
- [ ] [Component/HAS](../library/tag.md#component-tags) subtags [HIGH]
- [ ] Tag Icons [HIGH]
- [ ] Small Icons [HIGH]
- [ ] Large Icons for Profiles [MEDIUM]
- [ ] Built-in Icon Packs (i.e. Boxicons) [HIGH]
- [ ] User Defined Icons [HIGH]
- [ ] Multiple Languages for Tag Strings [MEDIUM]
- [ ] Title is tag name [HIGH]
- [ ] Title has tag color [MEDIUM]
- [ ] Tag marked as category does not display as a tag itself [HIGH]
- [ ] [Tag Overrides](../library/tag_overrides.md) [MEDIUM]
- [ ] Per-file overrides of subtags [HIGH]
## [Library](../library/index.md)
#### Fields
### :material-wrench: Library Mechanics
- [ ] Datetime fields [HIGH]
- [ ] Custom field names [HIGH]
- [x] Per-Library Tags
- [ ] Global Tags :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Multiple Root Directories :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Ability to store TagStudio library folder separate from library files :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Automatic Entry Relinking :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.7.0]**
- [ ] Detect Renames :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Detect Moves :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Detect Deletions :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Performant :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Background File Scanning :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.7.0]**
- [x] Thumbnail Caching **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [ ] Audio Waveform Caching :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.7.0]**
#### Search
### :material-grid: [Entries](../library/entry.md)
- [ ] Field content search [HIGH]
- [ ] Sort by date created [HIGH]
- [ ] Sort by date modified [HIGH]
- [x] Sort by filename [HIGH]
- [ ] HAS operator for composition tags [HIGH]
- [ ] Search bar rework
- [ ] Improved tag autocomplete [HIGH]
- [ ] Tags appear as widgets in search bar [HIGH]
Library representations of files or file-like objects.
#### UI
- [x] File Entries **[v1.0.0]**
- [ ] Folder Entries :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] URL Entries / Bookmarks :material-chevron-up:{ .priority-low title="Low Priority" }
- [x] Fields
- [x] Text Lines
- [x] Text Boxes
- [x] Datetimes **[v9.5.4]**
- [ ] User-Titled Fields :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Removal of Deprecated Fields :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Entry Groups :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.7.0]**
- [ ] Non-exclusive; Entries can be in multiple groups :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Ability to number entries within group :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Ability to set sorting method for group :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Ability to set custom thumbnail for group :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Group is treated as entry with tags and metadata :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Nested groups :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] File duration on video thumbnails [HIGH]
- [ ] 3D Model Previews [MEDIUM]
- [ ] STL Previews [HIGH]
- [ ] Word count/line count on text thumbnails [LOW]
- [x] Settings Menu [HIGH]
- [x] Application Settings [HIGH]
- [x] Stored in system user folder/designated folder [HIGH]
- [ ] Library Settings [HIGH]
- [ ] Stored in `.TagStudio` folder [HIGH]
- [ ] Tagging Panel [HIGH]
### :material-tag-text: [Tags](../library/tag.md)
Toggleable persistent main window panel or pop-out. Replaces the current tag manager.
Discrete library objects representing [attributes](<https://en.wikipedia.org/wiki/Property_(philosophy)>). Can be applied to library [entries](../library/entry.md), or applied to other tags to build traversable relationships.
- [ ] Top Tags [HIGH]
- [ ] Recent Tags [HIGH]
- [ ] Tag Search [HIGH]
- [ ] Pinned Tags [HIGH]
- [x] Tag Name **[v8.0.0]**
- [x] Tag Shorthand Name **[v8.0.0]**
- [x] Tag Aliases List **[v8.0.0]**
- [x] Tag Color **[v8.0.0]**
- [ ] Tag Description :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.6.0]**
- [x] Tag Colors
- [x] Built-in Color Palette **[v8.0.0]**
- [x] User-Defined Colors **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [x] Primary and Secondary Colors **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [ ] Tag Icons :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Small Icons :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Large Icons for Profiles :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.6.0]**
- [ ] Built-in Icon Packs (i.e. Boxicons) :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] User-Defined Icons :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [x] [Category Property](../library/tag_categories.md) **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [x] Property available for tags that allow the tag and any inheriting from it to be displayed separately in the preview panel under a title
- [ ] Fine-tuned exclusion from categories :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Hidden Property :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Built-in "Archived" tag has this property by default :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Checkbox near search bar to show hidden tags in search :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Tag Relationships
- [x] [Parent Tags](../library/tag.md#parent-tags) ([Inheritance](<https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)>) Relationship) **[v9.0.0]**
- [ ] [Component Tags](../library/tag.md#component-tags) ([Composition](https://en.wikipedia.org/wiki/Object_composition) Relationship) :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Multiple Language Support :material-chevron-up:{ .priority-low title="Low Priority" } **[v9.9.0]**
- [ ] Tag Overrides :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Tag Merging :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] New tabbed tag building UI to support the new tag features [HIGH]
### :material-magnify: [Search](../library/library_search.md)
### v9.7
- [x] Tag Search **[v8.0.0]**
- [x] Filename Search **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [x] Glob Search **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [x] Filetype Search **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [x] Search by Extension (e.g. ".jpg", ".png") **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [x] Optional consolidation of extension synonyms (i.e. ".jpg" can equal ".jpeg") **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [x] Search by media type (e.g. "image", "video", "document") **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [ ] Field Content Search :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [x] [Boolean Operators](../library/library_search.md) **[[v9.5.0](./changelog.md#950-2025-03-03)]**
- [x] `AND` Operator
- [x] `OR` Operator
- [x] `NOT` Operator
- [x] Parenthesis Grouping
- [x] Character Escaping
- [ ] `HAS` Operator (for [Component Tags](../library/tag.md#component-tags)) :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Conditional Search :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.7.0]**
- [ ] Compare Dates :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Compare Durations :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Compare File Sizes :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Compare Dimensions :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [x] Smartcase Search [[v9.5.0](./changelog.md#950-2025-03-03)]
- [ ] Search Result Sorting
- [x] Sort by Filename **[[v9.5.2](./changelog.md#952-2025-03-31)]**
- [x] Sort by Date Entry Added to Library **[[v9.5.2](./changelog.md#952-2025-03-31)]**
- [ ] Sort by File Creation Date :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Sort by File Modification Date :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [ ] Sort by File Modification Date :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Sort by Date Taken (Photos) :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.6.0]**
- [x] Random/Shuffle Sort
- [ ] OCR Search :material-chevron-up:{ .priority-low title="Low Priority" }
- [ ] Fuzzy Search :material-chevron-up:{ .priority-low title="Low Priority" }
#### Library
### :material-file-cog: [Macros](../utilities/macro.md)
- [ ] [Entry groups](../library/entry_groups.md) [HIGH]
- [ ] Groups for files/entries where the same entry can be in multiple groups [HIGH]
- [ ] Ability to number entries within group [HIGH]
- [ ] Ability to set sorting method for group [HIGH]
- [ ] Ability to set custom thumbnail for group [HIGH]
- [ ] Group is treated as entry with tags and metadata [HIGH]
- [ ] Nested groups [MEDIUM]
#### Search
- [ ] Sort by relevance [HIGH]
- [ ] Sort by date taken (photos) [MEDIUM]
- [ ] Sort by file size [HIGH]
- [ ] Sort by file dimension (images/video) [LOW]
#### [Macros](../utilities/macro.md)
- [ ] Sharable Macros [MEDIUM]
- [ ] Standard notation format (TOML) contacting macro instructions [HIGH]
- [ ] Exportable [HIGH]
- [ ] Importable [HIGH]
- [ ] Triggers [HIGH]
- [ ] On new file [HIGH]
- [ ] On library refresh [HIGH]
- [ ] Standard, Human Readable Format (TOML) :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.5]**
- [ ] Versioning System :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.5]**
- [ ] Triggers **[v9.5.5]**
- [ ] On File Added :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] On Library Refresh :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] [...]
- [ ] Actions [HIGH]
- [ ] Add tag(s) [HIGH]
- [ ] Add field(s) [HIGH]
- [ ] Set field content [HIGH]
- [ ] Actions **[v9.5.5]**
- [ ] Add Tag(s) :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Add Field(s) :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Set Field Content :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] [...]
#### UI
### :material-table-arrow-right: Sharable Data
- [ ] Custom thumbnail overrides [MEDIUM]
- [ ] Toggle File Extension Label [MEDIUM]
- [ ] Toggle Duration Label [MEDIUM]
- [ ] Custom Tag Badges [LOW]
- [ ] Library list view [HIGH]
Sharable TagStudio library data in the form of data packs (tags, colors, etc.) or other formats.
Packs are intended as an easy way to import and export specific data between libraries and users, while export-only formats are intended to be imported by other programs.
### v9.8
#### Library
- [ ] Automatic Entry Relinking [HIGH]
- [ ] Detect Renames [HIGH]
- [ ] Detect Moves [HIGH]
- [ ] Detect Deletions [HIGH]
#### Search
- [ ] OCR search [LOW]
- [ ] Fuzzy Search [LOW]
### v9.9
#### Library
- [ ] Exportable Library Data [HIGH]
- [ ] Standard notation format (i.e. JSON) contacting all library data [HIGH]
#### Tags
- [ ] Tag Packs [MEDIUM]
- [ ] Human-readable (TOML) files containing tag data [HIGH]
- [ ] Multiple Languages for Tag Strings [MEDIUM]
- [ ] Importable [HIGH]
- [ ] Exportable [HIGH]
- [ ] Conflict resolution [HIGH]
### v10.0
- [ ] All remaining [HIGH] and optional [MEDIUM] features
### Post v10.0
#### Core
- [ ] Core Library/API
- [ ] Plugin Support
- [ ] Color Packs :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.5]**
- [ ] Importable
- [ ] Exportable
- [x] UUIDs + Namespaces :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Standard, Human Readable Format (TOML) :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Versioning System :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Tag Packs :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.9.0]**
- [ ] Importable :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Exportable :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] UUIDs + Namespaces :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Standard, Human Readable Format (TOML) :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Versioning System :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [ ] Macro Sharing :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.5]**
- [ ] Importable :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Exportable :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Sharable Entry Data :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.9.0]**
- _Specifics of this are yet to be determined_
- [ ] Export Library to Human Readable Format :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v10.0.0]**
- Intended to give users more flexible options with their data if they wish to migrate away from TagStudio

View File

@@ -1,11 +1,19 @@
# Save Format Changes
---
icon: material/database-edit
---
This page outlines the various changes made to the TagStudio save file format over time, sometimes referred to as the "database" or "database file".
# :material-database-edit: Save Format Changes
This page outlines the various changes made to the TagStudio library save file format over time, sometimes referred to as the "database" or "database file".
---
## JSON
Legacy (JSON) library save format versions were tied to the release version of the program itself. This number was stored in a `version` key inside the JSON file.
### Versions 1.0.0 - 9.4.2
| Used From | Used Until | Format | Location |
| --------- | ----------------------------------------------------------------------- | ------ | --------------------------------------------- |
| v1.0.0 | [v9.4.2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.4.2) | JSON | `<Library Folder>`/.TagStudio/ts_library.json |
@@ -16,11 +24,33 @@ Replaced by the new SQLite format introduced in TagStudio [v9.5.0 Pre-Release 1]
---
## DB_VERSION 6
## SQLite
Starting with TagStudio [v9.5.0-pr1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1), the library save format has been moved to a [SQLite](https://sqlite.org) format. Legacy JSON libraries are migrated (with the user's consent) to the new format when opening in current versions of the program. The save format versioning is now separate from the program's versioning number.
Versions **1-100** stored the database version in a table called `preferences` in a row with the `key` column of `"DB_VERSION"` inside the corresponding `value` column.
Versions **>101** store the database version in a table called `versions` in a row with the `key` column of `'CURRENT'` inside the corresponding `value` column. The `versions` table also stores the initial database version in which the file was created with under the `'INITIAL'` key. Databases created before this key was introduced will always have `'INITIAL'` value of `100`.
```mermaid
erDiagram
versions {
TEXT key PK "Values: ['INITIAL', 'CURRENT']"
INTEGER value
}
```
### Versions 1 - 5
These versions were used while developing the new SQLite file format, outside any official or recommended release. These versions **were never supported** in any official capacity and were actively warned against using for real libraries.
---
### Version 6
| Used From | Used Until | Format | Location |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- |
| [v9.5.0-PR1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1) | [v9.5.0-PR1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
| [v9.5.0-pr1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1) | [v9.5.0-pr1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr1) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
The first public version of the SQLite save file format.
@@ -28,22 +58,22 @@ Migration from the legacy JSON format is provided via a walkthrough when opening
---
## DB_VERSION 7
### Version 7
| Used From | Used Until | Format | Location |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------ | ----------------------------------------------- |
| [v9.5.0-PR2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr2) | [v9.5.0-PR3](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr3) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
| [v9.5.0-pr2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr2) | [v9.5.0-pr3](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr3) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
- Repairs "Description" fields to use a TEXT_LINE key instead of a TEXT_BOX key.
- Repairs tags that may have a disambiguation_id pointing towards a deleted tag.
---
## DB_VERSION 8
### Version 8
| Used From | Used Until | Format | Location |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
| [v9.5.0-PR4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr4) | [v9.5.1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.1) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
| [v9.5.0-pr4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.0-pr4) | [v9.5.1](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.1) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
- Adds the `color_border` column to the `tag_colors` table. Used for instructing the [secondary color](../library/tag_color.md#secondary-color) to apply to a tag's border as a new optional behavior.
- Adds three new default colors: "Burgundy (TagStudio Shades)", "Dark Teal (TagStudio Shades)", and "Dark Lavender (TagStudio Shades)".
@@ -51,10 +81,37 @@ Migration from the legacy JSON format is provided via a walkthrough when opening
---
## DB_VERSION 9
### Version 9
| Used From | Used Until | Format | Location |
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
| [v9.5.2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.2) | [v9.5.3](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.3) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
- Adds the `filename` column to the `entries` table. Used for sorting entries by filename in search results.
---
### Version 100
| Used From | Used Until | Format | Location |
| ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------ | ----------------------------------------------- |
| [74383e3](https://github.com/TagStudioDev/TagStudio/commit/74383e3c3c12f72be1481ab0b86c7360b95c2d85) | [v9.5.4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.4) | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
- Introduces built-in minor versioning
- The version number divided by 100 (and floored) constitutes the **major** version. Major version indicate breaking changes that prevent libraries from being opened in TagStudio versions older than the ones they were created in.
- Values more precise than this ("ones" through "tens" columns) constitute the **minor** version. These indicate minor changes that don't prevent a newer library from being opened in an older version of TagStudio, as long as the major version is not also increased.
- Swaps `parent_id` and `child_id` values in the `tag_parents` table, which have erroneously been flipped since the first SQLite DB version.
#### Version 101
| Used From | Used Until | Format | Location |
| ----------------------------------------------------------------------- | ---------- | ------ | ----------------------------------------------- |
| [v9.5.2](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.2) | _Current_ | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
| [v9.5.4](https://github.com/TagStudioDev/TagStudio/releases/tag/v9.5.4) | _Current_ | SQLite | `<Library Folder>`/.TagStudio/ts_library.sqlite |
- Adds the `filename` column to the `entries` table. Used for sorting entries by filename in search results.
- Deprecates the `preferences` table, set to be removed in a future TagStudio version.
- Introduces the `versions` table
- Has a string `key` column and an int `value` column
- The `key` column stores one of two values: `'INITIAL'` and `'CURRENT'`
- `'INITIAL'` stores the database version number in which in was created
- Pre-existing databases set this number to `100`
- `'CURRENT'` stores the current database version number

View File

@@ -1,4 +1,8 @@
# Usage
---
icon: material/mouse
---
# :material-mouse: Usage
## Creating/Opening a Library
@@ -67,7 +71,9 @@ As of version 9.5, libraries are saved automatically as you go. To save a backup
There are a handful of launch arguments you can pass to TagStudio via the command line or a desktop shortcut.
| Argument | Short | Description |
| ---------------------- | ----- | ---------------------------------------------------- |
| `--open <path>` | `-o` | Path to a TagStudio Library folder to open on start. |
| `--config-file <path>` | `-c` | Path to the TagStudio config file to load. |
| Argument | Short | Description |
| ------------------------ | ----- | ------------------------------------------------------ |
| `--cache-file <path>` | `-c` | Path to a TagStudio .ini or .plist cache file to use. |
| `--open <path>` | `-o` | Path to a TagStudio Library folder to open on start. |
| `--settings-file <path>` | `-s` | Path to a TagStudio .toml global settings file to use. |
| `--version` | `-v` | Displays TagStudio version information. |

322
docs/utilities/ignore.md Normal file
View File

@@ -0,0 +1,322 @@
---
title: Ignore Files
icon: material/file-document-remove
---
# :material-file-document-remove: Ignore Files & Directories
<!-- prettier-ignore -->
!!! warning "Legacy File Extension Ignoring"
TagStudio versions prior to v9.5.4 use a different, more limited method to exclude or include file extensions from your library and subsequent searches. Opening a pre-exiting library in v9.5.4 or later will non-destructively convert this to the newer, more extensive `.ts_ignore` format.
If you're still running an older version of TagStudio in the meantime, you can access the legacy system by going to "Edit -> Manage File Extensions" in the menubar.
TagStudio offers the ability to ignore specific files and directories via a `.ts_ignore` file located inside your [library's](../library/index.md) `.TagStudio` folder. This file is designed to use very similar [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>)-style pattern matching as the [`.gitignore`](https://git-scm.com/docs/gitignore) file used by Git™[^1]. It can be edited within TagStudio or opened to edit with an external program by going to the "Edit -> Ignore Files" option in the menubar.
This file is only referenced when scanning directories for new files to add to your library, and does not apply to files that have already been added to your library.
<!-- prettier-ignore -->
!!! tip
If you just want some specific examples of how to achieve common tasks with the ignore patterns (e.g. ignoring a single file type, ignoring a specific folder) then jump to the "[Use Cases](#use-cases)" section!
<!-- prettier-ignore-start -->
=== "Example .ts_ignore file"
```toml title="My Library/.TagStudio/.ts_ignore"
# TagStudio .ts_ignore file.
# Code
__pycache__
.pytest_cache
.venv
.vs
# Projects
Minecraft/**/Metadata
Minecraft/Website
!Minecraft/Website/*.png
!Minecraft/Website/*.css
# Documents
*.doc
*.docx
*.ppt
*.pptx
*.xls
*.xlsx
```
<!-- prettier-ignore-end -->
## Pattern Format
<!-- prettier-ignore -->
!!! note ""
_This section sourced and adapted from Git's[^1] `.gitignore` [documentation](https://git-scm.com/docs/gitignore)._
### Internal Processes
When scanning your library directories, the `.ts_ignore` file is read by either the [`wcmatch`](https://facelessuser.github.io/wcmatch/glob/) library or [`ripgrep`](https://github.com/BurntSushi/ripgrep) in glob mode depending if you have the later installed on your system and it's detected by TagStudio. Ripgrep is the preferred method for scanning directories due to its improved performance and identical pattern matching to `.gitignore`. This mixture of tools may lead to slight inconsistencies if not using `ripgrep`.
---
### Comments ( `#` )
A `#` symbol at the start of a line indicates that this line is a comment, and match no items. Blank lines are used to enhance readability and also match no items.
- Can be escaped by putting a backslash ("`\`") in front of the `#` symbol.
<!-- prettier-ignore-start -->
=== "Example comment"
```toml
# This is a comment! I can say whatever I want on this line.
file_that_is_being_matched.txt
# file_that_is_NOT_being_matched.png
file_that_is_being_matched.png
```
=== "Organizing with comments"
```toml
# TagStudio .ts_ignore file.
# Minecraft Stuff
Minecraft/**/Metadata
Minecraft/Website
!Minecraft/Website/*.png
!Minecraft/Website/*.css
# Microsoft Office
*.doc
*.docx
*.ppt
*.pptx
*.xls
*.xlsx
```
=== "Escape a # symbol"
```toml
# To ensure a file named '#hashtag.jpg' is ignored:
\#hashtag.jpg
```
<!-- prettier-ignore-end -->
---
### Directories ( `/` )
The forward slash "`/`" is used as the directory separator. Separators may occur at the beginning, middle or end of the `.ts_ignore` search pattern.
- If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular `.TagStudio` library folder itself. Otherwise the pattern may also match at any level below the `.TagStudio` folder level.
- If there is a separator at the end of the pattern then the pattern will only match directories, otherwise the pattern can match both files and directories.
<!-- prettier-ignore-start -->
=== "Example folder pattern"
```toml
# Matches "frotz" and "a/frotz" if they are directories.
frotz/
```
=== "Example nested folder pattern"
```toml
# Matches "doc/frotz" but not "a/doc/frotz".
doc/frotz/
```
<!-- prettier-ignore-end -->
---
### Negation ( `!` )
A `!` prefix before a pattern negates the pattern, allowing any files matched matched by previous patterns to be un-matched.
- Any matching file excluded by a previous pattern will become included again.
- **It is not possible to re-include a file if a parent directory of that file is excluded.**
<!-- prettier-ignore-start -->
=== "Example negation"
```toml
# All .jpg files will be ignored, except any located in the 'Photos' folder.
*.jpg
Photos/!*.jpg
```
=== "Escape a ! Symbol"
```toml
# To ensure a file named '!wowee.jpg' is ignored:
\!wowee.jpg
```
<!-- prettier-ignore-end -->
---
### Wildcards
#### Single Asterisks ( `*` )
An asterisk "`*`" matches anything except a slash.
<!-- prettier-ignore-start -->
=== "File examples"
```toml
# Matches all .png files in the "Images" folder.
Images/*.png
# Matches all .png files in all folders
*.png
```
=== "Folder examples"
```toml
# Matches any files or folders directly in "Images/" but not deeper levels.
# Matches file "Images/mario.jpg"
# Matches folder "Images/Mario"
# Does not match file "Images/Mario/cat.jpg"
Images/*
```
<!-- prettier-ignore-end -->
#### Question Marks ( `?` )
The character "`?`" matches any one character except "`/`".
<!-- prettier-ignore-start -->
=== "File examples"
```toml
# Matches any .png file starting with "IMG_" and ending in any four characters.
# Matches "IMG_0001.png"
# Matches "Photos/IMG_1234.png"
# Does not match "IMG_1.png"
IMG_????.png
# Same as above, except matches any file extension instead of only .png
IMG_????.*
```
=== "Folder examples"
```toml
# Matches all files in any direct subfolder of "Photos" beginning in "20".
# Matches "Photos/2000"
# Matches "Photos/2024"
# Matches "Photos/2099"
# Does not match "Photos/1995"
Photos/20??/
```
<!-- prettier-ignore-end -->
#### Double Asterisks ( `**` )
Two consecutive asterisks ("`**`") in patterns matched against full pathname may have special meaning:
- A leading "`**`" followed by a slash means matches in all directories.
- A trailing "`/**`" matches everything inside.
- A slash followed by two consecutive asterisks then a slash ("`/**/`") matches zero or more directories.
- Other consecutive asterisks are considered regular asterisks and will match according to the previous rules.
<!-- prettier-ignore-start -->
=== "Leading **"
```toml
# Both match file or directory "foo" anywhere
**/foo
foo
# Matches file or directory "bar" anywhere that is directly under directory "foo"
**/foo/bar
```
=== "Trailing /**"
```toml
# Matches all files inside directory "abc" with infinite depth.
abc/**
```
=== "Middle /**/"
```toml
# Matches "a/b", "a/x/b", "a/x/y/b" and so on.
a/**/b
```
<!-- prettier-ignore-end -->
#### Square Brackets ( `[a-Z]` )
Character sets and ranges are specific and powerful forms of wildcards that use characters inside of brackets (`[]`) to leverage very specific matching. The range notation, e.g. `[a-zA-Z]`, can be used to match one of the characters in a range.
<!-- prettier-ignore -->
!!! tip
For more in-depth examples and explanations on how to use ranges, please reference the [`glob`](https://man7.org/linux/man-pages/man7/glob.7.html) man page.
<!-- prettier-ignore-start -->
=== "Range examples"
```toml
# Matches all files that start with "IMG_" and end in a single numeric character.
# Matches "IMG_0.jpg", "IMG_7.png"
# Does not match "IMG_10.jpg", "IMG_A.jpg"
IMG_[0-9]
# Matches all files that start with "IMG_" and end in a single alphabetic character
IMG_[a-z]
```
=== "Set examples"
```toml
# Matches all files that start with "IMG_" and in any character in the set.
# Matches "draft_a.docx", "draft_b.docx", "draft_c.docx"
# Does not match "draft_d.docx"
draft_[abc]
# Matches all files that start with "IMG_" and end in a single alphabetic character
IMG_[a-z]
```
<!-- prettier-ignore-end -->
---
## Use Cases
### Ignoring Files by Extension
<!-- prettier-ignore -->
=== "Ignore all .jpg files"
```toml
*.jpg
```
=== "Ignore all files EXCEPT .jpg files"
```toml
*
!*.jpg
```
=== "Ignore all .jpg files in specific folders"
```toml
./Photos/Worst Vacation/*.jpg
Music/Artwork Art/*.jpg
```
<!-- prettier-ignore -->
!!! tip "Ensuring Complete Extension Matches"
For some filetypes, it may be nessisary to specify different casing and alternative spellings in order to match with all possible variations of an extension in your library.
```toml title="Ignore (Most) Possible JPEG File Extensions"
# The JPEG Cinematic Universe
*.jpg
*.jpeg
*.jfif
*.jpeg_large
*.JPG
*.JPEG
*.JFIF
*.JPEG_LARGE
```
### Ignoring a Folder
<!-- prettier-ignore -->
=== "Ignore all "Cache" folders"
```toml
# Matches any folder called "Cache" no matter where it is in your library.
cache/
```
=== "Ignore a "Downloads" folder"
```toml
# "Downloads" must be a folder on the same level as your ".TagStudio" folder.
# Does not match with folders name "Downloads" elsewhere in your library
# Does not match with a file called "Downloads"
/Downloads/
```
=== "Ignore .jpg files in specific folders"
```toml
Photos/Worst Vacation/*.jpg
/Music/Artwork Art/*.jpg
```
[^1]: The term "Git" is a licensed trademark of "The Git Project", a member of the Software Freedom Conservancy. Git is released under the [GNU General Public License version 2.0](https://opensource.org/license/GPL-2.0), an open source license. TagStudio is not associated with the Git Project, only including systems based on some therein.

View File

@@ -1,4 +1,8 @@
# Tools & Macros
---
icon: material/script-text
---
# :material-script-text: Tools & Macros
Tools and macros are features that serve to create a more fluid [library](../library/index.md)-managing process, or provide some extra functionality. Please note that some are still in active development and will be fleshed out in future updates.

12
flake.lock generated
View File

@@ -7,11 +7,11 @@
]
},
"locked": {
"lastModified": 1743550720,
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
"lastModified": 1754487366,
"narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
"rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18",
"type": "github"
},
"original": {
@@ -22,11 +22,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1744932701,
"narHash": "sha256-fusHbZCyv126cyArUwwKrLdCkgVAIaa/fQJYFlCEqiU=",
"lastModified": 1755615617,
"narHash": "sha256-HMwfAJBdrr8wXAkbGhtcby1zGFvs+StOp19xNsbqdOg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef",
"rev": "20075955deac2583bb12f07151c2df830ef346b4",
"type": "github"
},
"original": {

View File

@@ -27,48 +27,30 @@
perSystem =
{ pkgs, ... }:
let
python3 = pkgs.python312;
in
{
packages =
let
python3Packages = pkgs.python312Packages;
python3Packages = python3.pkgs;
pillow-jxl-plugin = python3Packages.callPackage ./nix/package/pillow-jxl-plugin.nix {
inherit (pkgs) cmake;
inherit pyexiv2;
};
pyexiv2 = python3Packages.callPackage ./nix/package/pyexiv2.nix { inherit (pkgs) exiv2; };
vtf2img = python3Packages.callPackage ./nix/package/vtf2img.nix { };
in
rec {
default = tagstudio;
tagstudio = pkgs.callPackage ./nix/package {
# HACK: Remove when PySide6 is bumped to 6.9.x.
# Sourced from https://github.com/NixOS/nixpkgs/commit/2f9c1ad5e19a6154d541f878774a9aacc27381b7.
pyside6 =
if lib.versionAtLeast python3Packages.pyside6.version "6.9.0" then
(python3Packages.pyside6.override {
shiboken6 = python3Packages.shiboken6.overrideAttrs {
version = "6.8.0.2";
inherit python3Packages;
src = pkgs.fetchurl {
url = "mirror://qt/official_releases/QtForPython/shiboken6/PySide6-6.8.0.2-src/pyside-setup-everywhere-src-6.8.0.tar.xz";
hash = "sha256-Ghohmo8yfjQNJYJ1+tOp8mG48EvFcEF0fnPdatJStOE=";
};
sourceRoot = "pyside-setup-everywhere-src-6.8.0/sources/shiboken6";
patches = [ ./nix/package/shiboken6-fix-include-qt-headers.patch ];
};
}).overrideAttrs
{ sourceRoot = "pyside-setup-everywhere-src-6.8.0/sources/pyside6"; }
else
python3Packages.pyside6;
inherit pillow-jxl-plugin vtf2img;
inherit pillow-jxl-plugin;
};
tagstudio-jxl = tagstudio.override { withJXLSupport = true; };
inherit pillow-jxl-plugin pyexiv2 vtf2img;
inherit pillow-jxl-plugin pyexiv2;
};
devShells = rec {
@@ -79,6 +61,8 @@
lib
pkgs
self
python3
;
};
};

View File

@@ -36,15 +36,14 @@ nav:
- help/ffmpeg.md
- Library:
- library/index.md
- library/entry.md
- library/entry_groups.md
- library/field.md
- library/library_search.md
- library/entry.md
- library/field.md
- library/tag.md
- library/tag_categories.md
- library/tag_color.md
- library/tag_overrides.md
- Utilities:
- utilities/ignore.md
- utilities/macro.md
- Updates:
- updates/changelog.md
@@ -63,16 +62,16 @@ theme:
# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: deep purple
accent: deep purple
primary: purple
accent: purple
toggle:
icon: material/lightbulb
name: Switch to Dark Mode
# Palette toggle for dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: deep purple
accent: deep purple
primary: purple
accent: purple
toggle:
icon: material/lightbulb-night-outline
name: Switch to System Preference
@@ -91,6 +90,7 @@ theme:
- content.code.annotate
- content.code.copy
- content.action.edit
- content.tooltips
icon:
repo: fontawesome/brands/github
tag:
@@ -105,6 +105,7 @@ markdown_extensions:
- def_list
- footnotes
- md_in_html
- tables
- toc:
permalink: true
@@ -115,11 +116,15 @@ markdown_extensions:
smart_enable: all
- pymdownx.caret
- pymdownx.details
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.highlight
- pymdownx.inlinehilite
- pymdownx.keys
- pymdownx.mark
- pymdownx.smartsymbols
- pymdownx.snippets
- pymdownx.superfences:
custom_fences:
- name: mermaid

View File

@@ -4,12 +4,11 @@
pipewire,
python3Packages,
qt6,
ripgrep,
stdenv,
wrapGAppsHook,
pillow-jxl-plugin,
pyside6,
vtf2img,
withJXLSupport ? false,
}:
@@ -28,7 +27,7 @@ python3Packages.buildPythonApplication {
python3Packages.pythonRelaxDepsHook
qt6.wrapQtAppsHook
# INFO: Should be unnecessary once PR is pulled.
# Should be unnecessary once PR is pulled.
# PR: https://github.com/NixOS/nixpkgs/pull/271037
# Issue: https://github.com/NixOS/nixpkgs/issues/149812
wrapGAppsHook
@@ -53,18 +52,32 @@ python3Packages.buildPythonApplication {
cp $src/src/tagstudio/resources/icon.png $out/share/icons/hicolor/512x512/apps/tagstudio.png
'';
makeWrapperArgs =
[ "--prefix PATH : ${lib.makeBinPath [ ffmpeg-headless ]}" ]
++ lib.optional stdenv.hostPlatform.isLinux "--prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [ pipewire ]
}";
dontWrapGApps = true;
dontWrapQtApps = true;
makeWrapperArgs = [
"--prefix PATH : ${
lib.makeBinPath [
ffmpeg-headless
ripgrep
]
}"
]
++ lib.optional stdenv.hostPlatform.isLinux "--prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [ pipewire ]
}"
++ [
"\${gappsWrapperArgs[@]}"
"\${qtWrapperArgs[@]}"
];
pythonRemoveDeps = lib.optional (!withJXLSupport) [ "pillow_jxl" ];
pythonRelaxDeps = [
"numpy"
"pillow"
"pillow-avif-plugin"
"pillow-heif"
"pillow-jxl-plugin"
"pyside6"
"structlog"
"typing-extensions"
];
@@ -81,6 +94,7 @@ python3Packages.buildPythonApplication {
numpy
opencv-python
pillow
pillow-avif-plugin
pillow-heif
pydantic
pydub
@@ -88,41 +102,32 @@ python3Packages.buildPythonApplication {
rawpy
send2trash
sqlalchemy
srctools
structlog
toml
ujson
vtf2img
wcmatch
]
++ lib.optional withJXLSupport pillow-jxl-plugin;
# These tests require modifications to a library, which does not work
# in a read-only environment.
disabledTests = [
# INFO: These tests require modifications to a library, which does not work
# in a read-only environment.
"test_build_tag_panel_add_alias_callback"
"test_build_tag_panel_add_aliases"
"test_build_tag_panel_add_sub_tag_callback"
"test_build_tag_panel_build_tag"
"test_build_tag_panel_remove_alias_callback"
"test_build_tag_panel_remove_subtag_callback"
"test_build_tag_panel_set_aliases"
"test_build_tag_panel_set_parent_tags"
"test_build_tag_panel_set_tag"
"test_badge_visual_state"
"test_browsing_state_update"
"test_flow_layout_happy_path"
"test_json_migration"
"test_library_migrations"
"test_add_same_tag_to_selection_single"
"test_add_tag_to_selection_multiple"
"test_add_tag_to_selection_single"
"test_custom_tag_category"
"test_file_path_display"
"test_meta_tag_category"
"test_update_selection_empty"
"test_update_selection_empty"
"test_update_selection_multiple"
"test_update_selection_single"
# INFO: This test requires modification of a configuration file.
"test_filepath_setting"
"test_update_tags"
];
disabledTestPaths = [
"tests/qt/test_build_tag_panel.py"
"tests/qt/test_field_containers.py"
"tests/qt/test_file_path_options.py"
"tests/qt/test_preview_panel.py"
"tests/qt/test_tag_panel.py"
"tests/qt/test_tag_search_panel.py"
"tests/test_library.py"
];
meta = {

View File

@@ -13,18 +13,18 @@
buildPythonPackage rec {
pname = "pillow-jxl-plugin";
version = "1.3.2";
version = "1.3.4";
pyproject = true;
src = fetchPypi {
pname = builtins.replaceStrings [ "-" ] [ "_" ] pname;
pname = "pillow_jxl_plugin";
inherit version;
hash = "sha256-efBoek8yUFR+ArhS55lm9F2XhkZ7/I3GsScQEe8U/2I=";
hash = "sha256-jqWJ/FWep8XfzLQq9NgUj121CPX01FGDKLq1ox/LJo4=";
};
cargoDeps = rustPlatform.fetchCargoVendor {
inherit src;
hash = "sha256-vZHrwGfgo3fIIOY7p0vy4XIKiHoddPDdJggkBen+w/A=";
hash = "sha256-7j+sCn+P6q6tsm2MJ/cM7hF2KEjILJNA6SDb35tecPg=";
};
nativeBuildInputs = [
@@ -39,9 +39,9 @@ buildPythonPackage rec {
pytestCheckHook
];
# INFO: Working directory takes precedence in the Python path. Remove
# Working directory takes precedence in the Python path. Remove
# `pillow_jxl` to prevent it from being loaded during pytest, rather than the
# built module, as it includes a `pillow_jxl.pillow_jxl` .so that is imported.
# built module, as it includes a `pillow_jxl.pillow_jxl.so` that is imported.
# See: https://github.com/NixOS/nixpkgs/issues/255262
# See: https://github.com/NixOS/nixpkgs/pull/255471
preCheck = ''
@@ -58,8 +58,9 @@ buildPythonPackage rec {
];
meta = {
description = "Pillow plugin for JPEG-XL, using Rust for bindings.";
description = "Pillow plugin for JPEG-XL, using Rust for bindings";
homepage = "https://github.com/Isotr0py/pillow-jpegxl-plugin";
changelog = "https://github.com/Isotr0py/pillow-jpegxl-plugin/releases/tag/v${version}";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ xarvex ];
platforms = lib.platforms.unix;

View File

@@ -4,16 +4,18 @@
exiv2,
fetchFromGitHub,
lib,
setuptools,
}:
buildPythonPackage rec {
pname = "pyexiv2";
version = "2.15.3";
pyproject = true;
src = fetchFromGitHub {
owner = "LeoHsiao1";
repo = pname;
rev = "v${version}";
repo = "pyexiv2";
tag = "v${version}";
hash = "sha256-83bFMaoXncvhRJNcCgkkC7B29wR5pjuLO/EdkQdqxxo=";
};
@@ -22,9 +24,12 @@ buildPythonPackage rec {
pythonImportsCheck = [ "pyexiv2" ];
build-system = [ setuptools ];
meta = {
description = "Read and write image metadata, including EXIF, IPTC, XMP, ICC Profile.";
description = "Read and write image metadata, including EXIF, IPTC, XMP, ICC Profile";
homepage = "https://github.com/LeoHsiao1/pyexiv2";
changelog = "https://github.com/LeoHsiao1/pyexiv2/releases/tag/v${version}";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ xarvex ];
platforms = with lib.platforms; darwin ++ linux ++ windows;

View File

@@ -1,81 +0,0 @@
Sourced from https://github.com/NixOS/nixpkgs/blob/5ba0f1ea90b0afa2abc23a43edb63af51d932e6d/pkgs/development/python-modules/shiboken6/fix-include-qt-headers.patch.
--- a/ApiExtractor/clangparser/compilersupport.cpp
+++ b/ApiExtractor/clangparser/compilersupport.cpp
@@ -16,6 +16,7 @@
#include <QtCore/QStandardPaths>
#include <QtCore/QStringList>
#include <QtCore/QVersionNumber>
+#include <QtCore/QRegularExpression>
#include <clang-c/Index.h>
@@ -341,6 +342,13 @@ QByteArrayList emulatedCompilerOptions()
{
QByteArrayList result;
HeaderPaths headerPaths;
+
+ bool isNixDebug = qgetenv("NIX_DEBUG").toInt() > 0;
+ // examples:
+ // /nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-qtsensors-6.4.2-dev/include
+ // /nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-qtbase-6.4.2-dev/include
+ QRegularExpression qtHeaderRegex(uR"(/[0-9a-z]{32}-qt[a-z0-9]+-)"_s);
+
switch (compiler()) {
case Compiler::Msvc:
result.append(QByteArrayLiteral("-fms-compatibility-version=19.26.28806"));
@@ -352,9 +360,30 @@ QByteArrayList emulatedCompilerOptions()
appendClangBuiltinIncludes(&headerPaths);
break;
case Compiler::Clang:
- headerPaths.append(gppInternalIncludePaths(compilerFromCMake(u"clang++"_s)));
+ // fix: error: cannot jump from switch statement to this case label: case Compiler::Gpp
+ // note: jump bypasses variable initialization: const HeaderPaths clangPaths =
+ {
+ //headerPaths.append(gppInternalIncludePaths(compilerFromCMake(u"clang++"_s)));
+ // fix: qt.shiboken: x is specified in typesystem, but not defined. This could potentially lead to compilation errors.
+ // PySide requires that Qt headers are not -isystem
+ // https://bugreports.qt.io/browse/PYSIDE-787
+ const HeaderPaths clangPaths = gppInternalIncludePaths(compilerFromCMake(u"clang++"_qs));
+ for (const HeaderPath &h : clangPaths) {
+ auto match = qtHeaderRegex.match(QString::fromUtf8(h.path));
+ if (!match.hasMatch()) {
+ if (isNixDebug)
+ qDebug() << "shiboken compilersupport.cpp: found non-qt header: " << h.path;
+ // add using -isystem
+ headerPaths.append(h);
+ } else {
+ if (isNixDebug)
+ qDebug() << "shiboken compilersupport.cpp: found qt header: " << h.path;
+ headerPaths.append({h.path, HeaderType::Standard});
+ }
+ }
result.append(noStandardIncludeOption());
break;
+ }
case Compiler::Gpp:
if (needsClangBuiltinIncludes())
appendClangBuiltinIncludes(&headerPaths);
@@ -363,8 +392,20 @@ QByteArrayList emulatedCompilerOptions()
// <type_traits> etc (g++ 11.3).
const HeaderPaths gppPaths = gppInternalIncludePaths(compilerFromCMake(u"g++"_qs));
for (const HeaderPath &h : gppPaths) {
- if (h.path.contains("c++") || h.path.contains("sysroot"))
+ // fix: qt.shiboken: x is specified in typesystem, but not defined. This could potentially lead to compilation errors.
+ // PySide requires that Qt headers are not -isystem
+ // https://bugreports.qt.io/browse/PYSIDE-787
+ auto match = qtHeaderRegex.match(QString::fromUtf8(h.path));
+ if (!match.hasMatch()) {
+ if (isNixDebug)
+ qDebug() << "shiboken compilersupport.cpp: found non-qt header: " << h.path;
+ // add using -isystem
headerPaths.append(h);
+ } else {
+ if (isNixDebug)
+ qDebug() << "shiboken compilersupport.cpp: found qt header: " << h.path;
+ headerPaths.append({h.path, HeaderType::Standard});
+ }
}
break;
}
--
2.39.0

View File

@@ -1,29 +0,0 @@
{
buildPythonPackage,
fetchPypi,
lib,
pillow,
}:
buildPythonPackage rec {
pname = "vtf2img";
version = "0.1.0";
src = fetchPypi {
inherit pname version;
hash = "sha256-YmWs8673d72wH4nTOXP4AFGs2grIETln4s1MD5PfE0A=";
};
pythonImportsCheck = [ "vtf2img" ];
dependencies = [ pillow ];
meta = {
description = "A Python library to convert Valve Texture Format (VTF) files to images.";
homepage = "https://github.com/julienc91/vtf2img";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ xarvex ];
mainProgram = "vtf2img";
platforms = lib.platforms.unix;
};
}

View File

@@ -1,59 +1,72 @@
{ lib, pkgs, ... }:
{
lib,
pkgs,
python3,
...
}:
let
# INFO: PySide6 from PIP is compiled for 6.8.0 of Qt, must pin to match version.
# Long term this can be solved with an alternative like uv2nix for the devshell.
qt6Pkgs = import (builtins.fetchTarball {
name = "nixos-unstable-qt6-pinned";
url = "https://github.com/NixOS/nixpkgs/archive/93ff48c9be84a76319dac293733df09bbbe3f25c.tar.gz";
sha256 = "038m7932v4z0zn2lk7k7mbqbank30q84r1viyhchw9pcm3aq3q23";
}) { inherit (pkgs) system; };
pythonLibraryPath = lib.makeLibraryPath (
(with pkgs; [
fontconfig.lib
freetype
glib
stdenv.cc.cc.lib
zstd
])
++ (with qt6Pkgs.qt6; [ qtbase ])
++ lib.optionals (!pkgs.stdenv.isDarwin) (
(with pkgs; [
dbus.lib
pythonLibraryPath =
with pkgs;
lib.makeLibraryPath (
[
fontconfig
freetype
glib
qt6.qtbase
stdenv.cc.cc
zstd
]
++ lib.optionals (!stdenv.isDarwin) [
dbus
libGL
libdrm
libpulseaudio
libva
libxkbcommon
pipewire
qt6.qtwayland
xorg.libX11
xorg.libXrandr
])
++ (with qt6Pkgs.qt6; [ qtwayland ])
)
);
]
);
libraryPath = "${lib.optionalString pkgs.stdenv.isDarwin "DY"}LD_LIBRARY_PATH";
python = pkgs.python312;
pythonWrapped = pkgs.symlinkJoin {
inherit (python)
python3Wrapped = pkgs.symlinkJoin {
inherit (python3)
name
pname
version
meta
;
paths = [ python ];
paths = [ python3 ];
nativeBuildInputs = (with pkgs; [ makeWrapper ]) ++ (with qt6Pkgs.qt6; [ wrapQtAppsHook ]);
buildInputs = with qt6Pkgs.qt6; [ qtbase ];
nativeBuildInputs = with pkgs; [
makeWrapper
qt6.wrapQtAppsHook
# Should be unnecessary once PR is pulled.
# PR: https://github.com/NixOS/nixpkgs/pull/271037
# Issue: https://github.com/NixOS/nixpkgs/issues/149812
wrapGAppsHook
];
buildInputs = with pkgs.qt6; [
qtbase
qtmultimedia
];
postBuild = ''
wrapProgram $out/bin/python3.12 \
wrapProgram $out/bin/${python3.meta.mainProgram} \
--prefix ${libraryPath} : ${pythonLibraryPath} \
"''${gappsWrapperArgs[@]}" \
"''${qtWrapperArgs[@]}"
'';
dontWrapGApps = true;
dontWrapQtApps = true;
};
in
pkgs.mkShellNoCC {
@@ -63,7 +76,13 @@ pkgs.mkShellNoCC {
ruff
];
buildInputs = [ pythonWrapped ] ++ (with pkgs; [ ffmpeg-headless ]);
buildInputs = [
python3Wrapped
]
++ (with pkgs; [
ffmpeg-headless
ripgrep
]);
env = {
QT_QPA_PLATFORM = "wayland;xcb";
@@ -74,11 +93,16 @@ pkgs.mkShellNoCC {
shellHook =
let
python = lib.getExe pythonWrapped;
python = lib.getExe python3Wrapped;
# PySide/Qt are very particular about matching versions. Override with nixpkgs package.
pythonPath = lib.makeSearchPathOutput "lib" python3.sitePackages (
with python3.pkgs; [ pyside6 ] ++ pyside6.propagatedBuildInputs or [ ]
);
in
# bash
''
venv="''${UV_PROJECT_ENVIRONMENT:-.venv}"
venv=''${UV_PROJECT_ENVIRONMENT:-.venv}
if [ ! -f "''${venv}"/bin/activate ] || [ "$(readlink -f "''${venv}"/bin/python)" != "$(readlink -f ${python})" ]; then
printf '%s\n' 'Regenerating virtual environment, Python interpreter changed...' >&2
@@ -87,6 +111,7 @@ pkgs.mkShellNoCC {
fi
source "''${venv}"/bin/activate
PYTHONPATH=${pythonPath}''${PYTHONPATH:+:}''${PYTHONPATH:-}
if [ ! -f "''${venv}"/pyproject.toml ] || ! diff --brief pyproject.toml "''${venv}"/pyproject.toml >/dev/null; then
printf '%s\n' 'Installing dependencies, pyproject.toml changed...' >&2

View File

@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
[project]
name = "TagStudio"
description = "A User-Focused Photo & File Management System."
version = "9.5.3"
version = "9.5.4"
license = "GPL-3.0-only"
readme = "README.md"
requires-python = ">=3.12,<3.13"
@@ -16,7 +16,8 @@ dependencies = [
"mutagen~=1.47",
"numpy~=2.2",
"opencv_python~=4.11",
"Pillow>=10.2,<=12.0",
"Pillow>=10.2,<=11",
"pillow-avif-plugin~=1.5",
"pillow-heif~=0.22",
"pillow-jxl-plugin~=1.3",
"pydantic~=2.10",
@@ -30,6 +31,7 @@ dependencies = [
"toml~=0.10",
"typing_extensions~=4.13",
"ujson~=5.10",
"wcmatch==10.*",
]
[project.optional-dependencies]
@@ -83,13 +85,17 @@ ignore_errors = true
qt_api = "pyside6"
[tool.pyright]
ignore = [".venv/**"]
ignore = [
".venv/**",
"src/tagstudio/core/library/json/",
"src/tagstudio/qt/helpers/vendored/pydub/",
]
include = ["src/tagstudio", "tests"]
extraPaths = ["src/tagstudio", "tests"]
reportAny = false
reportIgnoreCommentWithoutRule = false
reportImplicitStringConcatenation = false
reportMissingTypeArgument = false
reportMissingTypeStubs = false
# reportOptionalMemberAccess = false
reportUnannotatedClassAttribute = false
reportUnknownArgumentType = false

View File

@@ -2,13 +2,14 @@
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
VERSION: str = "9.5.3" # Major.Minor.Patch
VERSION: str = "9.5.4" # Major.Minor.Patch
VERSION_BRANCH: str = "" # Usually "" or "Pre-Release"
# The folder & file names where TagStudio keeps its data relative to a library.
TS_FOLDER_NAME: str = ".TagStudio"
BACKUP_FOLDER_NAME: str = "backups"
COLLAGE_FOLDER_NAME: str = "collages"
IGNORE_NAME: str = ".ts_ignore"
THUMB_CACHE_NAME: str = "thumbs"
FONT_SAMPLE_TEXT: str = (

View File

@@ -12,7 +12,6 @@ class SettingItems(str, enum.Enum):
LAST_LIBRARY = "last_library"
LIBS_LIST = "libs_list"
THUMB_CACHE_SIZE_LIMIT = "thumb_cache_size_limit"
class ShowFilepathOption(int, enum.Enum):
@@ -79,9 +78,9 @@ class DefaultEnum(enum.Enum):
raise AttributeError("access the value via .default property instead")
# TODO: Remove DefaultEnum and LibraryPrefs classes once remaining values are removed.
class LibraryPrefs(DefaultEnum):
"""Library preferences with default value accessible via .default property."""
IS_EXCLUDE_LIST = True
EXTENSION_LIST = [".json", ".xmp", ".aae"]
DB_VERSION = 9

View File

@@ -3,7 +3,7 @@
import platform
from datetime import datetime
from enum import Enum
from enum import Enum, IntEnum, StrEnum
from pathlib import Path
from typing import override
@@ -13,44 +13,58 @@ from pydantic import BaseModel, Field
from tagstudio.core.enums import ShowFilepathOption, TagClickActionOption
if platform.system() == "Windows":
DEFAULT_GLOBAL_SETTINGS_PATH = (
Path.home() / "Appdata" / "Roaming" / "TagStudio" / "settings.toml"
)
else:
DEFAULT_GLOBAL_SETTINGS_PATH = Path.home() / ".config" / "TagStudio" / "settings.toml"
logger = structlog.get_logger(__name__)
DEFAULT_GLOBAL_SETTINGS_PATH = (
Path.home() / "Appdata" / "Roaming" / "TagStudio" / "settings.toml"
if platform.system() == "Windows"
else Path.home() / ".config" / "TagStudio" / "settings.toml"
)
class TomlEnumEncoder(toml.TomlEncoder):
@override
def dump_value(self, v):
if isinstance(v, Enum):
return super().dump_value(v.value)
return super().dump_value(v)
DEFAULT_THUMB_CACHE_SIZE = 500 # Number in MiB
MIN_THUMB_CACHE_SIZE = 10 # Number in MiB
class Theme(Enum):
class Theme(IntEnum):
DARK = 0
LIGHT = 1
SYSTEM = 2
DEFAULT = SYSTEM
class Splash(StrEnum):
DEFAULT = "default"
RANDOM = "random"
CLASSIC = "classic"
GOO_GEARS = "goo_gears"
NINETY_FIVE = "95"
class TomlEnumEncoder(toml.TomlEncoder):
@override
def dump_value(self, v): # pyright: ignore[reportMissingParameterType]
if isinstance(v, Enum):
return super().dump_value(v.value)
return super().dump_value(v)
# NOTE: pydantic also has a BaseSettings class (from pydantic-settings) that allows any settings
# properties to be overwritten with environment variables. as tagstudio is not currently using
# environment variables, i did not base it on that, but that may be useful in the future.
# properties to be overwritten with environment variables. As TagStudio is not currently using
# environment variables, this was not based on that, but that may be useful in the future.
class GlobalSettings(BaseModel):
language: str = Field(default="en")
open_last_loaded_on_startup: bool = Field(default=True)
generate_thumbs: bool = Field(default=True)
thumb_cache_size: float = Field(default=DEFAULT_THUMB_CACHE_SIZE)
autoplay: bool = Field(default=True)
loop: bool = Field(default=True)
show_filenames_in_grid: bool = Field(default=True)
page_size: int = Field(default=100)
show_filepath: ShowFilepathOption = Field(default=ShowFilepathOption.DEFAULT)
theme: Theme = Field(default=Theme.SYSTEM)
tag_click_action: TagClickActionOption = Field(default=TagClickActionOption.DEFAULT)
theme: Theme = Field(default=Theme.SYSTEM)
splash: Splash = Field(default=Splash.DEFAULT)
windows_start_command: bool = Field(default=False)
date_format: str = Field(default="%x")
hour_format: bool = Field(default=True)

View File

@@ -0,0 +1,36 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from sqlalchemy import text
SQL_FILENAME: str = "ts_library.sqlite"
JSON_FILENAME: str = "ts_library.json"
DB_VERSION_LEGACY_KEY: str = "DB_VERSION"
DB_VERSION_CURRENT_KEY: str = "CURRENT"
DB_VERSION_INITIAL_KEY: str = "INITIAL"
DB_VERSION: int = 101
TAG_CHILDREN_QUERY = text("""
WITH RECURSIVE ChildTags AS (
SELECT :tag_id AS tag_id
UNION
SELECT tp.child_id AS tag_id
FROM tag_parents tp
INNER JOIN ChildTags c ON tp.parent_id = c.tag_id
)
SELECT * FROM ChildTags;
""")
TAG_CHILDREN_ID_QUERY = text("""
WITH RECURSIVE ChildTags AS (
SELECT :tag_id AS tag_id
UNION
SELECT tp.child_id AS tag_id
FROM tag_parents tp
INNER JOIN ChildTags c ON tp.parent_id = c.tag_id
)
SELECT tag_id FROM ChildTags;
""")

View File

@@ -4,6 +4,7 @@
from pathlib import Path
from typing import override
import structlog
from sqlalchemy import Dialect, Engine, String, TypeDecorator, create_engine, text
@@ -19,12 +20,14 @@ class PathType(TypeDecorator):
impl = String
cache_ok = True
def process_bind_param(self, value: Path, dialect: Dialect):
@override
def process_bind_param(self, value: Path | None, dialect: Dialect):
if value is not None:
return Path(value).as_posix()
return None
def process_result_value(self, value: str, dialect: Dialect):
@override
def process_result_value(self, value: str | None, dialect: Dialect):
if value is not None:
return Path(value)
return None

View File

@@ -1,572 +0,0 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import structlog
from tagstudio.core.library.alchemy.models import Namespace, TagColorGroup
logger = structlog.get_logger(__name__)
def namespaces() -> list[Namespace]:
tagstudio_standard = Namespace("tagstudio-standard", "TagStudio Standard")
tagstudio_pastels = Namespace("tagstudio-pastels", "TagStudio Pastels")
tagstudio_shades = Namespace("tagstudio-shades", "TagStudio Shades")
tagstudio_earth_tones = Namespace("tagstudio-earth-tones", "TagStudio Earth Tones")
tagstudio_grayscale = Namespace("tagstudio-grayscale", "TagStudio Grayscale")
tagstudio_neon = Namespace("tagstudio-neon", "TagStudio Neon")
return [
tagstudio_standard,
tagstudio_pastels,
tagstudio_shades,
tagstudio_earth_tones,
tagstudio_grayscale,
tagstudio_neon,
]
def json_to_sql_color(json_color: str) -> tuple[str | None, str | None]:
"""Convert a color string from a <=9.4 JSON library to a 9.5+ (namespace, slug) tuple."""
json_color_ = json_color.lower()
match json_color_:
case "black":
return ("tagstudio-grayscale", "black")
case "dark gray":
return ("tagstudio-grayscale", "dark-gray")
case "gray":
return ("tagstudio-grayscale", "gray")
case "light gray":
return ("tagstudio-grayscale", "light-gray")
case "white":
return ("tagstudio-grayscale", "white")
case "light pink":
return ("tagstudio-pastels", "light-pink")
case "pink":
return ("tagstudio-standard", "pink")
case "magenta":
return ("tagstudio-standard", "magenta")
case "red":
return ("tagstudio-standard", "red")
case "red orange":
return ("tagstudio-standard", "red-orange")
case "salmon":
return ("tagstudio-pastels", "salmon")
case "orange":
return ("tagstudio-standard", "orange")
case "yellow orange":
return ("tagstudio-standard", "amber")
case "yellow":
return ("tagstudio-standard", "yellow")
case "mint":
return ("tagstudio-pastels", "mint")
case "lime":
return ("tagstudio-standard", "lime")
case "light green":
return ("tagstudio-pastels", "light-green")
case "green":
return ("tagstudio-standard", "green")
case "teal":
return ("tagstudio-standard", "teal")
case "cyan":
return ("tagstudio-standard", "cyan")
case "light blue":
return ("tagstudio-pastels", "light-blue")
case "blue":
return ("tagstudio-standard", "blue")
case "blue violet":
return ("tagstudio-shades", "navy")
case "violet":
return ("tagstudio-standard", "indigo")
case "purple":
return ("tagstudio-standard", "purple")
case "peach":
return ("tagstudio-earth-tones", "peach")
case "brown":
return ("tagstudio-earth-tones", "brown")
case "lavender":
return ("tagstudio-pastels", "lavender")
case "blonde":
return ("tagstudio-earth-tones", "blonde")
case "auburn":
return ("tagstudio-shades", "auburn")
case "light brown":
return ("tagstudio-earth-tones", "light-brown")
case "dark brown":
return ("tagstudio-earth-tones", "dark-brown")
case "cool gray":
return ("tagstudio-earth-tones", "cool-gray")
case "warm gray":
return ("tagstudio-earth-tones", "warm-gray")
case "olive":
return ("tagstudio-shades", "olive")
case "berry":
return ("tagstudio-shades", "berry")
case _:
return (None, None)
def standard() -> list[TagColorGroup]:
red = TagColorGroup(
slug="red",
namespace="tagstudio-standard",
name="Red",
primary="#E22C3C",
)
red_orange = TagColorGroup(
slug="red-orange",
namespace="tagstudio-standard",
name="Red Orange",
primary="#E83726",
)
orange = TagColorGroup(
slug="orange",
namespace="tagstudio-standard",
name="Orange",
primary="#ED6022",
)
amber = TagColorGroup(
slug="amber",
namespace="tagstudio-standard",
name="Amber",
primary="#FA9A2C",
)
yellow = TagColorGroup(
slug="yellow",
namespace="tagstudio-standard",
name="Yellow",
primary="#FFD63D",
)
lime = TagColorGroup(
slug="lime",
namespace="tagstudio-standard",
name="Lime",
primary="#92E649",
)
green = TagColorGroup(
slug="green",
namespace="tagstudio-standard",
name="Green",
primary="#45D649",
)
teal = TagColorGroup(
slug="teal",
namespace="tagstudio-standard",
name="Teal",
primary="#22D589",
)
cyan = TagColorGroup(
slug="cyan",
namespace="tagstudio-standard",
name="Cyan",
primary="#3DDBDB",
)
blue = TagColorGroup(
slug="blue",
namespace="tagstudio-standard",
name="Blue",
primary="#3B87F0",
)
indigo = TagColorGroup(
slug="indigo",
namespace="tagstudio-standard",
name="Indigo",
primary="#874FF5",
)
purple = TagColorGroup(
slug="purple",
namespace="tagstudio-standard",
name="Purple",
primary="#BB4FF0",
)
magenta = TagColorGroup(
slug="magenta",
namespace="tagstudio-standard",
name="Magenta",
primary="#F64680",
)
pink = TagColorGroup(
slug="pink",
namespace="tagstudio-standard",
name="Pink",
primary="#FF62AF",
)
return [
red,
red_orange,
orange,
amber,
yellow,
lime,
green,
teal,
cyan,
blue,
indigo,
purple,
pink,
magenta,
]
def pastels() -> list[TagColorGroup]:
coral = TagColorGroup(
slug="coral",
namespace="tagstudio-pastels",
name="Coral",
primary="#F2525F",
)
salmon = TagColorGroup(
slug="salmon",
namespace="tagstudio-pastels",
name="Salmon",
primary="#F66348",
)
light_orange = TagColorGroup(
slug="light-orange",
namespace="tagstudio-pastels",
name="Light Orange",
primary="#FF9450",
)
light_amber = TagColorGroup(
slug="light-amber",
namespace="tagstudio-pastels",
name="Light Amber",
primary="#FFBA57",
)
light_yellow = TagColorGroup(
slug="light-yellow",
namespace="tagstudio-pastels",
name="Light Yellow",
primary="#FFE173",
)
light_lime = TagColorGroup(
slug="light-lime",
namespace="tagstudio-pastels",
name="Light Lime",
primary="#C9FF7A",
)
light_green = TagColorGroup(
slug="light-green",
namespace="tagstudio-pastels",
name="Light Green",
primary="#81FF76",
)
mint = TagColorGroup(
slug="mint",
namespace="tagstudio-pastels",
name="Mint",
primary="#68FFB4",
)
sky_blue = TagColorGroup(
slug="sky-blue",
namespace="tagstudio-pastels",
name="Sky Blue",
primary="#8EFFF4",
)
light_blue = TagColorGroup(
slug="light-blue",
namespace="tagstudio-pastels",
name="Light Blue",
primary="#64C6FF",
)
lavender = TagColorGroup(
slug="lavender",
namespace="tagstudio-pastels",
name="Lavender",
primary="#908AF6",
)
lilac = TagColorGroup(
slug="lilac",
namespace="tagstudio-pastels",
name="Lilac",
primary="#DF95FF",
)
light_pink = TagColorGroup(
slug="light-pink",
namespace="tagstudio-pastels",
name="Light Pink",
primary="#FF87BA",
)
return [
coral,
salmon,
light_orange,
light_amber,
light_yellow,
light_lime,
light_green,
mint,
sky_blue,
light_blue,
lavender,
lilac,
light_pink,
]
def shades() -> list[TagColorGroup]:
burgundy = TagColorGroup(
slug="burgundy",
namespace="tagstudio-shades",
name="Burgundy",
primary="#6E1C24",
)
auburn = TagColorGroup(
slug="auburn",
namespace="tagstudio-shades",
name="Auburn",
primary="#A13220",
)
olive = TagColorGroup(
slug="olive",
namespace="tagstudio-shades",
name="Olive",
primary="#4C652E",
)
dark_teal = TagColorGroup(
slug="dark-teal",
namespace="tagstudio-shades",
name="Dark Teal",
primary="#1F5E47",
)
navy = TagColorGroup(
slug="navy",
namespace="tagstudio-shades",
name="Navy",
primary="#104B98",
)
dark_lavender = TagColorGroup(
slug="dark_lavender",
namespace="tagstudio-shades",
name="Dark Lavender",
primary="#3D3B6C",
)
berry = TagColorGroup(
slug="berry",
namespace="tagstudio-shades",
name="Berry",
primary="#9F2AA7",
)
return [burgundy, auburn, olive, dark_teal, navy, dark_lavender, berry]
def earth_tones() -> list[TagColorGroup]:
dark_brown = TagColorGroup(
slug="dark-brown",
namespace="tagstudio-earth-tones",
name="Dark Brown",
primary="#4C2315",
)
brown = TagColorGroup(
slug="brown",
namespace="tagstudio-earth-tones",
name="Brown",
primary="#823216",
)
light_brown = TagColorGroup(
slug="light-brown",
namespace="tagstudio-earth-tones",
name="Light Brown",
primary="#BE5B2D",
)
blonde = TagColorGroup(
slug="blonde",
namespace="tagstudio-earth-tones",
name="Blonde",
primary="#EFC664",
)
peach = TagColorGroup(
slug="peach",
namespace="tagstudio-earth-tones",
name="Peach",
primary="#F1C69C",
)
warm_gray = TagColorGroup(
slug="warm-gray",
namespace="tagstudio-earth-tones",
name="Warm Gray",
primary="#625550",
)
cool_gray = TagColorGroup(
slug="cool-gray",
namespace="tagstudio-earth-tones",
name="Cool Gray",
primary="#515768",
)
return [dark_brown, brown, light_brown, blonde, peach, warm_gray, cool_gray]
def grayscale() -> list[TagColorGroup]:
black = TagColorGroup(
slug="black",
namespace="tagstudio-grayscale",
name="Black",
primary="#111018",
)
dark_gray = TagColorGroup(
slug="dark-gray",
namespace="tagstudio-grayscale",
name="Dark Gray",
primary="#242424",
)
gray = TagColorGroup(
slug="gray",
namespace="tagstudio-grayscale",
name="Gray",
primary="#53525A",
)
light_gray = TagColorGroup(
slug="light-gray",
namespace="tagstudio-grayscale",
name="Light Gray",
primary="#AAAAAA",
)
white = TagColorGroup(
slug="white",
namespace="tagstudio-grayscale",
name="White",
primary="#F2F1F8",
)
return [black, dark_gray, gray, light_gray, white]
def neon() -> list[TagColorGroup]:
neon_red = TagColorGroup(
slug="neon-red",
namespace="tagstudio-neon",
name="Neon Red",
primary="#180607",
secondary="#E22C3C",
color_border=True,
)
neon_red_orange = TagColorGroup(
slug="neon-red-orange",
namespace="tagstudio-neon",
name="Neon Red Orange",
primary="#220905",
secondary="#E83726",
color_border=True,
)
neon_orange = TagColorGroup(
slug="neon-orange",
namespace="tagstudio-neon",
name="Neon Orange",
primary="#1F0D05",
secondary="#ED6022",
color_border=True,
)
neon_amber = TagColorGroup(
slug="neon-amber",
namespace="tagstudio-neon",
name="Neon Amber",
primary="#251507",
secondary="#FA9A2C",
color_border=True,
)
neon_yellow = TagColorGroup(
slug="neon-yellow",
namespace="tagstudio-neon",
name="Neon Yellow",
primary="#2B1C0B",
secondary="#FFD63D",
color_border=True,
)
neon_lime = TagColorGroup(
slug="neon-lime",
namespace="tagstudio-neon",
name="Neon Lime",
primary="#1B220C",
secondary="#92E649",
color_border=True,
)
neon_green = TagColorGroup(
slug="neon-green",
namespace="tagstudio-neon",
name="Neon Green",
primary="#091610",
secondary="#45D649",
color_border=True,
)
neon_teal = TagColorGroup(
slug="neon-teal",
namespace="tagstudio-neon",
name="Neon Teal",
primary="#09191D",
secondary="#22D589",
color_border=True,
)
neon_cyan = TagColorGroup(
slug="neon-cyan",
namespace="tagstudio-neon",
name="Neon Cyan",
primary="#0B191C",
secondary="#3DDBDB",
color_border=True,
)
neon_blue = TagColorGroup(
slug="neon-blue",
namespace="tagstudio-neon",
name="Neon Blue",
primary="#09101C",
secondary="#3B87F0",
color_border=True,
)
neon_indigo = TagColorGroup(
slug="neon-indigo",
namespace="tagstudio-neon",
name="Neon Indigo",
primary="#150B24",
secondary="#874FF5",
color_border=True,
)
neon_purple = TagColorGroup(
slug="neon-purple",
namespace="tagstudio-neon",
name="Neon Purple",
primary="#1E0B26",
secondary="#BB4FF0",
color_border=True,
)
neon_magenta = TagColorGroup(
slug="neon-magenta",
namespace="tagstudio-neon",
name="Neon Magenta",
primary="#220A13",
secondary="#F64680",
color_border=True,
)
neon_pink = TagColorGroup(
slug="neon-pink",
namespace="tagstudio-neon",
name="Neon Pink",
primary="#210E15",
secondary="#FF62AF",
color_border=True,
)
neon_white = TagColorGroup(
slug="neon-white",
namespace="tagstudio-neon",
name="Neon White",
primary="#131315",
secondary="#F2F1F8",
color_border=True,
)
return [
neon_red,
neon_red_orange,
neon_orange,
neon_amber,
neon_yellow,
neon_lime,
neon_green,
neon_teal,
neon_cyan,
neon_blue,
neon_indigo,
neon_purple,
neon_pink,
neon_magenta,
neon_white,
]

View File

@@ -1,4 +1,5 @@
import enum
import random
from dataclasses import dataclass, replace
from pathlib import Path
@@ -69,6 +70,7 @@ class SortingModeEnum(enum.Enum):
DATE_ADDED = "file.date_added"
FILE_NAME = "generic.filename"
PATH = "file.path"
RANDOM = "sorting.mode.random"
@dataclass
@@ -78,6 +80,7 @@ class BrowsingState:
page_index: int = 0
sorting_mode: SortingModeEnum = SortingModeEnum.DATE_ADDED
ascending: bool = True
random_seed: float = 0
query: str | None = None
@@ -97,7 +100,20 @@ class BrowsingState:
return cls(query=search_query)
@classmethod
def from_tag_id(cls, tag_id: int | str) -> "BrowsingState":
def from_tag_id(
cls, tag_id: int | str, state: "BrowsingState | None" = None
) -> "BrowsingState":
"""Create and return a BrowsingState object given a tag ID.
Args:
tag_id(int): The tag ID to search for.
state(BrowsingState|None): An optional BrowsingState object to use
existing options from, such as sorting options.
"""
logger.warning(state)
if state:
return state.with_search_query(f"tag_id:{str(tag_id)}")
return cls(query=f"tag_id:{str(tag_id)}")
@classmethod
@@ -120,7 +136,10 @@ class BrowsingState:
return replace(self, page_index=index)
def with_sorting_mode(self, mode: SortingModeEnum) -> "BrowsingState":
return replace(self, sorting_mode=mode)
seed = self.random_seed
if mode == SortingModeEnum.RANDOM:
seed = random.random()
return replace(self, sorting_mode=mode, random_seed=seed)
def with_sorting_direction(self, ascending: bool) -> "BrowsingState":
return replace(self, ascending=ascending)

View File

@@ -1,140 +0,0 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from __future__ import annotations
from dataclasses import dataclass, field
from enum import Enum
from typing import TYPE_CHECKING, Any
from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship
from tagstudio.core.library.alchemy.db import Base
from tagstudio.core.library.alchemy.enums import FieldTypeEnum
if TYPE_CHECKING:
from tagstudio.core.library.alchemy.models import Entry, ValueType
class BaseField(Base):
__abstract__ = True
@declared_attr
def id(self) -> Mapped[int]:
return mapped_column(primary_key=True, autoincrement=True)
@declared_attr
def type_key(self) -> Mapped[str]:
return mapped_column(ForeignKey("value_type.key"))
@declared_attr
def type(self) -> Mapped[ValueType]:
return relationship(foreign_keys=[self.type_key], lazy=False) # type: ignore
@declared_attr
def entry_id(self) -> Mapped[int]:
return mapped_column(ForeignKey("entries.id"))
@declared_attr
def entry(self) -> Mapped[Entry]:
return relationship(foreign_keys=[self.entry_id]) # type: ignore
@declared_attr
def position(self) -> Mapped[int]:
return mapped_column(default=0)
def __hash__(self):
return hash(self.__key())
def __key(self):
raise NotImplementedError
value: Any
class BooleanField(BaseField):
__tablename__ = "boolean_fields"
value: Mapped[bool]
def __key(self):
return (self.type, self.value)
def __eq__(self, value) -> bool:
if isinstance(value, BooleanField):
return self.__key() == value.__key()
raise NotImplementedError
class TextField(BaseField):
__tablename__ = "text_fields"
value: Mapped[str | None]
def __key(self) -> tuple:
return self.type, self.value
def __eq__(self, value) -> bool:
if isinstance(value, TextField):
return self.__key() == value.__key()
elif isinstance(value, DatetimeField):
return False
raise NotImplementedError
class DatetimeField(BaseField):
__tablename__ = "datetime_fields"
value: Mapped[str | None]
def __key(self):
return (self.type, self.value)
def __eq__(self, value) -> bool:
if isinstance(value, DatetimeField):
return self.__key() == value.__key()
raise NotImplementedError
@dataclass
class DefaultField:
id: int
name: str
type: FieldTypeEnum
is_default: bool = field(default=False)
class _FieldID(Enum):
"""Only for bootstrapping content of DB table."""
TITLE = DefaultField(id=0, name="Title", type=FieldTypeEnum.TEXT_LINE, is_default=True)
AUTHOR = DefaultField(id=1, name="Author", type=FieldTypeEnum.TEXT_LINE)
ARTIST = DefaultField(id=2, name="Artist", type=FieldTypeEnum.TEXT_LINE)
URL = DefaultField(id=3, name="URL", type=FieldTypeEnum.TEXT_LINE)
DESCRIPTION = DefaultField(id=4, name="Description", type=FieldTypeEnum.TEXT_BOX)
NOTES = DefaultField(id=5, name="Notes", type=FieldTypeEnum.TEXT_BOX)
COLLATION = DefaultField(id=9, name="Collation", type=FieldTypeEnum.TEXT_LINE)
DATE = DefaultField(id=10, name="Date", type=FieldTypeEnum.DATETIME)
DATE_CREATED = DefaultField(id=11, name="Date Created", type=FieldTypeEnum.DATETIME)
DATE_MODIFIED = DefaultField(id=12, name="Date Modified", type=FieldTypeEnum.DATETIME)
DATE_TAKEN = DefaultField(id=13, name="Date Taken", type=FieldTypeEnum.DATETIME)
DATE_PUBLISHED = DefaultField(id=14, name="Date Published", type=FieldTypeEnum.DATETIME)
# ARCHIVED = DefaultField(id=15, name="Archived", type=CheckboxField.checkbox)
# FAVORITE = DefaultField(id=16, name="Favorite", type=CheckboxField.checkbox)
BOOK = DefaultField(id=17, name="Book", type=FieldTypeEnum.TEXT_LINE)
COMIC = DefaultField(id=18, name="Comic", type=FieldTypeEnum.TEXT_LINE)
SERIES = DefaultField(id=19, name="Series", type=FieldTypeEnum.TEXT_LINE)
MANGA = DefaultField(id=20, name="Manga", type=FieldTypeEnum.TEXT_LINE)
SOURCE = DefaultField(id=21, name="Source", type=FieldTypeEnum.TEXT_LINE)
DATE_UPLOADED = DefaultField(id=22, name="Date Uploaded", type=FieldTypeEnum.DATETIME)
DATE_RELEASED = DefaultField(id=23, name="Date Released", type=FieldTypeEnum.DATETIME)
VOLUME = DefaultField(id=24, name="Volume", type=FieldTypeEnum.TEXT_LINE)
ANTHOLOGY = DefaultField(id=25, name="Anthology", type=FieldTypeEnum.TEXT_LINE)
MAGAZINE = DefaultField(id=26, name="Magazine", type=FieldTypeEnum.TEXT_LINE)
PUBLISHER = DefaultField(id=27, name="Publisher", type=FieldTypeEnum.TEXT_LINE)
GUEST_ARTIST = DefaultField(id=28, name="Guest Artist", type=FieldTypeEnum.TEXT_LINE)
COMPOSER = DefaultField(id=29, name="Composer", type=FieldTypeEnum.TEXT_LINE)
COMMENTS = DefaultField(id=30, name="Comments", type=FieldTypeEnum.TEXT_LINE)

View File

@@ -1,23 +0,0 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped, mapped_column
from tagstudio.core.library.alchemy.db import Base
class TagParent(Base):
__tablename__ = "tag_parents"
parent_id: Mapped[int] = mapped_column(ForeignKey("tags.id"), primary_key=True)
child_id: Mapped[int] = mapped_column(ForeignKey("tags.id"), primary_key=True)
class TagEntry(Base):
__tablename__ = "tag_entries"
tag_id: Mapped[int] = mapped_column(ForeignKey("tags.id"), primary_key=True)
entry_id: Mapped[int] = mapped_column(ForeignKey("entries.id"), primary_key=True)

File diff suppressed because it is too large Load Diff

View File

@@ -1,318 +0,0 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from datetime import datetime as dt
from pathlib import Path
from sqlalchemy import JSON, ForeignKey, ForeignKeyConstraint, Integer, event
from sqlalchemy.orm import Mapped, mapped_column, relationship
from tagstudio.core.constants import TAG_ARCHIVED, TAG_FAVORITE
from tagstudio.core.library.alchemy.db import Base, PathType
from tagstudio.core.library.alchemy.enums import FieldTypeEnum
from tagstudio.core.library.alchemy.fields import (
BaseField,
BooleanField,
DatetimeField,
TextField,
)
from tagstudio.core.library.alchemy.joins import TagParent
class Namespace(Base):
__tablename__ = "namespaces"
namespace: Mapped[str] = mapped_column(primary_key=True, nullable=False)
name: Mapped[str] = mapped_column(nullable=False)
def __init__(
self,
namespace: str,
name: str,
):
self.namespace = namespace
self.name = name
super().__init__()
class TagAlias(Base):
__tablename__ = "tag_aliases"
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(nullable=False)
tag_id: Mapped[int] = mapped_column(ForeignKey("tags.id"))
tag: Mapped["Tag"] = relationship(back_populates="aliases")
def __init__(self, name: str, tag_id: int | None = None):
self.name = name
if tag_id is not None:
self.tag_id = tag_id
super().__init__()
class TagColorGroup(Base):
__tablename__ = "tag_colors"
slug: Mapped[str] = mapped_column(primary_key=True, nullable=False)
namespace: Mapped[str] = mapped_column(
ForeignKey("namespaces.namespace"), primary_key=True, nullable=False
)
name: Mapped[str] = mapped_column()
primary: Mapped[str] = mapped_column(nullable=False)
secondary: Mapped[str | None]
color_border: Mapped[bool] = mapped_column(nullable=False, default=False)
# TODO: Determine if slug and namespace can be optional and generated/added here if needed.
def __init__(
self,
slug: str,
namespace: str,
name: str,
primary: str,
secondary: str | None = None,
color_border: bool = False,
):
self.slug = slug
self.namespace = namespace
self.name = name
self.primary = primary
if secondary:
self.secondary = secondary
self.color_border = color_border
super().__init__()
class Tag(Base):
__tablename__ = "tags"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
name: Mapped[str]
shorthand: Mapped[str | None]
color_namespace: Mapped[str | None] = mapped_column()
color_slug: Mapped[str | None] = mapped_column()
color: Mapped[TagColorGroup | None] = relationship(lazy="joined")
is_category: Mapped[bool]
icon: Mapped[str | None]
aliases: Mapped[set[TagAlias]] = relationship(back_populates="tag")
parent_tags: Mapped[set["Tag"]] = relationship(
secondary=TagParent.__tablename__,
primaryjoin="Tag.id == TagParent.parent_id",
secondaryjoin="Tag.id == TagParent.child_id",
back_populates="parent_tags",
)
disambiguation_id: Mapped[int | None]
__table_args__ = (
ForeignKeyConstraint(
[color_namespace, color_slug], [TagColorGroup.namespace, TagColorGroup.slug]
),
{"sqlite_autoincrement": True},
)
@property
def parent_ids(self) -> list[int]:
return [tag.id for tag in self.parent_tags]
@property
def alias_strings(self) -> list[str]:
return [alias.name for alias in self.aliases]
@property
def alias_ids(self) -> list[int]:
return [tag.id for tag in self.aliases]
def __init__(
self,
id: int | None = None,
name: str | None = None,
shorthand: str | None = None,
aliases: set[TagAlias] | None = None,
parent_tags: set["Tag"] | None = None,
icon: str | None = None,
color_namespace: str | None = None,
color_slug: str | None = None,
disambiguation_id: int | None = None,
is_category: bool = False,
):
self.name = name
self.aliases = aliases or set()
self.parent_tags = parent_tags or set()
self.color_namespace = color_namespace
self.color_slug = color_slug
self.icon = icon
self.shorthand = shorthand
self.disambiguation_id = disambiguation_id
self.is_category = is_category
assert not self.id
self.id = id
super().__init__()
def __str__(self) -> str:
return f"<Tag ID: {self.id} Name: {self.name}>"
def __repr__(self) -> str:
return self.__str__()
def __lt__(self, other) -> bool:
return self.name < other.name
def __le__(self, other) -> bool:
return self.name <= other.name
def __gt__(self, other) -> bool:
return self.name > other.name
def __ge__(self, other) -> bool:
return self.name >= other.name
class Folder(Base):
__tablename__ = "folders"
# TODO - implement this
id: Mapped[int] = mapped_column(primary_key=True)
path: Mapped[Path] = mapped_column(PathType, unique=True)
uuid: Mapped[str] = mapped_column(unique=True)
class Entry(Base):
__tablename__ = "entries"
id: Mapped[int] = mapped_column(primary_key=True)
folder_id: Mapped[int] = mapped_column(ForeignKey("folders.id"))
folder: Mapped[Folder] = relationship("Folder")
path: Mapped[Path] = mapped_column(PathType, unique=True)
filename: Mapped[str] = mapped_column()
suffix: Mapped[str] = mapped_column()
date_created: Mapped[dt | None]
date_modified: Mapped[dt | None]
date_added: Mapped[dt | None]
tags: Mapped[set[Tag]] = relationship(secondary="tag_entries")
text_fields: Mapped[list[TextField]] = relationship(
back_populates="entry",
cascade="all, delete",
)
datetime_fields: Mapped[list[DatetimeField]] = relationship(
back_populates="entry",
cascade="all, delete",
)
@property
def fields(self) -> list[BaseField]:
fields: list[BaseField] = []
fields.extend(self.text_fields)
fields.extend(self.datetime_fields)
fields = sorted(fields, key=lambda field: field.type.position)
return fields
@property
def is_favorite(self) -> bool:
return any(tag.id == TAG_FAVORITE for tag in self.tags)
@property
def is_archived(self) -> bool:
return any(tag.id == TAG_ARCHIVED for tag in self.tags)
def __init__(
self,
path: Path,
folder: Folder,
fields: list[BaseField],
id: int | None = None,
date_created: dt | None = None,
date_modified: dt | None = None,
date_added: dt | None = None,
) -> None:
self.path = path
self.folder = folder
self.id = id
self.filename = path.name
self.suffix = path.suffix.lstrip(".").lower()
# The date the file associated with this entry was created.
# st_birthtime on Windows and Mac, st_ctime on Linux.
self.date_created = date_created
# The date the file associated with this entry was last modified: st_mtime.
self.date_modified = date_modified
# The date this entry was added to the library.
self.date_added = date_added
for field in fields:
if isinstance(field, TextField):
self.text_fields.append(field)
elif isinstance(field, DatetimeField):
self.datetime_fields.append(field)
else:
raise ValueError(f"Invalid field type: {field}")
def has_tag(self, tag: Tag) -> bool:
return tag in self.tags
def remove_tag(self, tag: Tag) -> None:
"""Removes a Tag from the Entry."""
self.tags.remove(tag)
class ValueType(Base):
"""Define Field Types in the Library.
Example:
key: content_tags (this field is slugified `name`)
name: Content Tags (this field is human readable name)
kind: type of content (Text Line, Text Box, Tags, Datetime, Checkbox)
is_default: Should the field be present in new Entry?
order: position of the field widget in the Entry form
"""
__tablename__ = "value_type"
key: Mapped[str] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(nullable=False)
type: Mapped[FieldTypeEnum] = mapped_column(default=FieldTypeEnum.TEXT_LINE)
is_default: Mapped[bool]
position: Mapped[int]
# add relations to other tables
text_fields: Mapped[list[TextField]] = relationship("TextField", back_populates="type")
datetime_fields: Mapped[list[DatetimeField]] = relationship(
"DatetimeField", back_populates="type"
)
boolean_fields: Mapped[list[BooleanField]] = relationship("BooleanField", back_populates="type")
@property
def as_field(self) -> BaseField:
FieldClass = { # noqa: N806
FieldTypeEnum.TEXT_LINE: TextField,
FieldTypeEnum.TEXT_BOX: TextField,
FieldTypeEnum.DATETIME: DatetimeField,
FieldTypeEnum.BOOLEAN: BooleanField,
}
return FieldClass[self.type](
type_key=self.key,
position=self.position,
)
@event.listens_for(ValueType, "before_insert")
def slugify_field_key(mapper, connection, target):
"""Slugify the field key before inserting into the database."""
if not target.key:
from tagstudio.core.library.alchemy.library import slugify
target.key = slugify(target.tag)
class Preferences(Base):
__tablename__ = "preferences"
key: Mapped[str] = mapped_column(primary_key=True)
value: Mapped[dict] = mapped_column(JSON, nullable=False)

View File

@@ -1,203 +0,0 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import re
from typing import TYPE_CHECKING
import structlog
from sqlalchemy import ColumnElement, and_, distinct, func, or_, select, text
from sqlalchemy.orm import Session
from sqlalchemy.sql.operators import ilike_op
from tagstudio.core.library.alchemy.joins import TagEntry
from tagstudio.core.library.alchemy.models import Entry, Tag, TagAlias
from tagstudio.core.media_types import FILETYPE_EQUIVALENTS, MediaCategories
from tagstudio.core.query_lang.ast import (
ANDList,
BaseVisitor,
Constraint,
ConstraintType,
Not,
ORList,
Property,
)
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.core.library.alchemy.library import Library
else:
Library = None # don't import library because of circular imports
logger = structlog.get_logger(__name__)
# TODO: Reevaluate after subtags -> parent tags name change
TAG_CHILDREN_ID_QUERY = text("""
-- Note for this entire query that tag_parents.child_id is the parent id and tag_parents.parent_id is the child id due to bad naming
WITH RECURSIVE ChildTags AS (
SELECT :tag_id AS child_id
UNION
SELECT tp.parent_id AS child_id
FROM tag_parents tp
INNER JOIN ChildTags c ON tp.child_id = c.child_id
)
SELECT child_id FROM ChildTags;
""") # noqa: E501
def get_filetype_equivalency_list(item: str) -> list[str] | set[str]:
for s in FILETYPE_EQUIVALENTS:
if item in s:
return s
return [item]
class SQLBoolExpressionBuilder(BaseVisitor[ColumnElement[bool]]):
def __init__(self, lib: Library) -> None:
super().__init__()
self.lib = lib
def visit_or_list(self, node: ORList) -> ColumnElement[bool]:
return or_(*[self.visit(element) for element in node.elements])
def visit_and_list(self, node: ANDList) -> ColumnElement[bool]:
tag_ids: list[int] = []
bool_expressions: list[ColumnElement[bool]] = []
# Search for TagID / unambiguous Tag Constraints and store the respective tag ids separately
for term in node.terms:
if isinstance(term, Constraint) and len(term.properties) == 0:
match term.type:
case ConstraintType.TagID:
try:
tag_ids.append(int(term.value))
except ValueError:
logger.error(
"[SQLBoolExpressionBuilder] Could not cast value to an int Tag ID",
value=term.value,
)
continue
case ConstraintType.Tag:
if len(ids := self.__get_tag_ids(term.value)) == 1:
tag_ids.append(ids[0])
continue
bool_expressions.append(self.visit(term))
# If there are at least two tag ids use a relational division query
# to efficiently check all of them
if len(tag_ids) > 1:
bool_expressions.append(self.__entry_has_all_tags(tag_ids))
# If there is just one tag id, check the normal way
elif len(tag_ids) == 1:
bool_expressions.append(
self.__entry_satisfies_expression(TagEntry.tag_id == tag_ids[0])
)
return and_(*bool_expressions)
def visit_constraint(self, node: Constraint) -> ColumnElement[bool]:
"""Returns a Boolean Expression that is true, if the Entry satisfies the constraint."""
if len(node.properties) != 0:
raise NotImplementedError("Properties are not implemented yet") # TODO TSQLANG
if node.type == ConstraintType.Tag:
return self.__entry_matches_tag_ids(self.__get_tag_ids(node.value))
elif node.type == ConstraintType.TagID:
return self.__entry_matches_tag_ids([int(node.value)])
elif node.type == ConstraintType.Path:
ilike = False
glob = False
# Smartcase check
if node.value == node.value.lower():
ilike = True
if node.value.startswith("*") or node.value.endswith("*"):
glob = True
if ilike and glob:
logger.info("ConstraintType.Path", ilike=True, glob=True)
return func.lower(Entry.path).op("GLOB")(f"{node.value.lower()}")
elif ilike:
logger.info("ConstraintType.Path", ilike=True, glob=False)
return ilike_op(Entry.path, f"%{node.value}%")
elif glob:
logger.info("ConstraintType.Path", ilike=False, glob=True)
return Entry.path.op("GLOB")(node.value)
else:
logger.info(
"ConstraintType.Path", ilike=False, glob=False, re=re.escape(node.value)
)
return Entry.path.regexp_match(re.escape(node.value))
elif node.type == ConstraintType.MediaType:
extensions: set[str] = set[str]()
for media_cat in MediaCategories.ALL_CATEGORIES:
if node.value == media_cat.name:
extensions = extensions | media_cat.extensions
break
return Entry.suffix.in_(map(lambda x: x.replace(".", ""), extensions))
elif node.type == ConstraintType.FileType:
return or_(
*[Entry.suffix.ilike(ft) for ft in get_filetype_equivalency_list(node.value)]
)
elif node.type == ConstraintType.Special: # noqa: SIM102 unnecessary once there is a second special constraint
if node.value.lower() == "untagged":
return ~Entry.id.in_(select(Entry.id).join(TagEntry))
# raise exception if Constraint stays unhandled
raise NotImplementedError("This type of constraint is not implemented yet")
def visit_property(self, node: Property) -> ColumnElement[bool]:
raise NotImplementedError("This should never be reached!")
def visit_not(self, node: Not) -> ColumnElement[bool]:
return ~self.visit(node.child)
def __entry_matches_tag_ids(self, tag_ids: list[int]) -> ColumnElement[bool]:
"""Returns a boolean expression that is true if the entry has at least one of the supplied tags.""" # noqa: E501
return (
select(1)
.correlate(Entry)
.where(and_(TagEntry.entry_id == Entry.id, TagEntry.tag_id.in_(tag_ids)))
.exists()
)
def __get_tag_ids(self, tag_name: str, include_children: bool = True) -> list[int]:
"""Given a tag name find the ids of all tags that this name could refer to."""
with Session(self.lib.engine) as session:
tag_ids = list(
session.scalars(
select(Tag.id)
.where(or_(Tag.name.ilike(tag_name), Tag.shorthand.ilike(tag_name)))
.union(select(TagAlias.tag_id).where(TagAlias.name.ilike(tag_name)))
)
)
if len(tag_ids) > 1:
logger.debug(
f'Tag Constraint "{tag_name}" is ambiguous, {len(tag_ids)} matching tags found',
tag_ids=tag_ids,
include_children=include_children,
)
if not include_children:
return tag_ids
outp = []
for tag_id in tag_ids:
outp.extend(list(session.scalars(TAG_CHILDREN_ID_QUERY, {"tag_id": tag_id})))
return outp
def __entry_has_all_tags(self, tag_ids: list[int]) -> ColumnElement[bool]:
"""Returns Binary Expression that is true if the Entry has all provided tag ids."""
# Relational Division Query
return Entry.id.in_(
select(TagEntry.entry_id)
.where(TagEntry.tag_id.in_(tag_ids))
.group_by(TagEntry.entry_id)
.having(func.count(distinct(TagEntry.tag_id)) == len(tag_ids))
)
def __entry_satisfies_expression(self, expr: ColumnElement[bool]) -> ColumnElement[bool]:
"""Returns Binary Expression that is true if the Entry satisfies the column expression.
Executed on: Entry ⟕ TagEntry (Entry LEFT OUTER JOIN TagEntry).
"""
return Entry.id.in_(select(Entry.id).outerjoin(TagEntry).where(expr))

View File

@@ -0,0 +1,83 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
def json_to_sql_color(json_color: str) -> tuple[str | None, str | None]:
"""Convert a color string from a <=9.4 JSON library to a 9.5+ (namespace, slug) tuple."""
json_color_ = json_color.lower()
match json_color_:
case "black":
return ("tagstudio-grayscale", "black")
case "dark gray":
return ("tagstudio-grayscale", "dark-gray")
case "gray":
return ("tagstudio-grayscale", "gray")
case "light gray":
return ("tagstudio-grayscale", "light-gray")
case "white":
return ("tagstudio-grayscale", "white")
case "light pink":
return ("tagstudio-pastels", "light-pink")
case "pink":
return ("tagstudio-standard", "pink")
case "magenta":
return ("tagstudio-standard", "magenta")
case "red":
return ("tagstudio-standard", "red")
case "red orange":
return ("tagstudio-standard", "red-orange")
case "salmon":
return ("tagstudio-pastels", "salmon")
case "orange":
return ("tagstudio-standard", "orange")
case "yellow orange":
return ("tagstudio-standard", "amber")
case "yellow":
return ("tagstudio-standard", "yellow")
case "mint":
return ("tagstudio-pastels", "mint")
case "lime":
return ("tagstudio-standard", "lime")
case "light green":
return ("tagstudio-pastels", "light-green")
case "green":
return ("tagstudio-standard", "green")
case "teal":
return ("tagstudio-standard", "teal")
case "cyan":
return ("tagstudio-standard", "cyan")
case "light blue":
return ("tagstudio-pastels", "light-blue")
case "blue":
return ("tagstudio-standard", "blue")
case "blue violet":
return ("tagstudio-shades", "navy")
case "violet":
return ("tagstudio-standard", "indigo")
case "purple":
return ("tagstudio-standard", "purple")
case "peach":
return ("tagstudio-earth-tones", "peach")
case "brown":
return ("tagstudio-earth-tones", "brown")
case "lavender":
return ("tagstudio-pastels", "lavender")
case "blonde":
return ("tagstudio-earth-tones", "blonde")
case "auburn":
return ("tagstudio-shades", "auburn")
case "light brown":
return ("tagstudio-earth-tones", "light-brown")
case "dark brown":
return ("tagstudio-earth-tones", "dark-brown")
case "cool gray":
return ("tagstudio-earth-tones", "cool-gray")
case "warm gray":
return ("tagstudio-earth-tones", "warm-gray")
case "olive":
return ("tagstudio-shades", "olive")
case "berry":
return ("tagstudio-shades", "berry")
case _:
return (None, None)

View File

@@ -0,0 +1,200 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from copy import deepcopy
from pathlib import Path
import structlog
import wcmatch.fnmatch as fnmatch
from wcmatch import glob, pathlib
from tagstudio.core.constants import IGNORE_NAME, TS_FOLDER_NAME
from tagstudio.core.singleton import Singleton
logger = structlog.get_logger()
PATH_GLOB_FLAGS = glob.GLOBSTARLONG | glob.DOTGLOB | glob.NEGATE | pathlib.MATCHBASE
GLOBAL_IGNORE = [
# TagStudio -------------------
f"{TS_FOLDER_NAME}",
# Trash -----------------------
".Trash-*",
".Trash",
".Trashes",
"$RECYCLE.BIN",
# System ----------------------
"._*",
".DS_Store",
".fseventsd",
".Spotlight-V100",
".TemporaryItems",
"desktop.ini",
"System Volume Information",
".localized",
]
def ignore_to_glob(ignore_patterns: list[str]) -> list[str]:
"""Convert .gitignore-like patterns to explicit glob syntax.
Args:
ignore_patterns (list[str]): The .gitignore-like patterns to convert.
"""
glob_patterns: list[str] = deepcopy(ignore_patterns)
glob_patterns_remove: list[str] = []
additional_patterns: list[str] = []
root_patterns: list[str] = []
# Mimic implicit .gitignore syntax behavior for the SQLite GLOB function.
for pattern in glob_patterns:
# Temporarily remove any exclusion character before processing
exclusion_char = ""
gp = pattern
if pattern.startswith("!"):
gp = pattern[1:]
exclusion_char = "!"
if not gp.startswith("**/") and not gp.startswith("*/") and not gp.startswith("/"):
# Create a version of a prefix-less pattern that starts with "**/"
gp = "**/" + gp
additional_patterns.append(exclusion_char + gp)
gp = gp.removesuffix("/**").removesuffix("/*").removesuffix("/")
additional_patterns.append(exclusion_char + gp)
gp = gp.removeprefix("**/").removeprefix("*/")
additional_patterns.append(exclusion_char + gp)
elif gp.startswith("/"):
# Matches "/file" case for .gitignore behavior where it should only match
# a file or folder int the root directory, and nowhere else.
glob_patterns_remove.append(gp)
gp = gp.lstrip("/")
root_patterns.append(exclusion_char + gp)
for gp in glob_patterns_remove:
glob_patterns.remove(gp)
glob_patterns = glob_patterns + additional_patterns
# Add "/**" suffix to suffix-less patterns to match implicit .gitignore behavior.
for pattern in glob_patterns:
if pattern.endswith("/**"):
continue
glob_patterns.append(pattern.removesuffix("/*").removesuffix("/") + "/**")
glob_patterns = glob_patterns + root_patterns
glob_patterns = list(set(glob_patterns))
logger.info("[Ignore]", glob_patterns=glob_patterns)
return glob_patterns
class Ignore(metaclass=Singleton):
"""Class for processing and managing glob-like file ignore file patterns."""
_last_loaded: tuple[Path, float] | None = None
_patterns: list[str] = []
compiled_patterns: fnmatch.WcMatcher | None = None
@staticmethod
def read_ignore_file(library_dir: Path) -> list[str]:
"""Get the entire raw '.ts_ignore' file contents as a list of strings."""
ts_ignore_path = Path(library_dir / TS_FOLDER_NAME / IGNORE_NAME)
if not ts_ignore_path.exists():
logger.info(
"[Ignore] No .ts_ignore file found",
path=ts_ignore_path,
)
return []
with open(ts_ignore_path, encoding="utf8") as f:
return f.readlines()
@staticmethod
def write_ignore_file(library_dir: Path, lines: list[str]) -> None:
"""Write to the '.ts_ignore' file."""
ts_ignore_path = Path(library_dir / TS_FOLDER_NAME / IGNORE_NAME)
if not ts_ignore_path.exists():
logger.info(
"[Ignore] No .ts_ignore file found",
path=ts_ignore_path,
)
return
with open(ts_ignore_path, "w", encoding="utf8") as f:
f.writelines(lines)
@staticmethod
def get_patterns(library_dir: Path, include_global: bool = True) -> list[str]:
"""Get the ignore patterns for the given library directory.
Args:
library_dir (Path): The path of the library to load patterns from.
include_global (bool): Flag for including the global ignore set.
In most scenarios, this should be True.
"""
patterns = GLOBAL_IGNORE if include_global else []
ts_ignore_path = Path(library_dir / TS_FOLDER_NAME / IGNORE_NAME)
if not ts_ignore_path.exists():
logger.info(
"[Ignore] No .ts_ignore file found",
path=ts_ignore_path,
)
Ignore._last_loaded = None
Ignore._patterns = patterns
return Ignore._patterns
# Process the .ts_ignore file if the previous result is non-existent or outdated.
loaded = (ts_ignore_path, ts_ignore_path.stat().st_mtime)
if not Ignore._last_loaded or (Ignore._last_loaded and Ignore._last_loaded != loaded):
logger.info(
"[Ignore] Processing the .ts_ignore file...",
library=library_dir,
last_mtime=Ignore._last_loaded[1] if Ignore._last_loaded else None,
new_mtime=loaded[1],
)
Ignore._patterns = patterns + Ignore._load_ignore_file(ts_ignore_path)
Ignore.compiled_patterns = fnmatch.compile(
ignore_to_glob(Ignore._patterns),
PATH_GLOB_FLAGS,
)
else:
logger.info(
"[Ignore] No updates to the .ts_ignore detected",
library=library_dir,
last_mtime=Ignore._last_loaded[1],
new_mtime=loaded[1],
)
Ignore._last_loaded = loaded
return Ignore._patterns
@staticmethod
def _load_ignore_file(path: Path) -> list[str]:
"""Load and process the .ts_ignore file into a list of glob patterns.
Args:
path (Path): The path of the .ts_ignore file.
"""
patterns: list[str] = []
if path.exists():
with open(path, encoding="utf8") as f:
for line_raw in f.readlines():
line = line_raw.strip()
# Ignore blank lines and comments
if not line or line.startswith("#"):
continue
patterns.append(line)
return patterns

View File

@@ -129,6 +129,7 @@ class MediaCategories:
".aifc",
".aiff",
".alac",
".caf",
".flac",
".m4a",
".m4p",
@@ -242,7 +243,7 @@ class MediaCategories:
".sqlite",
".sqlite3",
}
_DISK_IMAGE_SET: set[str] = {".bios", ".dmg", ".iso"}
_DISK_IMAGE_SET: set[str] = {".bios", ".dmg", ".fhdx", ".iso"}
_DOCUMENT_SET: set[str] = {
".doc",
".docm",
@@ -297,10 +298,13 @@ class MediaCategories:
".crw",
".dng",
".nef",
".nrw",
".orf",
".raf",
".raw",
".rw2",
".srf",
".srf2",
}
_IMAGE_VECTOR_SET: set[str] = {".eps", ".epsf", ".epsi", ".svg", ".svgz"}
_IMAGE_RASTER_SET: set[str] = {
@@ -365,6 +369,7 @@ class MediaCategories:
".md",
".mkd",
".rmd",
".text",
".txt",
"contributing",
"license",
@@ -408,6 +413,7 @@ class MediaCategories:
".mp4",
".webm",
".wmv",
".ts",
}
ADOBE_PHOTOSHOP_TYPES = MediaCategory(

View File

@@ -26,9 +26,11 @@ class UiColor(IntEnum):
THEME_DARK = 1
THEME_LIGHT = 2
RED = 3
GREEN = 4
BLUE = 5
PURPLE = 6
ORANGE = 4
AMBER = 5
GREEN = 6
BLUE = 7
PURPLE = 8
TAG_COLORS: dict[TagColorEnum, dict[ColorType, Any]] = {
@@ -54,6 +56,18 @@ UI_COLORS: dict[UiColor, dict[ColorType, Any]] = {
ColorType.LIGHT_ACCENT: "#f39caa",
ColorType.DARK_ACCENT: "#440d12",
},
UiColor.ORANGE: {
ColorType.PRIMARY: "#FF8020",
ColorType.BORDER: "#E86919",
ColorType.LIGHT_ACCENT: "#FFECB3",
ColorType.DARK_ACCENT: "#752809",
},
UiColor.AMBER: {
ColorType.PRIMARY: "#FFC107",
ColorType.BORDER: "#FFD54F",
ColorType.LIGHT_ACCENT: "#FFECB3",
ColorType.DARK_ACCENT: "#772505",
},
UiColor.GREEN: {
ColorType.PRIMARY: "#28bb48",
ColorType.BORDER: "#43c568",

View File

@@ -1,6 +1,11 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from abc import ABC, abstractmethod
from enum import Enum
from typing import Generic, TypeVar, Union
from typing import Generic, TypeVar, override
class ConstraintType(Enum):
@@ -12,7 +17,7 @@ class ConstraintType(Enum):
Special = 5
@staticmethod
def from_string(text: str) -> Union["ConstraintType", None]:
def from_string(text: str) -> "ConstraintType | None":
return {
"tag": ConstraintType.Tag,
"tag_id": ConstraintType.TagID,
@@ -24,14 +29,16 @@ class ConstraintType(Enum):
class AST:
parent: Union["AST", None] = None
parent: "AST | None" = None
@override
def __str__(self):
class_name = self.__class__.__name__
fields = vars(self) # Get all instance variables as a dictionary
field_str = ", ".join(f"{key}={value}" for key, value in fields.items())
return f"{class_name}({field_str})"
@override
def __repr__(self) -> str:
return self.__str__()

View File

@@ -1,3 +1,8 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from tagstudio.core.query_lang.ast import (
AST,
ANDList,
@@ -27,7 +32,7 @@ class Parser:
if self.next_token.type == TokenType.EOF:
return ORList([])
out = self.__or_list()
if self.next_token.type != TokenType.EOF:
if self.next_token.type != TokenType.EOF: # pyright: ignore[reportUnnecessaryComparison]
raise ParsingError(self.next_token.start, self.next_token.end, "Syntax Error")
return out
@@ -41,7 +46,7 @@ class Parser:
return ORList(terms) if len(terms) > 1 else terms[0]
def __is_next_or(self) -> bool:
return self.next_token.type == TokenType.ULITERAL and self.next_token.value.upper() == "OR"
return self.next_token.type == TokenType.ULITERAL and self.next_token.value.upper() == "OR" # pyright: ignore
def __and_list(self) -> AST:
elements = [self.__term()]
@@ -67,7 +72,7 @@ class Parser:
raise self.__syntax_error("Unexpected AND")
def __is_next_and(self) -> bool:
return self.next_token.type == TokenType.ULITERAL and self.next_token.value.upper() == "AND"
return self.next_token.type == TokenType.ULITERAL and self.next_token.value.upper() == "AND" # pyright: ignore
def __term(self) -> AST:
if self.__is_next_not():
@@ -85,11 +90,14 @@ class Parser:
return self.__constraint()
def __is_next_not(self) -> bool:
return self.next_token.type == TokenType.ULITERAL and self.next_token.value.upper() == "NOT"
return self.next_token.type == TokenType.ULITERAL and self.next_token.value.upper() == "NOT" # pyright: ignore
def __constraint(self) -> Constraint:
if self.next_token.type == TokenType.CONSTRAINTTYPE:
self.last_constraint_type = self.__eat(TokenType.CONSTRAINTTYPE).value
constraint = self.__eat(TokenType.CONSTRAINTTYPE).value
if not isinstance(constraint, ConstraintType):
raise self.__syntax_error()
self.last_constraint_type = constraint
value = self.__literal()
@@ -98,7 +106,7 @@ class Parser:
self.__eat(TokenType.SBRACKETO)
properties.append(self.__property())
while self.next_token.type == TokenType.COMMA:
while self.next_token.type == TokenType.COMMA: # pyright: ignore[reportUnnecessaryComparison]
self.__eat(TokenType.COMMA)
properties.append(self.__property())
@@ -110,11 +118,16 @@ class Parser:
key = self.__eat(TokenType.ULITERAL).value
self.__eat(TokenType.EQUALS)
value = self.__literal()
if not isinstance(key, str):
raise self.__syntax_error()
return Property(key, value)
def __literal(self) -> str:
if self.next_token.type in [TokenType.QLITERAL, TokenType.ULITERAL]:
return self.__eat(self.next_token.type).value
literal = self.__eat(self.next_token.type).value
if not isinstance(literal, str):
raise self.__syntax_error()
return literal
raise self.__syntax_error()
def __eat(self, type: TokenType) -> Token:

View File

@@ -1,5 +1,10 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from enum import Enum
from typing import Any
from typing import override
from tagstudio.core.query_lang.ast import ConstraintType
from tagstudio.core.query_lang.util import ParsingError
@@ -21,12 +26,14 @@ class TokenType(Enum):
class Token:
type: TokenType
value: Any
value: str | ConstraintType | None
start: int
end: int
def __init__(self, type: TokenType, value: Any, start: int, end: int) -> None:
def __init__(
self, type: TokenType, value: str | ConstraintType | None, start: int, end: int
) -> None:
self.type = type
self.value = value
self.start = start
@@ -40,9 +47,11 @@ class Token:
def EOF(pos: int) -> "Token": # noqa: N802
return Token.from_type(TokenType.EOF, pos)
@override
def __str__(self) -> str:
return f"Token({self.type}, {self.value}, {self.start}, {self.end})" # pragma: nocover
@override
def __repr__(self) -> str:
return self.__str__() # pragma: nocover

View File

@@ -1,15 +1,26 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from typing import override
class ParsingError(BaseException):
start: int
end: int
msg: str
def __init__(self, start: int, end: int, msg: str = "Syntax Error") -> None:
super().__init__()
self.start = start
self.end = end
self.msg = msg
@override
def __str__(self) -> str:
return f"Syntax Error {self.start}->{self.end}: {self.msg}" # pragma: nocover
@override
def __repr__(self) -> str:
return self.__str__() # pragma: nocover

View File

@@ -8,10 +8,8 @@ import json
from pathlib import Path
from tagstudio.core.constants import TS_FOLDER_NAME
from tagstudio.core.library.alchemy.fields import _FieldID
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.utils.missing_files import logger
from tagstudio.core.library.alchemy.library import Entry, FieldID, Library
from tagstudio.core.utils.unlinked_registry import logger
class TagStudioCore:
@@ -43,27 +41,27 @@ class TagStudioCore:
return {}
if source == "twitter":
info[_FieldID.DESCRIPTION] = json_dump["content"].strip()
info[_FieldID.DATE_PUBLISHED] = json_dump["date"]
info[FieldID.DESCRIPTION] = json_dump["content"].strip()
info[FieldID.DATE_PUBLISHED] = json_dump["date"]
elif source == "instagram":
info[_FieldID.DESCRIPTION] = json_dump["description"].strip()
info[_FieldID.DATE_PUBLISHED] = json_dump["date"]
info[FieldID.DESCRIPTION] = json_dump["description"].strip()
info[FieldID.DATE_PUBLISHED] = json_dump["date"]
elif source == "artstation":
info[_FieldID.TITLE] = json_dump["title"].strip()
info[_FieldID.ARTIST] = json_dump["user"]["full_name"].strip()
info[_FieldID.DESCRIPTION] = json_dump["description"].strip()
info[_FieldID.TAGS] = json_dump["tags"]
info[FieldID.TITLE] = json_dump["title"].strip()
info[FieldID.ARTIST] = json_dump["user"]["full_name"].strip()
info[FieldID.DESCRIPTION] = json_dump["description"].strip()
info[FieldID.TAGS] = json_dump["tags"]
# info["tags"] = [x for x in json_dump["mediums"]["name"]]
info[_FieldID.DATE_PUBLISHED] = json_dump["date"]
info[FieldID.DATE_PUBLISHED] = json_dump["date"]
elif source == "newgrounds":
# info["title"] = json_dump["title"]
# info["artist"] = json_dump["artist"]
# info["description"] = json_dump["description"]
info[_FieldID.TAGS] = json_dump["tags"]
info[_FieldID.DATE_PUBLISHED] = json_dump["date"]
info[_FieldID.ARTIST] = json_dump["user"].strip()
info[_FieldID.DESCRIPTION] = json_dump["description"].strip()
info[_FieldID.SOURCE] = json_dump["post_url"].strip()
info[FieldID.TAGS] = json_dump["tags"]
info[FieldID.DATE_PUBLISHED] = json_dump["date"]
info[FieldID.ARTIST] = json_dump["user"].strip()
info[FieldID.DESCRIPTION] = json_dump["description"].strip()
info[FieldID.SOURCE] = json_dump["post_url"].strip()
except Exception:
logger.exception("Error handling sidecar file.", path=_filepath)

View File

@@ -5,8 +5,7 @@ from pathlib import Path
import structlog
from tagstudio.core.library.alchemy.enums import BrowsingState
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.library.alchemy.library import Entry, Library
logger = structlog.get_logger()

View File

@@ -0,0 +1,50 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from collections.abc import Iterator
from dataclasses import dataclass, field
from pathlib import Path
import structlog
from tagstudio.core.library.alchemy.library import Entry, Library
from tagstudio.core.library.ignore import Ignore
from tagstudio.core.utils.types import unwrap
logger = structlog.get_logger(__name__)
@dataclass
class IgnoredRegistry:
"""State tracker for ignored entries."""
lib: Library
ignored_entries: list[Entry] = field(default_factory=list)
@property
def ignored_count(self) -> int:
return len(self.ignored_entries)
def reset(self):
self.ignored_entries.clear()
def refresh_ignored_entries(self) -> Iterator[int]:
"""Track the number of entries that would otherwise be ignored by the current rules."""
logger.info("[IgnoredRegistry] Refreshing ignored entries...")
self.ignored_entries = []
library_dir: Path = unwrap(self.lib.library_dir)
for i, entry in enumerate(self.lib.all_entries()):
if not Ignore.compiled_patterns:
# If the compiled_patterns has malfunctioned, don't consider that a false positive
yield i
elif Ignore.compiled_patterns.match(library_dir / entry.path):
self.ignored_entries.append(entry)
yield i
def remove_ignored_entries(self) -> None:
self.lib.remove_entries(list(map(lambda ignored: ignored.id, self.ignored_entries)))
self.ignored_entries = []

View File

@@ -1,89 +0,0 @@
from collections.abc import Iterator
from dataclasses import dataclass, field
from pathlib import Path
import structlog
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.utils.refresh_dir import GLOBAL_IGNORE_SET
logger = structlog.get_logger()
@dataclass
class MissingRegistry:
"""State tracker for unlinked and moved files."""
library: Library
files_fixed_count: int = 0
missing_file_entries: list[Entry] = field(default_factory=list)
@property
def missing_file_entries_count(self) -> int:
return len(self.missing_file_entries)
def refresh_missing_files(self) -> Iterator[int]:
"""Track the number of entries that point to an invalid filepath."""
logger.info("[refresh_missing_files] Refreshing missing files...")
self.missing_file_entries = []
for i, entry in enumerate(self.library.all_entries()):
full_path = self.library.library_dir / entry.path
if not full_path.exists() or not full_path.is_file():
self.missing_file_entries.append(entry)
yield i
def match_missing_file_entry(self, match_entry: Entry) -> list[Path]:
"""Try and match unlinked file entries with matching results in the library directory.
Works if files were just moved to different subfolders and don't have duplicate names.
"""
matches = []
for path in self.library.library_dir.glob(f"**/{match_entry.path.name}"):
# Ensure matched file isn't in a globally ignored folder
skip: bool = False
for part in path.parts:
if part in GLOBAL_IGNORE_SET:
skip = True
break
if skip:
continue
if path.name == match_entry.path.name:
new_path = Path(path).relative_to(self.library.library_dir)
matches.append(new_path)
logger.info("[MissingRegistry] Matches", matches=matches)
return matches
def fix_unlinked_entries(self) -> Iterator[int]:
"""Attempt to fix unlinked file entries by finding a match in the library directory."""
self.files_fixed_count = 0
matched_entries: list[Entry] = []
for i, entry in enumerate(self.missing_file_entries):
item_matches = self.match_missing_file_entry(entry)
if len(item_matches) == 1:
logger.info(
"[fix_unlinked_entries]",
entry=entry.path.as_posix(),
item_matches=item_matches[0].as_posix(),
)
if not self.library.update_entry_path(entry.id, item_matches[0]):
try:
match = self.library.get_entry_full_by_path(item_matches[0])
entry_full = self.library.get_entry_full(entry.id)
self.library.merge_entries(entry_full, match)
except AttributeError:
continue
self.files_fixed_count += 1
matched_entries.append(entry)
yield i
for entry in matched_entries:
self.missing_file_entries.remove(entry)
def execute_deletion(self) -> None:
self.library.remove_entries(
list(map(lambda missing: missing.id, self.missing_file_entries))
)
self.missing_file_entries = []

View File

@@ -1,3 +1,9 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import shutil
from collections.abc import Iterator
from dataclasses import dataclass, field
from datetime import datetime as dt
@@ -5,27 +11,14 @@ from pathlib import Path
from time import time
import structlog
from wcmatch import pathlib
from tagstudio.core.constants import TS_FOLDER_NAME
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.library.alchemy.library import Entry, Library
from tagstudio.core.library.ignore import PATH_GLOB_FLAGS, Ignore, ignore_to_glob
from tagstudio.qt.helpers.silent_popen import silent_run # pyright: ignore
logger = structlog.get_logger(__name__)
GLOBAL_IGNORE_SET: set[str] = set(
[
TS_FOLDER_NAME,
"$RECYCLE.BIN",
".Trashes",
".Trash",
"tagstudio_thumbs",
".fseventsd",
".Spotlight-V100",
"System Volume Information",
".DS_Store",
]
)
@dataclass
class RefreshDirTracker:
@@ -42,7 +35,7 @@ class RefreshDirTracker:
entries = [
Entry(
path=entry_path,
folder=self.library.folder,
folder=self.library.folder, # pyright: ignore[reportArgumentType]
fields=[],
date_added=dt.now(),
)
@@ -54,18 +47,81 @@ class RefreshDirTracker:
yield
def refresh_dir(self, lib_path: Path) -> Iterator[int]:
"""Scan a directory for files, and add those relative filenames to internal variables."""
def refresh_dir(self, library_dir: Path, force_internal_tools: bool = False) -> Iterator[int]:
"""Scan a directory for files, and add those relative filenames to internal variables.
Args:
library_dir (Path): The library directory.
force_internal_tools (bool): Option to force the use of internal tools for scanning
(i.e. wcmatch) instead of using tools found on the system (i.e. ripgrep).
"""
if self.library.library_dir is None:
raise ValueError("No library directory set.")
ignore_patterns = Ignore.get_patterns(library_dir)
if force_internal_tools:
return self.__wc_add(library_dir, ignore_to_glob(ignore_patterns))
dir_list: list[str] | None = self.__get_dir_list(library_dir, ignore_patterns)
# Use ripgrep if it was found and working, else fallback to wcmatch.
if dir_list is not None:
return self.__rg_add(library_dir, dir_list)
else:
return self.__wc_add(library_dir, ignore_to_glob(ignore_patterns))
def __get_dir_list(self, library_dir: Path, ignore_patterns: list[str]) -> list[str] | None:
"""Use ripgrep to return a list of matched directories and files.
Return `None` if ripgrep not found on system.
"""
rg_path = shutil.which("rg")
# Use ripgrep if found on system
if rg_path is not None:
logger.info("[Refresh: Using ripgrep for scanning]")
compiled_ignore_path = library_dir / ".TagStudio" / ".compiled_ignore"
# Write compiled ignore patterns (built-in + user) to a temp file to pass to ripgrep
with open(compiled_ignore_path, "w") as pattern_file:
pattern_file.write("\n".join(ignore_patterns))
result = silent_run(
" ".join(
[
"rg",
"--files",
"--follow",
"--hidden",
"--ignore-file",
f'"{str(compiled_ignore_path)}"',
]
),
cwd=library_dir,
capture_output=True,
text=True,
shell=True,
)
compiled_ignore_path.unlink()
if result.stderr:
logger.error(result.stderr)
return result.stdout.splitlines() # pyright: ignore [reportReturnType]
logger.warning("[Refresh: ripgrep not found on system]")
return None
def __rg_add(self, library_dir: Path, dir_list: list[str]) -> Iterator[int]:
start_time_total = time()
start_time_loop = time()
self.files_not_in_library = []
dir_file_count = 0
self.files_not_in_library = []
for r in dir_list:
f = pathlib.Path(r)
for f in lib_path.glob("**/*"):
end_time_loop = time()
# Yield output every 1/30 of a second
if (end_time_loop - start_time_loop) > 0.034:
@@ -81,31 +137,65 @@ class RefreshDirTracker:
if f.is_dir():
continue
# Ensure new file isn't in a globally ignored folder
skip: bool = False
for part in f.parts:
# NOTE: Files starting with "._" are sometimes generated by macOS Finder.
# More info: https://lists.apple.com/archives/applescript-users/2006/Jun/msg00180.html
if part.startswith("._") or part in GLOBAL_IGNORE_SET:
skip = True
break
if skip:
continue
dir_file_count += 1
self.library.included_files.add(f)
relative_path = f.relative_to(lib_path)
# TODO - load these in batch somehow
if not self.library.has_path_entry(relative_path):
self.files_not_in_library.append(relative_path)
if not self.library.has_path_entry(f):
self.files_not_in_library.append(f)
end_time_total = time()
yield dir_file_count
logger.info(
"Directory scan time",
path=lib_path,
"[Refresh]: Directory scan time",
path=library_dir,
duration=(end_time_total - start_time_total),
files_not_in_lib=self.files_not_in_library,
files_scanned=dir_file_count,
tool_used="ripgrep (system)",
)
def __wc_add(self, library_dir: Path, ignore_patterns: list[str]) -> Iterator[int]:
start_time_total = time()
start_time_loop = time()
dir_file_count = 0
self.files_not_in_library = []
logger.info("[Refresh]: Falling back to wcmatch for scanning")
try:
for f in pathlib.Path(str(library_dir)).glob(
"***/*", flags=PATH_GLOB_FLAGS, exclude=ignore_patterns
):
end_time_loop = time()
# Yield output every 1/30 of a second
if (end_time_loop - start_time_loop) > 0.034:
yield dir_file_count
start_time_loop = time()
# Skip if the file/path is already mapped in the Library
if f in self.library.included_files:
dir_file_count += 1
continue
# Ignore if the file is a directory
if f.is_dir():
continue
dir_file_count += 1
self.library.included_files.add(f)
relative_path = f.relative_to(library_dir)
if not self.library.has_path_entry(relative_path):
self.files_not_in_library.append(relative_path)
except ValueError:
logger.info("[Refresh]: ValueError when refreshing directory with wcmatch!")
end_time_total = time()
yield dir_file_count
logger.info(
"[Refresh]: Directory scan time",
path=library_dir,
duration=(end_time_total - start_time_total),
files_scanned=dir_file_count,
tool_used="wcmatch (internal)",
)

View File

@@ -0,0 +1,14 @@
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from typing import TypeVar
T = TypeVar("T")
def unwrap(optional: T | None, default: T | None = None) -> T:
if optional is not None:
return optional
if default is not None:
return default
raise ValueError("Expected a value, but got None and no default was provided.")

View File

@@ -0,0 +1,92 @@
from collections.abc import Iterator
from dataclasses import dataclass, field
from pathlib import Path
import structlog
from wcmatch import pathlib
from tagstudio.core.library.alchemy.library import Entry, Library
from tagstudio.core.library.ignore import PATH_GLOB_FLAGS, Ignore
from tagstudio.core.utils.types import unwrap
logger = structlog.get_logger()
@dataclass
class UnlinkedRegistry:
"""State tracker for unlinked entries."""
lib: Library
files_fixed_count: int = 0
unlinked_entries: list[Entry] = field(default_factory=list)
@property
def unlinked_entries_count(self) -> int:
return len(self.unlinked_entries)
def reset(self):
self.unlinked_entries.clear()
def refresh_unlinked_files(self) -> Iterator[int]:
"""Track the number of entries that point to an invalid filepath."""
logger.info("[UnlinkedRegistry] Refreshing unlinked files...")
self.unlinked_entries = []
for i, entry in enumerate(self.lib.all_entries()):
full_path = unwrap(self.lib.library_dir) / entry.path
if not full_path.exists() or not full_path.is_file():
self.unlinked_entries.append(entry)
yield i
def match_unlinked_file_entry(self, match_entry: Entry) -> list[Path]:
"""Try and match unlinked file entries with matching results in the library directory.
Works if files were just moved to different subfolders and don't have duplicate names.
"""
library_dir = unwrap(self.lib.library_dir)
matches: list[Path] = []
ignore_patterns = Ignore.get_patterns(library_dir)
for path in pathlib.Path(str(library_dir)).glob(
f"***/{match_entry.path.name}",
flags=PATH_GLOB_FLAGS,
exclude=ignore_patterns,
):
if path.is_dir():
continue
if path.name == match_entry.path.name:
new_path = Path(path).relative_to(library_dir)
matches.append(new_path)
logger.info("[UnlinkedRegistry] Matches", matches=matches)
return matches
def fix_unlinked_entries(self) -> Iterator[int]:
"""Attempt to fix unlinked file entries by finding a match in the library directory."""
self.files_fixed_count = 0
matched_entries: list[Entry] = []
for i, entry in enumerate(self.unlinked_entries):
item_matches = self.match_unlinked_file_entry(entry)
if len(item_matches) == 1:
logger.info(
"[UnlinkedRegistry]",
entry=entry.path.as_posix(),
item_matches=item_matches[0].as_posix(),
)
if not self.lib.update_entry_path(entry.id, item_matches[0]):
try:
match = unwrap(self.lib.get_entry_full_by_path(item_matches[0]))
entry_full = unwrap(self.lib.get_entry_full(entry.id))
self.lib.merge_entries(entry_full, match)
except AttributeError:
continue
self.files_fixed_count += 1
matched_entries.append(entry)
yield i
for entry in matched_entries:
self.unlinked_entries.remove(entry)
def remove_unlinked_entries(self) -> None:
self.lib.remove_entries(list(map(lambda unlinked: unlinked.id, self.unlinked_entries)))
self.unlinked_entries = []

View File

@@ -11,6 +11,7 @@ import traceback
import structlog
from tagstudio.core.constants import VERSION, VERSION_BRANCH
from tagstudio.qt.ts_qt import QtDriver
logger = structlog.get_logger(__name__)
@@ -54,6 +55,13 @@ def main():
action="store_true",
help="Reveals additional internal data useful for debugging.",
)
parser.add_argument(
"-v",
"--version",
action="version",
help="Displays TagStudio version information.",
version=f"TagStudio v{VERSION} {VERSION_BRANCH}",
)
args = parser.parse_args()
driver = QtDriver(args)

View File

@@ -2,189 +2,180 @@
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import contextlib
import math
import typing
from collections.abc import Iterable
from datetime import datetime as dt
from pathlib import Path
from threading import RLock
import structlog
from PIL import Image
from tagstudio.core.constants import THUMB_CACHE_NAME, TS_FOLDER_NAME
from tagstudio.core.singleton import Singleton
# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
from tagstudio.core.library import Library
from tagstudio.core.global_settings import DEFAULT_THUMB_CACHE_SIZE
logger = structlog.get_logger(__name__)
class CacheManager(metaclass=Singleton):
FOLDER_SIZE = 10000000 # Each cache folder assumed to be 10 MiB
size_limit = 500000000 # 500 MiB default
class CacheFolder:
def __init__(self, path: Path, size: int):
self.path: Path = path
self.size: int = size
folder_dict: dict[Path, int] = {}
def __init__(self):
self.lib: Library | None = None
self.last_lib_path: Path | None = None
class CacheManager:
MAX_FOLDER_SIZE = 10 # Number in MiB
STAT_MULTIPLIER = 1_000_000 # Multiplier to apply to file stats (bytes) to get user units (MiB)
@staticmethod
def clear_cache(library_dir: Path | None) -> bool:
"""Clear all files and folders within the cached folder.
def __init__(
self,
library_dir: Path,
max_size: int | float = DEFAULT_THUMB_CACHE_SIZE,
):
"""A class for managing frontend caches, such as for file thumbnails.
Returns:
bool: True if successfully deleted, else False.
Args:
library_dir(Path): The path of the folder containing the .TagStudio library folder.
max_size: (int | float) The maximum size of the cache, in MiB.
"""
cleared = True
self._lock = RLock()
self.cache_path = library_dir / TS_FOLDER_NAME / THUMB_CACHE_NAME
self.max_size: int = max(
math.floor(max_size * CacheManager.STAT_MULTIPLIER),
math.floor(CacheManager.MAX_FOLDER_SIZE * CacheManager.STAT_MULTIPLIER),
)
if library_dir:
tree: Path = library_dir / TS_FOLDER_NAME / THUMB_CACHE_NAME
self.folders: list[CacheFolder] = []
self.current_size = 0
if self.cache_path.exists():
for folder in self.cache_path.iterdir():
if not folder.is_dir():
continue
folder_size = 0
for file in folder.iterdir():
folder_size += file.stat().st_size
self.folders.append(CacheFolder(folder, folder_size))
self.current_size += folder_size
for folder in tree.glob("*"):
for file in folder.glob("*"):
# NOTE: On macOS with non-native file systems, this will commonly raise
# FileNotFound errors due to trying to delete "._" files that have
# already been deleted: https://bugs.python.org/issue29699
with contextlib.suppress(FileNotFoundError):
file.unlink()
def _set_most_recent_folder(self, index: int):
"""Move CacheFolder at index so it's considered the most recently used folder."""
with self._lock as _lock:
if index == (len(self.folders) - 1):
return
cache_folder = self.folders.pop(index)
self.folders.append(cache_folder)
def _get_most_recent_folder(self) -> Iterable[int]:
"""Get each folders index sorted most recently used first."""
with self._lock as _lock:
return reversed(range(len(self.folders)))
def _least_recent_folder(self) -> Iterable[int]:
"""Get each folder's index sorted least recently used first."""
with self._lock as _lock:
return range(len(self.folders))
def clear_cache(self):
"""Clear all files and folders within the cached folder."""
with self._lock as _lock:
folders = []
for folder in self.folders:
if not self._remove_folder(folder):
folders.append(folders)
logger.warn("[CacheManager] Failed to remove folder", folder=folder)
self.folders = folders
logger.info("[CacheManager] Cleared cache!")
def _remove_folder(self, cache_folder: CacheFolder) -> bool:
with self._lock as _lock:
self.current_size -= cache_folder.size
if not cache_folder.path.is_dir():
return True
is_empty = True
for file in cache_folder.path.iterdir():
assert file.is_file() and file.suffix == ".webp"
try:
folder.rmdir()
with contextlib.suppress(KeyError):
CacheManager.folder_dict.pop(folder)
except Exception as e:
logger.error(
"[CacheManager] Couldn't unlink empty cache folder!",
error=e,
folder=folder,
tree=tree,
)
file.unlink(missing_ok=True)
except BaseException as e:
is_empty = False
logger.warn("[CacheManager] Failed to remove file", file=file, error=e)
for _ in tree.glob("*"):
cleared = False
if cleared:
logger.info("[CacheManager] Cleared cache!")
if is_empty:
cache_folder.path.rmdir()
return True
else:
logger.error("[CacheManager] Couldn't delete cache!", tree=tree)
size = 0
for file in cache_folder.path.iterdir():
size += file.stat().st_size
cache_folder.size = size
self.current_size += size
return False
return cleared
def get_file_path(self, file_name: Path) -> Path | None:
with self._lock as _lock:
for i in self._get_most_recent_folder():
cache_folder = self.folders[i]
file_path = cache_folder.path / file_name
if file_path.exists():
self._set_most_recent_folder(i)
return file_path
return None
def set_library(self, library):
"""Set the TagStudio library for the cache manager."""
self.lib = library
self.last_lib_path = self.lib.library_dir
if library.library_dir:
self.check_folder_status()
def cache_dir(self) -> Path | None:
"""Return the current cache directory, not including folder slugs."""
if not self.lib.library_dir:
return None
return Path(self.lib.library_dir / TS_FOLDER_NAME / THUMB_CACHE_NAME)
def save_image(self, image: Image.Image, path: Path, mode: str = "RGBA"):
def save_image(self, image: Image.Image, file_name: Path, mode: str = "RGBA"):
"""Save an image to the cache."""
folder = self.get_current_folder()
if folder:
image_path: Path = folder / path
image.save(image_path, mode=mode)
with contextlib.suppress(KeyError):
CacheManager.folder_dict[folder] += image_path.stat().st_size
with self._lock as _lock:
cache_folder: CacheFolder = self._get_current_folder()
file_path = cache_folder.path / file_name
image.save(file_path, mode=mode)
def check_folder_status(self):
"""Check the status of the cache folders.
size = file_path.stat().st_size
cache_folder.size += size
self.current_size += size
self._cull_folders()
This includes registering existing ones and creating new ones if needed.
"""
if (
(self.last_lib_path != self.lib.library_dir)
or not self.cache_dir()
or not self.cache_dir().exists()
):
self.register_existing_folders()
def create_folder() -> Path | None:
"""Create a new cache folder."""
if not self.lib.library_dir:
return None
folder_path = Path(self.cache_dir() / str(math.floor(dt.timestamp(dt.now()))))
logger.info("[CacheManager] Creating new folder", folder=folder_path)
def _create_folder(self) -> CacheFolder:
with self._lock as _lock:
folder = self.cache_path / Path(str(math.floor(dt.timestamp(dt.now()))))
try:
folder_path.mkdir(exist_ok=True)
except NotADirectoryError:
logger.error("[CacheManager] Not a directory", path=folder_path)
return folder_path
folder.mkdir(parents=True)
except FileExistsError:
for cache_folder in self.folders:
if cache_folder.path == folder:
return cache_folder
cache_folder = CacheFolder(folder, 0)
self.folders.append(cache_folder)
return cache_folder
# Get size of most recent folder, if any exist.
if CacheManager.folder_dict:
last_folder = sorted(CacheManager.folder_dict.keys())[-1]
def _get_current_folder(self) -> CacheFolder:
with self._lock as _lock:
if len(self.folders) == 0:
return self._create_folder()
if CacheManager.folder_dict[last_folder] > CacheManager.FOLDER_SIZE:
new_folder = create_folder()
CacheManager.folder_dict[new_folder] = 0
else:
new_folder = create_folder()
CacheManager.folder_dict[new_folder] = 0
for i in self._get_most_recent_folder():
cache_folder: CacheFolder = self.folders[i]
if cache_folder.size < CacheManager.MAX_FOLDER_SIZE * CacheManager.STAT_MULTIPLIER:
self._set_most_recent_folder(i)
return cache_folder
def get_current_folder(self) -> Path:
"""Get the current cache folder path that should be used."""
self.check_folder_status()
self.cull_folders()
return self._create_folder()
return sorted(CacheManager.folder_dict.keys())[-1]
def register_existing_folders(self):
"""Scan and register any pre-existing cache folders with the most recent size."""
self.last_lib_path = self.lib.library_dir
CacheManager.folder_dict.clear()
if self.last_lib_path:
# Ensure thumbnail cache path exists.
self.cache_dir().mkdir(exist_ok=True)
# Registers any existing folders and counts the capacity of the most recent one.
for f in sorted(self.cache_dir().glob("*")):
if f.is_dir():
# A folder is found. Add it to the class dict.BlockingIOError
CacheManager.folder_dict[f] = 0
CacheManager.folder_dict = dict(
sorted(CacheManager.folder_dict.items(), key=lambda kv: kv[0])
)
if CacheManager.folder_dict:
last_folder = sorted(CacheManager.folder_dict.keys())[-1]
for f in last_folder.glob("*"):
if not f.is_dir():
with contextlib.suppress(KeyError):
CacheManager.folder_dict[last_folder] += f.stat().st_size
def cull_folders(self):
def _cull_folders(self):
"""Remove folders and their cached context based on size or age limits."""
# Ensure that the user's configured size limit isn't less than the internal folder size.
size_limit = max(CacheManager.size_limit, CacheManager.FOLDER_SIZE)
with self._lock as _lock:
if self.current_size < self.max_size:
return
if len(CacheManager.folder_dict) > (size_limit / CacheManager.FOLDER_SIZE):
f = sorted(CacheManager.folder_dict.keys())[0]
folder = self.cache_dir() / f
logger.info("[CacheManager] Removing folder due to size limit", folder=folder)
removed: list[int] = []
for i in self._least_recent_folder():
cache_folder: CacheFolder = self.folders[i]
logger.info(
"[CacheManager] Removing folder due to size limit", folder=cache_folder.path
)
if self._remove_folder(cache_folder):
removed.append(i)
if self.current_size < self.max_size:
break
for file in folder.glob("*"):
try:
file.unlink()
except Exception as e:
logger.error(
"[CacheManager] Couldn't cull file inside of folder!",
error=e,
file=file,
folder=folder,
)
try:
folder.rmdir()
with contextlib.suppress(KeyError):
CacheManager.folder_dict.pop(f)
self.cull_folders()
except Exception as e:
logger.error("[CacheManager] Couldn't cull folder!", error=e, folder=folder)
pass
for index in sorted(removed, reverse=True):
self.folders.pop(index)

View File

@@ -9,7 +9,8 @@ from PySide6.QtCore import Signal
from tagstudio.core.enums import TagClickActionOption
from tagstudio.core.library.alchemy.enums import BrowsingState
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.core.library.alchemy.library import Tag
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.modals.build_tag import BuildTagPanel
from tagstudio.qt.view.components.tag_box_view import TagBoxWidgetView
from tagstudio.qt.widgets.panel import PanelModal
@@ -38,15 +39,18 @@ class TagBoxWidget(TagBoxWidgetView):
case TagClickActionOption.OPEN_EDIT:
self._on_edit(tag)
case TagClickActionOption.SET_SEARCH:
self.__driver.update_browsing_state(BrowsingState.from_tag_id(tag.id))
self.__driver.update_browsing_state(
BrowsingState.from_tag_id(tag.id, self.__driver.browsing_history.current)
)
case TagClickActionOption.ADD_TO_SEARCH:
# NOTE: modifying the ast and then setting that would be nicer
# than this string manipulation, but also much more complex,
# due to needing to implement a visitor that turns an AST to a string
# So if that exists when you read this, change the following accordingly.
current = self.__driver.browsing_history.current
suffix = BrowsingState.from_tag_id(tag.id).query
assert suffix is not None
suffix = unwrap(
BrowsingState.from_tag_id(tag.id, self.__driver.browsing_history.current).query
)
self.__driver.update_browsing_state(
current.with_search_query(
f"{current.query} {suffix}" if current.query else suffix
@@ -71,7 +75,7 @@ class TagBoxWidget(TagBoxWidgetView):
edit_modal = PanelModal(
build_tag_panel,
self.__driver.lib.tag_display_name(tag.id),
self.__driver.lib.tag_display_name(tag),
"Edit Tag",
done_callback=self.on_update.emit,
has_save=True,
@@ -90,4 +94,6 @@ class TagBoxWidget(TagBoxWidgetView):
@override
def _on_search(self, tag: Tag) -> None: # type: ignore[misc]
self.__driver.main_window.search_field.setText(f"tag_id:{tag.id}")
self.__driver.update_browsing_state(BrowsingState.from_tag_id(tag.id))
self.__driver.update_browsing_state(
BrowsingState.from_tag_id(tag.id, self.__driver.browsing_history.current)
)

View File

@@ -0,0 +1,94 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from typing import TYPE_CHECKING, override
import structlog
from PySide6 import QtGui
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.utils.ignored_registry import IgnoredRegistry
from tagstudio.qt.modals.remove_ignored_modal import RemoveIgnoredModal
from tagstudio.qt.translations import Translations
from tagstudio.qt.view.widgets.fix_ignored_modal_view import FixIgnoredEntriesModalView
from tagstudio.qt.widgets.progress import ProgressWidget
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
logger = structlog.get_logger(__name__)
class FixIgnoredEntriesModal(FixIgnoredEntriesModalView):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__(library, driver)
self.tracker = IgnoredRegistry(self.lib)
self.remove_modal = RemoveIgnoredModal(self.driver, self.tracker)
self.remove_modal.done.connect(
lambda: (
self.update_ignored_count(),
self.driver.update_browsing_state(),
self.driver.library_info_window.update_cleanup(),
self.refresh_ignored(),
)
)
self.refresh_ignored_button.clicked.connect(self.refresh_ignored)
self.remove_button.clicked.connect(self.remove_modal.show)
self.done_button.clicked.connect(self.hide)
self.update_ignored_count()
def refresh_ignored(self):
pw = ProgressWidget(
cancel_button_text=None,
minimum=0,
maximum=self.lib.entries_count,
)
pw.setWindowTitle(Translations["library.scan_library.title"])
pw.update_label(Translations["entries.ignored.scanning"])
def update_driver_widgets():
if (
hasattr(self.driver, "library_info_window")
and self.driver.library_info_window.isVisible()
):
self.driver.library_info_window.update_cleanup()
pw.from_iterable_function(
self.tracker.refresh_ignored_entries,
None,
self.set_ignored_count,
self.update_ignored_count,
self.remove_modal.refresh_list,
update_driver_widgets,
)
def set_ignored_count(self):
"""Sets the ignored_entries_count in the Library to the tracker's value."""
self.lib.ignored_entries_count = self.tracker.ignored_count
def update_ignored_count(self):
"""Updates the UI to reflect the Library's current ignored_entries_count."""
# Indicates that the library is new compared to the last update.
# NOTE: Make sure set_ignored_count() is called before this!
if self.tracker.ignored_count > 0 and self.lib.ignored_entries_count < 0:
self.tracker.reset()
count: int = self.lib.ignored_entries_count
self.remove_button.setDisabled(count < 1)
count_text: str = Translations.format(
"entries.ignored.ignored_count", count=count if count >= 0 else ""
)
self.ignored_count_label.setText(f"<h3>{count_text}</h3>")
@override
def showEvent(self, event: QtGui.QShowEvent) -> None: # type: ignore
self.update_ignored_count()
return super().showEvent(event)

View File

@@ -0,0 +1,51 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from pathlib import Path
from typing import override
import structlog
from PySide6 import QtGui
from PySide6.QtCore import Signal
from tagstudio.core.constants import IGNORE_NAME, TS_FOLDER_NAME
from tagstudio.core.library.alchemy.library import Library, Tag
from tagstudio.core.library.ignore import Ignore
from tagstudio.qt.helpers import file_opener
from tagstudio.qt.view.widgets.ignore_modal_view import IgnoreModalView
logger = structlog.get_logger(__name__)
class IgnoreModal(IgnoreModalView):
on_edit = Signal(Tag)
def __init__(self, library: Library) -> None:
super().__init__(library)
self.open_button.clicked.connect(self.__open_file)
def __load_file(self):
if not self.lib.library_dir:
return
ts_ignore: list[str] = Ignore.read_ignore_file(self.lib.library_dir)
self.text_edit.setPlainText("".join(ts_ignore))
def __open_file(self):
if not self.lib.library_dir:
return
ts_ignore_path = Path(self.lib.library_dir / TS_FOLDER_NAME / IGNORE_NAME)
file_opener.open_file(ts_ignore_path, file_manager=True)
def save(self):
if not self.lib.library_dir:
return
lines = self.text_edit.toPlainText().split("\n")
lines = [f"{line}\n" for line in lines]
Ignore.write_ignore_file(self.lib.library_dir, lines)
@override
def showEvent(self, event: QtGui.QShowEvent) -> None: # type: ignore
self.__load_file()
return super().showEvent(event)

View File

@@ -0,0 +1,166 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import os
from pathlib import Path
from typing import TYPE_CHECKING, override
from warnings import catch_warnings
import structlog
from humanfriendly import format_size # pyright: ignore[reportUnknownVariableType]
from PySide6 import QtGui
from tagstudio.core.constants import BACKUP_FOLDER_NAME, TS_FOLDER_NAME
from tagstudio.core.library.alchemy.constants import (
DB_VERSION,
DB_VERSION_CURRENT_KEY,
JSON_FILENAME,
)
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.helpers import file_opener
from tagstudio.qt.translations import Translations
from tagstudio.qt.view.widgets.library_info_window_view import LibraryInfoWindowView
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
logger = structlog.get_logger(__name__)
class LibraryInfoWindow(LibraryInfoWindowView):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__(library, driver)
# Statistics Buttons
self.manage_tags_button.clicked.connect(
self.driver.main_window.menu_bar.tag_manager_action.trigger
)
self.manage_colors_button.clicked.connect(
self.driver.main_window.menu_bar.color_manager_action.trigger
)
# Cleanup Buttons
self.fix_unlinked_entries.clicked.connect(
self.driver.main_window.menu_bar.fix_unlinked_entries_action.trigger
)
self.fix_ignored_entries.clicked.connect(
self.driver.main_window.menu_bar.fix_ignored_entries_action.trigger
)
self.fix_dupe_files.clicked.connect(
self.driver.main_window.menu_bar.fix_dupe_files_action.trigger
)
# General Buttons
self.close_button.clicked.connect(lambda: self.close())
def update_title(self):
assert self.lib.library_dir
title: str = Translations.format(
"library_info.title", library_dir=self.lib.library_dir.stem
)
self.title_label.setText(f"<h2>{title}</h2>")
def update_stats(self):
self.entry_count_label.setText(f"<b>{self.lib.entries_count}</b>")
self.tag_count_label.setText(f"<b>{len(self.lib.tags)}</b>")
self.field_count_label.setText(f"<b>{len(self.lib.field_types)}</b>")
self.namespaces_count_label.setText(f"<b>{len(self.lib.namespaces)}</b>")
colors_total = 0
for c in self.lib.tag_color_groups.values():
colors_total += len(c)
self.color_count_label.setText(f"<b>{colors_total}</b>")
self.macros_count_label.setText("<b>1</b>") # TODO: Implement macros system
def update_cleanup(self):
# Unlinked Entries
unlinked_count: str = (
str(self.lib.unlinked_entries_count) if self.lib.unlinked_entries_count >= 0 else ""
)
self.unlinked_count_label.setText(f"<b>{unlinked_count}</b>")
# Ignored Entries
ignored_count: str = (
str(self.lib.ignored_entries_count) if self.lib.ignored_entries_count >= 0 else ""
)
self.ignored_count_label.setText(f"<b>{ignored_count}</b>")
# Duplicate Files
dupe_files_count: str = (
str(self.lib.dupe_files_count) if self.lib.dupe_files_count >= 0 else ""
)
self.dupe_files_count_label.setText(f"<b>{dupe_files_count}</b>")
# Legacy JSON Library Present
json_library_text: str = (
Translations["generic.yes"]
if self.__is_json_library_present
else Translations["generic.no"]
)
self.legacy_json_status_label.setText(f"<b>{json_library_text}</b>")
# Backups
self.backups_count_label.setText(
f"<b>{self.__backups_count}</b> ({format_size(self.__backups_size)})"
)
# Buttons
with catch_warnings(record=True):
self.view_legacy_json_file.clicked.disconnect()
self.open_backups_folder.clicked.disconnect()
if self.__is_json_library_present:
self.view_legacy_json_file.setEnabled(True)
self.view_legacy_json_file.clicked.connect(
lambda: file_opener.open_file(
unwrap(self.lib.library_dir) / TS_FOLDER_NAME / JSON_FILENAME, file_manager=True
)
)
else:
self.view_legacy_json_file.setEnabled(False)
self.open_backups_folder.clicked.connect(
lambda: file_opener.open_file(
unwrap(self.lib.library_dir) / TS_FOLDER_NAME / BACKUP_FOLDER_NAME
)
)
def update_version(self):
version_text: str = f"<b>{self.lib.get_version(DB_VERSION_CURRENT_KEY)}</b> / {DB_VERSION}"
self.version_label.setText(
Translations.format("library_info.version", version=version_text)
)
def refresh(self):
self.update_title()
self.update_stats()
self.update_cleanup()
self.update_version()
@property
def __is_json_library_present(self):
json_path = unwrap(self.lib.library_dir) / TS_FOLDER_NAME / JSON_FILENAME
return json_path.exists()
@property
def __backups_count(self):
backups_path = unwrap(self.lib.library_dir) / TS_FOLDER_NAME / BACKUP_FOLDER_NAME
return len(os.listdir(backups_path))
@property
def __backups_size(self):
backups_path = unwrap(self.lib.library_dir) / TS_FOLDER_NAME / BACKUP_FOLDER_NAME
size: int = 0
for f in backups_path.glob("*"):
if not f.is_dir() and f.exists():
size += Path(f).stat().st_size
return size
@override
def showEvent(self, event: QtGui.QShowEvent): # type: ignore
self.refresh()
return super().showEvent(event)

View File

@@ -39,7 +39,9 @@ class PreviewThumb(PreviewThumbView):
stats = FileAttributeData()
ext = filepath.suffix.lower()
if MediaCategories.IMAGE_RAW_TYPES.contains(ext, mime_fallback=True):
if filepath.is_dir():
pass
elif MediaCategories.IMAGE_RAW_TYPES.contains(ext, mime_fallback=True):
try:
with rawpy.imread(str(filepath)) as raw:
rgb = raw.postprocess()
@@ -142,7 +144,9 @@ class PreviewThumb(PreviewThumbView):
return self.__get_image_stats(filepath)
def _open_file_action_callback(self):
open_file(self.__current_file)
open_file(
self.__current_file, windows_start_command=self.__driver.settings.windows_start_command
)
def _open_explorer_action_callback(self):
open_file(self.__current_file, file_manager=True)
@@ -152,4 +156,6 @@ class PreviewThumb(PreviewThumbView):
self.__driver.delete_files_callback(self.__current_file)
def _button_wrapper_callback(self):
open_file(self.__current_file)
open_file(
self.__current_file, windows_start_command=self.__driver.settings.windows_start_command
)

View File

@@ -3,7 +3,9 @@
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import os
from pathlib import Path
from platform import system
import structlog
from send2trash import send2trash
@@ -19,13 +21,38 @@ def delete_file(path: str | Path) -> bool:
"""
_path = Path(path)
try:
if _path.is_dir():
return False
logger.info(f"[delete_file] Sending to Trash: {_path}")
send2trash(_path)
return True
except PermissionError as e:
logger.error(f"[delete_file][ERROR] PermissionError: {e}")
logger.error(f"[delete_file] PermissionError: {e}")
except FileNotFoundError:
logger.error(f"[delete_file][ERROR] File Not Found: {_path}")
logger.error(f"[delete_file] File Not Found: {_path}")
except OSError as e:
if system() == "Darwin" and _path.exists():
logger.info(
f'[delete_file] Encountered "{e}" on macOS and file exists; '
"Assuming it's on a network volume and proceeding to delete..."
)
return _hard_delete_file(_path)
else:
logger.error("[delete_file] OSError", error=e)
except Exception as e:
logger.error(e)
logger.error("[delete_file] Unknown Error", error_type=type(e).__name__, error=e)
return False
def _hard_delete_file(path: Path) -> bool:
"""Hard delete a file from the system. Does NOT send to system trash.
Args:
path (str | Path): The path of the file to delete.
"""
try:
os.remove(path)
return True
except Exception as e:
logger.error("[hard_delete_file] Error", error_type=type(e).__name__, error=e)
return False

View File

@@ -14,18 +14,21 @@ from PySide6.QtCore import Qt
from PySide6.QtGui import QMouseEvent
from PySide6.QtWidgets import QLabel, QWidget
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.helpers.silent_popen import silent_Popen
logger = structlog.get_logger(__name__)
def open_file(path: str | Path, file_manager: bool = False):
def open_file(path: str | Path, file_manager: bool = False, windows_start_command: bool = False):
"""Open a file in the default application or file explorer.
Args:
path (str): The path to the file to open.
file_manager (bool, optional): Whether to open the file in the file manager
(e.g. Finder on macOS). Defaults to False.
windows_start_command (bool): Flag to determine if the older 'start' command should be used
on Windows for opening files. This fixes issues on some systems in niche cases.
"""
path = Path(path)
logger.info("Opening file", path=path)
@@ -50,14 +53,26 @@ def open_file(path: str | Path, file_manager: bool = False):
| subprocess.CREATE_BREAKAWAY_FROM_JOB,
)
else:
command = f'"{normpath}"'
silent_Popen(
command,
shell=True,
close_fds=True,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
| subprocess.CREATE_BREAKAWAY_FROM_JOB,
)
if windows_start_command:
command_name = "start"
# First parameter is for title, NOT filepath
command_args = ["", normpath]
subprocess.Popen(
[command_name] + command_args,
shell=True,
close_fds=True,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
| subprocess.CREATE_BREAKAWAY_FROM_JOB,
)
else:
command = f'"{normpath}"'
silent_Popen(
command,
shell=True,
close_fds=True,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
| subprocess.CREATE_BREAKAWAY_FROM_JOB,
)
else:
if sys.platform == "darwin":
command_name = "open"
@@ -109,11 +124,13 @@ class FileOpenerHelper:
def open_file(self):
"""Open the file in the default application."""
open_file(self.filepath)
if Path(self.filepath).is_file():
open_file(self.filepath)
def open_explorer(self):
"""Open the file in the default file explorer."""
open_file(self.filepath, file_manager=True)
if Path(self.filepath).is_file():
open_file(self.filepath, file_manager=True)
class FileOpenerLabel(QLabel):
@@ -146,8 +163,7 @@ class FileOpenerLabel(QLabel):
ev (QMouseEvent): The mouse press event.
"""
if ev.button() == Qt.MouseButton.LeftButton:
assert self.filepath is not None, "File path is not set"
opener = FileOpenerHelper(self.filepath)
opener = FileOpenerHelper(unwrap(self.filepath))
opener.open_explorer()
elif ev.button() == Qt.MouseButton.RightButton:
# Show context menu

View File

@@ -86,7 +86,7 @@ def silent_Popen( # noqa: N802
)
def silent_run( # noqa: N802
def silent_run(
args,
bufsize=-1,
executable=None,

View File

@@ -38,6 +38,7 @@ from tagstudio.core.library.alchemy.enums import SortingModeEnum
from tagstudio.qt.controller.widgets.preview_panel_controller import PreviewPanel
from tagstudio.qt.flowlayout import FlowLayout
from tagstudio.qt.helpers.color_overlay import theme_fg_overlay
from tagstudio.qt.mnemonics import assign_mnemonics
from tagstudio.qt.pagination import Pagination
from tagstudio.qt.platform_strings import trash_term
from tagstudio.qt.resource_manager import ResourceManager
@@ -71,7 +72,7 @@ class MainMenuBar(QMenuBar):
paste_fields_action: QAction
add_tag_to_selected_action: QAction
delete_file_action: QAction
manage_file_ext_action: QAction
ignore_modal_action: QAction
tag_manager_action: QAction
color_manager_action: QAction
@@ -80,6 +81,7 @@ class MainMenuBar(QMenuBar):
tools_menu: QMenu
fix_unlinked_entries_action: QAction
fix_ignored_entries_action: QAction
fix_dupe_files_action: QAction
clear_thumb_cache_action: QAction
@@ -166,6 +168,7 @@ class MainMenuBar(QMenuBar):
self.file_menu.addSeparator()
assign_mnemonics(self.file_menu)
self.addMenu(self.file_menu)
def setup_edit_menu(self):
@@ -271,12 +274,10 @@ class MainMenuBar(QMenuBar):
self.edit_menu.addSeparator()
# Manage File Extensions
self.manage_file_ext_action = QAction(
Translations["menu.edit.manage_file_extensions"], self
)
self.manage_file_ext_action.setEnabled(False)
self.edit_menu.addAction(self.manage_file_ext_action)
# Ignore Files and Directories (.ts_ignore System)
self.ignore_modal_action = QAction(Translations["menu.edit.ignore_files"], self)
self.ignore_modal_action.setEnabled(False)
self.edit_menu.addAction(self.ignore_modal_action)
# Manage Tags
self.tag_manager_action = QAction(Translations["menu.edit.manage_tags"], self)
@@ -295,11 +296,15 @@ class MainMenuBar(QMenuBar):
self.color_manager_action.setEnabled(False)
self.edit_menu.addAction(self.color_manager_action)
assign_mnemonics(self.edit_menu)
self.addMenu(self.edit_menu)
def setup_view_menu(self):
self.view_menu = QMenu(Translations["menu.view"], self)
self.library_info_action = QAction(Translations["menu.view.library_info"])
self.view_menu.addAction(self.library_info_action)
# show_libs_list_action = QAction(Translations["settings.show_recent_libraries"], menu_bar)
# show_libs_list_action.setCheckable(True)
# show_libs_list_action.setChecked(self.settings.show_library_list)
@@ -336,6 +341,7 @@ class MainMenuBar(QMenuBar):
self.view_menu.addSeparator()
assign_mnemonics(self.view_menu)
self.addMenu(self.view_menu)
def setup_tools_menu(self):
@@ -348,6 +354,13 @@ class MainMenuBar(QMenuBar):
self.fix_unlinked_entries_action.setEnabled(False)
self.tools_menu.addAction(self.fix_unlinked_entries_action)
# Fix Ignored Entries
self.fix_ignored_entries_action = QAction(
Translations["menu.tools.fix_ignored_entries"], self
)
self.fix_ignored_entries_action.setEnabled(False)
self.tools_menu.addAction(self.fix_ignored_entries_action)
# Fix Duplicate Files
self.fix_dupe_files_action = QAction(Translations["menu.tools.fix_duplicate_files"], self)
self.fix_dupe_files_action.setEnabled(False)
@@ -362,6 +375,7 @@ class MainMenuBar(QMenuBar):
self.clear_thumb_cache_action.setEnabled(False)
self.tools_menu.addAction(self.clear_thumb_cache_action)
assign_mnemonics(self.tools_menu)
self.addMenu(self.tools_menu)
def setup_macros_menu(self):
@@ -371,6 +385,7 @@ class MainMenuBar(QMenuBar):
self.folders_to_tags_action.setEnabled(False)
self.macros_menu.addAction(self.folders_to_tags_action)
assign_mnemonics(self.macros_menu)
self.addMenu(self.macros_menu)
def setup_help_menu(self):
@@ -379,6 +394,7 @@ class MainMenuBar(QMenuBar):
self.about_action = QAction(Translations["menu.help.about"], self)
self.help_menu.addAction(self.about_action)
assign_mnemonics(self.help_menu)
self.addMenu(self.help_menu)
def rebuild_open_recent_library_menu(
@@ -509,11 +525,8 @@ class MainWindow(QMainWindow):
self.central_layout.setObjectName("central_layout")
self.setup_search_bar()
self.setup_extra_input_bar()
self.setup_content(driver)
self.setCentralWidget(self.central_widget)
def setup_search_bar(self):
@@ -617,7 +630,6 @@ class MainWindow(QMainWindow):
self.content_splitter.setHandleWidth(12)
self.setup_entry_list(driver)
self.setup_preview_panel(driver)
self.content_splitter.setStretchFactor(0, 1)

View File

@@ -0,0 +1,142 @@
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from PySide6.QtGui import QAction
from PySide6.QtWidgets import QMenu
def remove_mnemonic_marker(label: str) -> str:
"""Remove existing accelerator markers (&) from a label."""
result = ""
skip = False
for i, ch in enumerate(label):
if skip:
skip = False
continue
if ch == "&":
# escaped ampersand "&&"
if i + 1 < len(label) and label[i + 1] == "&":
result += "&"
skip = True
# otherwise skip this '&'
continue
result += ch
return result
# Additional weight for first character in string
FIRST_CHARACTER_EXTRA_WEIGHT = 50
# Additional weight for the beginning of a word
WORD_BEGINNING_EXTRA_WEIGHT = 50
# Additional weight for a 'wanted' accelerator ie string with '&'
WANTED_ACCEL_EXTRA_WEIGHT = 150
def calculate_weights(text: str):
weights: dict[int, str] = {}
pos = 0
start_character = True
wanted_character = False
while pos < len(text):
c = text[pos]
# skip non typeable characters
if not c.isalnum() and c != "&":
start_character = True
pos += 1
continue
weight = 1
# add special weight to first character
if pos == 0:
weight += FIRST_CHARACTER_EXTRA_WEIGHT
elif start_character: # add weight to word beginnings
weight += WORD_BEGINNING_EXTRA_WEIGHT
start_character = False
# add weight to characters that have an & beforehand
if wanted_character:
weight += WANTED_ACCEL_EXTRA_WEIGHT
wanted_character = False
# add decreasing weight to left characters
if pos < 50:
weight += 50 - pos
# try to preserve the wanted accelerators
if c == "&" and (pos != len(text) - 1 and text[pos + 1] != "&" and text[pos + 1].isalnum()):
wanted_character = True
pos += 1
continue
while weight in weights:
weight += 1
if c != "&":
weights[weight] = c
pos += 1
# update our maximum weight
max_weight = 0 if len(weights) == 0 else max(weights.keys())
return max_weight, weights
def insert_mnemonic(label: str, char: str) -> str:
pos = label.lower().find(char)
if pos >= 0:
return label[:pos] + "&" + label[pos:]
return label
def assign_mnemonics(menu: QMenu):
# Collect actions
actions = [a for a in menu.actions() if not a.isSeparator()]
# Sequence map: mnemonic key -> QAction
sequence_to_action: dict[str, QAction] = {}
final_text: dict[QAction, str] = {}
actions.reverse()
while len(actions) > 0:
action = actions.pop()
label = action.text()
_, weights = calculate_weights(label)
chosen_char = None
# Try candidates, starting from highest weight
for weight in sorted(weights.keys(), reverse=True):
c = weights[weight].lower()
other = sequence_to_action.get(c)
if other is None:
chosen_char = c
sequence_to_action[c] = action
break
else:
# Compare weights with existing action
other_max, _ = calculate_weights(remove_mnemonic_marker(other.text()))
if weight > other_max:
# Take over from weaker action
actions.append(other)
sequence_to_action[c] = action
chosen_char = c
# Apply mnemonic if found
if chosen_char:
plain = remove_mnemonic_marker(label)
new_label = insert_mnemonic(plain, chosen_char)
final_text[action] = new_label
else:
# No mnemonic assigned → clean text
final_text[action] = remove_mnemonic_marker(label)
for a, t in final_text.items():
a.setText(t)

View File

@@ -22,8 +22,7 @@ from PySide6.QtWidgets import (
from tagstudio.core import palette
from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.library import Library, slugify
from tagstudio.core.library.alchemy.models import TagColorGroup
from tagstudio.core.library.alchemy.library import Library, TagColorGroup, slugify
from tagstudio.core.palette import ColorType, UiColor, get_tag_color, get_ui_color
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.panel import PanelWidget

View File

@@ -11,8 +11,12 @@ from PySide6.QtCore import Qt, Signal
from PySide6.QtWidgets import QLabel, QLineEdit, QVBoxLayout, QWidget
from tagstudio.core.constants import RESERVED_NAMESPACE_PREFIX
from tagstudio.core.library.alchemy.library import Library, ReservedNamespaceError, slugify
from tagstudio.core.library.alchemy.models import Namespace
from tagstudio.core.library.alchemy.library import (
Library,
Namespace,
ReservedNamespaceError,
slugify,
)
from tagstudio.core.palette import ColorType, UiColor, get_ui_color
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.panel import PanelWidget

View File

@@ -26,11 +26,10 @@ from PySide6.QtWidgets import (
)
from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag, TagColorGroup
from tagstudio.core.library.alchemy.library import Library, Tag, TagColorGroup
from tagstudio.core.palette import ColorType, UiColor, get_tag_color, get_ui_color
from tagstudio.qt.modals.tag_color_selection import TagColorSelection
from tagstudio.qt.modals.tag_search import TagSearchModal
from tagstudio.qt.modals.tag_search import TagSearchModal, TagSearchPanel
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.panel import PanelModal, PanelWidget
from tagstudio.qt.widgets.tag import (
@@ -385,10 +384,11 @@ class BuildTagPanel(PanelWidget):
tag_widget = TagWidget(
tag,
library=self.lib,
has_edit=False,
has_edit=True,
has_remove=True,
)
tag_widget.on_remove.connect(lambda t=parent_id: self.remove_parent_tag_callback(t))
tag_widget.on_edit.connect(lambda t=tag: TagSearchPanel(library=self.lib).edit_tag(t))
row.addWidget(tag_widget)
# Add Disambiguation Tag Button

View File

@@ -1,112 +0,0 @@
# Copyright (C) 2024 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from PySide6.QtCore import Qt, Signal
from PySide6.QtWidgets import (
QComboBox,
QHBoxLayout,
QLabel,
QLineEdit,
QPushButton,
QStyledItemDelegate,
QTableWidget,
QTableWidgetItem,
QVBoxLayout,
QWidget,
)
from tagstudio.core.enums import LibraryPrefs
from tagstudio.core.library.alchemy.library import Library
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.panel import PanelWidget
class FileExtensionItemDelegate(QStyledItemDelegate):
def setModelData(self, editor, model, index): # noqa: N802
if isinstance(editor, QLineEdit) and editor.text() and not editor.text().startswith("."):
editor.setText(f".{editor.text()}")
super().setModelData(editor, model, index)
class FileExtensionModal(PanelWidget):
done = Signal()
def __init__(self, library: "Library"):
super().__init__()
# Initialize Modal =====================================================
self.lib = library
self.setWindowTitle(Translations["ignore_list.title"])
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.setMinimumSize(240, 400)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
# Create Table Widget --------------------------------------------------
self.table = QTableWidget(len(self.lib.prefs(LibraryPrefs.EXTENSION_LIST)), 1)
self.table.horizontalHeader().setVisible(False)
self.table.verticalHeader().setVisible(False)
self.table.horizontalHeader().setStretchLastSection(True)
self.table.setItemDelegate(FileExtensionItemDelegate())
# Create "Add Button" Widget -------------------------------------------
self.add_button = QPushButton(Translations["ignore_list.add_extension"])
self.add_button.clicked.connect(self.add_item)
self.add_button.setDefault(True)
self.add_button.setMinimumWidth(100)
# Create Mode Widgets --------------------------------------------------
self.mode_widget = QWidget()
self.mode_layout = QHBoxLayout(self.mode_widget)
self.mode_layout.setContentsMargins(0, 0, 0, 0)
self.mode_layout.setSpacing(12)
self.mode_label = QLabel(Translations["ignore_list.mode.label"])
self.mode_combobox = QComboBox()
self.mode_combobox.setEditable(False)
self.mode_combobox.addItem("")
self.mode_combobox.addItem("")
self.mode_combobox.setItemText(0, Translations["ignore_list.mode.include"])
self.mode_combobox.setItemText(1, Translations["ignore_list.mode.exclude"])
is_exclude_list = int(bool(self.lib.prefs(LibraryPrefs.IS_EXCLUDE_LIST)))
self.mode_combobox.setCurrentIndex(is_exclude_list)
self.mode_combobox.currentIndexChanged.connect(lambda i: self.update_list_mode(i))
self.mode_layout.addWidget(self.mode_label)
self.mode_layout.addWidget(self.mode_combobox)
self.mode_layout.setStretch(1, 1)
# Add Widgets To Layout ------------------------------------------------
self.root_layout.addWidget(self.mode_widget)
self.root_layout.addWidget(self.table)
self.root_layout.addWidget(self.add_button, alignment=Qt.AlignmentFlag.AlignCenter)
# Finalize Modal -------------------------------------------------------
self.refresh_list()
def update_list_mode(self, mode: int):
"""Update the mode of the extension list: "Exclude" or "Include".
Args:
mode (int): The list mode, given by the index of the mode inside
the mode combobox. 1 for "Exclude", 0 for "Include".
"""
self.lib.set_prefs(LibraryPrefs.IS_EXCLUDE_LIST, bool(mode))
def refresh_list(self):
for i, ext in enumerate(self.lib.prefs(LibraryPrefs.EXTENSION_LIST)):
self.table.setItem(i, 0, QTableWidgetItem(ext))
def add_item(self):
self.table.insertRow(self.table.rowCount())
def save(self):
extensions = []
for i in range(self.table.rowCount()):
ext = self.table.item(i, 0)
if ext and ext.text().strip():
extensions.append(ext.text().strip().lstrip(".").lower())
# save preference
self.lib.set_prefs(LibraryPrefs.EXTENSION_LIST, extensions)

View File

@@ -18,7 +18,7 @@ from PySide6.QtWidgets import (
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.utils.dupe_files import DupeRegistry
from tagstudio.qt.modals.mirror_entities import MirrorEntriesModal
from tagstudio.qt.modals.mirror_entries_modal import MirrorEntriesModal
from tagstudio.qt.translations import Translations
# Only import for type checking/autocompletion, will not be imported at runtime.
@@ -26,6 +26,7 @@ if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
# TODO: Break up into MVC classes, similar to fix_ignored_modal
class FixDupeFilesModal(QWidget):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__()

View File

@@ -10,10 +10,10 @@ from PySide6.QtCore import Qt
from PySide6.QtWidgets import QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.utils.missing_files import MissingRegistry
from tagstudio.qt.modals.delete_unlinked import DeleteUnlinkedEntriesModal
from tagstudio.core.utils.unlinked_registry import UnlinkedRegistry
from tagstudio.qt.modals.merge_dupe_entries import MergeDuplicateEntries
from tagstudio.qt.modals.relink_unlinked import RelinkUnlinkedEntries
from tagstudio.qt.modals.relink_entries_modal import RelinkUnlinkedEntries
from tagstudio.qt.modals.remove_unlinked_modal import RemoveUnlinkedEntriesModal
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.progress import ProgressWidget
@@ -22,15 +22,16 @@ if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
# TODO: Break up into MVC classes, similar to fix_ignored_modal
class FixUnlinkedEntriesModal(QWidget):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__()
self.lib = library
self.driver = driver
self.tracker = MissingRegistry(library=self.lib)
self.tracker = UnlinkedRegistry(lib=self.lib)
self.missing_count = -1
self.unlinked_count = -1
self.dupe_count = -1
self.setWindowTitle(Translations["entries.unlinked.title"])
self.setWindowModality(Qt.WindowModality.ApplicationModal)
@@ -43,18 +44,16 @@ class FixUnlinkedEntriesModal(QWidget):
self.unlinked_desc_widget.setWordWrap(True)
self.unlinked_desc_widget.setStyleSheet("text-align:left;")
self.missing_count_label = QLabel()
self.missing_count_label.setObjectName("missingCountLabel")
self.missing_count_label.setStyleSheet("font-weight:bold;font-size:14px;")
self.missing_count_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.unlinked_count_label = QLabel()
self.unlinked_count_label.setObjectName("unlinkedCountLabel")
self.unlinked_count_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.dupe_count_label = QLabel()
self.dupe_count_label.setObjectName("dupeCountLabel")
self.dupe_count_label.setStyleSheet("font-weight:bold;font-size:14px;")
self.dupe_count_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.refresh_unlinked_button = QPushButton(Translations["entries.unlinked.refresh_all"])
self.refresh_unlinked_button.clicked.connect(self.refresh_missing_files)
self.refresh_unlinked_button = QPushButton(Translations["entries.generic.refresh_alt"])
self.refresh_unlinked_button.clicked.connect(self.refresh_unlinked)
self.merge_class = MergeDuplicateEntries(self.lib, self.driver)
self.relink_class = RelinkUnlinkedEntries(self.tracker)
@@ -64,7 +63,7 @@ class FixUnlinkedEntriesModal(QWidget):
# refresh the grid
lambda: (
self.driver.update_browsing_state(),
self.refresh_missing_files(),
self.refresh_unlinked(),
)
)
self.search_button.clicked.connect(self.relink_class.repair_entries)
@@ -72,16 +71,17 @@ class FixUnlinkedEntriesModal(QWidget):
self.manual_button = QPushButton(Translations["entries.unlinked.relink.manual"])
self.manual_button.setHidden(True)
self.delete_button = QPushButton(Translations["entries.unlinked.delete_alt"])
self.delete_modal = DeleteUnlinkedEntriesModal(self.driver, self.tracker)
self.delete_modal.done.connect(
self.remove_button = QPushButton(Translations["entries.unlinked.remove_alt"])
self.remove_modal = RemoveUnlinkedEntriesModal(self.driver, self.tracker)
self.remove_modal.done.connect(
lambda: (
self.set_missing_count(),
self.set_unlinked_count(),
# refresh the grid
self.driver.update_browsing_state(),
self.refresh_unlinked(),
)
)
self.delete_button.clicked.connect(self.delete_modal.show)
self.remove_button.clicked.connect(self.remove_modal.show)
self.button_container = QWidget()
self.button_layout = QHBoxLayout(self.button_container)
@@ -93,19 +93,19 @@ class FixUnlinkedEntriesModal(QWidget):
self.done_button.clicked.connect(self.hide)
self.button_layout.addWidget(self.done_button)
self.root_layout.addWidget(self.missing_count_label)
self.root_layout.addWidget(self.unlinked_count_label)
self.root_layout.addWidget(self.unlinked_desc_widget)
self.root_layout.addWidget(self.refresh_unlinked_button)
self.root_layout.addWidget(self.search_button)
self.root_layout.addWidget(self.manual_button)
self.root_layout.addWidget(self.delete_button)
self.root_layout.addWidget(self.remove_button)
self.root_layout.addStretch(1)
self.root_layout.addStretch(2)
self.root_layout.addWidget(self.button_container)
self.set_missing_count(self.missing_count)
self.update_unlinked_count()
def refresh_missing_files(self):
def refresh_unlinked(self):
pw = ProgressWidget(
cancel_button_text=None,
minimum=0,
@@ -114,30 +114,47 @@ class FixUnlinkedEntriesModal(QWidget):
pw.setWindowTitle(Translations["library.scan_library.title"])
pw.update_label(Translations["entries.unlinked.scanning"])
def update_driver_widgets():
if (
hasattr(self.driver, "library_info_window")
and self.driver.library_info_window.isVisible()
):
self.driver.library_info_window.update_cleanup()
pw.from_iterable_function(
self.tracker.refresh_missing_files,
self.tracker.refresh_unlinked_files,
None,
self.set_missing_count,
self.delete_modal.refresh_list,
self.set_unlinked_count,
self.update_unlinked_count,
self.remove_modal.refresh_list,
update_driver_widgets,
)
def set_missing_count(self, count: int | None = None):
if count is not None:
self.missing_count = count
else:
self.missing_count = self.tracker.missing_file_entries_count
def set_unlinked_count(self):
"""Sets the unlinked_entries_count in the Library to the tracker's value."""
self.lib.unlinked_entries_count = self.tracker.unlinked_entries_count
if self.missing_count < 0:
self.search_button.setDisabled(True)
self.delete_button.setDisabled(True)
self.missing_count_label.setText(Translations["entries.unlinked.missing_count.none"])
else:
# disable buttons if there are no files to fix
self.search_button.setDisabled(self.missing_count == 0)
self.delete_button.setDisabled(self.missing_count == 0)
self.missing_count_label.setText(
Translations.format("entries.unlinked.missing_count.some", count=self.missing_count)
)
def update_unlinked_count(self):
"""Updates the UI to reflect the Library's current unlinked_entries_count."""
# Indicates that the library is new compared to the last update.
# NOTE: Make sure set_unlinked_count() is called before this!
if self.tracker.unlinked_entries_count > 0 and self.lib.unlinked_entries_count < 0:
self.tracker.reset()
count: int = self.lib.unlinked_entries_count
self.search_button.setDisabled(count < 1)
self.remove_button.setDisabled(count < 1)
count_text: str = Translations.format(
"entries.unlinked.unlinked_count", count=count if count >= 0 else ""
)
self.unlinked_count_label.setText(f"<h3>{count_text}</h3>")
@override
def showEvent(self, event: QtGui.QShowEvent) -> None:
self.update_unlinked_count()
return super().showEvent(event)
@override
def keyPressEvent(self, event: QtGui.QKeyEvent) -> None: # noqa N802

View File

@@ -23,9 +23,9 @@ from PySide6.QtWidgets import (
from tagstudio.core.constants import TAG_ARCHIVED, TAG_FAVORITE
from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.core.library.alchemy.library import Library, Tag
from tagstudio.core.palette import ColorType, get_tag_color
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.flowlayout import FlowLayout
from tagstudio.qt.translations import Translations
@@ -93,8 +93,7 @@ def reverse_tag(library: Library, tag: Tag, items: list[Tag] | None) -> list[Tag
parent_tag = None # to avoid subtag unbound error
for parent_tag_id in tag.parent_ids:
parent_tag = library.get_tag(parent_tag_id)
assert parent_tag is not None
return reverse_tag(library, parent_tag, items)
return reverse_tag(library, unwrap(parent_tag), items)
# =========== UI ===========
@@ -274,8 +273,7 @@ class TreeItem(QWidget):
self.label = QLabel()
self.tag_layout.addWidget(self.label)
assert data.tag is not None and parent_tag is not None
self.tag_widget = ModifiedTagWidget(data.tag, parent_tag)
self.tag_widget = ModifiedTagWidget(unwrap(data.tag), unwrap(parent_tag))
self.tag_widget.bg_button.clicked.connect(lambda: self.hide_show())
self.tag_layout.addWidget(self.tag_widget)

View File

@@ -5,7 +5,7 @@
from PySide6.QtCore import QObject, Signal
from tagstudio.core.utils.missing_files import MissingRegistry
from tagstudio.core.utils.unlinked_registry import UnlinkedRegistry
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.progress import ProgressWidget
@@ -13,7 +13,7 @@ from tagstudio.qt.widgets.progress import ProgressWidget
class RelinkUnlinkedEntries(QObject):
done = Signal()
def __init__(self, tracker: MissingRegistry):
def __init__(self, tracker: UnlinkedRegistry):
super().__init__()
self.tracker = tracker
@@ -21,8 +21,8 @@ class RelinkUnlinkedEntries(QObject):
def displayed_text(x):
return Translations.format(
"entries.unlinked.relink.attempting",
idx=x,
missing_count=self.tracker.missing_file_entries_count,
index=x,
unlinked_count=self.tracker.unlinked_entries_count,
fixed_count=self.tracker.files_fixed_count,
)
@@ -30,8 +30,7 @@ class RelinkUnlinkedEntries(QObject):
label_text="",
cancel_button_text=None,
minimum=0,
maximum=self.tracker.missing_file_entries_count,
maximum=self.tracker.unlinked_entries_count,
)
pw.setWindowTitle(Translations["entries.unlinked.relink.title"])
pw.from_iterable_function(self.tracker.fix_unlinked_entries, displayed_text, self.done.emit)

View File

@@ -17,7 +17,7 @@ from PySide6.QtWidgets import (
QWidget,
)
from tagstudio.core.utils.missing_files import MissingRegistry
from tagstudio.core.utils.ignored_registry import IgnoredRegistry
from tagstudio.qt.helpers.custom_runnable import CustomRunnable
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.progress import ProgressWidget
@@ -27,14 +27,14 @@ if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
class DeleteUnlinkedEntriesModal(QWidget):
class RemoveIgnoredModal(QWidget):
done = Signal()
def __init__(self, driver: "QtDriver", tracker: MissingRegistry):
def __init__(self, driver: "QtDriver", tracker: IgnoredRegistry):
super().__init__()
self.driver = driver
self.tracker = tracker
self.setWindowTitle(Translations["entries.unlinked.delete"])
self.setWindowTitle(Translations["entries.ignored.remove"])
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.setMinimumSize(500, 400)
self.root_layout = QVBoxLayout(self)
@@ -42,8 +42,8 @@ class DeleteUnlinkedEntriesModal(QWidget):
self.desc_widget = QLabel(
Translations.format(
"entries.unlinked.delete.confirm",
count=self.tracker.missing_file_entries_count,
"entries.remove.plural.confirm",
count=self.tracker.ignored_count,
)
)
self.desc_widget.setObjectName("descriptionLabel")
@@ -64,7 +64,7 @@ class DeleteUnlinkedEntriesModal(QWidget):
self.cancel_button.clicked.connect(self.hide)
self.button_layout.addWidget(self.cancel_button)
self.delete_button = QPushButton(Translations["generic.delete_alt"])
self.delete_button = QPushButton(Translations["generic.remove_alt"])
self.delete_button.clicked.connect(self.hide)
self.delete_button.clicked.connect(lambda: self.delete_entries())
self.button_layout.addWidget(self.delete_button)
@@ -75,13 +75,11 @@ class DeleteUnlinkedEntriesModal(QWidget):
def refresh_list(self):
self.desc_widget.setText(
Translations.format(
"entries.unlinked.delete.confirm", count=self.tracker.missing_file_entries_count
)
Translations.format("entries.remove.plural.confirm", count=self.tracker.ignored_count)
)
self.model.clear()
for i in self.tracker.missing_file_entries:
for i in self.tracker.ignored_entries:
item = QStandardItem(str(i.path))
item.setEditable(False)
self.model.appendRow(item)
@@ -92,11 +90,15 @@ class DeleteUnlinkedEntriesModal(QWidget):
minimum=0,
maximum=0,
)
pw.setWindowTitle(Translations["entries.unlinked.delete.deleting"])
pw.update_label(Translations["entries.unlinked.delete.deleting"])
pw.setWindowTitle(Translations["entries.generic.remove.removing"])
pw.update_label(
Translations.format(
"entries.generic.remove.removing_count", count=self.tracker.ignored_count
)
)
pw.show()
r = CustomRunnable(self.tracker.execute_deletion)
r = CustomRunnable(self.tracker.remove_ignored_entries)
QThreadPool.globalInstance().start(r)
r.done.connect(
lambda: (

View File

@@ -0,0 +1,119 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from typing import TYPE_CHECKING, override
from PySide6 import QtCore, QtGui
from PySide6.QtCore import Qt, QThreadPool, Signal
from PySide6.QtGui import QStandardItem, QStandardItemModel
from PySide6.QtWidgets import (
QHBoxLayout,
QLabel,
QListView,
QPushButton,
QVBoxLayout,
QWidget,
)
from tagstudio.core.utils.unlinked_registry import UnlinkedRegistry
from tagstudio.qt.helpers.custom_runnable import CustomRunnable
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.progress import ProgressWidget
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
class RemoveUnlinkedEntriesModal(QWidget):
done = Signal()
def __init__(self, driver: "QtDriver", tracker: UnlinkedRegistry):
super().__init__()
self.driver = driver
self.tracker = tracker
self.setWindowTitle(Translations["entries.unlinked.remove"])
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.setMinimumSize(500, 400)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.desc_widget = QLabel(
Translations.format(
"entries.remove.plural.confirm",
count=self.tracker.unlinked_entries_count,
)
)
self.desc_widget.setObjectName("descriptionLabel")
self.desc_widget.setWordWrap(True)
self.desc_widget.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.list_view = QListView()
self.model = QStandardItemModel()
self.list_view.setModel(self.model)
self.button_container = QWidget()
self.button_layout = QHBoxLayout(self.button_container)
self.button_layout.setContentsMargins(6, 6, 6, 6)
self.button_layout.addStretch(1)
self.cancel_button = QPushButton(Translations["generic.cancel_alt"])
self.cancel_button.setDefault(True)
self.cancel_button.clicked.connect(self.hide)
self.button_layout.addWidget(self.cancel_button)
self.delete_button = QPushButton(Translations["generic.remove_alt"])
self.delete_button.clicked.connect(self.hide)
self.delete_button.clicked.connect(lambda: self.remove_entries())
self.button_layout.addWidget(self.delete_button)
self.root_layout.addWidget(self.desc_widget)
self.root_layout.addWidget(self.list_view)
self.root_layout.addWidget(self.button_container)
def refresh_list(self):
self.desc_widget.setText(
Translations.format(
"entries.remove.plural.confirm", count=self.tracker.unlinked_entries_count
)
)
self.model.clear()
for i in self.tracker.unlinked_entries:
item = QStandardItem(str(i.path))
item.setEditable(False)
self.model.appendRow(item)
def remove_entries(self):
pw = ProgressWidget(
cancel_button_text=None,
minimum=0,
maximum=0,
)
pw.setWindowTitle(Translations["entries.generic.remove.removing"])
pw.update_label(
Translations.format(
"entries.generic.remove.removing_count", count=self.tracker.unlinked_entries_count
)
)
pw.show()
r = CustomRunnable(self.tracker.remove_unlinked_entries)
QThreadPool.globalInstance().start(r)
r.done.connect(
lambda: (
pw.hide(),
pw.deleteLater(),
self.done.emit(),
)
)
@override
def keyPressEvent(self, event: QtGui.QKeyEvent) -> None: # noqa N802
if event.key() == QtCore.Qt.Key.Key_Escape:
self.cancel_button.click()
else: # Other key presses
pass
return super().keyPressEvent(event)

View File

@@ -3,13 +3,16 @@
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any
import structlog
from PySide6.QtCore import Qt
from PySide6.QtGui import QDoubleValidator
from PySide6.QtWidgets import (
QCheckBox,
QComboBox,
QFormLayout,
QHBoxLayout,
QLabel,
QLineEdit,
QTabWidget,
@@ -18,65 +21,72 @@ from PySide6.QtWidgets import (
)
from tagstudio.core.enums import ShowFilepathOption, TagClickActionOption
from tagstudio.core.global_settings import Theme
from tagstudio.core.global_settings import (
DEFAULT_THUMB_CACHE_SIZE,
MIN_THUMB_CACHE_SIZE,
Splash,
Theme,
)
from tagstudio.qt.translations import DEFAULT_TRANSLATION, LANGUAGES, Translations
from tagstudio.qt.widgets.panel import PanelModal, PanelWidget
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
FILEPATH_OPTION_MAP: dict[ShowFilepathOption, str] = {}
THEME_MAP: dict[Theme, str] = {}
TAG_CLICK_ACTION_MAP: dict[TagClickActionOption, str] = {}
DATE_FORMAT_MAP: dict[str, str] = {
"%d/%m/%y": "21/08/24",
"%d/%m/%Y": "21/08/2024",
"%d.%m.%y": "21.08.24",
"%d.%m.%Y": "21.08.2024",
"%d-%m-%y": "21-08-24",
"%d-%m-%Y": "21-08-2024",
"%x": "08/21/24",
"%m/%d/%Y": "08/21/2024",
"%m-%d-%y": "08-21-24",
"%m-%d-%Y": "08-21-2024",
"%m.%d.%y": "08.21.24",
"%m.%d.%Y": "08.21.2024",
"%Y/%m/%d": "2024/08/21",
"%Y-%m-%d": "2024-08-21",
"%Y.%m.%d": "2024.08.21",
}
logger = structlog.get_logger(__name__)
class SettingsPanel(PanelWidget):
driver: "QtDriver"
filepath_option_map: dict[ShowFilepathOption, str] = {
ShowFilepathOption.SHOW_FULL_PATHS: Translations["settings.filepath.option.full"],
ShowFilepathOption.SHOW_RELATIVE_PATHS: Translations["settings.filepath.option.relative"],
ShowFilepathOption.SHOW_FILENAMES_ONLY: Translations["settings.filepath.option.name"],
}
theme_map: dict[Theme, str] = {
Theme.SYSTEM: Translations["settings.theme.system"],
Theme.DARK: Translations["settings.theme.dark"],
Theme.LIGHT: Translations["settings.theme.light"],
}
splash_map: dict[Splash, str] = {
Splash.DEFAULT: Translations["settings.splash.option.default"],
Splash.RANDOM: Translations["settings.splash.option.random"],
Splash.CLASSIC: Translations["settings.splash.option.classic"],
Splash.GOO_GEARS: Translations["settings.splash.option.goo_gears"],
Splash.NINETY_FIVE: Translations["settings.splash.option.ninety_five"],
}
tag_click_action_map: dict[TagClickActionOption, str] = {
TagClickActionOption.OPEN_EDIT: Translations["settings.tag_click_action.open_edit"],
TagClickActionOption.SET_SEARCH: Translations["settings.tag_click_action.set_search"],
TagClickActionOption.ADD_TO_SEARCH: Translations["settings.tag_click_action.add_to_search"],
}
date_format_map: dict[str, str] = {
"%d/%m/%y": "21/08/24",
"%d/%m/%Y": "21/08/2024",
"%d.%m.%y": "21.08.24",
"%d.%m.%Y": "21.08.2024",
"%d-%m-%y": "21-08-24",
"%d-%m-%Y": "21-08-2024",
"%x": "08/21/24",
"%m/%d/%Y": "08/21/2024",
"%m-%d-%y": "08-21-24",
"%m-%d-%Y": "08-21-2024",
"%m.%d.%y": "08.21.24",
"%m.%d.%Y": "08.21.2024",
"%Y/%m/%d": "2024/08/21",
"%Y-%m-%d": "2024-08-21",
"%Y.%m.%d": "2024.08.21",
}
def __init__(self, driver: "QtDriver"):
super().__init__()
# set these "constants" because language will be loaded from config shortly after startup
# and we want to use the current language for the dropdowns
global FILEPATH_OPTION_MAP, THEME_MAP, TAG_CLICK_ACTION_MAP
FILEPATH_OPTION_MAP = {
ShowFilepathOption.SHOW_FULL_PATHS: Translations["settings.filepath.option.full"],
ShowFilepathOption.SHOW_RELATIVE_PATHS: Translations[
"settings.filepath.option.relative"
],
ShowFilepathOption.SHOW_FILENAMES_ONLY: Translations["settings.filepath.option.name"],
}
THEME_MAP = {
Theme.DARK: Translations["settings.theme.dark"],
Theme.LIGHT: Translations["settings.theme.light"],
Theme.SYSTEM: Translations["settings.theme.system"],
}
TAG_CLICK_ACTION_MAP = {
TagClickActionOption.OPEN_EDIT: Translations["settings.tag_click_action.open_edit"],
TagClickActionOption.SET_SEARCH: Translations["settings.tag_click_action.set_search"],
TagClickActionOption.ADD_TO_SEARCH: Translations[
"settings.tag_click_action.add_to_search"
],
}
self.driver = driver
self.setMinimumSize(400, 300)
@@ -84,6 +94,8 @@ class SettingsPanel(PanelWidget):
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(0, 6, 0, 0)
self.library_settings_container = QWidget()
# Tabs
self.tab_widget = QTabWidget()
@@ -135,6 +147,30 @@ class SettingsPanel(PanelWidget):
Translations["settings.open_library_on_start"], self.open_last_lib_checkbox
)
# Generate Thumbnails
self.generate_thumbs = QCheckBox()
self.generate_thumbs.setChecked(self.driver.settings.generate_thumbs)
form_layout.addRow(Translations["settings.generate_thumbs"], self.generate_thumbs)
# Thumbnail Cache Size
self.thumb_cache_size_container = QWidget()
self.thumb_cache_size_layout = QHBoxLayout(self.thumb_cache_size_container)
self.thumb_cache_size_layout.setContentsMargins(0, 0, 0, 0)
self.thumb_cache_size_layout.setSpacing(6)
self.thumb_cache_size = QLineEdit()
self.thumb_cache_size.setAlignment(Qt.AlignmentFlag.AlignRight)
self.validator = QDoubleValidator(MIN_THUMB_CACHE_SIZE, 1_000_000_000, 2) # High limit
self.thumb_cache_size.setValidator(self.validator)
self.thumb_cache_size.setText(
str(max(self.driver.settings.thumb_cache_size, MIN_THUMB_CACHE_SIZE)).removesuffix(".0")
)
self.thumb_cache_size_layout.addWidget(self.thumb_cache_size)
self.thumb_cache_size_layout.setStretch(1, 2)
self.thumb_cache_size_layout.addWidget(QLabel("MiB"))
form_layout.addRow(
Translations["settings.thumb_cache_size.label"], self.thumb_cache_size_container
)
# Autoplay
self.autoplay_checkbox = QCheckBox()
self.autoplay_checkbox.setChecked(self.driver.settings.autoplay)
@@ -161,49 +197,61 @@ class SettingsPanel(PanelWidget):
# Show Filepath
self.filepath_combobox = QComboBox()
for k in FILEPATH_OPTION_MAP:
self.filepath_combobox.addItem(FILEPATH_OPTION_MAP[k], k)
for k in SettingsPanel.filepath_option_map:
self.filepath_combobox.addItem(SettingsPanel.filepath_option_map[k], k)
filepath_option: ShowFilepathOption = self.driver.settings.show_filepath
if filepath_option not in FILEPATH_OPTION_MAP:
if filepath_option not in SettingsPanel.filepath_option_map:
filepath_option = ShowFilepathOption.DEFAULT
self.filepath_combobox.setCurrentIndex(
list(FILEPATH_OPTION_MAP.keys()).index(filepath_option)
list(SettingsPanel.filepath_option_map.keys()).index(filepath_option)
)
form_layout.addRow(Translations["settings.filepath.label"], self.filepath_combobox)
# Dark Mode
self.theme_combobox = QComboBox()
for k in THEME_MAP:
self.theme_combobox.addItem(THEME_MAP[k], k)
theme = self.driver.settings.theme
if theme not in THEME_MAP:
theme = Theme.DEFAULT
self.theme_combobox.setCurrentIndex(list(THEME_MAP.keys()).index(theme))
self.theme_combobox.currentIndexChanged.connect(self.__update_restart_label)
form_layout.addRow(Translations["settings.theme.label"], self.theme_combobox)
# Tag Click Action
self.tag_click_action_combobox = QComboBox()
for k in TAG_CLICK_ACTION_MAP:
self.tag_click_action_combobox.addItem(TAG_CLICK_ACTION_MAP[k], k)
for k in SettingsPanel.tag_click_action_map:
self.tag_click_action_combobox.addItem(SettingsPanel.tag_click_action_map[k], k)
tag_click_action = self.driver.settings.tag_click_action
if tag_click_action not in TAG_CLICK_ACTION_MAP:
if tag_click_action not in SettingsPanel.tag_click_action_map:
tag_click_action = TagClickActionOption.DEFAULT
self.tag_click_action_combobox.setCurrentIndex(
list(TAG_CLICK_ACTION_MAP.keys()).index(tag_click_action)
list(SettingsPanel.tag_click_action_map.keys()).index(tag_click_action)
)
form_layout.addRow(
Translations["settings.tag_click_action.label"], self.tag_click_action_combobox
)
# Dark Mode
self.theme_combobox = QComboBox()
for k in SettingsPanel.theme_map:
self.theme_combobox.addItem(SettingsPanel.theme_map[k], k)
theme = self.driver.settings.theme
if theme not in SettingsPanel.theme_map:
theme = Theme.DEFAULT
self.theme_combobox.setCurrentIndex(list(SettingsPanel.theme_map.keys()).index(theme))
self.theme_combobox.currentIndexChanged.connect(self.__update_restart_label)
form_layout.addRow(Translations["settings.theme.label"], self.theme_combobox)
# Splash Screen
self.splash_combobox = QComboBox()
for k in SettingsPanel.splash_map:
self.splash_combobox.addItem(SettingsPanel.splash_map[k], k)
splash = self.driver.settings.splash
if splash not in SettingsPanel.splash_map:
splash = Splash.DEFAULT
self.splash_combobox.setCurrentIndex(list(SettingsPanel.splash_map.keys()).index(splash))
form_layout.addRow(Translations["settings.splash.label"], self.splash_combobox)
# Date Format
self.dateformat_combobox = QComboBox()
for k in DATE_FORMAT_MAP:
self.dateformat_combobox.addItem(DATE_FORMAT_MAP[k], k)
for k in SettingsPanel.date_format_map:
self.dateformat_combobox.addItem(SettingsPanel.date_format_map[k], k)
dateformat: str = self.driver.settings.date_format
if dateformat not in DATE_FORMAT_MAP:
if dateformat not in SettingsPanel.date_format_map:
dateformat = "%x"
self.dateformat_combobox.setCurrentIndex(list(DATE_FORMAT_MAP.keys()).index(dateformat))
self.dateformat_combobox.setCurrentIndex(
list(SettingsPanel.date_format_map.keys()).index(dateformat)
)
self.dateformat_combobox.currentIndexChanged.connect(self.__update_restart_label)
form_layout.addRow(Translations["settings.dateformat.label"], self.dateformat_combobox)
@@ -217,8 +265,8 @@ class SettingsPanel(PanelWidget):
self.zeropadding_checkbox.setChecked(self.driver.settings.zero_padding)
form_layout.addRow(Translations["settings.zeropadding.label"], self.zeropadding_checkbox)
def __build_library_settings(self):
self.library_settings_container = QWidget()
# TODO: Implement Library Settings
def __build_library_settings(self): # pyright: ignore[reportUnusedFunction]
form_layout = QFormLayout(self.library_settings_container)
form_layout.setContentsMargins(6, 6, 6, 6)
@@ -228,10 +276,15 @@ class SettingsPanel(PanelWidget):
def __get_language(self) -> str:
return list(LANGUAGES.values())[self.language_combobox.currentIndex()]
def get_settings(self) -> dict:
def get_settings(self) -> dict[str, Any]: # pyright: ignore[reportExplicitAny]
return {
"language": self.__get_language(),
"open_last_loaded_on_startup": self.open_last_lib_checkbox.isChecked(),
"generate_thumbs": self.generate_thumbs.isChecked(),
"thumb_cache_size": max(
float(self.thumb_cache_size.text()) or DEFAULT_THUMB_CACHE_SIZE,
MIN_THUMB_CACHE_SIZE,
),
"autoplay": self.autoplay_checkbox.isChecked(),
"show_filenames_in_grid": self.show_filenames_checkbox.isChecked(),
"page_size": int(self.page_size_line_edit.text()),
@@ -241,6 +294,7 @@ class SettingsPanel(PanelWidget):
"date_format": self.dateformat_combobox.currentData(),
"hour_format": self.hourformat_checkbox.isChecked(),
"zero_padding": self.zeropadding_checkbox.isChecked(),
"splash": self.splash_combobox.currentData(),
}
def update_settings(self, driver: "QtDriver"):
@@ -249,6 +303,8 @@ class SettingsPanel(PanelWidget):
driver.settings.language = settings["language"]
driver.settings.open_last_loaded_on_startup = settings["open_last_loaded_on_startup"]
driver.settings.autoplay = settings["autoplay"]
driver.settings.generate_thumbs = settings["generate_thumbs"]
driver.settings.thumb_cache_size = settings["thumb_cache_size"]
driver.settings.show_filenames_in_grid = settings["show_filenames_in_grid"]
driver.settings.page_size = settings["page_size"]
driver.settings.show_filepath = settings["show_filepath"]
@@ -257,6 +313,7 @@ class SettingsPanel(PanelWidget):
driver.settings.date_format = settings["date_format"]
driver.settings.hour_format = settings["hour_format"]
driver.settings.zero_padding = settings["zero_padding"]
driver.settings.splash = settings["splash"]
driver.settings.save()

View File

@@ -19,8 +19,7 @@ from PySide6.QtWidgets import (
)
from tagstudio.core.library.alchemy.enums import TagColorEnum
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import TagColorGroup
from tagstudio.core.library.alchemy.library import Library, TagColorGroup
from tagstudio.core.palette import ColorType, get_tag_color
from tagstudio.qt.flowlayout import FlowLayout
from tagstudio.qt.translations import Translations

View File

@@ -7,8 +7,7 @@ import structlog
from PySide6.QtWidgets import QMessageBox, QPushButton
from tagstudio.core.constants import RESERVED_TAG_END, RESERVED_TAG_START
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.core.library.alchemy.library import Library, Tag
from tagstudio.qt.modals.build_tag import BuildTagPanel
from tagstudio.qt.modals.tag_search import TagSearchPanel
from tagstudio.qt.translations import Translations
@@ -62,7 +61,7 @@ class TagDatabasePanel(TagSearchPanel):
message_box = QMessageBox(
QMessageBox.Question, # type: ignore
Translations["tag.remove"],
Translations.format("tag.confirm_delete", tag_name=self.lib.tag_display_name(tag.id)),
Translations.format("tag.confirm_delete", tag_name=self.lib.tag_display_name(tag)),
QMessageBox.Ok | QMessageBox.Cancel, # type: ignore
)

View File

@@ -25,8 +25,7 @@ from PySide6.QtWidgets import (
from tagstudio.core.constants import RESERVED_TAG_END, RESERVED_TAG_START
from tagstudio.core.library.alchemy.enums import BrowsingState, TagColorEnum
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.core.library.alchemy.library import Library, Tag
from tagstudio.core.palette import ColorType, get_tag_color
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.panel import PanelModal, PanelWidget
@@ -213,11 +212,8 @@ class TagSearchPanel(PanelWidget):
logger.info("[TagSearchPanel] Updating Tags")
# Remove the "Create & Add" button if one exists
create_button: QPushButton | None = None
if self.create_button_in_layout and self.scroll_layout.count():
create_button = self.scroll_layout.takeAt(self.scroll_layout.count() - 1).widget() # type: ignore
assert create_button is not None
create_button.deleteLater()
self.scroll_layout.takeAt(self.scroll_layout.count() - 1).widget().deleteLater()
self.create_button_in_layout = False
# Get results for the search query
@@ -316,7 +312,9 @@ class TagSearchPanel(PanelWidget):
tag_widget.search_for_tag_action.triggered.connect(
lambda checked=False, tag_id=tag.id, driver=self.driver: (
driver.main_window.search_field.setText(f"tag_id:{tag_id}"),
driver.update_browsing_state(BrowsingState.from_tag_id(tag_id)),
driver.update_browsing_state(
BrowsingState.from_tag_id(tag_id, driver.browsing_history.current)
),
)
)
tag_widget.search_for_tag_action.setEnabled(True)
@@ -388,7 +386,7 @@ class TagSearchPanel(PanelWidget):
self.edit_modal = PanelModal(
build_tag_panel,
self.lib.tag_display_name(tag.id),
self.lib.tag_display_name(tag),
Translations["tag.edit"],
done_callback=(self.update_tags(self.search_field.text())),
has_save=True,

View File

@@ -5,6 +5,8 @@
"""A pagination widget created for TagStudio."""
from typing import override
from PIL import Image, ImageQt
from PySide6.QtCore import QObject, QSize, Signal
from PySide6.QtGui import QIntValidator, QPixmap
@@ -285,9 +287,10 @@ class Pagination(QWidget, QObject):
class Validator(QIntValidator):
def __init__(self, bottom: int, top: int, parent=None) -> None:
super().__init__(bottom, top, parent)
def __init__(self, bottom: int, top: int) -> None:
super().__init__(bottom, top)
@override
def fixup(self, input: str) -> str:
input = input.strip("0")
return super().fixup(str(self.top()) if input else "1")

View File

@@ -1,134 +1,150 @@
{
"splash_classic": {
"path": "qt/images/splash/classic.png",
"mode": "qpixmap"
},
"splash_goo_gears": {
"path": "qt/images/splash/goo_gears.png",
"mode": "qpixmap"
},
"icon": {
"path": "icon.png",
"mode": "pil"
},
"play_icon": {
"path": "qt/images/play.svg",
"mode": "rb"
},
"pause_icon": {
"path": "qt/images/pause.svg",
"mode": "rb"
},
"volume_icon": {
"path": "qt/images/volume.svg",
"mode": "rb"
},
"volume_mute_icon": {
"path": "qt/images/volume_mute.svg",
"mode": "rb"
},
"broken_link_icon": {
"path": "qt/images/broken_link_icon.png",
"mode": "pil"
},
"adobe_illustrator": {
"path": "qt/images/file_icons/adobe_illustrator.png",
"mode": "pil"
},
"adobe_photoshop": {
"path": "qt/images/file_icons/adobe_photoshop.png",
"mode": "pil"
},
"affinity_photo": {
"path": "qt/images/file_icons/affinity_photo.png",
"mode": "pil"
},
"archive": {
"path": "qt/images/file_icons/archive.png",
"mode": "pil"
},
"audio": {
"path": "qt/images/file_icons/audio.png",
"mode": "pil"
},
"blender": {
"path": "qt/images/file_icons/blender.png",
"mode": "pil"
},
"database": {
"path": "qt/images/file_icons/database.png",
"mode": "pil"
},
"document": {
"path": "qt/images/file_icons/document.png",
"mode": "pil"
},
"ebook": {
"path": "qt/images/file_icons/ebook.png",
"mode": "pil"
},
"file_generic": {
"path": "qt/images/file_icons/file_generic.png",
"mode": "pil"
},
"font": {
"path": "qt/images/file_icons/font.png",
"mode": "pil"
},
"image": {
"path": "qt/images/file_icons/image.png",
"mode": "pil"
},
"image_vector": {
"path": "qt/images/file_icons/image_vector.png",
"mode": "pil"
},
"material": {
"path": "qt/images/file_icons/material.png",
"mode": "pil"
},
"model": {
"path": "qt/images/file_icons/model.png",
"mode": "pil"
},
"presentation": {
"path": "qt/images/file_icons/presentation.png",
"mode": "pil"
},
"program": {
"path": "qt/images/file_icons/program.png",
"mode": "pil"
},
"shader": {
"path": "qt/images/file_icons/shader.png",
"mode": "pil"
},
"shortcut": {
"path": "qt/images/file_icons/shortcut.png",
"mode": "pil"
},
"spreadsheet": {
"path": "qt/images/file_icons/spreadsheet.png",
"mode": "pil"
},
"text": {
"path": "qt/images/file_icons/text.png",
"mode": "pil"
},
"video": {
"path": "qt/images/file_icons/video.png",
"mode": "pil"
},
"thumb_loading": {
"path": "qt/images/thumb_loading.png",
"mode": "pil"
},
"bxs-left-arrow": {
"path": "qt/images/bxs-left-arrow.png",
"mode": "pil"
},
"bxs-right-arrow": {
"path": "qt/images/bxs-right-arrow.png",
"mode": "pil"
}
"splash_classic": {
"path": "qt/images/splash/classic.png",
"mode": "qpixmap"
},
"splash_goo_gears": {
"path": "qt/images/splash/goo_gears.png",
"mode": "qpixmap"
},
"splash_95": {
"path": "qt/images/splash/95.png",
"mode": "qpixmap"
},
"icon": {
"path": "icon.png",
"mode": "pil"
},
"play_icon": {
"path": "qt/images/play.svg",
"mode": "rb"
},
"pause_icon": {
"path": "qt/images/pause.svg",
"mode": "rb"
},
"volume_icon": {
"path": "qt/images/volume.svg",
"mode": "rb"
},
"volume_mute_icon": {
"path": "qt/images/volume_mute.svg",
"mode": "rb"
},
"broken_link_icon": {
"path": "qt/images/broken_link_icon.png",
"mode": "pil"
},
"ignored": {
"path": "qt/images/ignored_128.png",
"mode": "pil"
},
"adobe_illustrator": {
"path": "qt/images/file_icons/adobe_illustrator.png",
"mode": "pil"
},
"adobe_photoshop": {
"path": "qt/images/file_icons/adobe_photoshop.png",
"mode": "pil"
},
"affinity_photo": {
"path": "qt/images/file_icons/affinity_photo.png",
"mode": "pil"
},
"archive": {
"path": "qt/images/file_icons/archive.png",
"mode": "pil"
},
"audio": {
"path": "qt/images/file_icons/audio.png",
"mode": "pil"
},
"database": {
"path": "qt/images/file_icons/database.png",
"mode": "pil"
},
"document": {
"path": "qt/images/file_icons/document.png",
"mode": "pil"
},
"ebook": {
"path": "qt/images/file_icons/ebook.png",
"mode": "pil"
},
"file_generic": {
"path": "qt/images/file_icons/file_generic.png",
"mode": "pil"
},
"font": {
"path": "qt/images/file_icons/font.png",
"mode": "pil"
},
"image": {
"path": "qt/images/file_icons/image.png",
"mode": "pil"
},
"image_vector": {
"path": "qt/images/file_icons/image_vector.png",
"mode": "pil"
},
"material": {
"path": "qt/images/file_icons/material.png",
"mode": "pil"
},
"model": {
"path": "qt/images/file_icons/model.png",
"mode": "pil"
},
"presentation": {
"path": "qt/images/file_icons/presentation.png",
"mode": "pil"
},
"program": {
"path": "qt/images/file_icons/program.png",
"mode": "pil"
},
"shader": {
"path": "qt/images/file_icons/shader.png",
"mode": "pil"
},
"shortcut": {
"path": "qt/images/file_icons/shortcut.png",
"mode": "pil"
},
"spreadsheet": {
"path": "qt/images/file_icons/spreadsheet.png",
"mode": "pil"
},
"text": {
"path": "qt/images/file_icons/text.png",
"mode": "pil"
},
"video": {
"path": "qt/images/file_icons/video.png",
"mode": "pil"
},
"thumb_loading": {
"path": "qt/images/thumb_loading.png",
"mode": "pil"
},
"bxs-left-arrow": {
"path": "qt/images/bxs-left-arrow.png",
"mode": "pil"
},
"bxs-right-arrow": {
"path": "qt/images/bxs-right-arrow.png",
"mode": "pil"
},
"unlinked_stat": {
"path": "qt/images/unlinked_stat.png",
"mode": "pil"
},
"ignored_stat": {
"path": "qt/images/ignored_stat.png",
"mode": "pil"
},
"dupe_file_stat": {
"path": "qt/images/dupe_file_stat.png",
"mode": "pil"
}
}

View File

@@ -4,6 +4,7 @@
import math
import random
import structlog
from PySide6.QtCore import QRect, Qt
@@ -11,12 +12,13 @@ from PySide6.QtGui import QColor, QFont, QPainter, QPen, QPixmap
from PySide6.QtWidgets import QSplashScreen, QWidget
from tagstudio.core.constants import VERSION, VERSION_BRANCH
from tagstudio.core.global_settings import Splash
from tagstudio.qt.resource_manager import ResourceManager
logger = structlog.get_logger(__name__)
class Splash:
class SplashScreen:
"""The custom splash screen widget for TagStudio."""
COPYRIGHT_YEARS: str = "2021-2025"
@@ -24,11 +26,7 @@ class Splash:
VERSION_STR: str = (
f"Version {VERSION} {(' (' + VERSION_BRANCH + ')') if VERSION_BRANCH else ''}"
)
SPLASH_CLASSIC: str = "classic"
SPLASH_GOO_GEARS: str = "goo_gears"
SPLASH_95: str = "95"
DEFAULT_SPLASH: str = SPLASH_GOO_GEARS
DEFAULT_SPLASH = Splash.GOO_GEARS
def __init__(
self,
@@ -41,11 +39,19 @@ class Splash:
self.screen_width = screen_width
self.ratio: float = device_ratio
self.splash_screen: QSplashScreen | None = None
self.splash_name: str = splash_name if splash_name else Splash.DEFAULT_SPLASH
if not splash_name or splash_name == Splash.DEFAULT:
self.splash_name: str = SplashScreen.DEFAULT_SPLASH
elif splash_name == Splash.RANDOM:
splash_list = list(Splash)
splash_list.remove(Splash.DEFAULT)
splash_list.remove(Splash.RANDOM)
self.splash_name = random.choice(splash_list)
else:
self.splash_name = splash_name
def get_pixmap(self) -> QPixmap:
"""Get the pixmap used for the splash screen."""
pixmap: QPixmap | None = self.rm.get(f"splash_{self.splash_name}")
pixmap: QPixmap | None = self.rm.get(f"splash_{self.splash_name}") # pyright: ignore[reportAssignmentType]
if not pixmap:
logger.error("[Splash] Splash screen not found:", splash_name=self.splash_name)
pixmap = QPixmap(960, 540)
@@ -55,10 +61,12 @@ class Splash:
match painter.font().family():
case "Segoe UI":
point_size_scale = 0.75
case _:
pass
# TODO: Store any differing data elsewhere and load dynamically instead of hardcoding.
match self.splash_name:
case Splash.SPLASH_CLASSIC:
case Splash.CLASSIC:
# Copyright
font = painter.font()
font.setPointSize(math.floor(22 * point_size_scale))
@@ -68,7 +76,7 @@ class Splash:
painter.drawText(
QRect(0, -50, 960, 540),
int(Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignHCenter),
Splash.COPYRIGHT_STR,
SplashScreen.COPYRIGHT_STR,
)
# Version
pen = QPen(QColor("#809782ff"))
@@ -76,10 +84,10 @@ class Splash:
painter.drawText(
QRect(0, -25, 960, 540),
int(Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignHCenter),
Splash.VERSION_STR,
SplashScreen.VERSION_STR,
)
case Splash.SPLASH_GOO_GEARS:
case Splash.GOO_GEARS:
# Copyright
font = painter.font()
font.setPointSize(math.floor(22 * point_size_scale))
@@ -88,7 +96,7 @@ class Splash:
painter.setPen(pen)
painter.drawText(
QRect(40, 450, 960, 540),
Splash.COPYRIGHT_STR,
SplashScreen.COPYRIGHT_STR,
)
# Version
font = painter.font()
@@ -98,10 +106,10 @@ class Splash:
painter.setPen(pen)
painter.drawText(
QRect(40, 475, 960, 540),
Splash.VERSION_STR,
SplashScreen.VERSION_STR,
)
case Splash.SPLASH_95:
case Splash.NINETY_FIVE:
# Copyright
font = QFont()
font.setFamily("Times")
@@ -114,7 +122,7 @@ class Splash:
painter.drawText(
QRect(88, -25, 960, 540),
int(Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignLeft),
Splash.COPYRIGHT_STR,
SplashScreen.COPYRIGHT_STR,
)
# Version
font.setPointSize(math.floor(22 * point_size_scale))
@@ -124,7 +132,7 @@ class Splash:
painter.drawText(
QRect(-30, 25, 960, 540),
int(Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight),
Splash.VERSION_STR,
SplashScreen.VERSION_STR,
)
case _:

View File

@@ -6,15 +6,16 @@ from typing import Any
import structlog
import ujson
from tagstudio.qt.mnemonics import remove_mnemonic_marker
logger = structlog.get_logger(__name__)
DEFAULT_TRANSLATION = "en"
LANGUAGES = {
# "Cantonese (Traditional)": "yue_Hant", # Empty
"Chinese (Simplified)": "zh_Hans",
"Chinese (Traditional)": "zh_Hant",
# "Czech": "cs", # Minimal
"Czech": "cs",
# "Danish": "da", # Minimal
"Dutch": "nl",
"English": "en",
@@ -27,7 +28,8 @@ LANGUAGES = {
"Norwegian Bokmål": "nb_NO",
"Polish": "pl",
"Portuguese (Brazil)": "pt_BR",
# "Portuguese (Portugal)": "pt", # Empty
"Portuguese (Portugal)": "pt",
"Romanian": "ro",
"Russian": "ru",
"Spanish": "es",
"Swedish": "sv",
@@ -61,9 +63,7 @@ class Translator:
self._strings = self.__get_translation_dict(lang)
if system() == "Darwin":
for k, v in self._strings.items():
self._strings[k] = (
v.replace("&&", "<ESC_AMP>").replace("&", "", 1).replace("<ESC_AMP>", "&&")
)
self._strings[k] = remove_mnemonic_marker(v)
def __format(self, text: str, **kwargs) -> str:
try:

View File

@@ -45,28 +45,36 @@ from PySide6.QtWidgets import (
QScrollArea,
)
# this import has side-effect of import PySide resources
import tagstudio.qt.resources_rc # noqa: F401
from tagstudio.core.constants import TAG_ARCHIVED, TAG_FAVORITE, VERSION, VERSION_BRANCH
from tagstudio.core.driver import DriverMixin
from tagstudio.core.enums import MacroID, SettingItems, ShowFilepathOption
from tagstudio.core.global_settings import DEFAULT_GLOBAL_SETTINGS_PATH, GlobalSettings, Theme
from tagstudio.core.global_settings import (
DEFAULT_GLOBAL_SETTINGS_PATH,
GlobalSettings,
Theme,
)
from tagstudio.core.library.alchemy.enums import (
BrowsingState,
FieldTypeEnum,
ItemType,
SortingModeEnum,
)
from tagstudio.core.library.alchemy.fields import _FieldID
from tagstudio.core.library.alchemy.library import Library, LibraryStatus
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.library.alchemy.library import Entry, FieldID, Library, LibraryStatus
from tagstudio.core.library.ignore import Ignore
from tagstudio.core.media_types import MediaCategories
from tagstudio.core.palette import ColorType, UiColor, get_ui_color
from tagstudio.core.query_lang.util import ParsingError
from tagstudio.core.ts_core import TagStudioCore
from tagstudio.core.utils.refresh_dir import RefreshDirTracker
from tagstudio.core.utils.types import unwrap
from tagstudio.core.utils.web import strip_web_protocol
from tagstudio.qt.cache_manager import CacheManager
# this import has side-effect of import PySide resources
from tagstudio.qt.controller.fix_ignored_modal_controller import FixIgnoredEntriesModal
from tagstudio.qt.controller.widgets.ignore_modal_controller import IgnoreModal
from tagstudio.qt.controller.widgets.library_info_window_controller import LibraryInfoWindow
from tagstudio.qt.helpers.custom_runnable import CustomRunnable
from tagstudio.qt.helpers.file_deleter import delete_file
from tagstudio.qt.helpers.function_iterator import FunctionIterator
@@ -76,7 +84,6 @@ from tagstudio.qt.modals.about import AboutModal
from tagstudio.qt.modals.build_tag import BuildTagPanel
from tagstudio.qt.modals.drop_import import DropImportModal
from tagstudio.qt.modals.ffmpeg_checker import FfmpegChecker
from tagstudio.qt.modals.file_extension import FileExtensionModal
from tagstudio.qt.modals.fix_dupes import FixDupeFilesModal
from tagstudio.qt.modals.fix_unlinked import FixUnlinkedEntriesModal
from tagstudio.qt.modals.folders_to_tags import FoldersToTagsModal
@@ -86,7 +93,7 @@ from tagstudio.qt.modals.tag_database import TagDatabasePanel
from tagstudio.qt.modals.tag_search import TagSearchModal
from tagstudio.qt.platform_strings import trash_term
from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.splash import Splash
from tagstudio.qt.splash import SplashScreen
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.item_thumb import BadgeType, ItemThumb
from tagstudio.qt.widgets.migration_modal import JsonMigrationModal
@@ -172,16 +179,19 @@ class QtDriver(DriverMixin, QObject):
tag_manager_panel: PanelModal | None = None
color_manager_panel: TagColorManager | None = None
file_extension_panel: PanelModal | None = None
ignore_modal: PanelModal | None = None
add_tag_modal: PanelModal | None = None
folders_modal: FoldersToTagsModal
about_modal: AboutModal
unlinked_modal: FixUnlinkedEntriesModal
ignored_modal: FixIgnoredEntriesModal
dupe_modal: FixDupeFilesModal
library_info_window: LibraryInfoWindow
applied_theme: Theme
lib: Library
cache_manager: CacheManager
browsing_history: History[BrowsingState]
@@ -244,24 +254,6 @@ class QtDriver(DriverMixin, QObject):
Translations.change_language(self.settings.language)
# NOTE: This should be a per-library setting rather than an application setting.
thumb_cache_size_limit: int = int(
str(
self.cached_values.value(
SettingItems.THUMB_CACHE_SIZE_LIMIT,
defaultValue=CacheManager.size_limit,
type=int,
)
)
)
CacheManager.size_limit = thumb_cache_size_limit
self.cached_values.setValue(SettingItems.THUMB_CACHE_SIZE_LIMIT, CacheManager.size_limit)
self.cached_values.sync()
logger.info(
f"[Config] Thumbnail cache size limit: {format_size(CacheManager.size_limit)}",
)
def __reset_navigation(self) -> None:
self.browsing_history = History(BrowsingState.show_all())
@@ -337,10 +329,10 @@ class QtDriver(DriverMixin, QObject):
self.main_window.dragMoveEvent = self.drag_move_event
self.main_window.dropEvent = self.drop_event
self.splash: Splash = Splash(
self.splash: SplashScreen = SplashScreen(
resource_manager=self.rm,
screen_width=QGuiApplication.primaryScreen().geometry().width(),
splash_name="", # TODO: Get splash name from config
splash_name=self.settings.splash,
device_ratio=self.main_window.devicePixelRatio(),
)
self.splash.show()
@@ -363,9 +355,8 @@ class QtDriver(DriverMixin, QObject):
self.tag_manager_panel = PanelModal(
widget=TagDatabasePanel(self, self.lib),
title=Translations["tag_manager.title"],
done_callback=lambda s=self.selected: self.main_window.preview_panel.set_selection(
s, update_preview=False
),
done_callback=lambda checked=False,
s=self.selected: self.main_window.preview_panel.set_selection(s, update_preview=False),
has_save=False,
)
@@ -469,6 +460,13 @@ class QtDriver(DriverMixin, QObject):
# region View Menu ============================================================
def create_library_info_window():
if not hasattr(self, "library_info_window"):
self.library_info_window = LibraryInfoWindow(self.lib, self)
self.library_info_window.show()
self.main_window.menu_bar.library_info_action.triggered.connect(create_library_info_window)
def on_show_filenames_action(checked: bool):
self.settings.show_filenames_in_grid = checked
self.settings.save()
@@ -510,6 +508,15 @@ class QtDriver(DriverMixin, QObject):
create_fix_unlinked_entries_modal
)
def create_ignored_entries_modal():
if not hasattr(self, "ignored_modal"):
self.ignored_modal = FixIgnoredEntriesModal(self.lib, self)
self.ignored_modal.show()
self.main_window.menu_bar.fix_ignored_entries_action.triggered.connect(
create_ignored_entries_modal
)
def create_dupe_files_modal():
if not hasattr(self, "dupe_modal"):
self.dupe_modal = FixDupeFilesModal(self.lib, self)
@@ -519,7 +526,7 @@ class QtDriver(DriverMixin, QObject):
# TODO: Move this to a settings screen.
self.main_window.menu_bar.clear_thumb_cache_action.triggered.connect(
lambda: CacheManager.clear_cache(self.lib.library_dir)
lambda: self.cache_manager.clear_cache()
)
# endregion
@@ -663,27 +670,23 @@ class QtDriver(DriverMixin, QObject):
self.splash.finish(self.main_window)
def init_file_extension_manager(self):
"""Initialize the File Extension panel."""
if self.file_extension_panel:
def init_ignore_modal(self):
"""Initialize the Ignore Files panel."""
if self.ignore_modal:
with catch_warnings(record=True):
self.main_window.menu_bar.manage_file_ext_action.triggered.disconnect()
self.file_extension_panel.saved.disconnect()
self.file_extension_panel.deleteLater()
self.file_extension_panel = None
self.main_window.menu_bar.ignore_modal_action.triggered.disconnect()
self.ignore_modal.saved.disconnect()
self.ignore_modal.deleteLater()
self.ignore_modal = None
panel = FileExtensionModal(self.lib)
self.file_extension_panel = PanelModal(
panel = IgnoreModal(self.lib)
self.ignore_modal = PanelModal(
panel,
Translations["ignore_list.title"],
Translations["menu.edit.ignore_files"],
has_save=True,
)
self.file_extension_panel.saved.connect(
lambda: (panel.save(), self.update_browsing_state())
)
self.main_window.menu_bar.manage_file_ext_action.triggered.connect(
self.file_extension_panel.show
)
self.ignore_modal.saved.connect(panel.save)
self.main_window.menu_bar.ignore_modal_action.triggered.connect(self.ignore_modal.show)
def show_grid_filenames(self, value: bool):
for thumb in self.item_thumbs:
@@ -731,6 +734,7 @@ class QtDriver(DriverMixin, QObject):
self.__reset_navigation()
self.lib.close()
self.cache_manager = None
self.thumb_job_queue.queue.clear()
if is_shutdown:
@@ -748,6 +752,9 @@ class QtDriver(DriverMixin, QObject):
self.set_clipboard_menu_viability()
self.set_select_actions_visibility()
if hasattr(self, "library_info_window"):
self.library_info_window.close()
self.main_window.preview_panel.set_selection(self.selected)
self.main_window.toggle_landing_page(enabled=True)
self.main_window.pagination.setHidden(True)
@@ -757,12 +764,14 @@ class QtDriver(DriverMixin, QObject):
self.main_window.menu_bar.refresh_dir_action.setEnabled(False)
self.main_window.menu_bar.tag_manager_action.setEnabled(False)
self.main_window.menu_bar.color_manager_action.setEnabled(False)
self.main_window.menu_bar.manage_file_ext_action.setEnabled(False)
self.main_window.menu_bar.ignore_modal_action.setEnabled(False)
self.main_window.menu_bar.new_tag_action.setEnabled(False)
self.main_window.menu_bar.fix_unlinked_entries_action.setEnabled(False)
self.main_window.menu_bar.fix_ignored_entries_action.setEnabled(False)
self.main_window.menu_bar.fix_dupe_files_action.setEnabled(False)
self.main_window.menu_bar.clear_thumb_cache_action.setEnabled(False)
self.main_window.menu_bar.folders_to_tags_action.setEnabled(False)
self.main_window.menu_bar.library_info_action.setEnabled(False)
except AttributeError:
logger.warning(
"[Library] Could not disable library management menu actions. Is this in a test?"
@@ -1003,10 +1012,11 @@ class QtDriver(DriverMixin, QObject):
)
pw.setWindowTitle(Translations["library.refresh.title"])
pw.update_label(Translations["library.refresh.scanning_preparing"])
pw.show()
iterator = FunctionIterator(lambda: tracker.refresh_dir(self.lib.library_dir))
iterator = FunctionIterator(
lambda lib=unwrap(self.lib.library_dir): tracker.refresh_dir(lib) # noqa: B008
)
iterator.value.connect(
lambda x: (
pw.update_progress(x + 1),
@@ -1117,7 +1127,7 @@ class QtDriver(DriverMixin, QObject):
elif name == MacroID.BUILD_URL:
url = TagStudioCore.build_url(entry, source)
if url is not None:
self.lib.add_field_to_entry(entry.id, field_id=_FieldID.SOURCE, value=url)
self.lib.add_field_to_entry(entry.id, field_id=FieldID.SOURCE, value=url)
elif name == MacroID.MATCH:
TagStudioCore.match_conditions(self.lib, entry.id)
elif name == MacroID.CLEAN_URL:
@@ -1549,7 +1559,6 @@ class QtDriver(DriverMixin, QObject):
if not self.lib.library_dir:
logger.info("Library not loaded")
return
assert self.lib.engine
if state:
self.browsing_history.push(state)
@@ -1562,6 +1571,7 @@ class QtDriver(DriverMixin, QObject):
# search the library
start_time = time.time()
Ignore.get_patterns(self.lib.library_dir, include_global=True)
results = self.lib.search_library(self.browsing_history.current, self.settings.page_size)
logger.info("items to render", count=len(results))
end_time = time.time()
@@ -1685,6 +1695,10 @@ class QtDriver(DriverMixin, QObject):
open_status = LibraryStatus(
success=False, library_path=path, message=type(e).__name__, msg_description=str(e)
)
self.cache_manager = CacheManager(path, max_size=self.settings.thumb_cache_size)
logger.info(
f"[Config] Thumbnail Cache Size: {format_size(self.settings.thumb_cache_size)}",
)
# Migration is required
if open_status.json_migration_req:
@@ -1706,8 +1720,9 @@ class QtDriver(DriverMixin, QObject):
)
return open_status
assert self.lib.library_dir
self.init_workers()
Ignore.get_patterns(self.lib.library_dir, include_global=True)
self.__reset_navigation()
# TODO - make this call optional
@@ -1729,7 +1744,7 @@ class QtDriver(DriverMixin, QObject):
)
self.main_window.setAcceptDrops(True)
self.init_file_extension_manager()
self.init_ignore_modal()
self.selected.clear()
self.set_select_actions_visibility()
@@ -1738,12 +1753,14 @@ class QtDriver(DriverMixin, QObject):
self.main_window.menu_bar.refresh_dir_action.setEnabled(True)
self.main_window.menu_bar.tag_manager_action.setEnabled(True)
self.main_window.menu_bar.color_manager_action.setEnabled(True)
self.main_window.menu_bar.manage_file_ext_action.setEnabled(True)
self.main_window.menu_bar.ignore_modal_action.setEnabled(True)
self.main_window.menu_bar.new_tag_action.setEnabled(True)
self.main_window.menu_bar.fix_unlinked_entries_action.setEnabled(True)
self.main_window.menu_bar.fix_ignored_entries_action.setEnabled(True)
self.main_window.menu_bar.fix_dupe_files_action.setEnabled(True)
self.main_window.menu_bar.clear_thumb_cache_action.setEnabled(True)
self.main_window.menu_bar.folders_to_tags_action.setEnabled(True)
self.main_window.menu_bar.library_info_action.setEnabled(True)
self.main_window.preview_panel.set_selection(self.selected)

View File

@@ -7,8 +7,7 @@ from typing import TYPE_CHECKING
import structlog
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
from tagstudio.core.library.alchemy.library import Library, Tag
from tagstudio.qt.flowlayout import FlowLayout
from tagstudio.qt.widgets.fields import FieldWidget
from tagstudio.qt.widgets.tag import TagWidget
@@ -32,7 +31,7 @@ class TagBoxWidgetView(FieldWidget):
self.setLayout(self.__root_layout)
def set_tags(self, tags: Iterable[Tag]) -> None:
tags_ = sorted(list(tags), key=lambda tag: self.__lib.tag_display_name(tag.id))
tags_ = sorted(list(tags), key=lambda tag: self.__lib.tag_display_name(tag))
logger.info("[TagBoxWidget] Tags:", tags=tags)
while self.__root_layout.itemAt(0):
self.__root_layout.takeAt(0).widget().deleteLater() # pyright: ignore[reportOptionalMemberAccess]

View File

@@ -0,0 +1,67 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from typing import TYPE_CHECKING, override
from PySide6 import QtCore, QtGui
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget
from tagstudio.core.library.alchemy.library import Library
from tagstudio.qt.translations import Translations
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.qt.ts_qt import QtDriver
class FixIgnoredEntriesModalView(QWidget):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__()
self.lib = library
self.driver = driver
self.setWindowTitle(Translations["entries.ignored.title"])
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.setMinimumSize(400, 300)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
self.ignored_desc_widget = QLabel(Translations["entries.ignored.description"])
self.ignored_desc_widget.setObjectName("ignoredDescriptionLabel")
self.ignored_desc_widget.setWordWrap(True)
self.ignored_desc_widget.setStyleSheet("text-align:left;")
self.ignored_count_label = QLabel()
self.ignored_count_label.setObjectName("ignoredCountLabel")
self.ignored_count_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.refresh_ignored_button = QPushButton(Translations["entries.generic.refresh_alt"])
self.remove_button = QPushButton(Translations["entries.ignored.remove_alt"])
self.button_container = QWidget()
self.button_layout = QHBoxLayout(self.button_container)
self.button_layout.setContentsMargins(6, 6, 6, 6)
self.button_layout.addStretch(1)
self.done_button = QPushButton(Translations["generic.done_alt"])
self.done_button.setDefault(True)
self.button_layout.addWidget(self.done_button)
self.root_layout.addWidget(self.ignored_count_label)
self.root_layout.addWidget(self.ignored_desc_widget)
self.root_layout.addWidget(self.refresh_ignored_button)
self.root_layout.addWidget(self.remove_button)
self.root_layout.addStretch(1)
self.root_layout.addStretch(2)
self.root_layout.addWidget(self.button_container)
@override
def keyPressEvent(self, event: QtGui.QKeyEvent) -> None: # noqa N802
if event.key() == QtCore.Qt.Key.Key_Escape:
self.done_button.click()
else: # Other key presses
pass
return super().keyPressEvent(event)

View File

@@ -0,0 +1,48 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import structlog
from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QFont
from PySide6.QtWidgets import (
QPlainTextEdit,
QPushButton,
QVBoxLayout,
)
from tagstudio.core.constants import IGNORE_NAME
from tagstudio.core.library.alchemy.library import Library, Tag
from tagstudio.qt.translations import Translations
from tagstudio.qt.widgets.panel import PanelWidget
logger = structlog.get_logger(__name__)
class IgnoreModalView(PanelWidget):
on_edit = Signal(Tag)
def __init__(self, library: Library) -> None:
super().__init__()
self.lib = library
self.setMinimumSize(640, 460)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 0, 6, 0)
self.root_layout.setAlignment(Qt.AlignmentFlag.AlignTop)
self.text_edit = QPlainTextEdit()
font = QFont()
font.setFamily("monospace")
font.setFixedPitch(True)
font.setStyleHint(QFont.StyleHint.Monospace)
self.text_edit.setFont(font)
self.open_button = QPushButton(
Translations.format("ignore.open_file", ts_ignore=IGNORE_NAME)
)
# Add Widgets to Layout ================================================
self.root_layout.addWidget(self.text_edit)
self.root_layout.addWidget(self.open_button)

View File

@@ -0,0 +1,465 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import math
from typing import TYPE_CHECKING
from PIL import Image, ImageQt
from PySide6.QtCore import Qt
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import (
QFrame,
QGraphicsOpacityEffect,
QGridLayout,
QHBoxLayout,
QLabel,
QPushButton,
QSizePolicy,
QSpacerItem,
QVBoxLayout,
QWidget,
)
from tagstudio.qt.helpers.color_overlay import theme_fg_overlay
from tagstudio.qt.platform_strings import open_file_str
from tagstudio.qt.translations import Translations
# Only import for type checking/autocompletion, will not be imported at runtime.
if TYPE_CHECKING:
from tagstudio.core.library.alchemy.library import Library
from tagstudio.qt.ts_qt import QtDriver
class LibraryInfoWindowView(QWidget):
def __init__(self, library: "Library", driver: "QtDriver"):
super().__init__()
self.lib = library
self.driver = driver
self.setWindowTitle("Library Information")
self.setMinimumSize(800, 480)
self.root_layout = QVBoxLayout(self)
self.root_layout.setContentsMargins(6, 6, 6, 6)
row_height: int = 22
icon_margin: int = 4
cell_alignment: Qt.AlignmentFlag = (
Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter
)
# Title ----------------------------------------------------------------
self.title_label = QLabel()
self.title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
# Body (Stats, etc.) ---------------------------------------------------
self.body_widget = QWidget()
self.body_layout = QHBoxLayout(self.body_widget)
self.body_layout.setContentsMargins(0, 0, 0, 0)
self.body_layout.setSpacing(6)
# Statistics -----------------------------------------------------------
self.stats_widget = QWidget()
self.stats_layout = QVBoxLayout(self.stats_widget)
self.stats_layout.setAlignment(Qt.AlignmentFlag.AlignTop)
self.stats_layout.setContentsMargins(0, 0, 0, 0)
self.stats_layout.setSpacing(12)
self.stats_label = QLabel(f"<h3>{Translations['library_info.stats']}</h3>")
self.stats_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.stats_grid: QWidget = QWidget()
self.stats_grid_layout: QGridLayout = QGridLayout(self.stats_grid)
self.stats_grid_layout.setContentsMargins(0, 0, 0, 0)
self.stats_grid_layout.setSpacing(0)
self.stats_grid_layout.setColumnMinimumWidth(1, 12)
self.stats_grid_layout.setColumnMinimumWidth(3, 12)
self.stats_entries_row: int = 0
self.stats_tags_row: int = 1
self.stats_fields_row: int = 2
self.stats_namespaces_row: int = 3
self.stats_colors_row: int = 4
self.stats_macros_row: int = 5
# NOTE: Alternating rows for visual padding
self.stats_labels_col: int = 0
self.stats_values_col: int = 2
self.stats_buttons_col: int = 4
self.entries_label: QLabel = QLabel(Translations["library_info.stats.entries"])
self.entries_label.setAlignment(cell_alignment)
self.tags_label: QLabel = QLabel(Translations["library_info.stats.tags"])
self.tags_label.setAlignment(cell_alignment)
self.fields_label: QLabel = QLabel(Translations["library_info.stats.fields"])
self.fields_label.setAlignment(cell_alignment)
self.namespaces_label: QLabel = QLabel(Translations["library_info.stats.namespaces"])
self.namespaces_label.setAlignment(cell_alignment)
self.colors_label: QLabel = QLabel(Translations["library_info.stats.colors"])
self.colors_label.setAlignment(cell_alignment)
self.macros_label: QLabel = QLabel(Translations["library_info.stats.macros"])
self.macros_label.setAlignment(cell_alignment)
self.stats_grid_layout.addWidget(
self.entries_label,
self.stats_entries_row,
self.stats_labels_col,
)
self.stats_grid_layout.addWidget(
self.tags_label,
self.stats_tags_row,
self.stats_labels_col,
)
self.stats_grid_layout.addWidget(
self.fields_label,
self.stats_fields_row,
self.stats_labels_col,
)
self.stats_grid_layout.addWidget(
self.namespaces_label,
self.stats_namespaces_row,
self.stats_labels_col,
)
self.stats_grid_layout.addWidget(
self.colors_label,
self.stats_colors_row,
self.stats_labels_col,
)
self.stats_grid_layout.addWidget(
self.macros_label,
self.stats_macros_row,
self.stats_labels_col,
)
self.stats_grid_layout.setRowMinimumHeight(self.stats_entries_row, row_height)
self.stats_grid_layout.setRowMinimumHeight(self.stats_tags_row, row_height)
self.stats_grid_layout.setRowMinimumHeight(self.stats_fields_row, row_height)
self.stats_grid_layout.setRowMinimumHeight(self.stats_namespaces_row, row_height)
self.stats_grid_layout.setRowMinimumHeight(self.stats_colors_row, row_height)
self.stats_grid_layout.setRowMinimumHeight(self.stats_macros_row, row_height)
self.entry_count_label: QLabel = QLabel()
self.entry_count_label.setAlignment(cell_alignment)
self.tag_count_label: QLabel = QLabel()
self.tag_count_label.setAlignment(cell_alignment)
self.field_count_label: QLabel = QLabel()
self.field_count_label.setAlignment(cell_alignment)
self.namespaces_count_label: QLabel = QLabel()
self.namespaces_count_label.setAlignment(cell_alignment)
self.color_count_label: QLabel = QLabel()
self.color_count_label.setAlignment(cell_alignment)
self.macros_count_label: QLabel = QLabel()
self.macros_count_label.setAlignment(cell_alignment)
self.stats_grid_layout.addWidget(
self.entry_count_label,
self.stats_entries_row,
self.stats_values_col,
)
self.stats_grid_layout.addWidget(
self.tag_count_label,
self.stats_tags_row,
self.stats_values_col,
)
self.stats_grid_layout.addWidget(
self.field_count_label,
self.stats_fields_row,
self.stats_values_col,
)
self.stats_grid_layout.addWidget(
self.namespaces_count_label,
self.stats_namespaces_row,
self.stats_values_col,
)
self.stats_grid_layout.addWidget(
self.color_count_label,
self.stats_colors_row,
self.stats_values_col,
)
self.stats_grid_layout.addWidget(
self.macros_count_label,
self.stats_macros_row,
self.stats_values_col,
)
self.manage_tags_button = QPushButton(Translations["edit.tag_manager"])
self.manage_colors_button = QPushButton(Translations["color_manager.title"])
self.stats_grid_layout.addWidget(
self.manage_tags_button,
self.stats_tags_row,
self.stats_buttons_col,
)
self.stats_grid_layout.addWidget(
self.manage_colors_button,
self.stats_colors_row,
self.stats_buttons_col,
)
self.stats_layout.addWidget(self.stats_label)
self.stats_layout.addWidget(self.stats_grid)
self.body_layout.addSpacerItem(
QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
)
self.body_layout.addWidget(self.stats_widget)
self.body_layout.addSpacerItem(
QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
)
# Vertical Separator
self.vertical_sep = QFrame()
self.vertical_sep.setFrameShape(QFrame.Shape.VLine)
self.vertical_sep.setFrameShadow(QFrame.Shadow.Plain)
opacity_effect_vert_sep = QGraphicsOpacityEffect(self)
opacity_effect_vert_sep.setOpacity(0.1)
self.vertical_sep.setGraphicsEffect(opacity_effect_vert_sep)
self.body_layout.addWidget(self.vertical_sep)
# Cleanup --------------------------------------------------------------
self.cleanup_widget = QWidget()
self.cleanup_layout = QVBoxLayout(self.cleanup_widget)
self.cleanup_layout.setAlignment(Qt.AlignmentFlag.AlignTop)
self.cleanup_layout.setContentsMargins(0, 0, 0, 0)
self.cleanup_layout.setSpacing(12)
self.cleanup_label = QLabel(f"<h3>{Translations['library_info.cleanup']}</h3>")
self.cleanup_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.cleanup_grid: QWidget = QWidget()
self.cleanup_grid_layout: QGridLayout = QGridLayout(self.cleanup_grid)
self.cleanup_grid_layout.setContentsMargins(0, 0, 0, 0)
self.cleanup_grid_layout.setSpacing(0)
self.cleanup_grid_layout.setColumnMinimumWidth(1, 12)
self.cleanup_grid_layout.setColumnMinimumWidth(3, 6)
self.cleanup_grid_layout.setColumnMinimumWidth(5, 6)
self.cleanup_layout.addWidget(self.cleanup_label)
self.cleanup_layout.addWidget(self.cleanup_grid)
self.cleanup_unlinked_row: int = 0
self.cleanup_ignored_row: int = 1
self.cleanup_dupe_files_row: int = 2
self.cleanup_section_break_row: int = 3
self.cleanup_legacy_json_row: int = 4
self.cleanup_backups_row: int = 5
# NOTE: Alternating rows for visual padding
self.cleanup_labels_col: int = 0
self.cleanup_values_col: int = 2
self.cleanup_icons_col: int = 4
self.cleanup_buttons_col: int = 6
# Horizontal Separator
self.horizontal_sep = QFrame()
self.horizontal_sep.setFrameShape(QFrame.Shape.HLine)
self.horizontal_sep.setFrameShadow(QFrame.Shadow.Plain)
self.horizontal_sep.setFixedHeight(row_height)
opacity_effect_hor_sep = QGraphicsOpacityEffect(self)
opacity_effect_hor_sep.setOpacity(0.1)
self.horizontal_sep.setGraphicsEffect(opacity_effect_hor_sep)
self.cleanup_grid_layout.addWidget(
self.horizontal_sep,
self.cleanup_section_break_row,
self.cleanup_labels_col,
1,
7,
Qt.AlignmentFlag.AlignVCenter,
)
self.unlinked_icon = QLabel()
unlinked_image: Image.Image = self.driver.rm.get("unlinked_stat") # pyright: ignore[reportAssignmentType]
unlinked_pixmap = QPixmap.fromImage(ImageQt.ImageQt(unlinked_image))
unlinked_pixmap.setDevicePixelRatio(self.devicePixelRatio())
unlinked_pixmap = unlinked_pixmap.scaledToWidth(
math.floor((row_height - icon_margin) * self.devicePixelRatio()),
Qt.TransformationMode.SmoothTransformation,
)
self.unlinked_icon.setPixmap(unlinked_pixmap)
self.ignored_icon = QLabel()
ignored_image: Image.Image = self.driver.rm.get("ignored_stat") # pyright: ignore[reportAssignmentType]
ignored_pixmap = QPixmap.fromImage(ImageQt.ImageQt(ignored_image))
ignored_pixmap.setDevicePixelRatio(self.devicePixelRatio())
ignored_pixmap = ignored_pixmap.scaledToWidth(
math.floor((row_height - icon_margin) * self.devicePixelRatio()),
Qt.TransformationMode.SmoothTransformation,
)
self.ignored_icon.setPixmap(ignored_pixmap)
self.dupe_file_icon = QLabel()
dupe_file_image: Image.Image = self.driver.rm.get("dupe_file_stat") # pyright: ignore[reportAssignmentType]
dupe_file_pixmap = QPixmap.fromImage(
ImageQt.ImageQt(theme_fg_overlay(dupe_file_image, use_alpha=False))
)
dupe_file_pixmap.setDevicePixelRatio(self.devicePixelRatio())
dupe_file_pixmap = dupe_file_pixmap.scaledToWidth(
math.floor((row_height - icon_margin) * self.devicePixelRatio()),
Qt.TransformationMode.SmoothTransformation,
)
self.dupe_file_icon.setPixmap(dupe_file_pixmap)
self.cleanup_grid_layout.addWidget(
self.unlinked_icon,
self.cleanup_unlinked_row,
self.cleanup_icons_col,
)
self.cleanup_grid_layout.addWidget(
self.ignored_icon,
self.cleanup_ignored_row,
self.cleanup_icons_col,
)
self.cleanup_grid_layout.addWidget(
self.dupe_file_icon,
self.cleanup_dupe_files_row,
self.cleanup_icons_col,
)
self.unlinked_label: QLabel = QLabel(Translations["library_info.cleanup.unlinked"])
self.unlinked_label.setAlignment(cell_alignment)
self.ignored_label: QLabel = QLabel(Translations["library_info.cleanup.ignored"])
self.ignored_label.setAlignment(cell_alignment)
self.dupe_files_label: QLabel = QLabel(Translations["library_info.cleanup.dupe_files"])
self.dupe_files_label.setAlignment(cell_alignment)
self.legacy_json_label: QLabel = QLabel(Translations["library_info.cleanup.legacy_json"])
self.legacy_json_label.setAlignment(cell_alignment)
self.backups_label: QLabel = QLabel(Translations["library_info.cleanup.backups"])
self.backups_label.setAlignment(cell_alignment)
self.cleanup_grid_layout.addWidget(
self.unlinked_label,
self.cleanup_unlinked_row,
self.cleanup_labels_col,
)
self.cleanup_grid_layout.addWidget(
self.ignored_label,
self.cleanup_ignored_row,
self.cleanup_labels_col,
)
self.cleanup_grid_layout.addWidget(
self.dupe_files_label,
self.cleanup_dupe_files_row,
self.cleanup_labels_col,
)
self.cleanup_grid_layout.addWidget(
self.legacy_json_label,
self.cleanup_legacy_json_row,
self.cleanup_labels_col,
)
self.cleanup_grid_layout.addWidget(
self.backups_label,
self.cleanup_backups_row,
self.cleanup_labels_col,
)
self.cleanup_grid_layout.setRowMinimumHeight(self.cleanup_unlinked_row, row_height)
self.cleanup_grid_layout.setRowMinimumHeight(self.cleanup_ignored_row, row_height)
self.cleanup_grid_layout.setRowMinimumHeight(self.cleanup_dupe_files_row, row_height)
self.cleanup_grid_layout.setRowMinimumHeight(self.cleanup_legacy_json_row, row_height)
self.cleanup_grid_layout.setRowMinimumHeight(self.cleanup_backups_row, row_height)
self.unlinked_count_label: QLabel = QLabel()
self.unlinked_count_label.setAlignment(cell_alignment)
self.ignored_count_label: QLabel = QLabel()
self.ignored_count_label.setAlignment(cell_alignment)
self.dupe_files_count_label: QLabel = QLabel()
self.dupe_files_count_label.setAlignment(cell_alignment)
self.legacy_json_status_label: QLabel = QLabel()
self.legacy_json_status_label.setAlignment(cell_alignment)
self.backups_count_label: QLabel = QLabel()
self.backups_count_label.setAlignment(cell_alignment)
self.cleanup_grid_layout.addWidget(
self.unlinked_count_label,
self.cleanup_unlinked_row,
self.cleanup_values_col,
)
self.cleanup_grid_layout.addWidget(
self.ignored_count_label,
self.cleanup_ignored_row,
self.cleanup_values_col,
)
self.cleanup_grid_layout.addWidget(
self.dupe_files_count_label,
self.cleanup_dupe_files_row,
self.cleanup_values_col,
)
self.cleanup_grid_layout.addWidget(
self.legacy_json_status_label,
self.cleanup_legacy_json_row,
self.cleanup_values_col,
)
self.cleanup_grid_layout.addWidget(
self.backups_count_label,
self.cleanup_backups_row,
self.cleanup_values_col,
)
self.fix_unlinked_entries = QPushButton(Translations["menu.tools.fix_unlinked_entries"])
self.fix_ignored_entries = QPushButton(Translations["menu.tools.fix_ignored_entries"])
self.fix_dupe_files = QPushButton(Translations["menu.tools.fix_duplicate_files"])
self.view_legacy_json_file = QPushButton(open_file_str())
self.open_backups_folder = QPushButton(Translations["menu.file.open_backups_folder"])
self.cleanup_grid_layout.addWidget(
self.fix_unlinked_entries,
self.cleanup_unlinked_row,
self.cleanup_buttons_col,
)
self.cleanup_grid_layout.addWidget(
self.fix_ignored_entries,
self.cleanup_ignored_row,
self.cleanup_buttons_col,
)
self.cleanup_grid_layout.addWidget(
self.fix_dupe_files,
self.cleanup_dupe_files_row,
self.cleanup_buttons_col,
)
self.cleanup_grid_layout.addWidget(
self.view_legacy_json_file,
self.cleanup_legacy_json_row,
self.cleanup_buttons_col,
)
self.cleanup_grid_layout.addWidget(
self.open_backups_folder,
self.cleanup_backups_row,
self.cleanup_buttons_col,
)
self.body_layout.addSpacerItem(
QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
)
self.body_layout.addWidget(self.cleanup_widget)
self.body_layout.addSpacerItem(
QSpacerItem(0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
)
# Details --------------------------------------------------------------
self.details_container = QWidget()
self.details_layout = QHBoxLayout(self.details_container)
self.details_layout.setContentsMargins(6, 0, 6, 0)
opacity_effect_details = QGraphicsOpacityEffect(self)
opacity_effect_details.setOpacity(0.5)
self.version_label = QLabel()
self.version_label.setGraphicsEffect(opacity_effect_details)
self.details_layout.addWidget(self.version_label)
# Buttons --------------------------------------------------------------
self.button_container = QWidget()
self.button_layout = QHBoxLayout(self.button_container)
self.button_layout.setContentsMargins(6, 6, 6, 6)
self.button_layout.addStretch(1)
self.close_button = QPushButton(Translations["generic.close"])
self.button_layout.addWidget(self.close_button)
# Add to root layout ---------------------------------------------------
self.root_layout.addWidget(self.title_label)
self.root_layout.addWidget(self.body_widget)
self.root_layout.addStretch(1)
self.root_layout.addStretch(2)
self.root_layout.addWidget(self.details_container)
self.root_layout.addWidget(self.button_container)

View File

@@ -98,7 +98,7 @@ class PreviewThumbView(QWidget):
self.__media_player_page = QWidget()
self.__stacked_page_setup(self.__media_player_page, self.__media_player)
self.__thumb_renderer = ThumbRenderer(library)
self.__thumb_renderer = ThumbRenderer(driver, library)
self.__thumb_renderer.updated.connect(self.__thumb_renderer_updated_callback)
self.__thumb_renderer.updated_ratio.connect(self.__thumb_renderer_updated_ratio_callback)

Some files were not shown because too many files have changed in this diff Show More