mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-24 05:45:27 +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(&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;
|
||||
initParsing();
|
||||
selectHexPreview();
|
||||
@ -1103,11 +1107,7 @@ void HexdumpWidget::wheelEvent(QWheelEvent *event)
|
||||
if (!numDegrees.isNull()) {
|
||||
const QPoint numSteps = numDegrees / 15;
|
||||
if ( 0 != numSteps.y() ) {
|
||||
if (numSteps.y() > 0) {
|
||||
zoomIn(1);
|
||||
} else if ( numSteps.y() < 0 ) {
|
||||
zoomOut(1);
|
||||
}
|
||||
zoomIn(numSteps.y() > 0 ? 1 : -1);
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
@ -1196,20 +1196,21 @@ void HexdumpWidget::showOffsets(bool show)
|
||||
|
||||
void HexdumpWidget::zoomIn(int range)
|
||||
{
|
||||
ui->hexOffsetText->zoomIn(range);
|
||||
ui->hexASCIIText->zoomIn(range);
|
||||
ui->hexHexText->zoomIn(range);
|
||||
|
||||
updateWidths();
|
||||
syncScale();
|
||||
}
|
||||
|
||||
void HexdumpWidget::zoomOut(int range)
|
||||
{
|
||||
ui->hexOffsetText->zoomOut(range);
|
||||
ui->hexASCIIText->zoomOut(range);
|
||||
ui->hexHexText->zoomOut(range);
|
||||
zoomIn(-range);
|
||||
}
|
||||
|
||||
updateWidths();
|
||||
void HexdumpWidget::zoomReset()
|
||||
{
|
||||
QFont font(ui->hexHexText->font());
|
||||
font.setPointSizeF(defaultFontSize);
|
||||
ui->hexHexText->setFont(font);
|
||||
syncScale();
|
||||
}
|
||||
|
||||
void HexdumpWidget::updateWidths()
|
||||
@ -1219,8 +1220,18 @@ void HexdumpWidget::updateWidths()
|
||||
ui->hexHexText->document()->setTextWidth(idealWidth);
|
||||
|
||||
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->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 zoomOut(int range = 1);
|
||||
void zoomReset();
|
||||
void toggleSync();
|
||||
|
||||
protected:
|
||||
@ -102,6 +103,7 @@ private:
|
||||
int hexAddressToPosition(RVA address);
|
||||
int asciiAddressToPosition(RVA address);
|
||||
void updateWidths();
|
||||
void syncScale();
|
||||
|
||||
void updateParseWindow(RVA start_address, int size);
|
||||
void clearParseWindow();
|
||||
@ -113,6 +115,7 @@ private:
|
||||
HexdumpRangeDialog rangeDialog;
|
||||
QAction syncAction;
|
||||
CutterSeekable *seekable;
|
||||
qreal defaultFontSize;
|
||||
|
||||
private slots:
|
||||
void onSeekChanged(RVA addr);
|
||||
|
@ -911,6 +911,20 @@
|
||||
<string>Select Block...</string>
|
||||
</property>
|
||||
</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>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
|
Loading…
Reference in New Issue
Block a user