Browse Source

UI: Save position and size of main window

Resolves bug tracker issue #0000143

Closes Pull Request #396
Socapex 10 years ago
parent
commit
baa1890ed6
1 changed files with 24 additions and 0 deletions
  1. 24 0
      obs/window-basic-main.cpp

+ 24 - 0
obs/window-basic-main.cpp

@@ -83,6 +83,22 @@ OBSBasic::OBSBasic(QWidget *parent)
 {
 	ui->setupUi(this);
 
+	int width = config_get_int(App()->GlobalConfig(), "MainWindow", "cx");
+
+	// Check if no values are saved (new installation).
+	if (width != 0) {
+		int height = config_get_int(App()->GlobalConfig(), "MainWindow",
+				"cy");
+		int posx = config_get_int(App()->GlobalConfig(), "MainWindow",
+				"posx");
+		int posy = config_get_int(App()->GlobalConfig(), "MainWindow",
+				"posy");
+
+		resize(width, height);
+		move(posx, posy);
+	}
+
+
 	char styleSheetPath[512];
 	int ret = os_get_config_path(styleSheetPath, sizeof(styleSheetPath),
 			"obs-studio/basic/stylesheet.qss");
@@ -660,6 +676,14 @@ OBSBasic::~OBSBasic()
 
 	config_set_int(App()->GlobalConfig(), "General", "LastVersion",
 			LIBOBS_API_VER);
+	config_set_int(App()->GlobalConfig(), "MainWindow", "cx",
+			this->width());
+	config_set_int(App()->GlobalConfig(), "MainWindow", "cy",
+			this->height());
+	config_set_int(App()->GlobalConfig(), "MainWindow", "posx",
+			this->pos().x());
+	config_set_int(App()->GlobalConfig(), "MainWindow", "posy",
+			this->pos().y());
 	config_save(App()->GlobalConfig());
 }