diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-07-30 13:59:28 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-07-30 13:59:28 +0300 |
commit | 622fc3f9c38a9226b3de7dcb3c0f5e52927560de (patch) | |
tree | 82364ea91ddf8e5813b04601cb1fb58c6cfac229 /src/MainWindow.cc | |
parent | 3c1f9696df002b40c30efe754777be489eb7429e (diff) |
Save and restore app's window size
closes #46
Diffstat (limited to 'src/MainWindow.cc')
-rw-r--r-- | src/MainWindow.cc | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/MainWindow.cc b/src/MainWindow.cc index 783ad5ff..649064b8 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -15,6 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "Config.h" #include "MainWindow.h" #include <QLayout> @@ -35,10 +36,11 @@ MainWindow::MainWindow(QWidget *parent) setObjectName("MainWindow"); setStyleSheet("QWidget#MainWindow {background-color: #f9f9f9}"); - resize(1066, 600); // 16:9 ratio - setMinimumSize(QSize(950, 600)); + restoreWindowSize(); + setMinimumSize(QSize(conf::window::minWidth, conf::window::minHeight)); - QFont font("Open Sans", 12); + QFont font("Open Sans"); + font.setPixelSize(conf::fontSize); font.setStyleStrategy(QFont::PreferAntialias); setFont(font); @@ -95,6 +97,27 @@ MainWindow::MainWindow(QWidget *parent) } } +void MainWindow::restoreWindowSize() +{ + QSettings settings; + int savedWidth = settings.value("window/width").toInt(); + int savedheight = settings.value("window/height").toInt(); + + if (savedWidth == 0 || savedheight == 0) + resize(conf::window::width, conf::window::height); + else + resize(savedWidth, savedheight); +} + +void MainWindow::saveCurrentWindowSize() +{ + QSettings settings; + QSize current = size(); + + settings.setValue("window/width", current.width()); + settings.setValue("window/height", current.height()); +} + void MainWindow::removeOverlayProgressBar() { QTimer *timer = new QTimer(this); |