From 82c10d493e93b98a3b9878d3e008e3d6be9459ef Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 5 Jul 2019 10:22:15 +0200 Subject: gui: fix process detector not reverting on cancel Issue: #967 --- gui/process_detector.cpp | 10 ++++++---- gui/process_detector.h | 2 +- gui/settings.cpp | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp index 85333849..c49afcb1 100644 --- a/gui/process_detector.cpp +++ b/gui/process_detector.cpp @@ -98,8 +98,8 @@ int process_detector::add_row(QString const& exe_name, QString const& profile) QComboBox* cb = new QComboBox(); cb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum); - cb->addItem(""); cb->addItems(ini_list()); + cb->setCurrentText(ini_filename()); ui.tableWidget->setCellWidget(i, 1, cb); QTableWidgetItem* twi = new QTableWidgetItem(exe_name); @@ -117,10 +117,11 @@ int process_detector::add_row(QString const& exe_name, QString const& profile) return i; } -void process_detector::add_items() +void process_detector::load_rows() { + for (int k = ui.tableWidget->size().height() - 1; k >= 0; k--) + ui.tableWidget->removeRow(k); auto names = s.split_process_names(); - ui.tableWidget->clearContents(); auto keys = names.keys(); std::sort(keys.begin(), keys.end()); for (auto const& n : keys) @@ -133,7 +134,7 @@ process_detector::process_detector(QWidget* parent) : QWidget(parent) connect(ui.add, SIGNAL(clicked()), this, SLOT(add())); connect(ui.remove, SIGNAL(clicked()), this, SLOT(remove())); - add_items(); + load_rows(); QResizeEvent e(ui.tableWidget->size(), ui.tableWidget->size()); ui.tableWidget->resizeEvent(&e); @@ -160,6 +161,7 @@ void process_detector::save() void process_detector::revert() { + load_rows(); } void process_detector::add() diff --git a/gui/process_detector.h b/gui/process_detector.h index 4e8842c6..01bda14b 100644 --- a/gui/process_detector.h +++ b/gui/process_detector.h @@ -35,7 +35,7 @@ class OTR_GUI_EXPORT process_detector final : public QWidget proc_detector_settings s; int add_row(const QString& exe_name = "...", const QString& profile = ""); - void add_items(); + void load_rows(); public: process_detector(QWidget* parent = nullptr); public slots: diff --git a/gui/settings.cpp b/gui/settings.cpp index 230c4410..3851f0c2 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -234,6 +234,8 @@ void options_dialog::doOK() void options_dialog::doCancel() { + ui.game_detector->revert(); + if (isHidden()) // close() can return true twice in a row it seems return; hide(); @@ -241,7 +243,6 @@ void options_dialog::doCancel() return; main.b->reload(); - ui.game_detector->revert(); emit closing(); } -- cgit v1.2.3