Skip to content

Commit 7312604

Browse files
authored
Merge pull request #896 from eoyilmaz/890-qt-profile-loader-exceptions-dialog-port
[#890] Port ProfileLoaderExceptionsDialog to Qt
2 parents 27f672b + e2a36cf commit 7312604

4 files changed

Lines changed: 617 additions & 6 deletions

File tree

DisplayCAL/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.10.0.dev55
1+
3.10.0.dev56

DisplayCAL/ui/tools/apply_profiles.py

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
platform: ``QSystemTrayIcon`` makes this essentially free, and it is the only
2020
way to see/exercise this daemon's UI outside of a Windows box.
2121
22-
Deferred to a follow-up issue (menu item is present but disabled): the
23-
Exceptions dialog. The Windows device/process hot-plug monitoring thread
24-
(``_check_display_conf_thread``) is also not ported; this Qt build instead
22+
The Windows device/process hot-plug monitoring thread
23+
(``_check_display_conf_thread``) is not ported; this Qt build instead
2524
triggers an immediate (backgrounded) re-apply whenever the
2625
``apply-profiles``/``reset-vcgt`` IPC command or a tray double-click asks for
2726
one, rather than only flipping a flag for a poller to notice later. Profile
@@ -35,6 +34,7 @@
3534

3635
from __future__ import annotations
3736

37+
import os
3838
import sys
3939
import threading
4040

@@ -306,8 +306,7 @@ def _rebuild_menu(self) -> None: # noqa: C901
306306
menu.addSeparator()
307307

308308
exceptions_action = menu.addAction(lang.getstr("exceptions"))
309-
exceptions_action.setEnabled(False)
310-
exceptions_action.setToolTip(_NOT_AVAILABLE_TOOLTIP)
309+
exceptions_action.triggered.connect(pl.set_exceptions)
311310

312311
menu.addSeparator()
313312

@@ -621,6 +620,40 @@ def _set_profile_associations(self, event: object = None) -> None:
621620
dlg = ProfileAssociationsDialog(self)
622621
dlg.exec()
623622

623+
def set_exceptions(self, event: object = None) -> None:
624+
"""Open the Qt exceptions dialog and persist any changes.
625+
626+
Mirrors wx's ``TaskBarIcon.set_exceptions``.
627+
628+
Args:
629+
event: Unused; kept for interface parity with the wx override.
630+
"""
631+
print("Menu command: Set exceptions")
632+
from DisplayCAL.ui.tools.profile_loader_exceptions import (
633+
ProfileLoaderExceptionsDialog,
634+
)
635+
636+
dlg = ProfileLoaderExceptionsDialog(self._exceptions, self._known_apps)
637+
result = dlg.exec()
638+
if result == QDialog.DialogCode.Accepted:
639+
exceptions = []
640+
for key in dlg._exceptions:
641+
enabled, reset, path = dlg._exceptions[key]
642+
exceptions.append(f"{enabled:d}:{reset:d}:{path}")
643+
print(
644+
f"Enabled={bool(enabled)}",
645+
"Action={}".format((reset and "Reset") or "Disable"),
646+
path,
647+
)
648+
if not exceptions:
649+
print("Clearing exceptions")
650+
setcfg("profile_loader.exceptions", ";".join(exceptions))
651+
self._exceptions = dlg._exceptions
652+
self._exception_names = {os.path.basename(key) for key in dlg._exceptions}
653+
self.writecfg()
654+
else:
655+
print("Cancelled setting exceptions")
656+
624657
def _toggle_fix_profile_associations(
625658
self, event: object, parent: QWidget | None = None
626659
) -> bool:

0 commit comments

Comments
 (0)