Skip to content

Commit

Permalink
fix: continued work on update to PyQt6
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Sep 23, 2022
1 parent 99de536 commit bf75c90
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 34 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

build:
poetry install
make aw_qt/resources.py

install:
bash scripts/config-autostart.sh
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions aw-qt.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand All @@ -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=[],
Expand Down
2 changes: 1 addition & 1 deletion aw_qt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import resources
#from . import resources

from .main import main
7 changes: 0 additions & 7 deletions aw_qt/resources.qrc

This file was deleted.

20 changes: 13 additions & 7 deletions aw_qt/trayicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down
29 changes: 17 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*"
Expand Down

0 comments on commit bf75c90

Please sign in to comment.