GUI: added to option to convert text from a codepage in HexEditDialog + save last code page in CodepageSelectionDialog
This commit is contained in:
parent
9d2335cbbb
commit
749d526257
|
@ -838,6 +838,7 @@ void CPUDump::hexCodepageSlot()
|
|||
CodepageSelectionDialog dialog(this);
|
||||
if(dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
auto codepage = dialog.getSelectedCodepage();
|
||||
|
||||
int charwidth = getCharWidth();
|
||||
ColumnDescriptor_t wColDesc;
|
||||
|
@ -854,11 +855,11 @@ void CPUDump::hexCodepageSlot()
|
|||
wColDesc.isData = true; //text (in code page)
|
||||
wColDesc.itemCount = 16;
|
||||
wColDesc.separator = 0;
|
||||
wColDesc.textCodec = QTextCodec::codecForName(dialog.getSelectedCodepage());
|
||||
wColDesc.textCodec = QTextCodec::codecForName(codepage);
|
||||
dDesc.itemSize = Byte;
|
||||
dDesc.byteMode = AsciiByte;
|
||||
wColDesc.data = dDesc;
|
||||
appendDescriptor(0, dialog.getSelectedCodepage(), false, wColDesc);
|
||||
appendDescriptor(0, codepage, false, wColDesc);
|
||||
|
||||
reloadData();
|
||||
}
|
||||
|
@ -920,6 +921,7 @@ void CPUDump::textCodepageSlot()
|
|||
CodepageSelectionDialog dialog(this);
|
||||
if(dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
auto codepage = dialog.getSelectedCodepage();
|
||||
|
||||
ColumnDescriptor_t wColDesc;
|
||||
DataDescriptor_t dDesc;
|
||||
|
@ -927,11 +929,11 @@ void CPUDump::textCodepageSlot()
|
|||
wColDesc.isData = true; //text (in code page)
|
||||
wColDesc.itemCount = 64;
|
||||
wColDesc.separator = 0;
|
||||
wColDesc.textCodec = QTextCodec::codecForName(dialog.getSelectedCodepage());
|
||||
wColDesc.textCodec = QTextCodec::codecForName(codepage);
|
||||
dDesc.itemSize = Byte;
|
||||
dDesc.byteMode = AsciiByte;
|
||||
wColDesc.data = dDesc;
|
||||
appendResetDescriptor(0, dialog.getSelectedCodepage(), false, wColDesc);
|
||||
appendResetDescriptor(0, codepage, false, wColDesc);
|
||||
|
||||
reloadData();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "CodepageSelectionDialog.h"
|
||||
#include "ui_CodepageSelectionDialog.h"
|
||||
#include "Bridge.h"
|
||||
#include <QTextCodec>
|
||||
|
||||
CodepageSelectionDialog::CodepageSelectionDialog(QWidget* parent) :
|
||||
|
@ -19,11 +20,16 @@ CodepageSelectionDialog::CodepageSelectionDialog(QWidget* parent) :
|
|||
ui->listCodepages->addItem(name);
|
||||
mCodepages.append(codec->name());
|
||||
}
|
||||
ui->listCodepages->setCurrentRow(0);
|
||||
duint setting;
|
||||
if(BridgeSettingGetUint("Misc", "LastCodepage", &setting) && setting < duint(ui->listCodepages->count()))
|
||||
ui->listCodepages->setCurrentRow(setting);
|
||||
else
|
||||
ui->listCodepages->setCurrentRow(0);
|
||||
}
|
||||
|
||||
CodepageSelectionDialog::~CodepageSelectionDialog()
|
||||
{
|
||||
BridgeSettingSetUint("Misc", "LastCodepage", ui->listCodepages->currentRow());
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include "ui_HexEditDialog.h"
|
||||
#include "Configuration.h"
|
||||
#include "Bridge.h"
|
||||
#include "CodepageSelectionDialog.h"
|
||||
#include "LineEditDialog.h"
|
||||
|
||||
HexEditDialog::HexEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HexEditDialog)
|
||||
{
|
||||
|
@ -128,3 +130,19 @@ QByteArray HexEditDialog::resizeData(QByteArray & data)
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
void HexEditDialog::on_btnCodepage_clicked()
|
||||
{
|
||||
CodepageSelectionDialog codepageDialog(this);
|
||||
if(codepageDialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
auto textCodec = QTextCodec::codecForName(codepageDialog.getSelectedCodepage());
|
||||
if(!textCodec)
|
||||
return;
|
||||
LineEditDialog lineEdit(this);
|
||||
lineEdit.setWindowTitle(tr("Enter text to convert..."));
|
||||
if(lineEdit.exec() != QDialog::Accepted)
|
||||
return;
|
||||
mHexEdit->setData(resizeData(textCodec->fromUnicode(lineEdit.editText)));
|
||||
dataEditedSlot();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ private slots:
|
|||
void dataEditedSlot();
|
||||
void on_lineEditAscii_dataEdited();
|
||||
void on_lineEditUnicode_dataEdited();
|
||||
void on_btnCodepage_clicked();
|
||||
|
||||
private:
|
||||
Ui::HexEditDialog* ui;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>381</width>
|
||||
<height>272</height>
|
||||
<height>280</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -28,22 +28,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="HexLineEdit" name="lineEditAscii">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {border-style: outset; border-width: 1px; border-color: black}</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>32767</number>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelUnicode">
|
||||
<property name="text">
|
||||
|
@ -70,6 +54,22 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="HexLineEdit" name="lineEditAscii">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit {border-style: outset; border-width: 1px; border-color: black}</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>32767</number>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelHex">
|
||||
<property name="text">
|
||||
|
@ -80,6 +80,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="chkKeepSize">
|
||||
<property name="text">
|
||||
<string>&Keep Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="4">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="focusPolicy">
|
||||
|
@ -97,19 +111,12 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>361</width>
|
||||
<height>118</height>
|
||||
<height>116</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="chkKeepSize">
|
||||
<property name="text">
|
||||
<string>&Keep Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="chkEntireBlock">
|
||||
<property name="text">
|
||||
|
@ -117,13 +124,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="3">
|
||||
<widget class="QPushButton" name="btnCancel">
|
||||
<property name="text">
|
||||
|
@ -131,6 +131,25 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QPushButton" name="btnCodepage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Codepage...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
|
|
@ -45,6 +45,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonOk">
|
||||
<property name="text">
|
||||
|
|
Loading…
Reference in New Issue