Skip to content

Commit 665a4f2

Browse files
committed
Fix a bug in encoding settings
1 parent c0997dc commit 665a4f2

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

src/datatab.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,10 @@ void DataTab::on_data_encodingSetButton_clicked()
122122
newCodec = QTextCodec::codecForName(box->currentText().toLatin1());
123123
if(newCodec != nullptr)
124124
{
125-
if(box->itemText(box->currentIndex()) == box->currentText()) // existing text
126-
dataEncodingId = box->currentIndex();
127125
if(RxDecoder != nullptr)
128126
delete RxDecoder;
129127
dataCodec = newCodec;
128+
box->setCurrentText(dataCodec->name());
130129
emit setDataCodec(dataCodec);
131130
RxDecoder = dataCodec->makeDecoder(); // clear state machine
132131
emit setPlotDecoder(dataCodec->makeDecoder());// clear state machine, standalone decoder for DataTab/PlotTab
@@ -137,7 +136,13 @@ void DataTab::on_data_encodingSetButton_clicked()
137136
else
138137
{
139138
QMessageBox::information(this, tr("Info"), ui->data_encodingNameBox->currentText() + " " + tr("is not a valid encoding."));
140-
box->setCurrentIndex(dataEncodingId);
139+
if(dataCodec != nullptr)
140+
box->setCurrentText(dataCodec->name());
141+
else
142+
{
143+
box->setCurrentText("UTF-8");
144+
on_data_encodingSetButton_clicked();
145+
}
141146
}
142147
}
143148

src/datatab.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ private slots:
7979
MySettings* settings;
8080
QTimer* repeatTimer;
8181

82-
int dataEncodingId = 0;
83-
8482
QScrollBar* RxSlider;
8583
int currRxSliderPos = 0;
8684
int userRequiredRxSliderPos = 0;

src/ui/datatab.ui

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,54 @@ margin-right:3em;
510510
<string>UTF-8</string>
511511
</property>
512512
</item>
513+
<item>
514+
<property name="text">
515+
<string>GB2312</string>
516+
</property>
517+
</item>
513518
<item>
514519
<property name="text">
515520
<string>GB18030</string>
516521
</property>
517522
</item>
518523
<item>
519524
<property name="text">
520-
<string>BIG5</string>
525+
<string>Big5</string>
526+
</property>
527+
</item>
528+
<item>
529+
<property name="text">
530+
<string>windows-1252</string>
531+
</property>
532+
</item>
533+
<item>
534+
<property name="text">
535+
<string>UTF-16LE</string>
536+
</property>
537+
</item>
538+
<item>
539+
<property name="text">
540+
<string>UTF-16BE</string>
541+
</property>
542+
</item>
543+
<item>
544+
<property name="text">
545+
<string>UTF-32LE</string>
546+
</property>
547+
</item>
548+
<item>
549+
<property name="text">
550+
<string>UTF-32BE</string>
551+
</property>
552+
</item>
553+
<item>
554+
<property name="text">
555+
<string>Shift_JIS</string>
556+
</property>
557+
</item>
558+
<item>
559+
<property name="text">
560+
<string>EUC-KR</string>
521561
</property>
522562
</item>
523563
</widget>

0 commit comments

Comments
 (0)