Skip to content

Commit

Permalink
persistent main UI position and size
Browse files Browse the repository at this point in the history
  • Loading branch information
masqu3rad3 committed Dec 5, 2024
1 parent eda81de commit 9f6e62c
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 0 deletions.
Binary file modified tik_manager4/dist/tik4/_internal/base_library.zip
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/install_dccs.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_photoshop.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_ps_new_version.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_ps_publish.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_standalone.exe
Binary file not shown.
19 changes: 19 additions & 0 deletions tik_manager4/objects/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,25 @@ def column_sizes(self, value):
"""
self.resume.edit_property("column_sizes", value)

@property
def main_window_state(self):
"""Retrieve the geometric position and scale of the main window."""
# calculate the default size and position for the center of the screen
# if the property does not exist, the window should be on the center of the screen


return self.resume.get_property("main_window_state", None)


@main_window_state.setter
def main_window_state(self, value):
"""Store the geometric position and scale of the main window.
Args:
value (dict): Dictionary of window state.
"""
self.resume.edit_property("main_window_state", value)

@classmethod
def __set_authentication_status(cls, state):
"""Sets the authentication status of the user.
Expand Down
12 changes: 12 additions & 0 deletions tik_manager4/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ def resume_last_state(self):
self.tik.user.column_sizes.get("categories", {})
)

# set the main window state back
window_state = self.tik.user.main_window_state
if window_state:
self.setGeometry(QtCore.QRect(*self.tik.user.main_window_state))

def initialize_mcv(self):
"""Initialize the model-control-views."""
self.project_mcv = TikProjectLayout(self.tik, parent=self)
Expand Down Expand Up @@ -365,6 +370,13 @@ def set_last_state(self):
}
self.tik.user.column_sizes = column_sizes

self.tik.user.main_window_state = (
self.geometry().x(),
self.geometry().y(),
self.geometry().width(),
self.geometry().height(),
)

# override the closeEvent to save the window state
def closeEvent(self, event): # pylint: disable=invalid-name
"""Override the close event to save the window state."""
Expand Down

0 comments on commit 9f6e62c

Please sign in to comment.