diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 9d6087b55..f5812d5a9 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -137,6 +137,7 @@ QT_FORMS_UI = \ qt/forms/receiverequestdialog.ui \ qt/forms/kevadialog.ui \ qt/forms/kevadetaildialog.ui \ + qt/forms/kevaaddkeydialog.ui \ qt/forms/kevanewnamespacedialog.ui \ qt/forms/kevamynamespacesdialog.ui \ qt/forms/debugwindow.ui \ @@ -180,6 +181,7 @@ QT_MOC_CPP = \ qt/moc_kevatablemodel.cpp \ qt/moc_kevanamespacemodel.cpp \ qt/moc_kevadetaildialog.cpp \ + qt/moc_kevaaddkeydialog.cpp \ qt/moc_kevanewnamespacedialog.cpp \ qt/moc_kevamynamespacesdialog.cpp \ qt/moc_rpcconsole.cpp \ @@ -272,6 +274,7 @@ BITCOIN_QT_H = \ qt/kevatablemodel.h \ qt/kevanamespacemodel.h \ qt/kevadetaildialog.h \ + qt/kevaaddkeydialog.h \ qt/kevanewnamespacedialog.h \ qt/kevamynamespacesdialog.h \ qt/utilitydialog.h \ @@ -393,6 +396,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/kevatablemodel.cpp \ qt/kevanamespacemodel.cpp \ qt/kevadetaildialog.cpp \ + qt/kevaaddkeydialog.cpp \ qt/kevanewnamespacedialog.cpp \ qt/kevamynamespacesdialog.cpp \ qt/walletframe.cpp \ diff --git a/src/qt/forms/kevaaddkeydialog.ui b/src/qt/forms/kevaaddkeydialog.ui new file mode 100644 index 000000000..8f15e1aa0 --- /dev/null +++ b/src/qt/forms/kevaaddkeydialog.ui @@ -0,0 +1,71 @@ + + + KevaAddKeyDialog + + + + 0 + 0 + 800 + 400 + + + + Add New Key-Value Pair + + + + + + Key + + + + + + + New value + + + + + + + Qt::Horizontal + + + + 40 + 15 + + + + + + + + Value + + + + + + + New value + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + + + + + diff --git a/src/qt/forms/kevadialog.ui b/src/qt/forms/kevadialog.ui index cea7b9bb5..407e70866 100644 --- a/src/qt/forms/kevadialog.ui +++ b/src/qt/forms/kevadialog.ui @@ -266,6 +266,26 @@ + + + + false + + + Add new key-value pair + + + Add key-value + + + + :/icons/add:/icons/add + + + false + + + diff --git a/src/qt/forms/kevamynamespacesdialog.ui b/src/qt/forms/kevamynamespacesdialog.ui index c0a481e8e..841154035 100644 --- a/src/qt/forms/kevamynamespacesdialog.ui +++ b/src/qt/forms/kevamynamespacesdialog.ui @@ -33,7 +33,7 @@ Qt::Horizontal - QDialogButtonBox::Apply|QDialogButtonBox::Close + QDialogButtonBox::Apply|QDialogButtonBox::Cancel diff --git a/src/qt/kevaaddkeydialog.cpp b/src/qt/kevaaddkeydialog.cpp new file mode 100644 index 000000000..e6fe99fc0 --- /dev/null +++ b/src/qt/kevaaddkeydialog.cpp @@ -0,0 +1,42 @@ +// Copyright (c) 2011-2017 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include + +#include + +#include + +KevaAddKeyDialog::KevaAddKeyDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::KevaAddKeyDialog) +{ + ui->setupUi(this); + connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(cancel())); + connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(create())); + connect(ui->keyText, SIGNAL(textChanged(const QString &)), this, SLOT(onKeyChanged(const QString &))); + ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); +} + +KevaAddKeyDialog::~KevaAddKeyDialog() +{ + delete ui; +} + +void KevaAddKeyDialog::create() +{ + QDialog::close(); +} + +void KevaAddKeyDialog::cancel() +{ + QDialog::close(); +} + +void KevaAddKeyDialog::onKeyChanged(const QString& key) +{ + bool enabled = key.length() > 0; + ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled); +} diff --git a/src/qt/kevaaddkeydialog.h b/src/qt/kevaaddkeydialog.h new file mode 100644 index 000000000..ab54e8880 --- /dev/null +++ b/src/qt/kevaaddkeydialog.h @@ -0,0 +1,39 @@ +// Copyright (c) 2011-2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_KEVAADDKEYDIALOG_H +#define BITCOIN_QT_KEVAADDKEYDIALOG_H + +#include +#include + +#include + +namespace Ui { + class KevaAddKeyDialog; +} + +QT_BEGIN_NAMESPACE +class QModelIndex; +QT_END_NAMESPACE + +/** Dialog add new key-value pair. */ +class KevaAddKeyDialog : public QDialog +{ + Q_OBJECT + +public: + explicit KevaAddKeyDialog(QWidget *parent = 0); + ~KevaAddKeyDialog(); + +private: + Ui::KevaAddKeyDialog *ui; + +public Q_SLOTS: + void create(); + void cancel(); + void onKeyChanged(const QString& key); +}; + +#endif // BITCOIN_QT_KEVAADDKEYDIALOG_H diff --git a/src/qt/kevadialog.cpp b/src/qt/kevadialog.cpp index e4e0dfe37..415d0b181 100644 --- a/src/qt/kevadialog.cpp +++ b/src/qt/kevadialog.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ KevaDialog::KevaDialog(const PlatformStyle *_platformStyle, QWidget *parent) : ui->receiveButton->setIcon(_platformStyle->SingleColorIcon(":/icons/address-book")); ui->showValueButton->setIcon(_platformStyle->SingleColorIcon(":/icons/edit")); ui->removeButton->setIcon(_platformStyle->SingleColorIcon(":/icons/remove")); + ui->addKVButton->setIcon(_platformStyle->SingleColorIcon(":/icons/add")); } // context menu actions @@ -65,6 +67,8 @@ KevaDialog::KevaDialog(const PlatformStyle *_platformStyle, QWidget *parent) : connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyMessageAction, SIGNAL(triggered()), this, SLOT(copyMessage())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); + + connect(ui->nameSpace, SIGNAL(textChanged(const QString &)), this, SLOT(onNamespaceChanged(const QString &))); } void KevaDialog::setModel(WalletModel *_model) @@ -138,6 +142,17 @@ void KevaDialog::on_createNamespace_clicked() dialog->show(); } +void KevaDialog::onNamespaceChanged(const QString& nameSpace) +{ + std::string namespaceStr = nameSpace.toStdString(); + valtype nameSpaceVal; + if (DecodeKevaNamespace(namespaceStr, Params(), nameSpaceVal)) { + ui->addKVButton->setEnabled(true); + } else { + ui->addKVButton->setEnabled(false); + } +} + void KevaDialog::on_listNamespaces_clicked() { @@ -187,6 +202,7 @@ void KevaDialog::kevaView_selectionChanged() bool enable = !ui->kevaView->selectionModel()->selectedRows().isEmpty(); ui->showValueButton->setEnabled(enable); ui->removeButton->setEnabled(enable); + ui->addKVButton->setEnabled(enable); } void KevaDialog::on_showValueButton_clicked() @@ -244,6 +260,13 @@ void KevaDialog::on_removeButton_clicked() model->getKevaTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent()); } +void KevaDialog::on_addKVButton_clicked() +{ + KevaAddKeyDialog *dialog = new KevaAddKeyDialog(this); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); +} + // We override the virtual resizeEvent of the QWidget to adjust tables column // sizes as the tables width is proportional to the dialogs width. void KevaDialog::resizeEvent(QResizeEvent *event) diff --git a/src/qt/kevadialog.h b/src/qt/kevadialog.h index b043676ef..070686aa3 100644 --- a/src/qt/kevadialog.h +++ b/src/qt/kevadialog.h @@ -50,6 +50,7 @@ public Q_SLOTS: void clear(); void reject(); void accept(); + void onNamespaceChanged(const QString& nameSpace); protected: virtual void keyPressEvent(QKeyEvent *event); @@ -71,6 +72,7 @@ private Q_SLOTS: void on_listNamespaces_clicked(); void on_showValueButton_clicked(); void on_removeButton_clicked(); + void on_addKVButton_clicked(); void on_kevaView_doubleClicked(const QModelIndex &index); void kevaView_selectionChanged(); void updateDisplayUnit(); diff --git a/src/qt/kevamynamespacesdialog.cpp b/src/qt/kevamynamespacesdialog.cpp index f9d712e67..191f08612 100644 --- a/src/qt/kevamynamespacesdialog.cpp +++ b/src/qt/kevamynamespacesdialog.cpp @@ -18,7 +18,7 @@ KevaMyNamespacesDialog::KevaMyNamespacesDialog(QWidget *parent) : ui->setupUi(this); ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); ui->buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Show")); - connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(reject())); + connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); }