aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-05-01 08:19:55 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-05-01 08:20:11 +0200
commitd69427a0c4b43d58f52fa8337196562d87cd99f7 (patch)
tree3a25664a76fb9e7528cd6d661a5c453ba4d89bad /src
parent191b087e0ecdb9cde19d7339452b84cebbc8ca2b (diff)
parent40c5b939f2bff960e397da6ae3651952adc68cbe (diff)
Merge pull request #4092
40c5b93 [Qt] Optionally add third party links to transaction context menu (Cozz Lovan)
Diffstat (limited to 'src')
-rw-r--r--src/qt/forms/optionsdialog.ui24
-rw-r--r--src/qt/optionsdialog.cpp5
-rw-r--r--src/qt/optionsmodel.cpp13
-rw-r--r--src/qt/optionsmodel.h3
-rw-r--r--src/qt/transactiontablemodel.cpp2
-rw-r--r--src/qt/transactiontablemodel.h2
-rw-r--r--src/qt/transactionview.cpp35
-rw-r--r--src/qt/transactionview.h3
8 files changed, 87 insertions, 0 deletions
diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui
index 9fbc865185..0103842e02 100644
--- a/src/qt/forms/optionsdialog.ui
+++ b/src/qt/forms/optionsdialog.ui
@@ -472,6 +472,30 @@
</widget>
</item>
<item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3_Display">
+ <item>
+ <widget class="QLabel" name="thirdPartyTxUrlsLabel">
+ <property name="toolTip">
+ <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>
+ </property>
+ <property name="text">
+ <string>Third party transaction URLs</string>
+ </property>
+ <property name="buddy">
+ <cstring>thirdPartyTxUrls</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="thirdPartyTxUrls">
+ <property name="toolTip">
+ <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>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
<spacer name="verticalSpacer_Display">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index 394b5f3aea..96464d2cc0 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -96,6 +96,9 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
#endif
}
}
+#if QT_VERSION >= 0x040700
+ ui->thirdPartyTxUrls->setPlaceholderText("https://example.com/tx/%s");
+#endif
ui->unit->setModel(new BitcoinUnits(this));
ui->transactionFee->setSingleStep(CTransaction::nMinTxFee);
@@ -151,6 +154,7 @@ void OptionsDialog::setModel(OptionsModel *model)
connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning()));
/* Display */
connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
+ connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning()));
}
void OptionsDialog::setMapper()
@@ -183,6 +187,7 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->lang, OptionsModel::Language);
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses);
+ mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls);
}
void OptionsDialog::enableOkButton()
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 9abe9351bb..74c6b10ce2 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -63,6 +63,10 @@ void OptionsModel::Init()
settings.setValue("bDisplayAddresses", false);
bDisplayAddresses = settings.value("bDisplayAddresses", false).toBool();
+ if (!settings.contains("strThirdPartyTxUrls"))
+ settings.setValue("strThirdPartyTxUrls", "");
+ strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString();
+
if (!settings.contains("fCoinControlFeatures"))
settings.setValue("fCoinControlFeatures", false);
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
@@ -203,6 +207,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return nDisplayUnit;
case DisplayAddresses:
return bDisplayAddresses;
+ case ThirdPartyTxUrls:
+ return strThirdPartyTxUrls;
case Language:
return settings.value("language");
case CoinControlFeatures:
@@ -304,6 +310,13 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
bDisplayAddresses = value.toBool();
settings.setValue("bDisplayAddresses", bDisplayAddresses);
break;
+ case ThirdPartyTxUrls:
+ if (strThirdPartyTxUrls != value.toString()) {
+ strThirdPartyTxUrls = value.toString();
+ settings.setValue("strThirdPartyTxUrls", strThirdPartyTxUrls);
+ setRestartRequired(true);
+ }
+ break;
case Language:
if (settings.value("language") != value) {
settings.setValue("language", value);
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index ece5ef78a4..f05e3e92de 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -36,6 +36,7 @@ public:
Fee, // qint64
DisplayUnit, // BitcoinUnits::Unit
DisplayAddresses, // bool
+ ThirdPartyTxUrls, // QString
Language, // QString
CoinControlFeatures, // bool
ThreadsScriptVerif, // int
@@ -56,6 +57,7 @@ public:
bool getMinimizeOnClose() { return fMinimizeOnClose; }
int getDisplayUnit() { return nDisplayUnit; }
bool getDisplayAddresses() { return bDisplayAddresses; }
+ QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; }
bool getProxySettings(QNetworkProxy& proxy) const;
bool getCoinControlFeatures() { return fCoinControlFeatures; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
@@ -71,6 +73,7 @@ private:
QString language;
int nDisplayUnit;
bool bDisplayAddresses;
+ QString strThirdPartyTxUrls;
bool fCoinControlFeatures;
/* settings that were overriden by command-line */
QString strOverriddenByCommandLine;
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index df412650d8..8cf2b0a1b1 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -564,6 +564,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return rec->credit + rec->debit;
case TxIDRole:
return rec->getTxID();
+ case TxHashRole:
+ return QString::fromStdString(rec->hash.ToString());
case ConfirmedRole:
return rec->status.countsForBalance;
case FormattedAmountRole:
diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h
index 04b5291f42..333e6bc6ed 100644
--- a/src/qt/transactiontablemodel.h
+++ b/src/qt/transactiontablemodel.h
@@ -50,6 +50,8 @@ public:
AmountRole,
/** Unique identifier */
TxIDRole,
+ /** Transaction hash */
+ TxHashRole,
/** Is transaction confirmed? */
ConfirmedRole,
/** Formatted amount, without brackets when unconfirmed */
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index a363150919..d4d29416ca 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -20,6 +20,7 @@
#include <QComboBox>
#include <QDateTimeEdit>
+#include <QDesktopServices>
#include <QDoubleValidator>
#include <QHBoxLayout>
#include <QHeaderView>
@@ -28,7 +29,9 @@
#include <QMenu>
#include <QPoint>
#include <QScrollBar>
+#include <QSignalMapper>
#include <QTableView>
+#include <QUrl>
#include <QVBoxLayout>
TransactionView::TransactionView(QWidget *parent) :
@@ -138,7 +141,11 @@ TransactionView::TransactionView(QWidget *parent) :
contextMenu->addAction(editLabelAction);
contextMenu->addAction(showDetailsAction);
+ mapperThirdPartyTxUrls = new QSignalMapper(this);
+
// Connect actions
+ connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, SLOT(openThirdPartyTxUrl(QString)));
+
connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString)));
@@ -183,6 +190,25 @@ void TransactionView::setModel(WalletModel *model)
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH);
+
+ if (model->getOptionsModel())
+ {
+ // Add third party transaction URLs to context menu
+ QStringList listUrls = model->getOptionsModel()->getThirdPartyTxUrls().split("|", QString::SkipEmptyParts);
+ for (int i = 0; i < listUrls.size(); ++i)
+ {
+ QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host();
+ if (!host.isEmpty())
+ {
+ QAction *thirdPartyTxUrlAction = new QAction(host, this); // use host as menu item label
+ if (i == 0)
+ contextMenu->addSeparator();
+ contextMenu->addAction(thirdPartyTxUrlAction);
+ connect(thirdPartyTxUrlAction, SIGNAL(triggered()), mapperThirdPartyTxUrls, SLOT(map()));
+ mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, listUrls[i].trimmed());
+ }
+ }
+ }
}
}
@@ -383,6 +409,15 @@ void TransactionView::showDetails()
}
}
+void TransactionView::openThirdPartyTxUrl(QString url)
+{
+ if(!transactionView || !transactionView->selectionModel())
+ return;
+ QModelIndexList selection = transactionView->selectionModel()->selectedRows(0);
+ if(!selection.isEmpty())
+ QDesktopServices::openUrl(QUrl::fromUserInput(url.replace("%s", selection.at(0).data(TransactionTableModel::TxHashRole).toString())));
+}
+
QWidget *TransactionView::createDateRangeWidget()
{
dateRangeWidget = new QFrame();
diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h
index ef4f9d6f34..7a89fa11ca 100644
--- a/src/qt/transactionview.h
+++ b/src/qt/transactionview.h
@@ -19,6 +19,7 @@ class QFrame;
class QLineEdit;
class QMenu;
class QModelIndex;
+class QSignalMapper;
class QTableView;
QT_END_NAMESPACE
@@ -65,6 +66,7 @@ private:
QLineEdit *amountWidget;
QMenu *contextMenu;
+ QSignalMapper *mapperThirdPartyTxUrls;
QFrame *dateRangeWidget;
QDateTimeEdit *dateFrom;
@@ -85,6 +87,7 @@ private slots:
void copyLabel();
void copyAmount();
void copyTxID();
+ void openThirdPartyTxUrl(QString url);
signals:
void doubleClicked(const QModelIndex&);