From 307ab43f637590a04ffe1f20377aa2cea659818e Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 10 Feb 2024 16:26:53 -0800 Subject: [PATCH] mainwindow: add an option to avoid restoring window geometry Do not save or restore window geometry when `restore_window_geometry=false` in `~/.config/nvim-qt/window-geometry.conf`. Defaults to `true`. Suggested-by: @damanis on github Related-to: #997 Related-to: #1094 --- src/gui/mainwindow.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 7892e2b5a..925feb336 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -312,6 +312,11 @@ Shell* MainWindow::shell() void MainWindow::saveWindowGeometry() { QSettings settings("nvim-qt", "window-geometry"); + bool restore_window_geometry = settings.value("restore_window_geometry", true).toBool(); + if (!restore_window_geometry) { + return; + } + settings.setValue("restore_window_geometry", restore_window_geometry); settings.setValue("window_geometry", saveGeometry()); settings.setValue("window_state", saveState()); } @@ -325,6 +330,9 @@ void MainWindow::restoreWindowGeometry() #endif QSettings settings("nvim-qt", "window-geometry"); + if (!settings.value("restore_window_geometry", true).toBool()) { + return; + } restoreGeometry(settings.value("window_geometry").toByteArray()); restoreState(settings.value("window_state").toByteArray()); }