Skip to content

Commit a300640

Browse files
committed
Fix jumping duration cursor.
1 parent da2de78 commit a300640

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

Common/Qt/Options/TimeDurationWidget.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ TimeDurationCellWidget<Type>::TimeDurationCellWidget(QWidget& parent, TimeDurati
3939
));
4040

4141
connect(
42-
this, &QLineEdit::textChanged,
43-
this, [this](const QString& text){
44-
std::string error = m_value.set(text.toStdString());
42+
this, &QLineEdit::editingFinished,
43+
this, [this](){
44+
m_value.set(this->text().toStdString());
4545
}
4646
);
4747

@@ -105,43 +105,47 @@ TimeDurationOptionWidget<Type>::TimeDurationOptionWidget(QWidget& parent, TimeDu
105105
"Wireless controllers have larger tick sizes and are imprecise due to wireless communication latency."
106106
));
107107

108-
QLabel* description = nullptr;
108+
m_description = nullptr;
109109
if (value.show_summary()){
110-
description = new QLabel(QString::fromStdString(m_value.time_string()), this);
111-
description->setAlignment(Qt::AlignHCenter);
112-
row1->addWidget(description);
110+
m_description = new QLabel(QString::fromStdString(m_value.time_string()), this);
111+
m_description->setAlignment(Qt::AlignHCenter);
112+
row1->addWidget(m_description);
113113
}
114114

115115
connect(
116116
m_box, &QLineEdit::editingFinished,
117-
this, [this, description](){
117+
this, [this](){
118118
std::string error = m_value.set(m_box->text().toStdString());
119-
if (description == nullptr){
119+
if (m_description == nullptr){
120120
return;
121121
}
122122
if (error.empty()){
123-
description->setText(QString::fromStdString(m_value.time_string()));
123+
m_description->setText(QString::fromStdString(m_value.time_string()));
124124
}else{
125-
description->setText(QString::fromStdString("<font color=\"red\">" + error + "</font>"));
125+
m_description->setText(QString::fromStdString("<font color=\"red\">" + error + "</font>"));
126126
}
127127
}
128128
);
129+
#if 0
129130
connect(
130131
m_box, &QLineEdit::textChanged,
131-
this, [this, description](){
132-
if (description == nullptr){
132+
this, [this, m_description](){
133+
if (m_description == nullptr){
133134
return;
134135
}
135136
std::string text = m_value.time_string(m_box->text().toStdString());
136-
description->setText(QString::fromStdString(text));
137+
m_description->setText(QString::fromStdString(text));
137138
}
138139
);
140+
#endif
139141

140142
value.add_listener(*this);
141143
}
142144
template <typename Type>
143145
void TimeDurationOptionWidget<Type>::update_value(){
144-
m_box->setText(QString::fromStdString(m_value.current_text()));
146+
std::string text = m_value.current_text();
147+
m_box->setText(QString::fromStdString(text));
148+
m_description->setText(QString::fromStdString(m_value.time_string()));
145149
}
146150
template <typename Type>
147151
void TimeDurationOptionWidget<Type>::on_config_value_changed(void* object){

Common/Qt/Options/TimeDurationWidget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "Common/Cpp/Options/TimeDurationOption.h"
1212
#include "ConfigWidget.h"
1313

14+
class QLabel;
15+
1416
namespace PokemonAutomation{
1517

1618

@@ -42,6 +44,7 @@ class TimeDurationOptionWidget : public QWidget, public ConfigWidget{
4244
private:
4345
TimeDurationOption<Type>& m_value;
4446
QLineEdit* m_box;
47+
QLabel* m_description;
4548
};
4649

4750

0 commit comments

Comments
 (0)