summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-07-05 10:22:15 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-07-05 10:24:19 +0200
commit82c10d493e93b98a3b9878d3e008e3d6be9459ef (patch)
tree6233ec88594eae0bee65d4dad5bbe29ed42a90f8 /gui
parent6e86249bd8cc6d707756ef79ac9d02c429a2db06 (diff)
gui: fix process detector not reverting on cancel
Issue: #967
Diffstat (limited to 'gui')
-rw-r--r--gui/process_detector.cpp10
-rw-r--r--gui/process_detector.h2
-rw-r--r--gui/settings.cpp3
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();
}