Skip to content

Commit 837a725

Browse files
committed
Some bugs fixed
1 parent 1ae0208 commit 837a725

6 files changed

Lines changed: 98 additions & 20 deletions

File tree

omodsim/controls/modbusmessagewidget.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <QEvent>
12
#include "formatutils.h"
23
#include "htmldelegate.h"
34
#include "modbusmessagewidget.h"
@@ -19,6 +20,19 @@ ModbusMessageWidget::ModbusMessageWidget(QWidget *parent)
1920
setEditTriggers(QAbstractItemView::NoEditTriggers);
2021
}
2122

23+
///
24+
/// \brief ModbusMessageWidget::changeEvent
25+
/// \param event
26+
///
27+
void ModbusMessageWidget::changeEvent(QEvent* event)
28+
{
29+
if (event->type() == QEvent::LanguageChange)
30+
{
31+
update();
32+
}
33+
QListWidget::changeEvent(event);
34+
}
35+
2236
///
2337
/// \brief ModbusMessageWidget::clear
2438
///

omodsim/controls/modbusmessagewidget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class ModbusMessageWidget : public QListWidget
2929

3030
void setStatusColor(const QColor& clr);
3131

32+
protected:
33+
void changeEvent(QEvent* event) override;
34+
3235
private:
3336
void update();
3437

omodsim/dialogs/dialogmsgparser.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ DialogMsgParser::DialogMsgParser(DataDisplayMode mode, QWidget *parent)
2020
Qt::WindowTitleHint);
2121

2222
ui->info->setShowTimestamp(false);
23-
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Parse"));
2423
ui->hexView->setCheckState(mode == DataDisplayMode::Hex ? Qt::Checked : Qt::Unchecked);
2524

2625
auto dispatcher = QAbstractEventDispatcher::instance();
@@ -36,13 +35,27 @@ DialogMsgParser::~DialogMsgParser()
3635
if(_mm) delete _mm;
3736
}
3837

38+
///
39+
/// \brief DialogMsgParser::changeEvent
40+
/// \param event
41+
///
42+
void DialogMsgParser::changeEvent(QEvent* event)
43+
{
44+
if (event->type() == QEvent::LanguageChange)
45+
{
46+
ui->retranslateUi(this);
47+
}
48+
49+
QDialog::changeEvent(event);
50+
}
51+
3952
///
4053
/// \brief DialogMsgParser::on_awake
4154
///
4255
void DialogMsgParser::on_awake()
4356
{
4457
ui->deviceIdIncluded->setVisible(ui->buttonPdu->isChecked());
45-
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->bytesData->isEmpty());
58+
ui->pushButtonParse->setEnabled(!ui->bytesData->isEmpty());
4659
}
4760

4861
///
@@ -75,9 +88,9 @@ void DialogMsgParser::on_bytesData_valueChanged(const QByteArray& value)
7588
}
7689

7790
///
78-
/// \brief DialogMsgParser::accept
91+
/// \brief DialogMsgParser::on_pushButtonParse_clicked
7992
///
80-
void DialogMsgParser::accept()
93+
void DialogMsgParser::on_pushButtonParse_clicked()
8194
{
8295
auto data = ui->bytesData->value();
8396
if(data.isEmpty()) return;

omodsim/dialogs/dialogmsgparser.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ class DialogMsgParser : public QDialog
2020
explicit DialogMsgParser(DataDisplayMode mode, QWidget *parent = nullptr);
2121
~DialogMsgParser();
2222

23-
void accept() override;
23+
protected:
24+
void changeEvent(QEvent* event) override;
2425

2526
private slots:
2627
void on_awake();
2728
void on_hexView_toggled(bool);
2829
void on_bytesData_valueChanged(const QByteArray& value);
30+
void on_pushButtonParse_clicked();
2931

3032
private:
3133
Ui::DialogMsgParser *ui;

omodsim/dialogs/dialogmsgparser.ui

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,63 @@
188188
</widget>
189189
</item>
190190
<item>
191-
<widget class="QDialogButtonBox" name="buttonBox">
192-
<property name="orientation">
193-
<enum>Qt::Horizontal</enum>
194-
</property>
195-
<property name="standardButtons">
196-
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
197-
</property>
198-
<property name="centerButtons">
199-
<bool>true</bool>
200-
</property>
201-
</widget>
191+
<layout class="QHBoxLayout" name="horizontalLayout_3">
192+
<item>
193+
<spacer name="horizontalSpacer_3">
194+
<property name="orientation">
195+
<enum>Qt::Horizontal</enum>
196+
</property>
197+
<property name="sizeHint" stdset="0">
198+
<size>
199+
<width>40</width>
200+
<height>20</height>
201+
</size>
202+
</property>
203+
</spacer>
204+
</item>
205+
<item>
206+
<widget class="QPushButton" name="pushButtonParse">
207+
<property name="text">
208+
<string>Parse</string>
209+
</property>
210+
<property name="autoDefault">
211+
<bool>false</bool>
212+
</property>
213+
</widget>
214+
</item>
215+
<item>
216+
<widget class="QDialogButtonBox" name="buttonBox">
217+
<property name="sizePolicy">
218+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
219+
<horstretch>0</horstretch>
220+
<verstretch>0</verstretch>
221+
</sizepolicy>
222+
</property>
223+
<property name="orientation">
224+
<enum>Qt::Horizontal</enum>
225+
</property>
226+
<property name="standardButtons">
227+
<set>QDialogButtonBox::Close</set>
228+
</property>
229+
<property name="centerButtons">
230+
<bool>false</bool>
231+
</property>
232+
</widget>
233+
</item>
234+
<item>
235+
<spacer name="horizontalSpacer_4">
236+
<property name="orientation">
237+
<enum>Qt::Horizontal</enum>
238+
</property>
239+
<property name="sizeHint" stdset="0">
240+
<size>
241+
<width>40</width>
242+
<height>20</height>
243+
</size>
244+
</property>
245+
</spacer>
246+
</item>
247+
</layout>
202248
</item>
203249
</layout>
204250
</widget>

omodsim/mainwindow.ui

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@
470470
<string>Swapped FP</string>
471471
</property>
472472
<property name="shortcut">
473-
<string>Ctrl+Shift+7</string>
473+
<string notr="true">Ctrl+Shift+7</string>
474474
</property>
475475
</action>
476476
<action name="actionDblFloat">
@@ -658,15 +658,15 @@
658658
<bool>true</bool>
659659
</property>
660660
<property name="text">
661-
<string>Big-Endian</string>
661+
<string notr="true">Big-Endian</string>
662662
</property>
663663
</action>
664664
<action name="actionLittleEndian">
665665
<property name="checkable">
666666
<bool>true</bool>
667667
</property>
668668
<property name="text">
669-
<string>Little-Endian</string>
669+
<string notr="true">Little-Endian</string>
670670
</property>
671671
</action>
672672
<action name="actionByteOrder">
@@ -897,7 +897,7 @@
897897
<string>Msg Parser</string>
898898
</property>
899899
<property name="shortcut">
900-
<string>F9</string>
900+
<string notr="true">F9</string>
901901
</property>
902902
</action>
903903
</widget>

0 commit comments

Comments
 (0)