| 157 | } |
| 158 | |
| 159 | OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new OpenRGBDialog2Ui) |
| 160 | { |
| 161 | ui->setupUi(this); |
| 162 | |
| 163 | /*-----------------------------------------------------*\ |
| 164 | | Set window icon | |
| 165 | \*-----------------------------------------------------*/ |
| 166 | QIcon logo(":OpenRGB.png"); |
| 167 | setWindowIcon(logo); |
| 168 | |
| 169 | /*-----------------------------------------------------*\ |
| 170 | | Set window geometry from config (if available) | |
| 171 | \*-----------------------------------------------------*/ |
| 172 | SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); |
| 173 | std::string ui_string = "UserInterface"; |
| 174 | json ui_settings; |
| 175 | |
| 176 | ui_settings = settings_manager->GetSettings(ui_string); |
| 177 | |
| 178 | /*-----------------------------------------------------*\ |
| 179 | | If geometry info doesn't exist, write it to config | |
| 180 | \*-----------------------------------------------------*/ |
| 181 | if(!ui_settings.contains("geometry")) |
| 182 | { |
| 183 | json geometry_settings; |
| 184 | |
| 185 | geometry_settings["load_geometry"] = false; |
| 186 | geometry_settings["save_on_exit"] = false; |
| 187 | geometry_settings["x"] = 0; |
| 188 | geometry_settings["y"] = 0; |
| 189 | geometry_settings["width"] = 0; |
| 190 | geometry_settings["height"] = 0; |
| 191 | |
| 192 | ui_settings["geometry"] = geometry_settings; |
| 193 | |
| 194 | settings_manager->SetSettings(ui_string, ui_settings); |
| 195 | settings_manager->SaveSettings(); |
| 196 | } |
| 197 | |
| 198 | /*-----------------------------------------------------*\ |
| 199 | | If geometry information exists in settings, apply it | |
| 200 | \*-----------------------------------------------------*/ |
| 201 | bool load_geometry = false; |
| 202 | |
| 203 | if(ui_settings["geometry"].contains("load_geometry")) |
| 204 | { |
| 205 | load_geometry = ui_settings["geometry"]["load_geometry"].get<bool>(); |
| 206 | } |
| 207 | |
| 208 | if(load_geometry) |
| 209 | { |
| 210 | QRect set_window; |
| 211 | |
| 212 | /*-----------------------------------------------------*\ |
| 213 | | x and y can be set independent of width and height | |
| 214 | | QT attempts to clamp these values in case the user | |
| 215 | | enters invalid numbers | |
| 216 | \*-----------------------------------------------------*/ |
nothing calls this directly
no test coverage detected