From ed4affc0940072d1ce2f0b63f76360dad9d7a6ec Mon Sep 17 00:00:00 2001 From: mrvladus Date: Mon, 20 May 2024 12:04:36 +0300 Subject: [PATCH] tweak state --- errands/application.py | 18 +++++------------ errands/state.py | 20 +++++++++++++++---- .../widgets/shared/task_toolbar/__init__.py | 4 ++-- .../shared/task_toolbar/datetime_window.py | 2 +- .../shared/task_toolbar/notes_window.py | 2 +- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/errands/application.py b/errands/application.py index d00b5930..49023d45 100644 --- a/errands/application.py +++ b/errands/application.py @@ -12,17 +12,15 @@ from errands.lib.gsettings import GSettings from errands.lib.logging import Log from errands.lib.notifications import ErrandsNotificationsDaemon -from errands.lib.plugins import PluginsLoader + +# from errands.lib.plugins import PluginsLoader from errands.lib.utils import threaded from errands.state import State -from errands.widgets.shared.task_toolbar import ErrandsAttachmentsWindow -from errands.widgets.shared.task_toolbar import DateTimeWindow -from errands.widgets.shared.task_toolbar import NotesWindow from errands.widgets.window import Window class ErrandsApplication(Adw.Application): - plugins_loader: PluginsLoader = None + # plugins_loader: PluginsLoader = None def __init__(self) -> None: super().__init__( @@ -152,14 +150,8 @@ def do_startup(self) -> None: # Plugins # self.plugins_loader = PluginsLoader(self) - # Notes window - State.notes_window = NotesWindow() - - # Date and time window - State.datetime_window = DateTimeWindow() - - # Attachments window - State.attachments_window = ErrandsAttachmentsWindow() + # Initialize State + State.init() # Main window State.main_window = Window(application=State.application) diff --git a/errands/state.py b/errands/state.py index f58dad93..f496a651 100644 --- a/errands/state.py +++ b/errands/state.py @@ -12,9 +12,9 @@ from errands.lib.notifications import ErrandsNotificationsDaemon from errands.widgets.loading_page import ErrandsLoadingPage from errands.widgets.shared.task_toolbar import ( - DateTimeWindow, + ErrandsDateTimeWindow, ErrandsAttachmentsWindow, - NotesWindow, + ErrandsNotesWindow, ) from errands.widgets.sidebar import Sidebar from errands.widgets.tags.tags import Tags @@ -62,14 +62,26 @@ class State: trash_sidebar_row: TrashSidebarRow | None = None # Notes window - notes_window: NotesWindow | None = None + notes_window: ErrandsNotesWindow | None = None # Date and time window - datetime_window: DateTimeWindow | None = None + datetime_window: ErrandsDateTimeWindow | None = None # Attachments window attachments_window: ErrandsAttachmentsWindow | None = None + @classmethod + def init(cls) -> None: + from errands.widgets.shared.task_toolbar import ( + ErrandsNotesWindow, + ErrandsDateTimeWindow, + ErrandsAttachmentsWindow, + ) + + cls.notes_window = ErrandsNotesWindow() + cls.datetime_window = ErrandsDateTimeWindow() + cls.attachments_window = ErrandsAttachmentsWindow() + @classmethod def get_task_list(cls, uid: str) -> TaskList: return [lst for lst in cls.get_task_lists() if lst.list_uid == uid][0] diff --git a/errands/widgets/shared/task_toolbar/__init__.py b/errands/widgets/shared/task_toolbar/__init__.py index 70cdbf4a..897720fc 100644 --- a/errands/widgets/shared/task_toolbar/__init__.py +++ b/errands/widgets/shared/task_toolbar/__init__.py @@ -2,5 +2,5 @@ from errands.widgets.shared.task_toolbar.attachments_window import ( ErrandsAttachmentsWindow, ) -from errands.widgets.shared.task_toolbar.datetime_window import DateTimeWindow -from errands.widgets.shared.task_toolbar.notes_window import NotesWindow +from errands.widgets.shared.task_toolbar.datetime_window import ErrandsDateTimeWindow +from errands.widgets.shared.task_toolbar.notes_window import ErrandsNotesWindow diff --git a/errands/widgets/shared/task_toolbar/datetime_window.py b/errands/widgets/shared/task_toolbar/datetime_window.py index 932b6ab1..1effc9ef 100644 --- a/errands/widgets/shared/task_toolbar/datetime_window.py +++ b/errands/widgets/shared/task_toolbar/datetime_window.py @@ -17,7 +17,7 @@ from errands.widgets.today.today_task import TodayTask -class DateTimeWindow(Adw.Dialog): +class ErrandsDateTimeWindow(Adw.Dialog): def __init__(self): super().__init__() self.__build_ui() diff --git a/errands/widgets/shared/task_toolbar/notes_window.py b/errands/widgets/shared/task_toolbar/notes_window.py index 2be0facb..c43170ea 100644 --- a/errands/widgets/shared/task_toolbar/notes_window.py +++ b/errands/widgets/shared/task_toolbar/notes_window.py @@ -16,7 +16,7 @@ from errands.widgets.task import Task -class NotesWindow(Adw.Dialog): +class ErrandsNotesWindow(Adw.Dialog): def __init__(self): super().__init__() self.__build_ui()