From 578732aa5864cae77e06e1bc80079bb0c391978c Mon Sep 17 00:00:00 2001 From: minuszka Date: Mon, 16 Nov 2026 00:46:13 +0100 Subject: [PATCH] qt: say what Abyss waits for, link translators to DeFCoN Abyss now shows 'Waiting for synchronization' instead of 'Loading' on an empty transaction list and uses plainer staking messages; the translation link and Transifex settings now point to DeFCoN's project. Tested on Linux and Windows; wallet behaviour is unchanged. --- .tx/config | 5 +- src/qt/emptystatewidget.cpp | 71 +++------ src/qt/emptystatewidget.h | 19 ++- src/qt/forms/optionsdialog.ui | 2 +- src/qt/locale/dash_de.ts | 4 +- src/qt/locale/dash_en.ts | 4 +- src/qt/locale/dash_en.xlf | 4 +- src/qt/locale/dash_fr.ts | 4 +- src/qt/locale/dash_ru.ts | 4 +- src/qt/locale/dash_zh_CN.ts | 4 +- src/qt/overviewpage.cpp | 30 ++-- src/qt/res/css/defcon-dark.css | 21 +-- src/qt/test/abysstests.cpp | 261 ++++++++++++++++++++++++++++++++- src/qt/test/abysstests.h | 3 + src/qt/transactionview.cpp | 3 +- src/qt/transactionview.h | 2 +- src/qt/walletview.cpp | 7 +- 17 files changed, 337 insertions(+), 111 deletions(-) diff --git a/.tx/config b/.tx/config index 7699aee5ff..5a5023bc55 100644 --- a/.tx/config +++ b/.tx/config @@ -1,7 +1,8 @@ [main] host = https://www.transifex.com -[dash.dash_ents] +[o:defcon:p:defcon:r:defcon-qt-wallet] file_filter = src/qt/locale/dash_.ts -source_file = src/qt/locale/dash_en.xlf +source_file = src/qt/locale/dash_en.ts source_lang = en +type = QT diff --git a/src/qt/emptystatewidget.cpp b/src/qt/emptystatewidget.cpp index 751d1ff094..ec4370b9fd 100644 --- a/src/qt/emptystatewidget.cpp +++ b/src/qt/emptystatewidget.cpp @@ -11,16 +11,15 @@ #include #include #include +#include #include -#include - -EmptyStateWidget::State EmptyStateWidget::stateFor(bool modern, int rows, int unfiltered_rows, bool loading) +EmptyStateWidget::State EmptyStateWidget::stateFor(bool modern, int rows, int unfiltered_rows, bool syncing) { if (!modern || rows > 0) return State::Hidden; // A filter explains an empty list better than a sync still running. if (unfiltered_rows > 0) return State::Filtered; - return loading ? State::Loading : State::Empty; + return syncing ? State::Syncing : State::Empty; } EmptyStateWidget::EmptyStateWidget(const QString& glyph, const QString& title, const QString& text, @@ -75,7 +74,8 @@ EmptyStateWidget::EmptyStateWidget(const QString& glyph, const QString& title, c text_row->addWidget(m_text, 1); text_row->addStretch(0); message->addLayout(text_row); - message->addSpacing(16); + m_action_gap = new QSpacerItem(0, 16, QSizePolicy::Minimum, QSizePolicy::Fixed); + message->addItem(m_action_gap); m_action = new QPushButton(m_message); m_action->setObjectName("emptyStateAction"); m_action->setMinimumWidth(150); @@ -90,45 +90,8 @@ EmptyStateWidget::EmptyStateWidget(const QString& glyph, const QString& title, c } }); - // Placeholder rows, as the list will look once its data is in. - m_skeleton = new QWidget(this); - m_skeleton->setObjectName("emptyStateSkeleton"); - auto* skeleton = new QVBoxLayout(m_skeleton); - skeleton->setContentsMargins(12, 12, 12, 0); - skeleton->setSpacing(24); - for (int row = 0; row < 3; ++row) { - auto* line = new QHBoxLayout; - line->setSpacing(14); - auto* dot = new QFrame(m_skeleton); - dot->setObjectName("skeletonDot"); - dot->setFixedSize(36, 36); - line->addWidget(dot); - auto* bars = new QVBoxLayout; - bars->setSpacing(9); - // A long bar over a short one, about three quarters and two fifths wide. - for (const auto& [name, width, height] : {std::tuple{"skeletonLine", 76, 11}, std::tuple{"skeletonLineShort", 42, 8}}) { - auto* bar_row = new QHBoxLayout; - bar_row->setSpacing(0); - auto* bar = new QFrame(m_skeleton); - bar->setObjectName(name); - bar->setFixedHeight(height); - bar_row->addWidget(bar, width); - bar_row->addStretch(100 - width); - bars->addLayout(bar_row); - } - line->addLayout(bars, 1); - skeleton->addLayout(line); - } - auto* loading = new QLabel(tr("Loading…"), m_skeleton); - loading->setObjectName("emptyStateLoading"); - loading->setAlignment(Qt::AlignCenter); - skeleton->addSpacing(6); - skeleton->addWidget(loading); - skeleton->addStretch(); - layout->addWidget(m_skeleton); - GUIUtil::setFont({m_title}, GUIUtil::FontWeight::Bold, 16); - GUIUtil::setFont({m_text, loading}, GUIUtil::FontWeight::Normal, 13); + GUIUtil::setFont({m_text}, GUIUtil::FontWeight::Normal, 13); GUIUtil::updateFonts(); paintSymbol(); hide(); @@ -163,12 +126,24 @@ void EmptyStateWidget::setState(State state) return; } const bool filtered = state == State::Filtered; - m_title->setText(filtered ? tr("No matching results") : m_title_text); - m_text->setText(filtered ? tr("Try a different search or clear your filters.") : m_text_text); + // The wallet's rows come with the blocks it catches up on, which can take + // hours on a first start: that is a wait for the network, not a list + // being loaded, and the list says which. There is nothing to press + // meanwhile, so the action goes, and its gap with it. + const bool syncing = state == State::Syncing; + m_title->setText(filtered ? tr("No matching results") : syncing ? tr("Waiting for synchronization") : m_title_text); + m_text->setText(filtered ? tr("Try a different search or clear your filters.") : + syncing ? tr("Your transactions will appear here as the wallet catches up with the network.") : m_text_text); m_action->setText(filtered ? tr("Clear filters") : m_action_text); - m_message->setVisible(state != State::Loading); - m_skeleton->setVisible(state == State::Loading); - setAccessibleName(state == State::Loading ? tr("Loading…") : m_title->text()); + if (m_action->isHidden() != syncing) { + // The gap first, and both before the list is fitted below: showing + // the button lays the card out at once, so fitList() measures the + // message with its button and the room above it. + m_action_gap->changeSize(0, syncing ? 0 : 16, QSizePolicy::Minimum, QSizePolicy::Fixed); + m_message->layout()->invalidate(); + m_action->setVisible(!syncing); + } + setAccessibleName(m_title->text()); followViewport(); show(); raise(); diff --git a/src/qt/emptystatewidget.h b/src/qt/emptystatewidget.h index 561345d73e..40656c6ddf 100644 --- a/src/qt/emptystatewidget.h +++ b/src/qt/emptystatewidget.h @@ -12,16 +12,17 @@ QT_BEGIN_NAMESPACE class QAbstractScrollArea; class QLabel; class QPushButton; +class QSpacerItem; class QWidget; QT_END_NAMESPACE /** * What Abyss shows where a list has nothing to show: a glyph, a title, one * sentence and one action. When only a filter hides the rows it offers to - * clear the filter instead, and while the wallet is still catching up it - * draws placeholder rows. Laid over a list's viewport, the list keeps its own - * header. The pages decide the state; classic themes always pass Hidden, so - * they never see it. + * clear the filter instead, and while the wallet is still catching up it says + * that it waits for the synchronization, with no action. Laid over a list's + * viewport, the list keeps its own header. The pages decide the state; classic + * themes always pass Hidden, so they never see it. */ class EmptyStateWidget : public QFrame { @@ -32,11 +33,12 @@ class EmptyStateWidget : public QFrame Hidden, //!< the list has rows, or the theme is classic Empty, //!< nothing yet: the page's own sentence and action Filtered, //!< there are rows, but the filters hide all of them - Loading, //!< nothing yet, and the wallet is still synchronizing + Syncing, //!< nothing yet, and the wallet is still synchronizing }; - //! The state for a list showing `rows` of `unfiltered_rows`. - static State stateFor(bool modern, int rows, int unfiltered_rows, bool loading); + //! The state for a list showing `rows` of `unfiltered_rows`. Only the + //! transaction lists wait on the synchronization. + static State stateFor(bool modern, int rows, int unfiltered_rows, bool syncing); EmptyStateWidget(const QString& glyph, const QString& title, const QString& text, const QString& action, QWidget* parent); @@ -75,10 +77,11 @@ class EmptyStateWidget : public QFrame int m_list_minimum{0}; int m_floor{0}; QWidget* m_message{nullptr}; - QWidget* m_skeleton{nullptr}; QLabel* m_symbol{nullptr}; QLabel* m_title{nullptr}; QLabel* m_text{nullptr}; + //! The room between the sentence and the action; it goes with the action. + QSpacerItem* m_action_gap{nullptr}; QPushButton* m_action{nullptr}; void paintSymbol(); diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index a4afd2e5ca..d256f57908 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -980,7 +980,7 @@ Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ true diff --git a/src/qt/locale/dash_de.ts b/src/qt/locale/dash_de.ts index 796c4ba574..f09822f2b1 100644 --- a/src/qt/locale/dash_de.ts +++ b/src/qt/locale/dash_de.ts @@ -3052,9 +3052,9 @@ Nur der Listeneintrag wird entfernt. Falls die Adresse in die Wallet importiert Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Fehlt eine Sprache oder ist eine Übersetzung unvollständig? Helfen Sie hier, die Übersetzung zu verbessern: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Options set in this dialog are overridden by the command line or in the configuration file: diff --git a/src/qt/locale/dash_en.ts b/src/qt/locale/dash_en.ts index f0e7dbfe8d..d795e8b828 100644 --- a/src/qt/locale/dash_en.ts +++ b/src/qt/locale/dash_en.ts @@ -3836,9 +3836,9 @@ Only the list entry is removed. If the address was imported into the wallet it r Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ diff --git a/src/qt/locale/dash_en.xlf b/src/qt/locale/dash_en.xlf index 7692c2e706..9e13cce35a 100644 --- a/src/qt/locale/dash_en.xlf +++ b/src/qt/locale/dash_en.xlf @@ -4135,9 +4135,9 @@ Only the list entry is removed. If the address was imported into the wallet it r Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ 982 diff --git a/src/qt/locale/dash_fr.ts b/src/qt/locale/dash_fr.ts index 4658da3e44..67b57ac550 100644 --- a/src/qt/locale/dash_fr.ts +++ b/src/qt/locale/dash_fr.ts @@ -3052,9 +3052,9 @@ Seule l’entrée de la liste sera retirée. Si l’adresse a été importée da Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Langue absent ou traduction incompléte ? Aidez à traduire ici : -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Options set in this dialog are overridden by the command line or in the configuration file: diff --git a/src/qt/locale/dash_ru.ts b/src/qt/locale/dash_ru.ts index 8bddbfd2a4..ea6eb97936 100644 --- a/src/qt/locale/dash_ru.ts +++ b/src/qt/locale/dash_ru.ts @@ -1813,9 +1813,9 @@ Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Нет Вашего языка или перевод неполон? Помогите нам сделать перевод лучше: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Options set in this dialog are overridden by the command line or in the configuration file: diff --git a/src/qt/locale/dash_zh_CN.ts b/src/qt/locale/dash_zh_CN.ts index dae65777d0..749ca3caa0 100644 --- a/src/qt/locale/dash_zh_CN.ts +++ b/src/qt/locale/dash_zh_CN.ts @@ -1801,9 +1801,9 @@ Language missing or translation incomplete? Help contributing translations here: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ 缺少相关语言或翻译不完整?请到这里协助翻译: -https://explore.transifex.com/dash/dash/ +https://app.transifex.com/defcon/defcon/ Options set in this dialog are overridden by the command line or in the configuration file: diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 5f61f9b065..cf4af145f4 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -483,7 +483,7 @@ OverviewPage::OverviewPage(QWidget* parent) : connect(ui->listTransactions, &TransactionOverviewWidget::clicked, this, &OverviewPage::handleTransactionClicked); - // Abyss says what an empty list means, or that it is still loading. + // Abyss says what an empty list means, or that it waits for the sync. m_transactions_empty = new EmptyStateWidget("history", tr("No recent transactions"), tr("Your recent transactions will appear here."), tr("Receive"), ui->listTransactions); m_transactions_empty->coverViewport(ui->listTransactions); @@ -686,7 +686,8 @@ void OverviewPage::updateEmptyState() { if (m_transactions_empty == nullptr) return; // Rows the overview leaves out (inactive ones, past the limit) are not a - // filter the user could clear, so an empty list is only empty or loading. + // filter the user could clear, so an empty list is only empty or waiting + // for the sync. m_transactions_empty->setState(filter == nullptr ? EmptyStateWidget::State::Hidden : EmptyStateWidget::stateFor(GUIUtil::isModernTheme(), filter->rowCount(), 0, m_out_of_sync)); } @@ -969,7 +970,10 @@ void OverviewPage::updateStakingCard() if (m_staking_card == nullptr) return; const bool modern = GUIUtil::isModernTheme(); const StakingState state = stakingState(); - QString word, detail, button; + // The line says what is the matter and what to do about it; what only a + // log or a command line can use (the thread, the option's name) is the + // line's tooltip. + QString word, detail, tip, button; GUIUtil::ThemedColor color = GUIUtil::ThemedColor::UNCONFIRMED; switch (state) { case StakingState::Unavailable: @@ -978,10 +982,16 @@ void OverviewPage::updateStakingCard() break; case StakingState::Disabled: word = tr("Off"); - // Not running while configured: the thread stopped on an error and is - // between retries; the log has the reason, the card must not guess one. - detail = m_staking.configured ? tr("The node's staking thread is not running. See debug.log.") - : tr("This node runs without staking (-staking=0)."); + if (m_staking.configured) { + // Not running while configured: the thread stopped on an error and + // is between retries; the log has the reason, the card must not + // guess one. + detail = tr("Staking stopped and will retry soon. If it stays off, restart the wallet."); + tip = tr("The staking thread is not running. The debug log file has the reason."); + } else { + detail = tr("Staking is turned off in the startup settings. To stake, turn it on and restart."); + tip = tr("The wallet was started with -staking=0, in its configuration file or on its command line."); + } break; case StakingState::Locked: // The banner over the network bar says why and holds the unlock, so @@ -1013,6 +1023,9 @@ void OverviewPage::updateStakingCard() detail = m_staking.wallet_state == NOT_STAKING_BALANCE ? tr("No spendable balance to stake.") : m_staking.wallet_state == NOT_STAKING_DEPTH ? tr("None of the coins can stake right now.") : tr("Looking for coins to stake."); + if (m_staking.wallet_state == NOT_STAKING_DEPTH) { + tip = tr("Coins stay out while immature or too young, under the smallest or over the largest stake, or exactly a masternode collateral."); + } button = tr("Pause staking"); color = GUIUtil::ThemedColor::BLUE; break; @@ -1028,8 +1041,7 @@ void OverviewPage::updateStakingCard() m_staking_detail->setText(detail); // An empty line would still take a row and its spacing. if (m_staking_detail->isHidden() == !detail.isEmpty()) m_staking_detail->setVisible(!detail.isEmpty()); - m_staking_detail->setToolTip(state == StakingState::Ready && m_staking.wallet_state == NOT_STAKING_DEPTH ? - tr("Coins stay out while immature or too young, under the smallest or over the largest stake, or exactly a masternode collateral.") : QString()); + m_staking_detail->setToolTip(tip); m_staking_button->setText(button); // Each tick lands here: a name that did not change is not announced again. if (m_staking_button->accessibleName() != button) m_staking_button->setAccessibleName(button); diff --git a/src/qt/res/css/defcon-dark.css b/src/qt/res/css/defcon-dark.css index 27997ac6d4..091d731703 100644 --- a/src/qt/res/css/defcon-dark.css +++ b/src/qt/res/css/defcon-dark.css @@ -1473,10 +1473,9 @@ QMenu QFrame#abyssMenuPairDivider { border: none; } -/* Stage 3: empty and loading states. Only Abyss shows them. */ +/* Stage 3: empty lists, and lists waiting for the synchronization. Only Abyss shows them. */ QFrame#emptyState, QFrame#emptyState QWidget#emptyStateMessage, -QFrame#emptyState QWidget#emptyStateSkeleton, QFrame#emptyState QLabel { background: transparent; border: none; @@ -1489,8 +1488,7 @@ QFrame#emptyState QFrame#emptyStateSymbol { QFrame#emptyState QLabel#emptyStateTitle { color: #ffffff; } -QFrame#emptyState QLabel#emptyStateText, -QFrame#emptyState QLabel#emptyStateLoading { +QFrame#emptyState QLabel#emptyStateText { color: #91a5bc; } QFrame#emptyState QPushButton#emptyStateAction, @@ -1521,21 +1519,6 @@ QFrame#emptyState QPushButton#emptyStateSecondary:pressed { border-color: #1297ff; color: #ffffff; } -QFrame#emptyState QFrame#skeletonDot { - background-color: #183048; - border: none; - border-radius: 18px; -} -QFrame#emptyState QFrame#skeletonLine { - background-color: #183048; - border: none; - border-radius: 4px; -} -QFrame#emptyState QFrame#skeletonLineShort { - background-color: #13283b; - border: none; - border-radius: 4px; -} /* A neutral chip where the classic themes print a red "(out of sync)". */ QWidget#OverviewPage QFrame#frame QLabel#labelWalletStatus, diff --git a/src/qt/test/abysstests.cpp b/src/qt/test/abysstests.cpp index 37a26e2c35..4b5113a417 100644 --- a/src/qt/test/abysstests.cpp +++ b/src/qt/test/abysstests.cpp @@ -2429,7 +2429,7 @@ void AbyssTests::emptyStates() empty->rect().contains(QRect(button->mapTo(empty, QPoint()), button->size())); }; - // Overview: an empty list says so, or that it is still loading. + // Overview: an empty list says so, or that it waits for the sync. { Theme("Abyss"); OverviewPage overview; @@ -2441,10 +2441,10 @@ void AbyssTests::emptyStates() auto* chip = overview.findChild("labelTransactionsStatus"); QVERIFY(empty && list && chip); QCOMPARE(chip->text(), OverviewPage::tr("out of sync")); - QCOMPARE(empty->state(), EmptyStateWidget::State::Loading); + QCOMPARE(empty->state(), EmptyStateWidget::State::Syncing); QVERIFY(empty->isVisible()); QCOMPARE(empty->geometry(), list->viewport()->geometry()); - QVERIFY(capture(overview, "overview-loading")); + QVERIFY(capture(overview, "overview-syncing")); overview.showOutOfSyncWarning(false); Settle(); QCOMPARE(empty->state(), EmptyStateWidget::State::Empty); QCOMPARE(empty->actionButton()->text(), OverviewPage::tr("Receive")); @@ -2467,7 +2467,7 @@ void AbyssTests::emptyStates() QCOMPARE(chip->text(), OverviewPage::tr("out of sync")); } - // Transactions: nothing yet, or still loading. The header stays visible. + // Transactions: nothing yet, or waiting for the sync. The header stays visible. { Theme("Light"); TransactionView view; @@ -2490,8 +2490,8 @@ void AbyssTests::emptyStates() QCOMPARE(receive.count(), 1); QVERIFY(capture(view, "transactions")); view.setOutOfSync(true); Settle(); - QCOMPARE(empty->state(), EmptyStateWidget::State::Loading); - QVERIFY(capture(view, "transactions-loading")); + QCOMPARE(empty->state(), EmptyStateWidget::State::Syncing); + QVERIFY(capture(view, "transactions-syncing")); view.setOutOfSync(false); QCOMPARE(empty->state(), EmptyStateWidget::State::Empty); Theme("Light"); Settle(); @@ -2725,6 +2725,138 @@ void AbyssTests::emptyStates() } } +void AbyssTests::emptyStateSyncVsLoading() +{ + // An empty transaction list on a wallet that is still catching up loads + // nothing: its rows come with the blocks, and a first synchronization + // takes hours. It says that it waits for the synchronization, in a title + // and one sentence, with nothing to press. The placeholder rows under + // "Loading…" that used to stand there all that time are gone. + using State = EmptyStateWidget::State; + QCOMPARE(EmptyStateWidget::stateFor(true, 0, 0, true), State::Syncing); + QCOMPARE(EmptyStateWidget::stateFor(true, 0, 0, false), State::Empty); + QCOMPARE(EmptyStateWidget::stateFor(true, 0, 3, true), State::Filtered); // A filter explains it better. + QCOMPARE(EmptyStateWidget::stateFor(true, 2, 3, true), State::Hidden); + QCOMPARE(EmptyStateWidget::stateFor(false, 0, 0, true), State::Hidden); // The classic themes show none of it. + + RestoreAppearance restore; + Theme("Abyss"); + WalletFixture fixture(m_node); + // What is wrong with the card of a list that waits, if anything. + const auto waiting = [](EmptyStateWidget* empty) -> QString { + auto* title = empty->findChild("emptyStateTitle"); + auto* text = empty->findChild("emptyStateText"); + if (!title || !text) return "no title or no sentence"; + if (!empty->isVisible() || !title->isVisible() || !text->isVisible()) return "the card, its title or its sentence is hidden"; + if (title->text() != EmptyStateWidget::tr("Waiting for synchronization")) return "title: " + title->text(); + if (!text->text().contains("catches up with the network")) return "sentence: " + text->text(); + if (text->height() < text->heightForWidth(text->width())) return "the sentence is cut"; + for (QLabel* label : {title, text}) { + if (!empty->rect().contains(QRect(label->mapTo(empty, QPoint()), label->size()))) return "outside the card: " + label->objectName(); + } + if (empty->actionButton()->isVisible()) return "a button to press while waiting"; + // The words stand in the card's middle: the button's room went with the button. + auto* ring = empty->findChild("emptyStateSymbol"); + if (!ring) return "no symbol"; + const int above = ring->mapTo(empty, QPoint()).y(); + const int below = empty->height() - (text->mapTo(empty, QPoint()).y() + text->height()); + if (std::abs(above - below) > 2) return QString("off the middle: %1 above, %2 below").arg(above).arg(below); + if (empty->accessibleName() != title->text()) return "accessible name: " + empty->accessibleName(); + for (QWidget* child : empty->findChildren()) { + if (child->objectName().contains("skeleton", Qt::CaseInsensitive)) return "placeholder rows: " + child->objectName(); + auto* label = qobject_cast(child); + if (label && label->text().contains("Loading", Qt::CaseInsensitive)) return "says: " + label->text(); + } + return QString(); + }; + + // Overview: a new page starts out of sync. + { + OverviewPage overview; + overview.setClientModel(fixture.client.get()); + overview.setWalletModel(fixture.model.get()); + overview.resize(1280, 820); overview.show(); Settle(); + auto* empty = overview.findChild("emptyState"); + QVERIFY(empty); + auto* title = empty->findChild("emptyStateTitle"); + QVERIFY(title); + QCOMPARE(empty->state(), State::Syncing); + QVERIFY2(waiting(empty).isEmpty(), qPrintable(waiting(empty))); + // In sync, the page's own words and its action. + overview.showOutOfSyncWarning(false); Settle(); + QCOMPARE(empty->state(), State::Empty); + QCOMPARE(title->text(), OverviewPage::tr("No recent transactions")); + QCOMPARE(empty->accessibleName(), title->text()); + QVERIFY(empty->actionButton()->isVisible()); + QCOMPARE(empty->actionButton()->text(), OverviewPage::tr("Receive")); + const auto place = [empty](QWidget* widget) { return QRect(widget->mapTo(empty, QPoint()), widget->size()); }; + const QRect title_in_sync = place(title), button_in_sync = place(empty->actionButton()); + // A wallet that falls behind waits again, and catches up to the same card: + // the button comes back where it was, with the room above it. + overview.showOutOfSyncWarning(true); Settle(); + QCOMPARE(empty->state(), State::Syncing); + QVERIFY2(waiting(empty).isEmpty(), qPrintable(waiting(empty))); + overview.showOutOfSyncWarning(false); Settle(); + QCOMPARE(empty->state(), State::Empty); + QVERIFY(empty->actionButton()->isVisible()); + QCOMPARE(place(title), title_in_sync); + QCOMPARE(place(empty->actionButton()), button_in_sync); + } + + // Transactions: the same under the table's header; a classic theme shows the bare table. + { + TransactionView view; + view.setModel(fixture.model.get()); + view.resize(1280, 700); view.show(); Settle(); + auto* empty = view.findChild("emptyState"); + auto* table = view.findChild("transactionView"); + QVERIFY(empty && table); + QCOMPARE(empty->state(), State::Empty); + view.setOutOfSync(true); Settle(); + QCOMPARE(empty->state(), State::Syncing); + QVERIFY2(waiting(empty).isEmpty(), qPrintable(waiting(empty))); + QVERIFY(table->horizontalHeader()->isVisible()); + QVERIFY(!empty->geometry().intersects(table->horizontalHeader()->geometry())); + Theme("Light"); Settle(); + QVERIFY(!empty->isVisible()); + Theme("Abyss"); Settle(); + QCOMPARE(empty->state(), State::Syncing); + QVERIFY2(waiting(empty).isEmpty(), qPrintable(waiting(empty))); + view.setOutOfSync(false); Settle(); + QCOMPARE(empty->state(), State::Empty); + QVERIFY(empty->actionButton()->isVisible()); + QCOMPARE(empty->findChild("emptyStateTitle")->text(), TransactionView::tr("No transactions yet")); + } + + // A history page as short as it gets, first shown while it waits: the table + // makes room for the title and the sentence. Caught up, the message is + // taller by its button, and the table grows for it at once, not at the + // window's next resize. + { + TransactionView view; + view.setModel(fixture.model.get()); + view.setOutOfSync(true); + view.resize(1280, 1); view.show(); Settle(); + auto* empty = view.findChild("emptyState"); + QVERIFY(empty); + QCOMPARE(empty->state(), State::Syncing); + QVERIFY2(waiting(empty).isEmpty(), qPrintable(waiting(empty))); + const int waiting_height = empty->height(); + view.setOutOfSync(false); Settle(); + QCOMPARE(empty->state(), State::Empty); + auto* text = empty->findChild("emptyStateText"); + auto* ring = empty->findChild("emptyStateSymbol"); + QPushButton* button = empty->actionButton(); + QVERIFY(text && ring && button->isVisible()); + QVERIFY2(empty->height() > waiting_height, qPrintable(QString("%1, was %2").arg(empty->height()).arg(waiting_height))); + QVERIFY(text->height() >= text->heightForWidth(text->width())); + QVERIFY2(empty->rect().contains(QRect(ring->mapTo(empty, QPoint()), ring->size())) && + empty->rect().contains(QRect(button->mapTo(empty, QPoint()), button->size())), + qPrintable(QString("card %1 high, symbol at %2, button to %3").arg(empty->height()) + .arg(ring->mapTo(empty, QPoint()).y()).arg(button->mapTo(empty, QPoint()).y() + button->height()))); + } +} + void AbyssTests::screenshots() { const QString output = qEnvironmentVariable("DEFCON_QT_SCREENSHOTS"); @@ -7023,8 +7155,23 @@ void AbyssTests::stakingCard() QVERIFY2(!detail->text().contains("mature") && detail->text().contains("None of the coins"), qPrintable(detail->text())); QVERIFY(detail->toolTip().contains("collateral")); } - if (QString(which.name) == "disabled") QVERIFY2(detail->text().contains("-staking=0"), qPrintable(detail->text())); - if (QString(which.name) == "stopped") QVERIFY2(!detail->text().contains("-staking") && detail->text().contains("not running"), qPrintable(detail->text())); + // Staking that is off for the whole node, and a thread that is down: the line says + // what is the matter and what to do, in the user's words; the option's name and + // the log are the tooltip's. + if (QString(which.name) == "disabled") { + QVERIFY2(detail->text().contains("turned off") && detail->text().contains("restart"), qPrintable(detail->text())); + QVERIFY2(detail->toolTip().contains("-staking=0"), qPrintable(detail->toolTip())); + } + if (QString(which.name) == "stopped") { + QVERIFY2(detail->text().contains("retry") && detail->text().contains("restart the wallet"), qPrintable(detail->text())); + QVERIFY2(detail->toolTip().contains("debug log file") && !detail->toolTip().contains("-staking"), qPrintable(detail->toolTip())); + } + // No state's line speaks of the node's insides, and only these three have more to say in a tooltip. + for (const char* word : {"thread", "debug", "-staking", "node", ".log"}) { + QVERIFY2(!detail->text().contains(word, Qt::CaseInsensitive), qPrintable(QString("%1: %2").arg(which.name, detail->text()))); + } + const bool has_tip = QStringList{"depth", "disabled", "stopped"}.contains(which.name); + QVERIFY2(detail->toolTip().isEmpty() != has_tip, qPrintable(QString("%1: %2").arg(which.name, detail->toolTip()))); widest = std::max(widest, card->minimumSizeHint().width()); if (!output.isEmpty()) { QVERIFY(QDir().mkpath(output)); @@ -7642,6 +7789,104 @@ void AbyssTests::stakingUnlockFlow() QCOMPARE(messages.count(), 0); } +void AbyssTests::stakingStartRefused() +{ + // "Start staking" on a wallet the staking thread has not listed yet (one + // loaded a moment ago) is refused. The message says so, offers another + // try first, and names the log last, as a file the user can open, not as + // an instruction to read debug.log. + RestoreAppearance restore; + Theme("Abyss"); + // The list as the thread builds it with no wallet loaded: the wallet made next is not in it. + MultiwalletInitialize(); + WalletFixture fixture(m_node); + const std::string name = fixture.wallet->GetName(); + const auto cleanup = interfaces::MakeHandler([&] { + if (IsWalletStaking(name)) ToggleWalletStaking(name); + }); + WalletView view(nullptr); + view.setClientModel(fixture.client.get()); + view.setWalletModel(fixture.model.get()); + view.resize(1280, 850); + view.show(); Settle(); + auto* page = view.findChild(); + QVERIFY(page); + auto* button = page->findChild("stakingButton"); + QVERIFY(button); + view.setStakingStatus(OverviewPage::StakingStatus{}); Settle(); // the thread up, the chain in + QCOMPARE(page->stakingState(), OverviewPage::StakingState::Off); + QCOMPARE(button->text(), QString("Start staking")); + QSignalSpy messages(&view, &WalletView::message); + button->click(); Settle(); + QVERIFY(!IsWalletStaking(name)); + QCOMPARE(page->stakingState(), OverviewPage::StakingState::Off); + QCOMPARE(messages.count(), 1); + QCOMPARE(messages.last().at(0).toString(), QString("Staking")); + const QString text = messages.last().at(1).toString(); + QVERIFY2(text.startsWith("Staking could not be started for this wallet."), qPrintable(text)); + const int retry_at = text.indexOf("try again"), log_at = text.indexOf("debug log file"); + QVERIFY2(retry_at > 0 && log_at > retry_at, qPrintable(text)); + QVERIFY2(!text.contains("debug.log"), qPrintable(text)); + QCOMPARE(messages.last().at(2).toUInt(), static_cast(CClientUIInterface::MSG_WARNING)); + // Listed, as after the thread's next pass, the same button starts it and nothing is said. + MultiwalletInitialize(); + button->click(); Settle(); + QVERIFY(IsWalletStaking(name)); + QCOMPARE(page->stakingState(), OverviewPage::StakingState::Ready); + QCOMPARE(messages.count(), 1); +} + +void AbyssTests::translationLink() +{ + // The Display tab's line for translators leads to DeFCoN's own Transifex + // project, in every theme and in every language. The address is part of + // the translated sentence, so no language's translation of the sentence + // may carry Dash's address; a language that does not translate it shows + // the form's own. The four translated languages the wallet keeps have + // the sentence with the new address: a language file that came back with + // the old sentence would lose it here. + const QString project = "https://app.transifex.com/defcon/defcon/"; + const QString sentence = QString("Language missing or translation incomplete? Help contributing translations here:\n") + project; + const QByteArray source = sentence.toUtf8(); + const QStringList languages = QDir(":/translations").entryList(); + QStringList translated; + for (const QString& language : languages) { + QTranslator translator; + QVERIFY2(translator.load(language, ":/translations/"), qPrintable(language)); + const QString text = translator.translate("OptionsDialog", source.constData()); + if (text.isEmpty()) continue; // Not translated: the form's own sentence shows. + QVERIFY2(text.contains(project), qPrintable(QString("%1: %2").arg(language, text))); + QVERIFY2(!text.contains("transifex.com/dash"), qPrintable(QString("%1: %2").arg(language, text))); + translated << language; + } + for (const char* language : {"de", "fr", "ru", "zh_CN"}) { + QVERIFY2(languages.contains(language), language); + QVERIFY2(translated.contains(language), language); + } + // The dialog's appearance page lists the loaded family's weights and + // asserts without fonts (appearanceFonts skips for the same reason). + if (!GUIUtil::fontsLoaded()) QSKIP("The options dialog needs the application fonts; the language files were checked."); + RestoreAppearance restore; + WalletFixture fixture(m_node); + const QString output = qEnvironmentVariable("DEFCON_QT_SCREENSHOTS"); + for (const char* theme : {"Abyss", "Light", "Dark", "Traditional"}) { + Theme(theme); + OptionsDialog options(nullptr, true); + options.setModel(fixture.options.get()); + QVERIFY(QMetaObject::invokeMethod(&options, "showPage", Q_ARG(int, 4))); // Display + options.show(); Settle(); + auto* label = options.findChild("label_3"); + QVERIFY2(label && label->isVisible(), theme); + QCOMPARE(label->text(), sentence); + // The whole address is on the page, not cut at the label's edge. + QVERIFY2(label->height() >= label->heightForWidth(label->width()), theme); + if (!output.isEmpty()) { + QVERIFY(QDir().mkpath(output)); + QVERIFY(options.grab().save(QDir(output).filePath(QString("%1-options-display.png").arg(theme)))); + } + } +} + void AbyssTests::stakingTipTime() { // The card's clock gate reads the active tip's time from every block diff --git a/src/qt/test/abysstests.h b/src/qt/test/abysstests.h index 302461d0b0..42ace327f8 100644 --- a/src/qt/test/abysstests.h +++ b/src/qt/test/abysstests.h @@ -55,6 +55,7 @@ private Q_SLOTS: void paymentSummaryLifecycle(); void networkModelLifecycle(); void emptyStates(); + void emptyStateSyncVsLoading(); void presentationIcons(); void iconPixelRatios(); void skyGeometry(); @@ -87,6 +88,7 @@ private Q_SLOTS: void stakingWindow(); void stakingSyncGates(); void stakingUnlockFlow(); + void stakingStartRefused(); void stakingTipTime(); void overviewColumnsAligned(); void overviewLockedFits(); @@ -111,6 +113,7 @@ private Q_SLOTS: void sidebarMoreGroup(); void sidebarMoreWalletGate(); void quickButtonsCompact(); + void translationLink(); // Last, after the window-activation checks of paymentPages: run before // them, its two short-lived wallet windows were followed by occasional // activation failures on xcb without a window manager. diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 9d430c1345..38f2488b74 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -156,7 +156,8 @@ TransactionView::TransactionView(QWidget* parent) : transactionView->setObjectName("transactionView"); // Abyss says what an empty history means: nothing yet, nothing that - // matches the filters, or still loading. The header stays visible above. + // matches the filters, or waiting for the sync. The header stays visible + // above. m_empty_state = new EmptyStateWidget("history", tr("No transactions yet"), tr("Your incoming and outgoing transactions will appear here."), tr("Receive"), transactionView); m_empty_state->coverViewport(transactionView); diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 17ac49fcf6..ee7a0f3610 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -40,7 +40,7 @@ class TransactionView : public QWidget explicit TransactionView(QWidget* parent = nullptr); void setModel(WalletModel *model); - //! While the wallet is still catching up, an empty history is loading. + //! While the wallet is still catching up, an empty history waits for the sync. void setOutOfSync(bool out_of_sync); // Date ranges for filter diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index d2c7834eb8..4fcbcdf6f1 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -305,10 +305,13 @@ void WalletView::toggleStaking(bool enable) // card is up to a tick old, and the menu or the RPC may have moved the // switch meanwhile, so "Start" must never pause and "Pause" never start. // Enabling goes through the one path the menu and the RPC share; it - // refuses a wallet that cannot sign, and says why in the log. + // refuses a wallet that cannot sign, and says why in the log. It also + // refuses a wallet loaded a moment ago, until the staking thread's next + // pass lists it: so the message offers another try first, and names the + // log last. const bool now_on = SetWalletStaking(name, enable); if (enable && !now_on) { - Q_EMIT message(tr("Staking"), tr("Staking could not be started for this wallet. See debug.log for details."), + Q_EMIT message(tr("Staking"), tr("Staking could not be started for this wallet. Please try again in a minute. If it still does not start, the debug log file has the reason."), CClientUIInterface::MSG_WARNING); if (model.isNull()) return; }