mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
Toggle the address maps in the Section Widget (#959)
* Toggle the addr maps in the Section Widget * Icon transform done. * Refactoring
This commit is contained in:
parent
84c489ee90
commit
26d985c9dc
@ -180,13 +180,30 @@ SectionsWidget::SectionsWidget(MainWindow *main, QAction *action) :
|
||||
rawAddrDock = new SectionAddrDock(sectionsModel, SectionAddrDock::Raw, this);
|
||||
virtualAddrDock = new SectionAddrDock(sectionsModel, SectionAddrDock::Virtual, this);
|
||||
|
||||
QWidget *addrDockWidget = new QWidget();
|
||||
addrDockWidget = new QWidget();
|
||||
QHBoxLayout *addrDockLayout = new QHBoxLayout();
|
||||
addrDockLayout->addWidget(rawAddrDock);
|
||||
addrDockLayout->addWidget(virtualAddrDock);
|
||||
addrDockWidget->setLayout(addrDockLayout);
|
||||
layout->addWidget(addrDockWidget);
|
||||
|
||||
QPixmap map(":/img/icons/previous.svg");
|
||||
QTransform transform;
|
||||
transform = transform.rotate(90);
|
||||
map = map.transformed(transform);
|
||||
QIcon icon;
|
||||
icon.addPixmap(map);
|
||||
|
||||
toggleButton = new QToolButton;
|
||||
toggleButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
toggleButton->setFixedHeight(30);
|
||||
toggleButton->setIcon(icon);
|
||||
toggleButton->setIconSize(QSize(16, 12));
|
||||
toggleButton->setAutoRaise(true);
|
||||
toggleButton->setArrowType(Qt::NoArrow);
|
||||
toggleButton->hide();
|
||||
layout->addWidget(toggleButton);
|
||||
|
||||
layout->setMargin(0);
|
||||
dockWidgetContents->setLayout(layout);
|
||||
setWidget(dockWidgetContents);
|
||||
@ -198,10 +215,27 @@ SectionsWidget::SectionsWidget(MainWindow *main, QAction *action) :
|
||||
});
|
||||
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSectionsSeekChanged(RVA)));
|
||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(refreshSections()));
|
||||
connect(toggleButton, &QToolButton::clicked, this, [ = ] {
|
||||
toggleButton->hide();
|
||||
addrDockWidget->show();
|
||||
rawAddrDock->show();
|
||||
virtualAddrDock->show();
|
||||
});
|
||||
|
||||
indicatorWidth = 600;
|
||||
indicatorHeight = 5;
|
||||
indicatorParamPosY = 20;
|
||||
|
||||
connect(rawAddrDock, &QDockWidget::visibilityChanged, this, [ = ](bool visibility) {
|
||||
if (!visibility) {
|
||||
updateToggle();
|
||||
}
|
||||
});
|
||||
connect(virtualAddrDock, &QDockWidget::visibilityChanged, this, [ = ](bool visibility) {
|
||||
if (!visibility) {
|
||||
updateToggle();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SectionsWidget::~SectionsWidget() {}
|
||||
@ -273,6 +307,14 @@ void SectionsWidget::updateIndicator(SectionAddrDock *targetDock, QString name,
|
||||
targetDock->addTextItem(color, QPoint(0, y - indicatorParamPosY), QString("0x%1").arg(offset, 0, 16));
|
||||
}
|
||||
|
||||
void SectionsWidget::updateToggle()
|
||||
{
|
||||
if (!rawAddrDock->isVisible() && !virtualAddrDock->isVisible()) {
|
||||
addrDockWidget->hide();
|
||||
toggleButton->show();
|
||||
}
|
||||
}
|
||||
|
||||
SectionAddrDock::SectionAddrDock(SectionsModel *model, AddrType type, QWidget *parent) :
|
||||
QDockWidget(parent),
|
||||
graphicsScene(new QGraphicsScene),
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QAbstractListModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QGraphicsScene>
|
||||
@ -77,14 +78,17 @@ private:
|
||||
QWidget *dockWidgetContents;
|
||||
QuickFilterView *quickFilterView;
|
||||
|
||||
QWidget *addrDockWidget;
|
||||
SectionAddrDock *rawAddrDock;
|
||||
SectionAddrDock *virtualAddrDock;
|
||||
QToolButton *toggleButton;
|
||||
|
||||
int indicatorWidth;
|
||||
int indicatorHeight;
|
||||
int indicatorParamPosY;
|
||||
void drawIndicatorOnAddrDocks();
|
||||
void updateIndicator(SectionAddrDock *targetDock, QString name, float ratio);
|
||||
void updateToggle();
|
||||
};
|
||||
|
||||
class SectionAddrDock : public QDockWidget
|
||||
|
Loading…
Reference in New Issue
Block a user