mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-03-13 06:01:45 +00:00
WIP: Added key-value dialog.
This commit is contained in:
parent
01cccf152f
commit
41789f0c1c
@ -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 \
|
||||
|
71
src/qt/forms/kevaaddkeydialog.ui
Normal file
71
src/qt/forms/kevaaddkeydialog.ui
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>KevaAddKeyDialog</class>
|
||||
<widget class="QDialog" name="KevaAddKeyDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Add New Key-Value Pair</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_1">
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="keyText">
|
||||
<property name="toolTip">
|
||||
<string>New value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="valueText">
|
||||
<property name="toolTip">
|
||||
<string>New value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
</ui>
|
@ -266,6 +266,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addKVButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add new key-value pair</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add key-value</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../bitcoin.qrc">
|
||||
<normaloff>:/icons/add</normaloff>:/icons/add</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@ -33,7 +33,7 @@
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close</set>
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
42
src/qt/kevaaddkeydialog.cpp
Normal file
42
src/qt/kevaaddkeydialog.cpp
Normal file
@ -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 <qt/kevaaddkeydialog.h>
|
||||
#include <qt/forms/ui_kevaaddkeydialog.h>
|
||||
|
||||
#include <qt/kevatablemodel.h>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
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);
|
||||
}
|
39
src/qt/kevaaddkeydialog.h
Normal file
39
src/qt/kevaaddkeydialog.h
Normal file
@ -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 <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
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
|
@ -17,6 +17,7 @@
|
||||
#include <qt/kevatablemodel.h>
|
||||
#include <qt/kevanamespacemodel.h>
|
||||
#include <qt/kevadetaildialog.h>
|
||||
#include <qt/kevaaddkeydialog.h>
|
||||
#include <qt/kevanewnamespacedialog.h>
|
||||
#include <qt/kevamynamespacesdialog.h>
|
||||
#include <qt/walletmodel.h>
|
||||
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user