settingswidget.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. #include "ui_settingswidget.h"
  2. #include "models/settings.h"
  3. #include "models/filesystem.h"
  4. #include "models/patchdownloader.h"
  5. #include "widgets/settingswidget.h"
  6. #include "widgets/mainwindow.h"
  7. #include "constants.h"
  8. #include <QDebug>
  9. #include <QScrollBar>
  10. #include <QFileDialog>
  11. #include <QMetaObject>
  12. #include <QMessageBox>
  13. using namespace SettingsWidgetPrivate;
  14. SettingsWidget::SettingsWidget(QWidget *parent)
  15. : QWidget(parent)
  16. , ui(new Ui::SettingsWidget)
  17. {
  18. settings_changed_ = false;
  19. ui->setupUi(this);
  20. combobox_scrolling_disabler = new ComboboxScrollingDisabler();
  21. scroller = new SettingsTabsScroller({ui->sub_entry_1,
  22. ui->sub_entry_2,
  23. ui->sub_entry_3,
  24. ui->sub_entry_4
  25. },
  26. ui->content_scroll_area);
  27. ui->lotro_base_language_combobox->installEventFilter(combobox_scrolling_disabler);
  28. ui->interface_scale_combobox->installEventFilter(combobox_scrolling_disabler);
  29. // ui->content_scroll_area->verticalScrollBar()->installEventFilter(scroller);
  30. ui->patch_installing_label->hide();
  31. connect(&PatchInstaller::instance(), &PatchInstaller::started, this, &SettingsWidget::onPatchTotalOperationsStarted);
  32. connect(&PatchInstaller::instance(), &PatchInstaller::finished, this, &SettingsWidget::onPatchTotalOperationsFinished);
  33. connect(&PatchDownloader::instance(), &PatchDownloader::started, this, &SettingsWidget::onPatchTotalOperationsStarted);
  34. connect(&PatchDownloader::instance(), &PatchDownloader::finished, this, &SettingsWidget::onPatchTotalOperationsFinished);
  35. // connect(legacy_patches, &PatchList::backupSettingsInfoChanged, this, &SettingsWidget::onBackupSettingsInfoChanged);
  36. // connect(legacy_patches->getManager(), &LotroDatManager::statusChanged, this, &SettingsWidget::onLotroManagerProcessChanged);
  37. ui->apply_changes_button->hide();
  38. ui->apply_changes_label->hide();
  39. ui->patch_installing_label->hide();
  40. settings_backup_ = Settings::createSettingsBackup();
  41. setActualParametersValues();
  42. }
  43. SettingsWidget::~SettingsWidget()
  44. {
  45. delete combobox_scrolling_disabler;
  46. delete scroller;
  47. delete ui;
  48. }
  49. void SettingsWidget::setActualParametersValues()
  50. {
  51. QString game_path = Settings::getValue("Lotro/game_path").toString();
  52. if (game_path == "none") {
  53. game_path = "Путь к файлам игры не выбран";
  54. }
  55. ui->game_folder_path->setText(game_path);
  56. QString original_locale = Settings::getValue("Lotro/original_locale").toString();
  57. int index = 0;
  58. if (original_locale == "English")
  59. index = 0;
  60. if (original_locale == "DE")
  61. index = 1;
  62. if (original_locale == "FR")
  63. index = 2;
  64. ui->lotro_base_language_combobox->setCurrentIndex(index);
  65. ui->skiprawdownload_checkbox->setChecked(Settings::getValue("Lotro/skip_raw_download").toBool());
  66. ui->nosplashscreen_checkbox->setChecked(Settings::getValue("Lotro/no_splash_screen").toBool());
  67. QString backup_status = Settings::getValue("Backup/installed").toBool() ? "Активна" : "Отсутствует";
  68. ui->backup_status_value->setText(backup_status);
  69. ui->backup_path_value->setText(QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString());
  70. QString backup_creation_time = Settings::getValue("Backup/creation_time").toString();
  71. if (backup_creation_time == "none")
  72. backup_creation_time = "-";
  73. ui->backup_creation_time_value->setText(backup_creation_time);
  74. ui->patch_texts_checkbox->setChecked(Settings::getValue("Components/texts_main").toBool());
  75. ui->patch_items_checkbox->setChecked(Settings::getValue("Components/texts_items").toBool());
  76. ui->patch_emotes_checkbox->setChecked(Settings::getValue("Components/texts_emotes").toBool());
  77. ui->patch_maps_checkbox->setChecked(Settings::getValue("Components/maps").toBool());
  78. ui->patch_loadscreens_checkbox->setChecked(Settings::getValue("Components/loadscreens").toBool());
  79. ui->patch_textures_checkbox->setChecked(Settings::getValue("Components/textures").toBool());
  80. ui->patch_sounds_checkbox->setChecked(Settings::getValue("Components/sounds").toBool());
  81. ui->patch_video_checkbox->setChecked(Settings::getValue("Components/videos").toBool());
  82. ui->micropatch_checkbox->setChecked(Settings::getValue("Components/micropatch").toBool());
  83. int interface_scale = Settings::getValue("General/UI_scale").toInt();
  84. int interface_scale_combobox_index = 0;
  85. if (interface_scale == 50)
  86. interface_scale_combobox_index = 0;
  87. if (interface_scale == 75)
  88. interface_scale_combobox_index = 1;
  89. if (interface_scale == 100)
  90. interface_scale_combobox_index = 2;
  91. if (interface_scale == 125)
  92. interface_scale_combobox_index = 3;
  93. if (interface_scale == 150)
  94. interface_scale_combobox_index = 4;
  95. if (interface_scale == 175)
  96. interface_scale_combobox_index = 5;
  97. if (interface_scale == 200)
  98. interface_scale_combobox_index = 6;
  99. ui->interface_scale_combobox->setCurrentIndex(interface_scale_combobox_index);
  100. }
  101. void SettingsWidget::updateFontsSizes()
  102. {
  103. ui->frame_title->setFont(trajan_10pt);
  104. ui->group_label_1->setFont(trajan_9pt);
  105. ui->group_label_2->setFont(trajan_9pt);
  106. ui->group_label_3->setFont(trajan_9pt);
  107. ui->group_label_4->setFont(trajan_9pt);
  108. ui->patch_installing_label->setFont(crimson_12pt);
  109. ui->apply_changes_button->setFont(trajan_10pt);
  110. ui->sub_entry_1_title->setFont(garamond_11pt);
  111. ui->sub_entry_2_title->setFont(garamond_11pt);
  112. ui->sub_entry_3_title->setFont(garamond_11pt);
  113. ui->sub_entry_4_title->setFont(garamond_11pt);
  114. ui->backup_create_button->setFont(trajan_8pt);
  115. ui->backup_restore_button->setFont(trajan_8pt);
  116. ui->backup_remove_button->setFont(trajan_8pt);
  117. ui->game_folder_label->setFont(crimson_11pt);
  118. ui->game_folder_path->setFont(crimson_11pt);
  119. ui->lotro_base_language_label->setFont(crimson_11pt);
  120. ui->lotro_base_language_combobox->setFont(crimson_11pt);
  121. ui->lotro_base_language_combobox->insertItem(ui->lotro_base_language_combobox->count(), ""); // is needed to invoke elements resize
  122. ui->lotro_base_language_combobox->removeItem(ui->lotro_base_language_combobox->count() - 1);
  123. ui->skiprawdownload_checkbox->setFont(crimson_11pt);
  124. ui->nosplashscreen_checkbox->setFont(crimson_11pt);
  125. ui->backup_status_label->setFont(crimson_11pt);
  126. ui->backup_status_value->setFont(crimson_11pt);
  127. ui->backup_creation_time_label->setFont(crimson_11pt);
  128. ui->backup_creation_time_value->setFont(crimson_11pt);
  129. ui->backup_path_label->setFont(crimson_11pt);
  130. ui->backup_path_value->setFont(crimson_11pt);
  131. ui->patch_emotes_checkbox->setFont(crimson_11pt);
  132. ui->patch_items_checkbox->setFont(crimson_11pt);
  133. ui->patch_loadscreens_checkbox->setFont(crimson_11pt);
  134. ui->patch_maps_checkbox->setFont(crimson_11pt);
  135. ui->patch_sounds_checkbox->setFont(crimson_11pt);
  136. ui->patch_textures_checkbox->setFont(crimson_11pt);
  137. ui->patch_video_checkbox->setFont(crimson_11pt);
  138. ui->patch_texts_checkbox->setFont(crimson_11pt);
  139. ui->micropatch_checkbox->setFont(crimson_11pt);
  140. ui->interface_scale_label->setFont(crimson_11pt);
  141. ui->interface_scale_combobox->setFont(crimson_11pt);
  142. ui->interface_scale_combobox->insertItem(ui->interface_scale_combobox->count(), "250%"); // is needed to invoke elements resize
  143. ui->interface_scale_combobox->removeItem(ui->interface_scale_combobox->count() - 1);
  144. ui->texts_block_label->setFont(crimson_12pt);
  145. ui->graphics_block_label->setFont(crimson_12pt);
  146. ui->sounds_block_label->setFont(crimson_12pt);
  147. }
  148. void SettingsWidget::resizeEvent(QResizeEvent *)
  149. {
  150. updateFontsSizes();
  151. double coefficient = window_width / default_window_width;
  152. ui->frame_title->move(QPoint(45, 33) * coefficient);
  153. ui->frame_title->resize(QSize(201, 21) * coefficient);
  154. ui->checkpoints_list->move(QPoint(25, 70) * coefficient);
  155. ui->checkpoints_list->resize(QSize(265, 451) * coefficient);
  156. ui->content_scroll_area->move(QPoint(310, 0) * coefficient);
  157. ui->content_scroll_area->resize(QSize(671, 521) * coefficient);
  158. ui->content_widget->setMinimumWidth(650 * coefficient);
  159. ui->change_folder_button->setMinimumSize(QSize(36, 32) * coefficient);
  160. ui->patch_texts_icon->setMinimumSize(QSize(80, 80) * coefficient);
  161. ui->patch_graphics_icon->setMinimumSize(QSize(80, 80) * coefficient);
  162. ui->patch_sounds_icon->setMinimumSize(QSize(80, 80) * coefficient);
  163. ui->apply_changes_button->setMinimumSize(QSize(160, 60) * coefficient);
  164. }
  165. void SettingsWidget::onLotroManagerProcessChanged(PatchInstaller::Status status)
  166. {
  167. // if (status.status != LOTRO_DAT::DatStatus::E_BACKUP_CREATING &&
  168. // status.status != LOTRO_DAT::DatStatus::E_BACKUP_REMOVING &&
  169. // status.status != LOTRO_DAT::DatStatus::E_BACKUP_RESTORING) {
  170. // return;
  171. // }
  172. // QString operation;
  173. // if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_CREATING) {
  174. // operation = "Создание копии";
  175. // }
  176. // if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_REMOVING) {
  177. // operation = "Удаление копии";
  178. // }
  179. // if (status.status == LOTRO_DAT::DatStatus::E_BACKUP_RESTORING) {
  180. // operation = "Восстановление данных";
  181. // }
  182. // operation = operation + " " + QString::number(status.percentage, 'f', 1) + "%";
  183. // ui->backup_status_value->setText(operation);
  184. }
  185. void SettingsWidget::onBackupSettingsInfoChanged()
  186. {
  187. settings_backup_["Backup/installed"] = Settings::getValue("Backup/installed");
  188. settings_backup_["Backup/path"] = Settings::getValue("Backup/path");
  189. settings_backup_["Backup/creation_time"] = Settings::getValue("Backup/creation_time");
  190. QString backup_status = Settings::getValue("Backup/installed").toBool() ? "Активна" : "Отсутствует";
  191. ui->backup_status_value->setText(backup_status);
  192. ui->backup_path_value->setText(QApplication::applicationDirPath() + Settings::getValue("Backup/path").toString());
  193. QString backup_creation_time = Settings::getValue("Backup/creation_time").toString();
  194. if (backup_creation_time == "none")
  195. backup_creation_time = "-";
  196. ui->backup_creation_time_value->setText(backup_creation_time);
  197. }
  198. void SettingsWidget::processParameterChange() {
  199. if (!settings_changed_) {
  200. settings_changed_ = true;
  201. emit SettingsChanged();
  202. ui->apply_changes_label->show();
  203. ui->apply_changes_button->show();
  204. }
  205. }
  206. void SettingsWidget::checkIfParametersWereReset() {
  207. if (settings_changed_ && settings_backup_ == Settings::createSettingsBackup()) {
  208. settings_changed_ = false;
  209. emit SettingsReset();
  210. ui->apply_changes_label->hide();
  211. ui->apply_changes_button->hide();
  212. }
  213. }
  214. void SettingsWidget::on_change_folder_button_clicked()
  215. {
  216. QStringList known_paths = FileSystem::recognizeRegistryLotroPath();
  217. QString template_path = known_paths.empty() ? "" : known_paths[0];
  218. QString str = QFileDialog::getOpenFileName(0, "Расположение игры", template_path, "LotroLauncher.exe");
  219. if (str.isEmpty()) {
  220. return;
  221. }
  222. QString game_folder= str.replace("/LotroLauncher.exe", "").replace("\\", "/").replace("//", "/") + "/";
  223. if (settings_backup_["Lotro/game_path"].toString() == game_folder) {
  224. return;
  225. }
  226. processParameterChange();
  227. settings_backup_["Lotro/game_path"] = game_folder;
  228. ui->game_folder_path->setText(game_folder);
  229. checkIfParametersWereReset();
  230. }
  231. void SettingsWidget::on_lotro_base_language_combobox_currentIndexChanged(int index)
  232. {
  233. QString value = "English";
  234. if (index == 0)
  235. value = "English";
  236. if (index == 1)
  237. value = "DE";
  238. if (index == 2)
  239. value = "FR";
  240. if (settings_backup_["Lotro/original_locale"].toString() == value) {
  241. return;
  242. }
  243. processParameterChange();
  244. settings_backup_["Lotro/original_locale"] = value;
  245. checkIfParametersWereReset();
  246. }
  247. void SettingsWidget::on_skiprawdownload_checkbox_stateChanged(int arg1) {
  248. if (arg1 == Qt::Checked) {
  249. Settings::setValue("Lotro/skip_raw_download", true);
  250. settings_backup_["Lotro/skip_raw_download"] = true;
  251. }
  252. if (arg1 == Qt::Unchecked) {
  253. Settings::setValue("Lotro/skip_raw_download", false);
  254. settings_backup_["Lotro/skip_raw_download"] = false;
  255. }
  256. }
  257. void SettingsWidget::on_nosplashscreen_checkbox_stateChanged(int arg1)
  258. {
  259. if (arg1 == Qt::Checked) {
  260. Settings::setValue("Lotro/no_splash_screen", true);
  261. settings_backup_["Lotro/no_splash_screen"] = true;
  262. }
  263. if (arg1 == Qt::Unchecked) {
  264. Settings::setValue("Lotro/no_splash_screen", false);
  265. settings_backup_["Lotro/no_splash_screen"] = false;
  266. }
  267. }
  268. void SettingsWidget::on_backup_create_button_clicked()
  269. {
  270. if (settings_changed_) {
  271. QMessageBox::warning(nullptr, "Невозможно выполнить действие!", "Некоторые настройки были изменены. Чтобы создать резервную копию, примените или отмените изменения!");
  272. return;
  273. }
  274. if (Settings::getValue("Backup/installed").toBool()) {
  275. int result = QMessageBox::question(nullptr, "Подтвердите действие", "Резервная копия уже существует. Вы хотите перезаписать существующую копию?", QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);
  276. if (result != QMessageBox::Yes) {
  277. return;
  278. }
  279. }
  280. // QMetaObject::invokeMethod(legacy_patches_, "createBackup", Qt::QueuedConnection);
  281. }
  282. void SettingsWidget::on_backup_restore_button_clicked()
  283. {
  284. if (!Settings::getValue("Backup/installed").toBool()) {
  285. QMessageBox::warning(nullptr, "Невозможно выполнить действие.", "Резервная копия не найдена. Создайте резервную копию, чтобы иметь возможность восстановления данных.");
  286. return;
  287. }
  288. if (settings_changed_) {
  289. QMessageBox::warning(nullptr, "Невозможно выполнить действие.", "Некоторые настройки были изменены. Чтобы восстановить данные из резервной копии, примените или отмените изменения!");
  290. return;
  291. }
  292. // QMetaObject::invokeMethod(legacy_patches_, "restoreFromBackup", Qt::QueuedConnection);
  293. }
  294. void SettingsWidget::on_backup_remove_button_clicked()
  295. {
  296. if (Settings::getValue("Backup/installed").toBool()) {
  297. int result = QMessageBox::question(nullptr, "Подтвердите действие", "Вы уверены, что хотите удалить существующую резервную копию?", QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);
  298. if (result != QMessageBox::Yes) {
  299. return;
  300. }
  301. } else {
  302. QMessageBox::information(nullptr, "Невозможно выполнить действие.", "Удаление невозможно: резервной копии не существует.");
  303. return;
  304. }
  305. // QMetaObject::invokeMethod(legacy_patches_, "removeBackup", Qt::QueuedConnection);
  306. }
  307. void SettingsWidget::on_patch_texts_checkbox_clicked()
  308. {
  309. processParameterChange();
  310. if (ui->patch_texts_checkbox->isChecked()) {
  311. settings_backup_["Components/texts_main"] = true;
  312. } else {
  313. settings_backup_["Components/texts_main"] = false;
  314. }
  315. checkIfParametersWereReset();
  316. }
  317. void SettingsWidget::on_patch_items_checkbox_clicked()
  318. {
  319. processParameterChange();
  320. if (ui->patch_items_checkbox->isChecked()) {
  321. settings_backup_["Components/texts_items"] = true;
  322. } else {
  323. settings_backup_["Components/texts_items"] = false;
  324. }
  325. checkIfParametersWereReset();
  326. }
  327. void SettingsWidget::on_patch_emotes_checkbox_clicked()
  328. {
  329. processParameterChange();
  330. if (ui->patch_emotes_checkbox->isChecked()) {
  331. settings_backup_["Components/texts_emotes"] = true;
  332. } else {
  333. settings_backup_["Components/texts_emotes"] = false;
  334. }
  335. checkIfParametersWereReset();
  336. }
  337. void SettingsWidget::on_patch_maps_checkbox_clicked()
  338. {
  339. processParameterChange();
  340. if (ui->patch_maps_checkbox->isChecked()) {
  341. settings_backup_["Components/maps"] = true;
  342. } else {
  343. settings_backup_["Components/maps"] = false;
  344. }
  345. checkIfParametersWereReset();
  346. }
  347. void SettingsWidget::on_patch_textures_checkbox_clicked()
  348. {
  349. processParameterChange();
  350. if (ui->patch_textures_checkbox->isChecked()) {
  351. settings_backup_["Components/textures"] = true;
  352. } else {
  353. settings_backup_["Components/textures"] = false;
  354. }
  355. checkIfParametersWereReset();
  356. }
  357. void SettingsWidget::on_patch_loadscreens_checkbox_clicked()
  358. {
  359. processParameterChange();
  360. if (ui->patch_loadscreens_checkbox->isChecked()) {
  361. settings_backup_["Components/loadscreens"] = true;
  362. } else {
  363. settings_backup_["Components/loadscreens"] = false;
  364. }
  365. checkIfParametersWereReset();
  366. }
  367. void SettingsWidget::on_patch_sounds_checkbox_clicked()
  368. {
  369. processParameterChange();
  370. if (ui->patch_sounds_checkbox->isChecked()) {
  371. settings_backup_["Components/sounds"] = true;
  372. } else {
  373. settings_backup_["Components/sounds"] = false;
  374. }
  375. checkIfParametersWereReset();
  376. }
  377. void SettingsWidget::on_patch_video_checkbox_clicked()
  378. {
  379. processParameterChange();
  380. if (ui->patch_video_checkbox->isChecked()) {
  381. settings_backup_["Components/videos"] = true;
  382. } else {
  383. settings_backup_["Components/videos"] = false;
  384. }
  385. checkIfParametersWereReset();
  386. }
  387. void SettingsWidget::on_patch_force_apply_button_clicked()
  388. {
  389. const auto isComponentActivated = [](QString component_name) -> bool {
  390. return Settings::getValue("Components/" + component_name).toBool();
  391. };
  392. const bool texts_activated = (isComponentActivated("videos") || isComponentActivated("texts_main") || isComponentActivated("texts_items") || isComponentActivated("texts_emotes"));
  393. const bool fonts_activated = (isComponentActivated("texts_main") || isComponentActivated("texts_items") || isComponentActivated("texts_emotes"));
  394. const bool images_activated = isComponentActivated("maps");
  395. const bool loadscreens_activated = isComponentActivated("loadscreens");
  396. const bool textures_activated = isComponentActivated("textures");
  397. const bool sounds_activated = isComponentActivated("sounds");
  398. const bool videos_activated = isComponentActivated("videos");
  399. const bool micropatch_activated = isComponentActivated("micropatch");
  400. if (texts_activated)
  401. Settings::setValue("DatabaseNeedInstall/text", true);
  402. if (fonts_activated)
  403. Settings::setValue("DatabaseNeedInstall/font", true);
  404. if (images_activated)
  405. Settings::setValue("DatabaseNeedInstall/image", true);
  406. if (loadscreens_activated)
  407. Settings::setValue("DatabaseNeedInstall/loadscreen", true);
  408. if (textures_activated)
  409. Settings::setValue("DatabaseNeedInstall/texture", true);
  410. if (sounds_activated)
  411. Settings::setValue("DatabaseNeedInstall/sound", true);
  412. if (videos_activated)
  413. Settings::setValue("DatabaseNeedInstall/video", true);
  414. if (micropatch_activated)
  415. Settings::setValue("DatabaseNeedInstall/micro", true);
  416. QMetaObject::invokeMethod(&PatchDownloader::instance(), "startPatchDownloaderChain");
  417. }
  418. void SettingsWidget::on_micropatch_checkbox_clicked()
  419. {
  420. processParameterChange();
  421. if (ui->micropatch_checkbox->isChecked()) {
  422. settings_backup_["Components/micropatch"] = true;
  423. } else {
  424. settings_backup_["Components/micropatch"] = false;
  425. }
  426. checkIfParametersWereReset();
  427. }
  428. void SettingsWidget::on_interface_scale_combobox_currentIndexChanged(const QString &arg1)
  429. {
  430. MainWindow* window = qobject_cast<MainWindow*>(qApp->activeWindow());
  431. if (!window) {
  432. ui->interface_scale_combobox->setCurrentText(Settings::getValue("General/UI_scale").toString() + "%");
  433. qDebug() << "CANNOT FIND MAIN WINDOW!!!";
  434. return;
  435. }
  436. int value = arg1.left(arg1.length() - 1).toInt();
  437. window->resize(default_window_width * value / 100, default_window_height * value / 100);
  438. Settings::setValue("General/UI_scale", value);
  439. settings_backup_["General/UI_scale"] = value;
  440. }
  441. void SettingsWidget::onPatchTotalOperationsStarted()
  442. {
  443. patch_operations_running_++;
  444. if (patch_operations_running_ == 1) {
  445. ui->patch_installing_label->show();
  446. ui->change_folder_button->setEnabled(false);
  447. ui->lotro_base_language_combobox->setEnabled(false);
  448. ui->backup_create_button->setEnabled(false);
  449. ui->backup_restore_button->setEnabled(false);
  450. ui->backup_remove_button->setEnabled(false);
  451. ui->patch_texts_checkbox->setEnabled(false);
  452. ui->patch_items_checkbox->setEnabled(false);
  453. ui->patch_emotes_checkbox->setEnabled(false);
  454. ui->patch_maps_checkbox->setEnabled(false);
  455. ui->patch_textures_checkbox->setEnabled(false);
  456. ui->patch_loadscreens_checkbox->setEnabled(false);
  457. ui->patch_sounds_checkbox->setEnabled(false);
  458. ui->patch_video_checkbox->setEnabled(false);
  459. ui->patch_force_apply_button->setEnabled(false);
  460. ui->micropatch_checkbox->setEnabled(false);
  461. }
  462. }
  463. void SettingsWidget::onPatchTotalOperationsFinished()
  464. {
  465. patch_operations_running_--;
  466. if (patch_operations_running_ == 0) {
  467. ui->patch_installing_label->hide();
  468. settings_backup_ = Settings::createSettingsBackup();
  469. ui->change_folder_button->setEnabled(true);
  470. ui->lotro_base_language_combobox->setEnabled(true);
  471. ui->backup_create_button->setEnabled(true);
  472. ui->backup_restore_button->setEnabled(true);
  473. ui->backup_remove_button->setEnabled(true);
  474. ui->patch_texts_checkbox->setEnabled(true);
  475. ui->patch_items_checkbox->setEnabled(true);
  476. ui->patch_emotes_checkbox->setEnabled(true);
  477. ui->patch_maps_checkbox->setEnabled(true);
  478. ui->patch_textures_checkbox->setEnabled(true);
  479. ui->patch_loadscreens_checkbox->setEnabled(true);
  480. ui->patch_sounds_checkbox->setEnabled(true);
  481. ui->patch_video_checkbox->setEnabled(true);
  482. ui->patch_force_apply_button->setEnabled(true);
  483. ui->micropatch_checkbox->setEnabled(true);
  484. }
  485. }
  486. void SettingsWidget::on_apply_changes_button_clicked()
  487. {
  488. Settings::restoreFromSettingsBackup(settings_backup_);
  489. Settings::updatePatchComponentsDependencies();
  490. settings_changed_ = false;
  491. ui->apply_changes_label->hide();
  492. ui->apply_changes_button->hide();
  493. emit SettingsApplied();
  494. }