Open MadHoek opened 1 year ago
Agreed, the app does store the position but moves lower and lower as it's opened and closed.
I have noticed that as well, I believe it may be recording the inner position of the window ( so the top corner below the title bar), and then setting the position of the top of the title bar...I'll look into it some more.
I have had some issues with resizing as well, and in particular with switching between monitors with different resolutions...I recall finding a stackoverflow thread related to how Qt deals with display resolutions, I'll try to find it
I couldn't find the exact thread, but it has to do with a monitor's DPI, and if one is scaled to 150%, it'll look different. I think there could be a fix for this but it may take a bit to figure out.
Thanks!
Thank you @majikat768, let me know if you want me to do any additional testing. I should be available.
By some research and fiddling, I think I figured out a fix. At least it restores the window position for me correctly now:
In src\MainWindow\MainWindow.py:
def __init__(self, parent=None) -> None:
...
# move window to last known position / size
#if settings.value("window_position", "") != "": # commented by @monsterdhal
#self.move(settings.value("window_position")) # commented by @monsterdhal
#if settings.value("window_size", "") != "": # commented by @monsterdhal
#size = settings.value("window_size") # commented by @monsterdhal
#self.resize(size.width(),size.height()) # commented by @monsterdhal
# use restoreGeometry() and restoreState() to restore window position (@monsterdhal)
if not settings.value("geometry") == None:
self.restoreGeometry(settings.value("geometry"))
if not settings.value("windowState") == None:
self.restoreState(settings.value("windowState"))
...
def closeEvent(self, a0):
...
#pos = self.mapToGlobal(QPoint(0,0)) # commented by @monsterdhal
if not self.isMini:
#settings.setValue("window_position", pos) # commented by @monsterdhal
#settings.setValue("window_size", self.size()) # commented by @monsterdhal
# instead of mapToGlobal(QPoint(0,0) use saveGeometry() and saveState() (@monsterdhal)
settings.setValue("geometry", self.saveGeometry())
settings.setValue("windowState", self.saveState())
thanks @monsterdhal! Haven't had much time to work on this lately, but I'll take a look at your fix and see if I can get it implemented 👍
That would be so nice, @majikat768. I am sorry, that I haven't really contributed my solution in the most convenient way, but I hope it's not too much of a hassle, dealing with my code snippet. You did great work with that tool, btw. Thank you a lot!
The app saves the last used window positon after it is closed. I noticed some weired behavior and it seems it auto lowers it after each time it is closed by 31 pixels, meaning one has to reposition it constantly. (I use a multi-screen setup, for your information)
The window size has a different behavior, if one sets it manually to like 960 by 1080 (1/2 HD screen) it sets back to 960 by 1061 but it stays that way through restarts.
A quick solution for the lowering position could be to have a switch for a fixed position.