diff --git a/src/widgets/SectionsWidget.cpp b/src/widgets/SectionsWidget.cpp index b6de7d01..98d2129e 100644 --- a/src/widgets/SectionsWidget.cpp +++ b/src/widgets/SectionsWidget.cpp @@ -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), diff --git a/src/widgets/SectionsWidget.h b/src/widgets/SectionsWidget.h index 6e53ceb6..c4c22e7f 100644 --- a/src/widgets/SectionsWidget.h +++ b/src/widgets/SectionsWidget.h @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -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