Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add setting for numerical base of addresses #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/hobbits-plugins/displays/Hex/hex.cpp
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ Hex::Hex() :
QList<ParameterDelegate::ParameterInfo> infos = {
{"font_size", ParameterDelegate::ParameterType::Integer},
{"column_grouping", ParameterDelegate::ParameterType::Integer},
{"address_display_base", ParameterDelegate::ParameterType::Integer},
{"show_headers", ParameterDelegate::ParameterType::Boolean}
};

@@ -130,14 +131,16 @@ QSharedPointer<DisplayResult> Hex::renderOverlay(QSize viewportSize, const Param

QSize fontSize = DisplayHelper::textSize(DisplayHelper::monoFont(m_lastParams.value("font_size").toInt()), "0");
int columnGrouping = m_lastParams.value("column_grouping").toInt();
int addressDisplayBase = m_lastParams.value("address_display_base").toInt();

auto overlay = DisplayHelper::drawHeadersFull(
viewportSize,
headerOffset(parameters),
m_handle,
QSizeF(double(fontSize.width()) / 4.0, DisplayHelper::textRowHeight(fontSize.height())),
columnGrouping,
columnGrouping > 1 ? 1 : 0);
columnGrouping > 1 ? 1 : 0,
addressDisplayBase);

return DisplayResult::result(overlay, parameters);
}
2 changes: 2 additions & 0 deletions src/hobbits-plugins/displays/Hex/hexform.cpp
Original file line number Diff line number Diff line change
@@ -8,12 +8,14 @@ HexForm::HexForm(QSharedPointer<ParameterDelegate> delegate):
ui->setupUi(this);

connect(ui->sb_columnGrouping, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
connect(ui->sb_addressDisplayBase, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
connect(ui->hs_fontSize, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
connect(ui->cb_showHeaders, SIGNAL(stateChanged(int)), this, SIGNAL(changed()));

m_paramHelper->addSliderIntParameter("font_size", ui->hs_fontSize);
m_paramHelper->addCheckBoxBoolParameter("show_headers", ui->cb_showHeaders);
m_paramHelper->addSpinBoxIntParameter("column_grouping", ui->sb_columnGrouping);
m_paramHelper->addSpinBoxIntParameter("address_display_base", ui->sb_addressDisplayBase);
}

HexForm::~HexForm()
20 changes: 13 additions & 7 deletions src/hobbits-widgets/displayhelper.cpp
Original file line number Diff line number Diff line change
@@ -300,7 +300,8 @@ QImage DisplayHelper::drawHeadersFull(QSize viewportSize,
QSharedPointer<DisplayHandle> handle,
QSizeF bitSize,
int columnGrouping,
int groupMargin)
int groupMargin,
int addressDisplayBase)
{
if (offset.x() == 0 && offset.y() == 0) {
return QImage();
@@ -315,15 +316,20 @@ QImage DisplayHelper::drawHeadersFull(QSize viewportSize,
DisplayHelper::drawFramesHeader(&painter,
QSize(offset.x(), viewportSize.height() - offset.y()),
handle,
bitSize.height());
bitSize.height(),
Qt::Vertical,
1,
0,
addressDisplayBase);

DisplayHelper::drawFramesHeader(&painter,
QSize(viewportSize.width() - offset.x(), offset.y()),
handle,
bitSize.width(),
Qt::Horizontal,
columnGrouping,
groupMargin);
groupMargin,
addressDisplayBase);

return headers;
}
@@ -334,7 +340,8 @@ void DisplayHelper::drawFramesHeader(QPainter *painter,
double frameHeight,
int orientation,
int grouping,
int groupMargin)
int groupMargin,
int addressDisplayBase)
{
painter->save();

@@ -395,7 +402,7 @@ void DisplayHelper::drawFramesHeader(QPainter *painter,
textSize,
fontSize.height(),
textAlign,
QString("%1").arg(i + offset));
QString("%1").arg(i + offset, 0, addressDisplayBase));
}

if (highlightOffset >= 0) {
@@ -429,7 +436,7 @@ void DisplayHelper::drawFramesHeader(QPainter *painter,
painter->drawText(
textRect,
textAlign,
QString("%1").arg(highlightOffset));
QString("%1").arg(highlightOffset, 0, addressDisplayBase));
}

painter->restore();
@@ -662,4 +669,3 @@ void DisplayHelper::sendHoverUpdate(QSharedPointer<DisplayHandle> handle, QPoint

handle->setBitHover(true, diff.x(), diff.y());
}

6 changes: 4 additions & 2 deletions src/hobbits-widgets/displayhelper.h
Original file line number Diff line number Diff line change
@@ -58,15 +58,17 @@ namespace DisplayHelper
QSharedPointer<DisplayHandle> displayHandle,
QSizeF bitSize,
int columnGrouping = 1,
int groupMargin = 0);
int groupMargin = 0,
int addressDisplayBase = 10);

void HOBBITSWIDGETSSHARED_EXPORT drawFramesHeader(QPainter *painter,
QSize viewportSize,
QSharedPointer<DisplayHandle> displayHandle,
double frameHeight,
int orientation = Qt::Vertical,
int grouping = 1,
int groupMargin = 0);
int groupMargin = 0,
int addressDisplayBase = 10);


void HOBBITSWIDGETSSHARED_EXPORT drawHoverBox(QPainter *painter,