Skip to content

Commit

Permalink
fix Cancel button in CSV loader (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartimaeus- authored Jun 6, 2022
1 parent 7e1d59e commit 62ecc25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions plotjuggler_plugins/DataLoadCSV/dataload_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QProgressDialog>
#include <QDateTime>
#include <QInputDialog>
#include <QPushButton>

const int TIME_INDEX_NOT_DEFINED = -2;
const int TIME_INDEX_GENERATED = -1;
Expand Down Expand Up @@ -91,16 +92,18 @@ DataLoadCSV::DataLoadCSV()
_ui = new Ui::DialogCSV();
_ui->setupUi(_dialog);

_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);

connect(_ui->radioButtonSelect, &QRadioButton::toggled, this, [this](bool checked) {
_ui->listWidgetSeries->setEnabled(checked);
auto selected = _ui->listWidgetSeries->selectionModel()->selectedIndexes();
bool box_enabled = !checked || selected.size() == 1;
_ui->buttonBox->setEnabled(box_enabled);
_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(box_enabled);
});
connect(_ui->listWidgetSeries, &QListWidget::itemSelectionChanged, this, [this]() {
auto selected = _ui->listWidgetSeries->selectionModel()->selectedIndexes();
bool box_enabled = _ui->radioButtonIndex->isChecked() || selected.size() == 1;
_ui->buttonBox->setEnabled(box_enabled);
_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(box_enabled);
});

connect(_ui->listWidgetSeries, &QListWidget::itemDoubleClicked, this,
Expand Down
2 changes: 1 addition & 1 deletion plotjuggler_plugins/DataLoadCSV/dataload_csv.ui
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down

0 comments on commit 62ecc25

Please sign in to comment.