Skip to content

Commit a697651

Browse files
committed
[WARP] Add a spinner to the possible matches widget while fetching from network
A little extra pizzaz
1 parent fd2f736 commit a697651

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

plugins/warp/ui/matches.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "warp.h"
1212
#include "shared/misc.h"
1313

14-
WarpCurrentFunctionWidget::WarpCurrentFunctionWidget()
14+
WarpCurrentFunctionWidget::WarpCurrentFunctionWidget(QWidget* parent) : QWidget(parent)
1515
{
1616
// We must explicitly support no current function.
1717
m_current = nullptr;
@@ -31,10 +31,27 @@ WarpCurrentFunctionWidget::WarpCurrentFunctionWidget()
3131
m_splitter = new QSplitter(Qt::Vertical);
3232
m_splitter->setContentsMargins(0, 0, 0, 0);
3333

34+
// Wrap the table and the spinner so that we can overlay the spinner on the table.
35+
QWidget* tableWrapper = new QWidget(m_splitter);
36+
QGridLayout* wrapperLayout = new QGridLayout(tableWrapper);
37+
wrapperLayout->setContentsMargins(0, 0, 0, 0);
38+
3439
// Add a widget to display the matches.
35-
m_tableWidget = new WarpFunctionTableWidget(this);
40+
m_tableWidget = new WarpFunctionTableWidget(tableWrapper);
3641
m_tableWidget->setContentsMargins(0, 0, 0, 0);
37-
m_splitter->addWidget(m_tableWidget);
42+
43+
// Spinner for when we are fetching functions over the network.
44+
m_spinner = new QProgressBar(tableWrapper);
45+
m_spinner->setRange(0, 0);
46+
m_spinner->setTextVisible(false);
47+
m_spinner->setFixedHeight(6);
48+
m_spinner->hide();
49+
50+
// The table has no alignment, so it expands to fill the entire cell.
51+
wrapperLayout->addWidget(m_tableWidget, 0, 0);
52+
wrapperLayout->addWidget(m_spinner, 0, 0, Qt::AlignBottom);
53+
54+
m_splitter->addWidget(tableWrapper);
3855

3956
// Add a widget to display the info about the selected function match.
4057
m_infoWidget = new WarpFunctionInfoWidget(this);
@@ -145,10 +162,12 @@ void WarpCurrentFunctionWidget::SetCurrentFunction(FunctionRef current)
145162
if (!m_fetcher->m_requestInProgress.exchange(true))
146163
{
147164
BinaryNinja::WorkerPriorityEnqueue([this]() {
165+
QMetaObject::invokeMethod(this, [this] { m_spinner->show(); }, Qt::QueuedConnection);
148166
BinaryNinja::Ref bgTask = new BinaryNinja::BackgroundTask("Fetching WARP Functions...", true);
149167
const auto allowedTags = GetAllowedTagsFromView(m_current->GetView());
150168
m_fetcher->FetchPendingFunctions(allowedTags);
151169
bgTask->Finish();
170+
QMetaObject::invokeMethod(this, [this] { m_spinner->hide(); }, Qt::QueuedConnection);
152171
});
153172
}
154173
}

plugins/warp/ui/matches.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <QSplitter>
4+
#include <QProgressBar>
45

56
#include "filter.h"
67
#include "render.h"
@@ -13,6 +14,7 @@ class WarpCurrentFunctionWidget : public QWidget
1314
FunctionRef m_current;
1415

1516
QSplitter* m_splitter;
17+
QProgressBar* m_spinner;
1618

1719
WarpFunctionTableWidget* m_tableWidget;
1820
WarpFunctionInfoWidget* m_infoWidget;
@@ -22,7 +24,7 @@ class WarpCurrentFunctionWidget : public QWidget
2224
std::shared_ptr<WarpFetcher> m_fetcher;
2325

2426
public:
25-
explicit WarpCurrentFunctionWidget();
27+
explicit WarpCurrentFunctionWidget(QWidget* parent = nullptr);
2628

2729
~WarpCurrentFunctionWidget() override = default;
2830

plugins/warp/ui/plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
136136
m_headerWidget->setLayout(headerLayout);
137137

138138
QFrame* currentFunctionFrame = new QFrame(this);
139-
m_currentFunctionWidget = new WarpCurrentFunctionWidget();
139+
m_currentFunctionWidget = new WarpCurrentFunctionWidget(this);
140140
QVBoxLayout* currentFunctionLayout = new QVBoxLayout();
141141
currentFunctionLayout->setContentsMargins(0, 0, 0, 0);
142142
currentFunctionLayout->setSpacing(0);

0 commit comments

Comments
 (0)