Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
humpback
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kasper Seweryn
humpback
Commits
6dfa5eb8
Commit
6dfa5eb8
authored
4 years ago
by
Kasper Seweryn
Browse files
Options
Downloads
Patches
Plain Diff
Preserve window position and state when reloaded
parent
1fe5ac80
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+24
-10
24 additions, 10 deletions
main.py
with
24 additions
and
10 deletions
main.py
+
24
−
10
View file @
6dfa5eb8
import
sys
import
sys
import
os
import
os
import
inotify.adapters
import
inotify.adapters
from
PySide6.QtCore
import
QThread
,
QObject
,
Signal
,
Slot
from
PySide6.QtCore
import
QThread
,
QObject
,
Signal
,
Slot
...
@@ -12,23 +13,36 @@ main = os.path.join(os.path.dirname(__file__), 'qml', "main.qml")
...
@@ -12,23 +13,36 @@ main = os.path.join(os.path.dirname(__file__), 'qml', "main.qml")
class
Master
(
QObject
):
class
Master
(
QObject
):
command
=
Signal
()
command
=
Signal
()
def
__init__
(
self
):
QObject
.
__init__
(
self
)
@Slot
()
@Slot
()
def
reload
(
self
):
def
reload
(
self
):
print
(
"
Loading UI
"
)
print
(
"
Loading UI
"
)
for
window
in
engine
.
rootObjects
():
windows
=
engine
.
rootObjects
()
window
.
destroy
()
if
len
(
windows
)
>
0
:
pos
=
windows
[
-
1
].
position
()
width
=
windows
[
-
1
].
width
()
height
=
windows
[
-
1
].
height
()
state
=
windows
[
-
1
].
windowState
()
for
window
in
windows
:
window
.
close
()
window
.
destroy
()
engine
.
clearComponentCache
()
engine
.
load
(
main
)
engine
.
clearComponentCache
()
if
not
engine
.
rootObjects
()
:
engine
.
load
(
main
)
sys
.
exit
(
-
1
)
if
not
engine
.
rootObjects
():
# NOTE: Every load creates new rootObject
sys
.
exit
(
-
1
)
window
=
engine
.
rootObjects
()[
-
1
]
window
.
setPosition
(
pos
);
window
.
setWindowState
(
state
)
window
.
resize
(
width
,
height
)
else
:
engine
.
load
(
main
)
# TODO: Move new window to old window position
if
not
engine
.
rootObjects
():
sys
.
exit
(
-
1
)
class
Worker
(
QObject
):
class
Worker
(
QObject
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment