Skip to content

Commit 379e257

Browse files
committed
Add empty placeholder to GUI recent transactions list
This adds a presentation nicety to the recent transactions list on the overview page that shows an empty placeholder text and icon in wallets with no transactions. It is a bit of polish that fills the empty space that new users see with a fresh installation. The placeholder is a widget that we can reuse in other components when we need to display a "nothing here" or "no results" message.
1 parent d03cb67 commit 379e257

11 files changed

+212
-2
lines changed

gridcoinresearch.pro

+5-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ HEADERS += src/qt/bitcoingui.h \
273273
src/backup.h \
274274
src/appcache.h \
275275
src/grcrestarter.h \
276-
src/qt/clicklabel.h
276+
src/qt/clicklabel.h \
277+
src/qt/noresult.h
277278

278279

279280
SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
@@ -368,7 +369,8 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
368369
src/backup.cpp \
369370
src/appcache.cpp \
370371
src/grcrestarter.cpp \
371-
src/qt/clicklabel.cpp
372+
src/qt/clicklabel.cpp \
373+
src/qt/noresult.cpp
372374

373375
##
374376
#RC_FILE = qaxserver.rc
@@ -379,6 +381,7 @@ RESOURCES += \
379381

380382
FORMS += \
381383
src/qt/forms/coincontroldialog.ui \
384+
src/qt/forms/noresult.ui \
382385
src/qt/forms/researcherwizard.ui \
383386
src/qt/forms/researcherwizardauthpage.ui \
384387
src/qt/forms/researcherwizardbeaconpage.ui \

src/Makefile.qt.include

+5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ QT_FORMS_UI = \
8585
qt/forms/signverifymessagedialog.ui \
8686
qt/forms/addressbookpage.ui \
8787
qt/forms/editaddressdialog.ui \
88+
qt/forms/noresult.ui \
8889
qt/forms/overviewpage.ui \
8990
qt/forms/receivecoinspage.ui \
9091
qt/forms/researcherwizard.ui \
@@ -130,6 +131,7 @@ QT_MOC_CPP = \
130131
qt/moc_macdockiconhandler.cpp \
131132
qt/moc_macnotificationhandler.cpp \
132133
qt/moc_monitoreddatamapper.cpp \
134+
qt/moc_noresult.cpp \
133135
qt/moc_notificator.cpp \
134136
qt/moc_optionsdialog.cpp \
135137
qt/moc_optionsmodel.cpp \
@@ -209,6 +211,7 @@ GRIDCOINRESEARCH_QT_H = \
209211
qt/macnotificationhandler.h \
210212
qt/macos_appnap.h \
211213
qt/monitoreddatamapper.h \
214+
qt/noresult.h \
212215
qt/notificator.h \
213216
qt/optionsdialog.h \
214217
qt/optionsmodel.h \
@@ -273,6 +276,7 @@ GRIDCOINRESEARCH_QT_CPP = \
273276
qt/guiutil.cpp \
274277
qt/intro.cpp \
275278
qt/monitoreddatamapper.cpp \
279+
qt/noresult.cpp \
276280
qt/notificator.cpp \
277281
qt/optionsdialog.cpp \
278282
qt/optionsmodel.cpp \
@@ -343,6 +347,7 @@ RES_ICONS = \
343347
qt/res/icons/menu.svg \
344348
qt/res/icons/menu_active.svg \
345349
qt/res/icons/message.svg \
350+
qt/res/icons/no_result.svg \
346351
qt/res/icons/qrcode.png \
347352
qt/res/icons/quit.png \
348353
qt/res/icons/remove.png \

src/qt/bitcoin.qrc

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
<file alias="dark_mode_active">res/icons/dark_mode_active.svg</file>
180180
<file alias="light_mode">res/icons/light_mode.svg</file>
181181
<file alias="light_mode_active">res/icons/light_mode_active.svg</file>
182+
<file alias="no_result">res/icons/no_result.svg</file>
182183

183184
</qresource>
184185
<qresource prefix="/images">

src/qt/forms/noresult.ui

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>NoResult</class>
4+
<widget class="QWidget" name="NoResult">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>300</height>
11+
</rect>
12+
</property>
13+
<property name="sizePolicy">
14+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
15+
<horstretch>0</horstretch>
16+
<verstretch>0</verstretch>
17+
</sizepolicy>
18+
</property>
19+
<property name="windowTitle">
20+
<string>Form</string>
21+
</property>
22+
<layout class="QVBoxLayout" name="verticalLayout" stretch="50,0,0,100">
23+
<property name="spacing">
24+
<number>16</number>
25+
</property>
26+
<item>
27+
<spacer name="topSpacer">
28+
<property name="orientation">
29+
<enum>Qt::Vertical</enum>
30+
</property>
31+
<property name="sizeHint" stdset="0">
32+
<size>
33+
<width>20</width>
34+
<height>0</height>
35+
</size>
36+
</property>
37+
</spacer>
38+
</item>
39+
<item alignment="Qt::AlignHCenter">
40+
<widget class="QLabel" name="iconLabel"/>
41+
</item>
42+
<item alignment="Qt::AlignHCenter">
43+
<widget class="QLabel" name="titleLabel">
44+
<property name="text">
45+
<string>Nothing here yet...</string>
46+
</property>
47+
</widget>
48+
</item>
49+
<item>
50+
<spacer name="bottomSpacer">
51+
<property name="orientation">
52+
<enum>Qt::Vertical</enum>
53+
</property>
54+
<property name="sizeHint" stdset="0">
55+
<size>
56+
<width>20</width>
57+
<height>0</height>
58+
</size>
59+
</property>
60+
</spacer>
61+
</item>
62+
</layout>
63+
</widget>
64+
<resources/>
65+
<connections/>
66+
</ui>

src/qt/forms/overviewpage.ui

+16
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,16 @@
10201020
</property>
10211021
</widget>
10221022
</item>
1023+
<item>
1024+
<widget class="NoResult" name="recentTransactionsNoResult" native="true">
1025+
<property name="sizePolicy">
1026+
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
1027+
<horstretch>0</horstretch>
1028+
<verstretch>100</verstretch>
1029+
</sizepolicy>
1030+
</property>
1031+
</widget>
1032+
</item>
10231033
<item>
10241034
<widget class="QListView" name="listTransactions">
10251035
<property name="sizePolicy">
@@ -1077,6 +1087,12 @@
10771087
<extends>QLabel</extends>
10781088
<header>clicklabel.h</header>
10791089
</customwidget>
1090+
<customwidget>
1091+
<class>NoResult</class>
1092+
<extends>QWidget</extends>
1093+
<header>noresult.h</header>
1094+
<container>1</container>
1095+
</customwidget>
10801096
</customwidgets>
10811097
<resources/>
10821098
<connections/>

src/qt/noresult.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) 2014-2021 The Gridcoin developers
2+
// Distributed under the MIT/X11 software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include "qt/decoration.h"
6+
#include "qt/forms/ui_noresult.h"
7+
#include "qt/noresult.h"
8+
9+
NoResult::NoResult(QWidget *parent)
10+
: QWidget(parent)
11+
, ui(new Ui::NoResult)
12+
, m_content_widget(nullptr)
13+
{
14+
ui->setupUi(this);
15+
16+
GRC::ScaleFontPointSize(ui->titleLabel, 13);
17+
}
18+
19+
NoResult::~NoResult()
20+
{
21+
delete ui;
22+
}
23+
24+
QWidget* NoResult::contentWidget()
25+
{
26+
return m_content_widget;
27+
}
28+
29+
void NoResult::setTitle(const QString& title)
30+
{
31+
ui->titleLabel->setText(title);
32+
}
33+
34+
void NoResult::setContentWidget(QWidget* widget)
35+
{
36+
if (m_content_widget != nullptr) {
37+
ui->verticalLayout->removeWidget(m_content_widget);
38+
}
39+
40+
m_content_widget = widget;
41+
42+
if (widget != nullptr) {
43+
// Insert the widget above the bottom spacer:
44+
const int index = ui->verticalLayout->count() - 1;
45+
ui->verticalLayout->insertWidget(index, widget, 0, Qt::AlignHCenter);
46+
}
47+
}

src/qt/noresult.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) 2014-2021 The Gridcoin developers
2+
// Distributed under the MIT/X11 software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef NORESULT_H
6+
#define NORESULT_H
7+
8+
#include <QWidget>
9+
10+
namespace Ui {
11+
class NoResult;
12+
}
13+
14+
class NoResult : public QWidget
15+
{
16+
Q_OBJECT
17+
18+
public:
19+
explicit NoResult(QWidget *parent = nullptr);
20+
~NoResult();
21+
22+
QWidget* contentWidget();
23+
24+
public slots:
25+
void setTitle(const QString& title);
26+
void setContentWidget(QWidget* widget);
27+
28+
private:
29+
Ui::NoResult *ui;
30+
QWidget* m_content_widget;
31+
};
32+
33+
#endif // NORESULT_H

src/qt/overviewpage.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@ void OverviewPage::updateTransactions()
209209
{
210210
int numItems = getNumTransactionsForView();
211211

212+
// When we receive our first transaction, we can free the memory used
213+
// for the "nothing here yet" placeholder in the transaction list. It
214+
// will never appear again:
215+
//
216+
if (numItems > 0)
217+
{
218+
delete ui->recentTransactionsNoResult;
219+
ui->recentTransactionsNoResult = nullptr;
220+
}
221+
212222
LogPrint(BCLog::LogFlags::QT, "OverviewPage::updateTransactions(): numItems = %d, getLimit() = %d", numItems, filter->getLimit());
213223

214224
// This is a "stairstep" approach, using x3 to x6 factors to size the setLimit.

src/qt/res/icons/no_result.svg

+3
Loading

src/qt/res/stylesheets/dark_stylesheet.qss

+13
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,19 @@ QStatusBar QToolTip {
579579
max-height:9.225em;
580580
}
581581

582+
NoResult #iconLabel {
583+
image: url(:/icons/no_result);
584+
min-width: 2em;
585+
max-width: 2em;
586+
min-height: 2em;
587+
max-height: 2em;
588+
}
589+
590+
NoResult #titleLabel {
591+
color: rgba(204, 208, 209, 0.6);
592+
font-weight: 500;
593+
}
594+
582595
#headerFrame {
583596
background: none;
584597
border-bottom: 0.065em solid rgb(18, 26, 34);

src/qt/res/stylesheets/light_stylesheet.qss

+13
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,19 @@ QStatusBar .QFrame QLabel {
582582
max-height:9.225em;
583583
}
584584

585+
NoResult #iconLabel {
586+
image: url(:/icons/no_result);
587+
min-width: 2em;
588+
max-width: 2em;
589+
min-height: 2em;
590+
max-height: 2em;
591+
}
592+
593+
NoResult #titleLabel {
594+
color: rgba(58, 70, 93, 0.6);
595+
font-weight: 500;
596+
}
597+
585598
#headerFrame {
586599
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgb(240, 240, 240), stop: 0.1 rgb(255, 255, 255));
587600
border-bottom: 0.065em solid rgb(230, 230, 230);

0 commit comments

Comments
 (0)