diff --git a/include/Config.h b/include/Config.h
index e33fd959..e12fac85 100644
--- a/include/Config.h
+++ b/include/Config.h
@@ -11,6 +11,16 @@ static const int fontSize = 12;
static const int emojiSize = 14;
static const int headerFontSize = 21;
+// Window geometry.
+namespace window
+{
+static const int height = 600;
+static const int width = 1066;
+
+static const int minHeight = 600;
+static const int minWidth = 950;
+}
+
// Button settings.
namespace btn
{
diff --git a/include/MainWindow.h b/include/MainWindow.h
index 9d0a601f..a8a86719 100644
--- a/include/MainWindow.h
+++ b/include/MainWindow.h
@@ -39,6 +39,7 @@ public:
~MainWindow();
static MainWindow *instance();
+ void saveCurrentWindowSize();
protected:
void closeEvent(QCloseEvent *event);
@@ -63,6 +64,7 @@ private slots:
private:
bool hasActiveUser();
+ void restoreWindowSize();
static MainWindow *instance_;
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 .
*/
+#include "Config.h"
#include "MainWindow.h"
#include
@@ -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);
diff --git a/src/main.cc b/src/main.cc
index 28523858..55e4ec9b 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -70,5 +70,7 @@ int main(int argc, char *argv[])
w.move(x, y);
w.show();
+ QObject::connect(&app, &QApplication::aboutToQuit, &w, &MainWindow::saveCurrentWindowSize);
+
return app.exec();
}