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