diff --git a/TODO.md b/TODO.md index f9f43c1a..0a1c2d14 100644 --- a/TODO.md +++ b/TODO.md @@ -2,16 +2,15 @@ - Merge login page - Refactoring - - Set Qt parents for all QObject - Migrate more JS functions to their own files / Implement in Python instead - Don't bake in size properties for components - Better names and organization for the Message components - Bug fixes - - Graphic bug when resizing window vertically for side pane? - Fix tooltip hide() - ![A picture](https://picsum.photos/256/256) not clickable? - Icons aren't reloaded + - Bug when resizing window being tiled (i3), can't figure it out - UI - Use HRowLayout and its totalSpacing wherever possible diff --git a/harmonyqml/backend/backend.py b/harmonyqml/backend/backend.py index 4504e614..107b1844 100644 --- a/harmonyqml/backend/backend.py +++ b/harmonyqml/backend/backend.py @@ -13,8 +13,8 @@ from .pyqt_future import futurize class Backend(QObject): - def __init__(self) -> None: - super().__init__() + def __init__(self, parent: QObject) -> None: + super().__init__(parent) self.pool: ThreadPoolExecutor = ThreadPoolExecutor(max_workers=6) self._queried_displaynames: Dict[str, str] = {} @@ -24,8 +24,8 @@ class Backend(QObject): from .client_manager import ClientManager self._client_manager: ClientManager = ClientManager(self) - self._models: QMLModels = QMLModels() - self._html_filter: HtmlFilter = HtmlFilter() + self._models: QMLModels = QMLModels(self) + self._html_filter: HtmlFilter = HtmlFilter(self) from .signal_manager import SignalManager self._signal_manager: SignalManager = SignalManager(self) diff --git a/harmonyqml/backend/client_manager.py b/harmonyqml/backend/client_manager.py index eed90521..c39d21c7 100644 --- a/harmonyqml/backend/client_manager.py +++ b/harmonyqml/backend/client_manager.py @@ -1,7 +1,6 @@ # Copyright 2018 miruka # This file is part of harmonyqt, licensed under GPLv3. -import hashlib import json import os import platform diff --git a/harmonyqml/backend/html_filter.py b/harmonyqml/backend/html_filter.py index b2ac09e3..fdcf523e 100644 --- a/harmonyqml/backend/html_filter.py +++ b/harmonyqml/backend/html_filter.py @@ -20,8 +20,8 @@ class HtmlFilter(QObject): ]] - def __init__(self) -> None: - super().__init__() + def __init__(self, parent: QObject) -> None: + super().__init__(parent) self._sanitizer = sanitizer.Sanitizer(self.sanitizer_settings) # The whitespace remover doesn't take
 into account
diff --git a/harmonyqml/backend/model/list_model.py b/harmonyqml/backend/model/list_model.py
index e33f0292..cb06f34a 100644
--- a/harmonyqml/backend/model/list_model.py
+++ b/harmonyqml/backend/model/list_model.py
@@ -19,9 +19,9 @@ class ListModel(QAbstractListModel):
     countChanged = pyqtSignal(int)
 
     def __init__(self,
+                 parent:       QObject,
                  initial_data: Optional[List[NewItem]]        = None,
-                 container:    Callable[..., MutableSequence]  = list,
-                 parent:       Optional[QObject]               = None) -> None:
+                 container:    Callable[..., MutableSequence]  = list) -> None:
         super().__init__(parent)
         self._data: MutableSequence[ListItem] = container()
 
diff --git a/harmonyqml/backend/model/list_model_map.py b/harmonyqml/backend/model/list_model_map.py
index 23c3a31e..c397690c 100644
--- a/harmonyqml/backend/model/list_model_map.py
+++ b/harmonyqml/backend/model/list_model_map.py
@@ -6,9 +6,11 @@ from .list_model import ListModel
 
 
 class ListModelMap(QObject):
-    def __init__(self, models_container: Callable[..., MutableSequence] = list
+    def __init__(self,
+                 parent:           QObject,
+                 models_container: Callable[..., MutableSequence] = list
                 ) -> None:
-        super().__init__()
+        super().__init__(parent)
 
         # Set the parent to prevent item garbage-collection on the C++ side
         self.dict: DefaultDict[Any, ListModel] = \
diff --git a/harmonyqml/backend/model/qml_models.py b/harmonyqml/backend/model/qml_models.py
index 82f17503..29f6e554 100644
--- a/harmonyqml/backend/model/qml_models.py
+++ b/harmonyqml/backend/model/qml_models.py
@@ -10,11 +10,12 @@ from .list_model_map import ListModelMap
 
 
 class QMLModels(QObject):
-    def __init__(self) -> None:
-        super().__init__()
-        self._accounts:    ListModel    = ListModel()
-        self._rooms:       ListModelMap = ListModelMap()
-        self._room_events: ListModelMap = ListModelMap(models_container=Deque)
+    def __init__(self, parent: QObject) -> None:
+        super().__init__(parent)
+        self._accounts:    ListModel    = ListModel(parent)
+        self._rooms:       ListModelMap = ListModelMap(parent)
+        self._room_events: ListModelMap = ListModelMap(parent,
+                                                       models_container=Deque)
 
 
     @pyqtProperty(ListModel, constant=True)
diff --git a/harmonyqml/components/UI.qml b/harmonyqml/components/UI.qml
index 3174bee7..2e641faf 100644
--- a/harmonyqml/components/UI.qml
+++ b/harmonyqml/components/UI.qml
@@ -19,7 +19,6 @@ Controls1.SplitView {
             pageStack.replace(
                 "chat/Root.qml", { userId: userId, roomId: roomId }
             )
-            console.log("replaced")
         }
 
         id: pageStack
diff --git a/harmonyqml/components/chat/Root.qml b/harmonyqml/components/chat/Root.qml
index 8adfeac4..f1b26e5e 100644
--- a/harmonyqml/components/chat/Root.qml
+++ b/harmonyqml/components/chat/Root.qml
@@ -9,6 +9,8 @@ ColumnLayout {
     readonly property var roomInfo:
         Backend.models.rooms.get(userId).getWhere("roomId", roomId)
 
+    Component.onCompleted: console.log("replaced")
+
 
     id: chatPage
     spacing: 0
diff --git a/harmonyqml/engine.py b/harmonyqml/engine.py
index 2f87bfc7..b0392eca 100644
--- a/harmonyqml/engine.py
+++ b/harmonyqml/engine.py
@@ -4,12 +4,11 @@
 import logging
 import sys
 from pathlib import Path
-from typing import Generator, Optional
+from typing import Generator
 
 from PyQt5.QtCore import QFileSystemWatcher, QObject, QTimer
 from PyQt5.QtQml import QQmlApplicationEngine
 
-from .__about__ import __doc__
 from .app import Application
 from .backend.backend import Backend
 
@@ -19,11 +18,10 @@ from .backend.backend import Backend
 class Engine(QQmlApplicationEngine):
     def __init__(self,
                  app:    Application,
-                 debug:  bool              = False,
-                 parent: Optional[QObject] = None) -> None:
-        super().__init__(parent)
+                 debug:  bool = False) -> None:
+        super().__init__(app)
         self.app     = app
-        self.backend = Backend()
+        self.backend = Backend(self)
         self.app_dir = Path(sys.argv[0]).resolve().parent
 
         # Set QML properties