Use last windows location when restoring the application.

This commit is contained in:
Julien Wadel 2022-12-20 18:20:57 +01:00
parent ea1fb992f2
commit 70f8e3ca65
3 changed files with 14 additions and 3 deletions

View file

@ -528,12 +528,20 @@ void App::smartShowWindow (QQuickWindow *window) {
window->show();
window->raise();// Raise ensure to get focus on Mac
window->requestActivate();
QSettings settings;
if(settings.contains("geometry"))
window->setGeometry(settings.value("geometry").toRect());
}
// -----------------------------------------------------------------------------
bool App::hasFocus () const {
return getMainWindow()->isActive() || (mCallsWindow && mCallsWindow->isActive());
}
void App::saveGeometry(){
QSettings settings;
settings.setValue("geometry", getMainWindow()->geometry());
}
void App::stateChanged(Qt::ApplicationState pState) {
DesktopTools::applicationStateChanged(pState);
auto core = CoreManager::getInstance();
@ -1106,4 +1114,4 @@ void App::checkForUpdates(bool force) {
CoreManager::getInstance()->getCore()->checkForUpdate(
Utils::appStringToCoreString(applicationVersion())
);
}
}

View file

@ -41,7 +41,6 @@ class DefaultTranslator;
class ImageListModel;
class Notifier;
class App : public SingleApplication {
Q_OBJECT
@ -117,6 +116,8 @@ public:
Q_INVOKABLE static void smartShowWindow (QQuickWindow *window);
Q_INVOKABLE static void checkForUpdates(bool force = false);
Q_INVOKABLE void saveGeometry();
public slots:
void stateChanged(Qt::ApplicationState);

View file

@ -48,7 +48,9 @@ ApplicationWindow {
// ---------------------------------------------------------------------------
onActiveFocusItemChanged: Logic.handleActiveFocusItemChanged(activeFocusItem)
onClosing: Logic.handleClosing(close)
onClosing: {App.saveGeometry()
Logic.handleClosing(close)
}
// ---------------------------------------------------------------------------