Skip to content

Commit ba1a82e

Browse files
committed
Merge #430: Improvements to the open up transaction in third-party link action
2ccde2f qt: hyphenate usage of third-party modifier (Jarol Rodriguez) 8177578 qt: ensure seperator when adding third-party transaction links (Jarol Rodriguez) a70a980 qt: improve text for open third-party tx url action (Jarol Rodriguez) 9980f4a qt, refactor: simplify third-party tx url action through overload (Jarol Rodriguez) Pull request description: [#4092](bitcoin/bitcoin#4092) introduced the ability to open up a transaction in a block explorer. This improves the related code by simplifying the addition and connection of the action through an [overloaded](https://doc.qt.io/archives/qt-5.9/qmenu.html#addAction-5) `addAction` function and prepends action description text to the host, "Show in". The reason to add this text is to make it clear what the action does. It also creates a clearer mental correlation between a user doing the work to add the 3rd-party tx link and this new menu action popping up. This updates the setting text so that "third-party" is hyphenated. It should be hyphenated because it is being used as a modifier of both "URL" and "transaction URLs". Additionally, this fixes #431 by ensuring that the seperator will be added before creating action. Screenshots of visual changes: **Context menu actions** | master | pr | |--------------|--------| | <img width="248" alt="3pt-master" src="https://user-images.githubusercontent.com/23396902/134618354-00278ac6-5094-44ee-8ba7-fe648fdcb7d2.png"> | <img width="248" alt="3pt-pr" src="https://user-images.githubusercontent.com/23396902/134618364-ddb64269-e5ee-40af-a2a6-1922001b6f4e.png"> | **Setting text** (tooltip text containing usage of "third-party" is also properly hyphenated) | master | pr | |--------------|--------| | ![unnamed](https://user-images.githubusercontent.com/23396902/134854070-fb299ba5-3491-487f-b37f-c0cd96514353.png) | ![pr-hyphenate](https://user-images.githubusercontent.com/23396902/134854127-88630cc2-a178-4376-a569-f413f66eba0d.png) | ACKs for top commit: stratospher: tested ACK 2ccde2f. promag: Code view ACK 2ccde2f. hebasto: ACK 2ccde2f Tree-SHA512: 8dfcd539a1d41c8abf3c8208d150d1480d4ef81a008de826299e8bad1dfa6e3c49dc76d041c5946fafcf0b033eebb9b9fbd3d49ba6d8af93dd388c488e92f143
2 parents ad47fb8 + 2ccde2f commit ba1a82e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/qt/forms/optionsdialog.ui

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,10 @@
739739
<item>
740740
<widget class="QLabel" name="thirdPartyTxUrlsLabel">
741741
<property name="toolTip">
742-
<string>Third party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items. %s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.</string>
742+
<string>Third-party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items. %s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.</string>
743743
</property>
744744
<property name="text">
745-
<string>&amp;Third party transaction URLs</string>
745+
<string>&amp;Third-party transaction URLs</string>
746746
</property>
747747
<property name="buddy">
748748
<cstring>thirdPartyTxUrls</cstring>
@@ -752,7 +752,7 @@
752752
<item>
753753
<widget class="QLineEdit" name="thirdPartyTxUrls">
754754
<property name="toolTip">
755-
<string>Third party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items. %s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.</string>
755+
<string>Third-party URLs (e.g. a block explorer) that appear in the transactions tab as context menu items. %s in the URL is replaced by transaction hash. Multiple URLs are separated by vertical bar |.</string>
756756
</property>
757757
<property name="placeholderText">
758758
<string notr="true">https://example.com/tx/%s</string>

src/qt/transactionview.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,21 @@ void TransactionView::setModel(WalletModel *_model)
222222
{
223223
// Add third party transaction URLs to context menu
224224
QStringList listUrls = GUIUtil::SplitSkipEmptyParts(_model->getOptionsModel()->getThirdPartyTxUrls(), "|");
225+
bool actions_created = false;
225226
for (int i = 0; i < listUrls.size(); ++i)
226227
{
227228
QString url = listUrls[i].trimmed();
228229
QString host = QUrl(url, QUrl::StrictMode).host();
229230
if (!host.isEmpty())
230231
{
231-
QAction *thirdPartyTxUrlAction = new QAction(host, this); // use host as menu item label
232-
if (i == 0)
232+
if (!actions_created) {
233233
contextMenu->addSeparator();
234-
contextMenu->addAction(thirdPartyTxUrlAction);
235-
connect(thirdPartyTxUrlAction, &QAction::triggered, [this, url] { openThirdPartyTxUrl(url); });
234+
actions_created = true;
235+
}
236+
/*: Transactions table context menu action to show the
237+
selected transaction in a third-party block explorer.
238+
%1 is a stand-in argument for the URL of the explorer. */
239+
contextMenu->addAction(tr("Show in %1").arg(host), [this, url] { openThirdPartyTxUrl(url); });
236240
}
237241
}
238242
}

0 commit comments

Comments
 (0)