diff --git a/Makefile b/Makefile index 41cd41a..3b62b81 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ build: poetry install - make aw_qt/resources.py install: bash scripts/config-autostart.sh @@ -31,5 +30,5 @@ clean: rm -rf build dist rm -rf __pycache__ aw_qt/__pycache__ -aw_qt/resources.py: aw_qt/resources.qrc - poetry run pyrcc5 -o aw_qt/resources.py aw_qt/resources.qrc +#aw_qt/resources.py: aw_qt/resources.qrc +# poetry run pyrcc5 -o aw_qt/resources.py aw_qt/resources.qrc diff --git a/aw-qt.spec b/aw-qt.spec index 39fc5e3..24b05fa 100644 --- a/aw-qt.spec +++ b/aw-qt.spec @@ -15,8 +15,8 @@ if platform.system() == "Windows": # The Windows version includes paths to Qt binaries which are # not automatically found due to bug in PyInstaller 3.2. # See: https://github.com/pyinstaller/pyinstaller/issues/2152 - import PyQt5 - pyqt_path = os.path.dirname(PyQt5.__file__) + import PyQt6 + pyqt_path = os.path.dirname(PyQt6.__file__) extra_pathex.append(pyqt_path + "\\Qt\\bin") @@ -27,7 +27,7 @@ block_cipher = None a = Analysis(['aw_qt/__main__.py'], pathex=[] + extra_pathex, binaries=None, - datas=[('resources/aw-qt.desktop', '.')], + datas=[('resources/aw-qt.desktop', '.'), ('media', 'media')], hiddenimports=[], hookspath=[], runtime_hooks=[], diff --git a/aw_qt/__init__.py b/aw_qt/__init__.py index c01fdda..28ac4d9 100644 --- a/aw_qt/__init__.py +++ b/aw_qt/__init__.py @@ -1,3 +1,3 @@ -from . import resources +#from . import resources from .main import main diff --git a/aw_qt/resources.qrc b/aw_qt/resources.qrc deleted file mode 100644 index 8084585..0000000 --- a/aw_qt/resources.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - - ../media/logo/logo.png - ../media/logo/black-monochrome-logo.png - - diff --git a/aw_qt/trayicon.py b/aw_qt/trayicon.py index 092f426..ef9e95e 100644 --- a/aw_qt/trayicon.py +++ b/aw_qt/trayicon.py @@ -132,14 +132,14 @@ def _build_rootmenu(self) -> None: def show_module_failed_dialog(module: Module) -> None: box = QMessageBox(self._parent) - box.setIcon(QMessageBox.Warning) + box.setIcon(QMessageBox.Icon.Warning) box.setText(f"Module {module.name} quit unexpectedly") box.setDetailedText(module.read_log(self.testing)) restart_button = QPushButton("Restart", box) restart_button.clicked.connect(module.start) - box.addButton(restart_button, QMessageBox.AcceptRole) - box.setStandardButtons(QMessageBox.Cancel) + box.addButton(restart_button, QMessageBox.ButtonRole.AcceptRole) + box.setStandardButtons(QMessageBox.StandardButton.Cancel) box.show() @@ -207,6 +207,10 @@ def run(manager: Manager, testing: bool = False) -> Any: app = QApplication(sys.argv) + # TODO: Set icon path correctly + QtCore.QDir.addSearchPath("icons", "media/logo/") + # QtCore.QDir.addSearchPath("icons", "../media/logo/") + # Without this, Ctrl+C will have no effect signal.signal(signal.SIGINT, lambda *args: exit(manager)) # Ensure cleanup happens on SIGTERM @@ -216,21 +220,23 @@ def run(manager: Manager, testing: bool = False) -> Any: timer.start(100) # You may change this if you wish. timer.timeout.connect(lambda: None) # Let the interpreter run each 500 ms. + # root widget + widget = QWidget() + if not QSystemTrayIcon.isSystemTrayAvailable(): QMessageBox.critical( - None, + widget, "Systray", "I couldn't detect any system tray on this system. Either get one or run the ActivityWatch modules from the console.", ) sys.exit(1) - widget = QWidget() if sys.platform == "darwin": - icon = QIcon(":/black-monochrome-logo.png") + icon = QIcon("icons:black-monochrome-logo.png") # Allow macOS to use filters for changing the icon's color icon.setIsMask(True) else: - icon = QIcon(":/logo.png") + icon = QIcon("icons:logo.png") trayIcon = TrayIcon(manager, icon, widget, testing=testing) trayIcon.show() diff --git a/poetry.lock b/poetry.lock index 3fd04b2..2ccbddb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -317,14 +317,6 @@ python-versions = ">=3.6.8" [package.extras] diagrams = ["jinja2", "railroad-diagrams"] -[[package]] -name = "PyQt5-stubs" -version = "5.14.2.2" -description = "PEP561 stub files for the PyQt5 framework" -category = "dev" -optional = false -python-versions = "*" - [[package]] name = "PyQt6" version = "6.3.1" @@ -353,6 +345,21 @@ category = "main" optional = false python-versions = ">=3.7" +[[package]] +name = "PyQt6-stubs" +version = "6.2.3.1" +description = "PEP561 stub files for the PyQt6 framework" +category = "dev" +optional = false +python-versions = ">= 3.6" +develop = false + +[package.source] +type = "git" +url = "https://github.com/TilmanK/PyQt6-stubs" +reference = "main" +resolved_reference = "f623a641cd5cdff53342177e4fbbf9cae8172336" + [[package]] name = "pyrsistent" version = "0.18.1" @@ -480,7 +487,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>= [metadata] lock-version = "1.1" python-versions = "^3.8,<3.11" -content-hash = "f61c0f9512fe60e867dd9d13d437aee2154012497a37a9e21d0a9777d4e5fdee" +content-hash = "6e8f26df8a147445b2b024939dfe160f70db2de87a468002fae275477c9a42fa" [metadata.files] altgraph = [ @@ -634,9 +641,6 @@ pyparsing = [ {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, ] -PyQt5-stubs = [ - {file = "PyQt5-stubs-5.14.2.2.tar.gz", hash = "sha256:b1a84b12bbeed74d95cc7fb4fd2df0a6711bd43e9a2651e552c83930c7b81638"}, -] PyQt6 = [ {file = "PyQt6-6.3.1-cp37-abi3-macosx_10_14_universal2.whl", hash = "sha256:f7ad13b44959b72c8d40fa1856470015fab3368983dd2c1c781d4061c45d96b3"}, {file = "PyQt6-6.3.1-cp37-abi3-manylinux1_x86_64.whl", hash = "sha256:c87c909eeafc44ea911a94490d55055058f51a27ec5ca0e439a9feb943a73fd1"}, @@ -664,6 +668,7 @@ PyQt6-sip = [ {file = "PyQt6_sip-13.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:3486914137f5336cff6e10a5e9d52c1e60ff883473938b45f267f794daeacb2f"}, {file = "PyQt6_sip-13.4.0.tar.gz", hash = "sha256:6d87a3ee5872d7511b76957d68a32109352caf3b7a42a01d9ee20032b350d979"}, ] +PyQt6-stubs = [] pyrsistent = [ {file = "pyrsistent-0.18.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:df46c854f490f81210870e509818b729db4488e1f30f2a1ce1698b2295a878d1"}, {file = "pyrsistent-0.18.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d45866ececf4a5fff8742c25722da6d4c9e180daa7b405dc0a2a2790d668c26"}, diff --git a/pyproject.toml b/pyproject.toml index 8df6bef..d5adc98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ setuptools = "*" [tool.poetry.dev-dependencies] mypy = "*" -PyQt5-stubs = "~5.14" # 5.15 not released yet +PyQt6-stubs = { git = "https://github.com/TilmanK/PyQt6-stubs", rev = "main" } flake8 = "*" pyinstaller = ">=5.1" types-click = "*"