mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 11:56:12 +00:00
Use same font size for all text in hexdump widget. (#1485)
This commit is contained in:
parent
7ce74cf1fe
commit
f68ed82489
@ -133,6 +133,10 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
|
|||||||
connect(seekable, &CutterSeekable::seekableSeekChanged, this, &HexdumpWidget::onSeekChanged);
|
connect(seekable, &CutterSeekable::seekableSeekChanged, this, &HexdumpWidget::onSeekChanged);
|
||||||
connect(&rangeDialog, &QDialog::accepted, this, &HexdumpWidget::on_rangeDialogAccepted);
|
connect(&rangeDialog, &QDialog::accepted, this, &HexdumpWidget::on_rangeDialogAccepted);
|
||||||
|
|
||||||
|
addAction(ui->actionResetZoom);
|
||||||
|
connect(ui->actionResetZoom, &QAction::triggered, this, &HexdumpWidget::zoomReset);
|
||||||
|
defaultFontSize = ui->hexHexText->font().pointSizeF();
|
||||||
|
|
||||||
format = Format::Hex;
|
format = Format::Hex;
|
||||||
initParsing();
|
initParsing();
|
||||||
selectHexPreview();
|
selectHexPreview();
|
||||||
@ -1103,11 +1107,7 @@ void HexdumpWidget::wheelEvent(QWheelEvent *event)
|
|||||||
if (!numDegrees.isNull()) {
|
if (!numDegrees.isNull()) {
|
||||||
const QPoint numSteps = numDegrees / 15;
|
const QPoint numSteps = numDegrees / 15;
|
||||||
if ( 0 != numSteps.y() ) {
|
if ( 0 != numSteps.y() ) {
|
||||||
if (numSteps.y() > 0) {
|
zoomIn(numSteps.y() > 0 ? 1 : -1);
|
||||||
zoomIn(1);
|
|
||||||
} else if ( numSteps.y() < 0 ) {
|
|
||||||
zoomOut(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
@ -1196,20 +1196,21 @@ void HexdumpWidget::showOffsets(bool show)
|
|||||||
|
|
||||||
void HexdumpWidget::zoomIn(int range)
|
void HexdumpWidget::zoomIn(int range)
|
||||||
{
|
{
|
||||||
ui->hexOffsetText->zoomIn(range);
|
|
||||||
ui->hexASCIIText->zoomIn(range);
|
|
||||||
ui->hexHexText->zoomIn(range);
|
ui->hexHexText->zoomIn(range);
|
||||||
|
syncScale();
|
||||||
updateWidths();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexdumpWidget::zoomOut(int range)
|
void HexdumpWidget::zoomOut(int range)
|
||||||
{
|
{
|
||||||
ui->hexOffsetText->zoomOut(range);
|
zoomIn(-range);
|
||||||
ui->hexASCIIText->zoomOut(range);
|
}
|
||||||
ui->hexHexText->zoomOut(range);
|
|
||||||
|
|
||||||
updateWidths();
|
void HexdumpWidget::zoomReset()
|
||||||
|
{
|
||||||
|
QFont font(ui->hexHexText->font());
|
||||||
|
font.setPointSizeF(defaultFontSize);
|
||||||
|
ui->hexHexText->setFont(font);
|
||||||
|
syncScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HexdumpWidget::updateWidths()
|
void HexdumpWidget::updateWidths()
|
||||||
@ -1219,8 +1220,18 @@ void HexdumpWidget::updateWidths()
|
|||||||
ui->hexHexText->document()->setTextWidth(idealWidth);
|
ui->hexHexText->document()->setTextWidth(idealWidth);
|
||||||
|
|
||||||
ui->hexOffsetText->document()->adjustSize();
|
ui->hexOffsetText->document()->adjustSize();
|
||||||
ui->hexOffsetText->setFixedWidth(ui->hexOffsetText->document()->size().width());
|
ui->hexOffsetText->setFixedWidth(ui->hexOffsetText->document()->size().width() + 1);
|
||||||
|
|
||||||
ui->hexASCIIText->document()->adjustSize();
|
ui->hexASCIIText->document()->adjustSize();
|
||||||
ui->hexASCIIText->setMinimumWidth(ui->hexASCIIText->document()->size().width());
|
ui->hexASCIIText->setMinimumWidth(ui->hexASCIIText->document()->size().width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HexdumpWidget::syncScale()
|
||||||
|
{
|
||||||
|
ui->hexOffsetText->setFont(ui->hexHexText->font());
|
||||||
|
ui->hexASCIIText->setFont(ui->hexHexText->font());
|
||||||
|
ui->offsetHeaderLabel->setFont(ui->hexHexText->font());
|
||||||
|
ui->hexHeaderLabel->setFont(ui->hexHexText->font());
|
||||||
|
ui->asciiHeaderLabel->setFont(ui->hexHexText->font());
|
||||||
|
updateWidths();
|
||||||
|
}
|
||||||
|
@ -53,6 +53,7 @@ public slots:
|
|||||||
|
|
||||||
void zoomIn(int range = 1);
|
void zoomIn(int range = 1);
|
||||||
void zoomOut(int range = 1);
|
void zoomOut(int range = 1);
|
||||||
|
void zoomReset();
|
||||||
void toggleSync();
|
void toggleSync();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -102,6 +103,7 @@ private:
|
|||||||
int hexAddressToPosition(RVA address);
|
int hexAddressToPosition(RVA address);
|
||||||
int asciiAddressToPosition(RVA address);
|
int asciiAddressToPosition(RVA address);
|
||||||
void updateWidths();
|
void updateWidths();
|
||||||
|
void syncScale();
|
||||||
|
|
||||||
void updateParseWindow(RVA start_address, int size);
|
void updateParseWindow(RVA start_address, int size);
|
||||||
void clearParseWindow();
|
void clearParseWindow();
|
||||||
@ -113,6 +115,7 @@ private:
|
|||||||
HexdumpRangeDialog rangeDialog;
|
HexdumpRangeDialog rangeDialog;
|
||||||
QAction syncAction;
|
QAction syncAction;
|
||||||
CutterSeekable *seekable;
|
CutterSeekable *seekable;
|
||||||
|
qreal defaultFontSize;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSeekChanged(RVA addr);
|
void onSeekChanged(RVA addr);
|
||||||
|
@ -911,6 +911,20 @@
|
|||||||
<string>Select Block...</string>
|
<string>Select Block...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionResetZoom">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset zoom</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+0</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcutContext">
|
||||||
|
<enum>Qt::WindowShortcut</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../resources.qrc"/>
|
<include location="../resources.qrc"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user