From d8e7bb9ca079e70524b6d91b042593aa256e9f85 Mon Sep 17 00:00:00 2001 From: ck <qt-info@nokia.com> Date: Thu, 18 Feb 2010 11:34:47 +0100 Subject: [PATCH] BinEditor: Flatten context menu. --- src/plugins/bineditor/bineditor.cpp | 33 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp index 4046ab6a076..2e3f2a361c6 100644 --- a/src/plugins/bineditor/bineditor.cpp +++ b/src/plugins/bineditor/bineditor.cpp @@ -1236,15 +1236,12 @@ void BinEditor::contextMenuEvent(QContextMenuEvent *event) QMenu contextMenu; QAction copyAsciiAction(tr("Copy Selection as ASCII Characters"), this); QAction copyHexAction(tr("Copy Selection as Hex Values"), this); - QMenu jumpBeMenu; - QMenu jumpLeMenu; - QAction jumpToBeAddressHere(tr("In This Window"), this); - QAction jumpToBeAddressNewWindow(tr("In New Window"), this); - QAction jumpToLeAddressHere(tr("In This Window"), this); - QAction jumpToLeAddressNewWindow(tr("In New Window"), this); + QAction jumpToBeAddressHere(this); + QAction jumpToBeAddressNewWindow(this); + QAction jumpToLeAddressHere(this); + QAction jumpToLeAddressNewWindow(this); contextMenu.addAction(©AsciiAction); contextMenu.addAction(©HexAction); - contextMenu.addMenu(&jumpBeMenu); quint64 beAddress = 0; quint64 leAddress = 0; @@ -1256,18 +1253,21 @@ void BinEditor::contextMenuEvent(QContextMenuEvent *event) leAddress += val << ((byteCount - pos - 1) * 8); } - setupJumpToMenuAction(&jumpBeMenu, &jumpToBeAddressHere, + setupJumpToMenuAction(&contextMenu, &jumpToBeAddressHere, &jumpToBeAddressNewWindow, beAddress); // If the menu entries would be identical, show only one of them. if (beAddress != leAddress) { - setupJumpToMenuAction(&jumpLeMenu, &jumpToLeAddressHere, + setupJumpToMenuAction(&contextMenu, &jumpToLeAddressHere, &jumpToLeAddressNewWindow, leAddress); - contextMenu.addMenu(&jumpLeMenu); } } else { - jumpBeMenu.setTitle(tr("Jump to Address")); - jumpBeMenu.setEnabled(false); + jumpToBeAddressHere.setText(tr("Jump to Address in This Window")); + jumpToBeAddressNewWindow.setText(tr("Jump to Address in New Window")); + jumpToBeAddressHere.setEnabled(false); + jumpToBeAddressNewWindow.setEnabled(false); + contextMenu.addAction(&jumpToBeAddressHere); + contextMenu.addAction(&jumpToBeAddressNewWindow); } QAction *action = contextMenu.exec(event->globalPos()); @@ -1288,15 +1288,16 @@ void BinEditor::contextMenuEvent(QContextMenuEvent *event) void BinEditor::setupJumpToMenuAction(QMenu *menu, QAction *actionHere, QAction *actionNew, quint64 addr) { - menu->setTitle(tr("Jump to Address 0x%1").arg(QString::number(addr, 16))); + actionHere->setText(tr("Jump to Address 0x%1 in This Window") + .arg(QString::number(addr, 16))); + actionNew->setText(tr("Jump to Address 0x%1 in New Window") + .arg(QString::number(addr, 16))); menu->addAction(actionHere); + menu->addAction(actionNew); if (addr < m_baseAddr || addr >= m_baseAddr + m_size) actionHere->setEnabled(false); if (!m_canRequestNewWindow) actionNew->setEnabled(false); - menu->addAction(actionNew); - if (!actionHere->isEnabled() && !actionNew->isEnabled()) - menu->setEnabled(false); } void BinEditor::setNewWindowRequestAllowed() -- GitLab