Skip to content

Commit

Permalink
Fix a bug in encoding settings
Browse files Browse the repository at this point in the history
  • Loading branch information
wh201906 committed Aug 20, 2022
1 parent c0997dc commit 665a4f2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/datatab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,10 @@ void DataTab::on_data_encodingSetButton_clicked()
newCodec = QTextCodec::codecForName(box->currentText().toLatin1());
if(newCodec != nullptr)
{
if(box->itemText(box->currentIndex()) == box->currentText()) // existing text
dataEncodingId = box->currentIndex();
if(RxDecoder != nullptr)
delete RxDecoder;
dataCodec = newCodec;
box->setCurrentText(dataCodec->name());
emit setDataCodec(dataCodec);
RxDecoder = dataCodec->makeDecoder(); // clear state machine
emit setPlotDecoder(dataCodec->makeDecoder());// clear state machine, standalone decoder for DataTab/PlotTab
Expand All @@ -137,7 +136,13 @@ void DataTab::on_data_encodingSetButton_clicked()
else
{
QMessageBox::information(this, tr("Info"), ui->data_encodingNameBox->currentText() + " " + tr("is not a valid encoding."));
box->setCurrentIndex(dataEncodingId);
if(dataCodec != nullptr)
box->setCurrentText(dataCodec->name());
else
{
box->setCurrentText("UTF-8");
on_data_encodingSetButton_clicked();
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/datatab.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ private slots:
MySettings* settings;
QTimer* repeatTimer;

int dataEncodingId = 0;

QScrollBar* RxSlider;
int currRxSliderPos = 0;
int userRequiredRxSliderPos = 0;
Expand Down
42 changes: 41 additions & 1 deletion src/ui/datatab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,54 @@ margin-right:3em;
<string>UTF-8</string>
</property>
</item>
<item>
<property name="text">
<string>GB2312</string>
</property>
</item>
<item>
<property name="text">
<string>GB18030</string>
</property>
</item>
<item>
<property name="text">
<string>BIG5</string>
<string>Big5</string>
</property>
</item>
<item>
<property name="text">
<string>windows-1252</string>
</property>
</item>
<item>
<property name="text">
<string>UTF-16LE</string>
</property>
</item>
<item>
<property name="text">
<string>UTF-16BE</string>
</property>
</item>
<item>
<property name="text">
<string>UTF-32LE</string>
</property>
</item>
<item>
<property name="text">
<string>UTF-32BE</string>
</property>
</item>
<item>
<property name="text">
<string>Shift_JIS</string>
</property>
</item>
<item>
<property name="text">
<string>EUC-KR</string>
</property>
</item>
</widget>
Expand Down

0 comments on commit 665a4f2

Please sign in to comment.