Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persistent main UI position and size #148

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading