mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-11 22:45:25 +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);
|
rawAddrDock = new SectionAddrDock(sectionsModel, SectionAddrDock::Raw, this);
|
||||||
virtualAddrDock = new SectionAddrDock(sectionsModel, SectionAddrDock::Virtual, this);
|
virtualAddrDock = new SectionAddrDock(sectionsModel, SectionAddrDock::Virtual, this);
|
||||||
|
|
||||||
QWidget *addrDockWidget = new QWidget();
|
addrDockWidget = new QWidget();
|
||||||
QHBoxLayout *addrDockLayout = new QHBoxLayout();
|
QHBoxLayout *addrDockLayout = new QHBoxLayout();
|
||||||
addrDockLayout->addWidget(rawAddrDock);
|
addrDockLayout->addWidget(rawAddrDock);
|
||||||
addrDockLayout->addWidget(virtualAddrDock);
|
addrDockLayout->addWidget(virtualAddrDock);
|
||||||
addrDockWidget->setLayout(addrDockLayout);
|
addrDockWidget->setLayout(addrDockLayout);
|
||||||
layout->addWidget(addrDockWidget);
|
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);
|
layout->setMargin(0);
|
||||||
dockWidgetContents->setLayout(layout);
|
dockWidgetContents->setLayout(layout);
|
||||||
setWidget(dockWidgetContents);
|
setWidget(dockWidgetContents);
|
||||||
@ -198,10 +215,27 @@ SectionsWidget::SectionsWidget(MainWindow *main, QAction *action) :
|
|||||||
});
|
});
|
||||||
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSectionsSeekChanged(RVA)));
|
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSectionsSeekChanged(RVA)));
|
||||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(refreshSections()));
|
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(refreshSections()));
|
||||||
|
connect(toggleButton, &QToolButton::clicked, this, [ = ] {
|
||||||
|
toggleButton->hide();
|
||||||
|
addrDockWidget->show();
|
||||||
|
rawAddrDock->show();
|
||||||
|
virtualAddrDock->show();
|
||||||
|
});
|
||||||
|
|
||||||
indicatorWidth = 600;
|
indicatorWidth = 600;
|
||||||
indicatorHeight = 5;
|
indicatorHeight = 5;
|
||||||
indicatorParamPosY = 20;
|
indicatorParamPosY = 20;
|
||||||
|
|
||||||
|
connect(rawAddrDock, &QDockWidget::visibilityChanged, this, [ = ](bool visibility) {
|
||||||
|
if (!visibility) {
|
||||||
|
updateToggle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(virtualAddrDock, &QDockWidget::visibilityChanged, this, [ = ](bool visibility) {
|
||||||
|
if (!visibility) {
|
||||||
|
updateToggle();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionsWidget::~SectionsWidget() {}
|
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));
|
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) :
|
SectionAddrDock::SectionAddrDock(SectionsModel *model, AddrType type, QWidget *parent) :
|
||||||
QDockWidget(parent),
|
QDockWidget(parent),
|
||||||
graphicsScene(new QGraphicsScene),
|
graphicsScene(new QGraphicsScene),
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include <QtWidgets/QToolButton>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
@ -77,14 +78,17 @@ private:
|
|||||||
QWidget *dockWidgetContents;
|
QWidget *dockWidgetContents;
|
||||||
QuickFilterView *quickFilterView;
|
QuickFilterView *quickFilterView;
|
||||||
|
|
||||||
|
QWidget *addrDockWidget;
|
||||||
SectionAddrDock *rawAddrDock;
|
SectionAddrDock *rawAddrDock;
|
||||||
SectionAddrDock *virtualAddrDock;
|
SectionAddrDock *virtualAddrDock;
|
||||||
|
QToolButton *toggleButton;
|
||||||
|
|
||||||
int indicatorWidth;
|
int indicatorWidth;
|
||||||
int indicatorHeight;
|
int indicatorHeight;
|
||||||
int indicatorParamPosY;
|
int indicatorParamPosY;
|
||||||
void drawIndicatorOnAddrDocks();
|
void drawIndicatorOnAddrDocks();
|
||||||
void updateIndicator(SectionAddrDock *targetDock, QString name, float ratio);
|
void updateIndicator(SectionAddrDock *targetDock, QString name, float ratio);
|
||||||
|
void updateToggle();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SectionAddrDock : public QDockWidget
|
class SectionAddrDock : public QDockWidget
|
||||||
|
Loading…
Reference in New Issue
Block a user