Skip to content

Commit

Permalink
Middle-click in the register widget now navigates to the register und…
Browse files Browse the repository at this point in the history
…er the mouse rather than the currently selected one
  • Loading branch information
xusheng6 committed Mar 8, 2023
1 parent 6ea452d commit cb4b908
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions ui/registerswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ limitations under the License.
#include <QGuiApplication>
#include <QMimeData>
#include <QClipboard>
#include "pane.h"
#include "clickablelabel.h"
#include "registerswidget.h"

Expand Down Expand Up @@ -662,26 +663,40 @@ void DebugRegistersWidget::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::MiddleButton)
{
QModelIndexList sel = selectionModel()->selectedIndexes();
if (sel.empty())
auto index = indexAt(event->pos());
if (!index.isValid())
return;

auto sourceIndex = m_filter->mapToSource(sel[0]);
auto sourceIndex = m_filter->mapToSource(index);
if (!sourceIndex.isValid())
return;

auto reg = m_model->getRow(sourceIndex.row());
uint64_t value = reg.value();

UIContext* context = UIContext::contextForWidget(this);
if (!context)
return;
ViewFrame* frame = ViewFrame::viewFrameForWidget(this);
auto* currentWindow = UIContext::contextForWidget(m_view);
if (frame && currentWindow)
{
auto* splitPaneWidget = qobject_cast<SplitPaneWidget*>(currentWindow->getCurrentTab());
if (!splitPaneWidget)
return;

View* view = context->getCurrentView();
if (!view)
return;
Qt::Orientation defaultSplitDirection = splitPaneWidget->defaultSplitDirection();
splitPaneWidget->splitCurrentPane(defaultSplitDirection);

view->navigateOnOtherPane(value);
ViewPane* newPane = splitPaneWidget->currentViewPane();

if (!newPane)
return;

ViewFrame* newViewFrame = newPane->viewFrame();
if (newViewFrame)
{
newViewFrame->disableSync();
newViewFrame->navigate(m_controller->GetLiveView(), value);
}
}
}
else
{
Expand Down

0 comments on commit cb4b908

Please sign in to comment.