aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/bitcoin.cpp6
-rw-r--r--src/qt/bitcoin.qrc1
-rw-r--r--src/qt/bitcoingui.cpp24
-rw-r--r--src/qt/bitcoingui.h3
-rw-r--r--src/qt/forms/messagepage.ui2
-rw-r--r--src/qt/guiutil.cpp22
-rw-r--r--src/qt/guiutil.h3
-rw-r--r--src/qt/qtipcserver.cpp22
-rw-r--r--src/qt/res/icons/filesave.pngbin0 -> 1741 bytes
-rw-r--r--src/qt/sendcoinsdialog.cpp2
-rw-r--r--src/qt/sendcoinsdialog.h2
-rw-r--r--src/qt/sendcoinsentry.cpp5
-rw-r--r--src/qt/test/urltests.cpp23
-rw-r--r--src/qt/walletmodel.cpp6
-rw-r--r--src/qt/walletmodel.h2
15 files changed, 78 insertions, 45 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 788009276e..354e87c983 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -154,11 +154,13 @@ int main(int argc, char *argv[])
ParseParameters(argc, argv);
- // Load language files for system locale:
+ // Get desired locale ("en_US") from command line or system locale
+ QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString()));
+ // Load language files for configured locale:
// - First load the translator for the base language, without territory
// - Then load the more specific locale translator
- QString lang_territory = QLocale::system().name(); // "en_US"
QString lang = lang_territory;
+
lang.truncate(lang_territory.lastIndexOf('_')); // "en"
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc
index 5693ae187e..d823752c9c 100644
--- a/src/qt/bitcoin.qrc
+++ b/src/qt/bitcoin.qrc
@@ -37,6 +37,7 @@
<file alias="lock_closed">res/icons/lock_closed.png</file>
<file alias="lock_open">res/icons/lock_open.png</file>
<file alias="key">res/icons/key.png</file>
+ <file alias="filesave">res/icons/filesave.png</file>
</qresource>
<qresource prefix="/images">
<file alias="about">res/images/about.png</file>
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index b72f128291..65753a1839 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -46,6 +46,8 @@
#include <QStackedWidget>
#include <QDateTime>
#include <QMovie>
+#include <QFileDialog>
+#include <QDesktopServices>
#include <QDragEnterEvent>
#include <QUrl>
@@ -163,6 +165,8 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
BitcoinGUI::~BitcoinGUI()
{
+ if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
+ trayIcon->hide();
#ifdef Q_WS_MAC
delete appMenuBar;
#endif
@@ -243,6 +247,8 @@ void BitcoinGUI::createActions()
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet"), this);
encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
encryptWalletAction->setCheckable(true);
+ backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet"), this);
+ backupWalletAction->setToolTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase"), this);
changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
@@ -252,6 +258,7 @@ void BitcoinGUI::createActions()
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(openBitcoinAction, SIGNAL(triggered()), this, SLOT(showNormal()));
connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
+ connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
}
@@ -277,6 +284,7 @@ void BitcoinGUI::createMenuBar()
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
settings->addAction(encryptWalletAction);
settings->addAction(changePassphraseAction);
+ settings->addAction(backupWalletAction);
settings->addSeparator();
settings->addAction(optionsAction);
@@ -723,7 +731,7 @@ void BitcoinGUI::dropEvent(QDropEvent *event)
QList<QUrl> urls = event->mimeData()->urls();
foreach(const QUrl &url, urls)
{
- sendCoinsPage->handleURL(&url);
+ sendCoinsPage->handleURL(url.toString());
}
}
@@ -733,8 +741,7 @@ void BitcoinGUI::dropEvent(QDropEvent *event)
void BitcoinGUI::handleURL(QString strURL)
{
gotoSendCoinsPage();
- QUrl url = QUrl(strURL);
- sendCoinsPage->handleURL(&url);
+ sendCoinsPage->handleURL(strURL);
}
void BitcoinGUI::setEncryptionStatus(int status)
@@ -778,6 +785,17 @@ void BitcoinGUI::encryptWallet(bool status)
setEncryptionStatus(walletModel->getEncryptionStatus());
}
+void BitcoinGUI::backupWallet()
+{
+ QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
+ QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)"));
+ if(!filename.isEmpty()) {
+ if(!walletModel->backupWallet(filename)) {
+ QMessageBox::warning(this, tr("Backup Failed"), tr("There was an error trying to save the wallet data to the new location."));
+ }
+ }
+}
+
void BitcoinGUI::changePassphrase()
{
AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this);
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 37ab12577c..a522429000 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -86,6 +86,7 @@ private:
QAction *openBitcoinAction;
QAction *exportAction;
QAction *encryptWalletAction;
+ QAction *backupWalletAction;
QAction *changePassphraseAction;
QAction *aboutQtAction;
@@ -162,6 +163,8 @@ private slots:
void incomingTransaction(const QModelIndex & parent, int start, int end);
/** Encrypt the wallet */
void encryptWallet(bool status);
+ /** Backup the wallet */
+ void backupWallet();
/** Change encrypted wallet passphrase */
void changePassphrase();
/** Ask for pass phrase to unlock wallet temporarily */
diff --git a/src/qt/forms/messagepage.ui b/src/qt/forms/messagepage.ui
index 8afa4b59dd..131e15bdb3 100644
--- a/src/qt/forms/messagepage.ui
+++ b/src/qt/forms/messagepage.ui
@@ -17,7 +17,7 @@
<item>
<widget class="QLabel" name="labelExplanation">
<property name="text">
- <string>You can sign messages with your addresses to prove you own them. Be careful to only sign statement you agree to with full details, as phishing attacks may try to trick you into signing access to them.</string>
+ <string>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index 29ef554ac3..02fc3b6700 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -49,15 +49,15 @@ void GUIUtil::setupAmountWidget(QLineEdit *widget, QWidget *parent)
widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
}
-bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out)
+bool GUIUtil::parseBitcoinURL(const QUrl &url, SendCoinsRecipient *out)
{
- if(url->scheme() != QString("bitcoin"))
+ if(url.scheme() != QString("bitcoin"))
return false;
SendCoinsRecipient rv;
- rv.address = url->path();
+ rv.address = url.path();
rv.amount = 0;
- QList<QPair<QString, QString> > items = url->queryItems();
+ QList<QPair<QString, QString> > items = url.queryItems();
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
{
bool fShouldReturnFalse = false;
@@ -94,6 +94,20 @@ bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out)
return true;
}
+bool GUIUtil::parseBitcoinURL(QString url, SendCoinsRecipient *out)
+{
+ // Convert bitcoin:// to bitcoin:
+ //
+ // Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host,
+ // which will lowercase it (and thus invalidate the address).
+ if(url.startsWith("bitcoin://"))
+ {
+ url.replace(0, 10, "bitcoin:");
+ }
+ QUrl urlInstance(url);
+ return parseBitcoinURL(urlInstance, out);
+}
+
QString GUIUtil::HtmlEscape(const QString& str, bool fMultiLine)
{
QString escaped = Qt::escape(str);
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index 3a81bd2f00..0c8b17186f 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -31,7 +31,8 @@ public:
// Parse "bitcoin:" URL into recipient object, return true on succesful parsing
// See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
- static bool parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out);
+ static bool parseBitcoinURL(const QUrl &url, SendCoinsRecipient *out);
+ static bool parseBitcoinURL(QString url, SendCoinsRecipient *out);
// HTML escaping for rich text controls
static QString HtmlEscape(const QString& str, bool fMultiLine=false);
diff --git a/src/qt/qtipcserver.cpp b/src/qt/qtipcserver.cpp
index 90d5c14211..018461a9b2 100644
--- a/src/qt/qtipcserver.cpp
+++ b/src/qt/qtipcserver.cpp
@@ -30,16 +30,7 @@ void ipcThread(void* parg)
ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100);
if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d))
{
- strBuf[nSize] = '\0';
- // Convert bitcoin:// URLs to bitcoin: URIs
- if (strBuf[8] == '/' && strBuf[9] == '/')
- {
- for (int i = 8; i < 256; i++)
- {
- strBuf[i] = strBuf[i+2];
- }
- }
- ThreadSafeHandleURL(strBuf);
+ ThreadSafeHandleURL(std::string(strBuf, nSize));
Sleep(1000);
}
if (fShutdown)
@@ -66,16 +57,7 @@ void ipcInit()
ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(1);
if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d))
{
- strBuf[nSize] = '\0';
- // Convert bitcoin:// URLs to bitcoin: URIs
- if (strBuf[8] == '/' && strBuf[9] == '/')
- {
- for (int i = 8; i < 256; i++)
- {
- strBuf[i] = strBuf[i+2];
- }
- }
- ThreadSafeHandleURL(strBuf);
+ ThreadSafeHandleURL(std::string(strBuf, nSize));
}
else
break;
diff --git a/src/qt/res/icons/filesave.png b/src/qt/res/icons/filesave.png
new file mode 100644
index 0000000000..ae13a151d5
--- /dev/null
+++ b/src/qt/res/icons/filesave.png
Binary files differ
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 0d9a604d3b..964313ea81 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -265,7 +265,7 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
}
-void SendCoinsDialog::handleURL(const QUrl *url)
+void SendCoinsDialog::handleURL(const QString &url)
{
SendCoinsRecipient rv;
if(!GUIUtil::parseBitcoinURL(url, &rv))
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index 847ee8b697..4dc3f08bc5 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -30,7 +30,7 @@ public:
QWidget *setupTabChain(QWidget *prev);
void pasteEntry(const SendCoinsRecipient &rv);
- void handleURL(const QUrl *url);
+ void handleURL(const QString &url);
public slots:
void clear();
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index ab5460f8c2..d98400c260 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -59,8 +59,9 @@ void SendCoinsEntry::on_payTo_textChanged(const QString &address)
{
if(!model)
return;
- ui->addAsLabel->setText(model->getAddressTableModel()->labelForAddress(address));
-}
+ // Fill in label from address book, if no label is filled in yet
+ if(ui->addAsLabel->text().isEmpty())
+ ui->addAsLabel->setText(model->getAddressTableModel()->labelForAddress(address));}
void SendCoinsEntry::setModel(WalletModel *model)
{
diff --git a/src/qt/test/urltests.cpp b/src/qt/test/urltests.cpp
index 5ecc846203..1f11795a9b 100644
--- a/src/qt/test/urltests.cpp
+++ b/src/qt/test/urltests.cpp
@@ -18,51 +18,54 @@ void URLTests::urlTests()
SendCoinsRecipient rv;
QUrl url;
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
- QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv));
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
- QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 0);
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
- QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString("Wikipedia Example Address"));
QVERIFY(rv.amount == 0);
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
- QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 100000);
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
- QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 100100000);
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
- QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.amount == 10000000000);
QVERIFY(rv.label == QString("Wikipedia Example"));
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
- QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString());
+
+ QVERIFY(GUIUtil::parseBitcoinURL("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString());
// We currently dont implement the message paramenter (ok, yea, we break spec...)
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
- QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv));
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
- QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv));
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
- QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
+ QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv));
}
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index f028f10f6c..8344a653d5 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -5,6 +5,7 @@
#include "transactiontablemodel.h"
#include "headers.h"
+#include "db.h" // for BackupWallet
#include <QTimer>
#include <QSet>
@@ -239,6 +240,11 @@ bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureStri
return retval;
}
+bool WalletModel::backupWallet(const QString &filename)
+{
+ return BackupWallet(*wallet, filename.toLocal8Bit().data());
+}
+
// WalletModel::UnlockContext implementation
WalletModel::UnlockContext WalletModel::requestUnlock()
{
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index 89e8cdd2a0..4123240e90 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -77,6 +77,8 @@ public:
// Passphrase only needed when unlocking
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString());
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass);
+ // Wallet backup
+ bool backupWallet(const QString &filename);
// RAI object for unlocking wallet, returned by requestUnlock()
class UnlockContext