Browse Source

WIP: some minor tweaks.

kevaview
Just Wonder 5 years ago
parent
commit
01cccf152f
  1. 24
      src/qt/forms/kevadialog.ui
  2. 34
      src/qt/forms/kevanewnamespacedialog.ui
  3. 38
      src/qt/kevadialog.cpp
  4. 1
      src/qt/kevamynamespacesdialog.cpp
  5. 17
      src/qt/kevanamespacemodel.cpp
  6. 13
      src/qt/kevanewnamespacedialog.cpp
  7. 4
      src/qt/kevanewnamespacedialog.h
  8. 10
      src/qt/kevatablemodel.cpp
  9. 112
      src/qt/locale/bitcoin_en.ts
  10. 17
      src/qt/walletmodel.cpp
  11. 8
      src/qt/walletmodel.h

24
src/qt/forms/kevadialog.ui

@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="receiveButton">
<widget class="QPushButton" name="createNamespace">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -92,19 +92,19 @@ @@ -92,19 +92,19 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>Bookmark this namespace</string>
<string>Create a new namespace</string>
</property>
<property name="text">
<string>&amp;Bookmark</string>
<string>&amp;Create namespace</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/address-book</normaloff>:/icons/address-book</iconset>
<normaloff>:/icons/add</normaloff>:/icons/add</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="createNamespace">
<widget class="QPushButton" name="listNamespaces">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -112,19 +112,19 @@ @@ -112,19 +112,19 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>Create a new namespace</string>
<string>List my namepsaces</string>
</property>
<property name="text">
<string>&amp;Create</string>
<string>&amp;My Namespaces</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/add</normaloff>:/icons/add</iconset>
<normaloff>:/icons/editpaste</normaloff>:/icons/editpaste</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="listNamespaces">
<widget class="QPushButton" name="receiveButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -132,14 +132,14 @@ @@ -132,14 +132,14 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>List my namepsaces</string>
<string>Show bookmarks</string>
</property>
<property name="text">
<string>&amp;My Namespaces</string>
<string>&amp;Bookmarks</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/editpaste</normaloff>:/icons/editpaste</iconset>
<normaloff>:/icons/address-book</normaloff>:/icons/address-book</iconset>
</property>
</widget>
</item>

34
src/qt/forms/kevanewnamespacedialog.ui

@ -57,38 +57,4 @@ @@ -57,38 +57,4 @@
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>KevaNewNamespaceDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>KevaNewNamespaceDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

38
src/qt/kevadialog.cpp

@ -222,11 +222,26 @@ void KevaDialog::on_removeButton_clicked() @@ -222,11 +222,26 @@ void KevaDialog::on_removeButton_clicked()
std::string nameSpace = ui->nameSpace->text().toStdString();
std::string key = keyStr.toStdString();
if (this->model->deleteKevaEntry(nameSpace, key)) {
// correct for selection mode ContiguousSelection
QModelIndex firstIndex = selection.at(0);
model->getKevaTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent());
int ret = this->model->deleteKevaEntry(nameSpace, key);
if (ret > 0) {
QString msg;
switch (ret) {
case WalletModel::InvalidNamespace:
msg = tr("Invalid namespace \"%1\"").arg(ui->nameSpace->text());
break;
case WalletModel::KeyNotFound:
msg = tr("Key not found: \"%1\".").arg(keyStr);
break;
default:
msg = tr("Unknown error.");
}
QMessageBox::critical(this, tr("Error"), msg, QMessageBox::Ok);
return;
}
// correct for selection mode ContiguousSelection
QModelIndex firstIndex = selection.at(0);
model->getKevaTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent());
}
// We override the virtual resizeEvent of the QWidget to adjust tables column
@ -324,9 +339,18 @@ int KevaDialog::createNamespace(std::string displayName, std::string& namespaceI @@ -324,9 +339,18 @@ int KevaDialog::createNamespace(std::string displayName, std::string& namespaceI
return 0;
}
if (!this->model->createNamespace(displayName, namespaceId)) {
// TODO: show error message.
return 1;
int ret = this->model->createNamespace(displayName, namespaceId);
if (ret > 0) {
QString msg;
switch (ret) {
case WalletModel::NamespaceTooLong:
msg = tr("Namespace too long \"%1\"").arg(QString::fromStdString(displayName));
break;
default:
msg = tr("Unknown error.");
}
QMessageBox::critical(this, tr("Error"), msg, QMessageBox::Ok);
return 0;
}
return 1;
}

1
src/qt/kevamynamespacesdialog.cpp

@ -17,6 +17,7 @@ KevaMyNamespacesDialog::KevaMyNamespacesDialog(QWidget *parent) : @@ -17,6 +17,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::Apply), SIGNAL(clicked()), this, SLOT(apply()));
}

17
src/qt/kevanamespacemodel.cpp

@ -45,7 +45,15 @@ QVariant KevaNamespaceModel::data(const QModelIndex &index, int role) const @@ -45,7 +45,15 @@ QVariant KevaNamespaceModel::data(const QModelIndex &index, int role) const
if(!index.isValid() || index.row() >= list.length())
return QVariant();
if(role == Qt::DisplayRole || role == Qt::EditRole)
if (role == Qt::TextColorRole)
{
const NamespaceEntry *rec = &list[index.row()];
if (!rec->confirmed) {
return QVariant(QBrush (QColor(Qt::gray)));
}
return QVariant();
}
else if(role == Qt::DisplayRole || role == Qt::EditRole)
{
const NamespaceEntry *rec = &list[index.row()];
switch(index.column())
@ -105,12 +113,7 @@ bool KevaNamespaceModel::removeRows(int row, int count, const QModelIndex &paren @@ -105,12 +113,7 @@ bool KevaNamespaceModel::removeRows(int row, int count, const QModelIndex &paren
Qt::ItemFlags KevaNamespaceModel::flags(const QModelIndex &index) const
{
const NamespaceEntry *rec = &list[index.row()];
if (rec->confirmed) {
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
} else {
return Qt::ItemIsSelectable;
}
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
// actually add to table in GUI

13
src/qt/kevanewnamespacedialog.cpp

@ -16,8 +16,8 @@ KevaNewNamespaceDialog::KevaNewNamespaceDialog(QWidget *parent) : @@ -16,8 +16,8 @@ KevaNewNamespaceDialog::KevaNewNamespaceDialog(QWidget *parent) :
ui(new Ui::KevaNewNamespaceDialog)
{
ui->setupUi(this);
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close()));
connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(create()));
connect(ui->namespaceText, SIGNAL(textChanged(const QString &)), this, SLOT(onNamespaceChanged(const QString &)));
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);
}
@ -29,21 +29,22 @@ void KevaNewNamespaceDialog::onNamespaceChanged(const QString & ns) @@ -29,21 +29,22 @@ void KevaNewNamespaceDialog::onNamespaceChanged(const QString & ns)
ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(enabled);
}
void KevaNewNamespaceDialog::accept()
void KevaNewNamespaceDialog::create()
{
KevaDialog* dialog = (KevaDialog*)this->parentWidget();
QString nsText = ui->namespaceText->text();
std::string namespaceId;
if (!dialog->createNamespace(nsText.toStdString(), namespaceId)) {
//TODO: error message.
QDialog::close();
return;
}
dialog->showNamespace(QString::fromStdString(namespaceId));
QDialog::accept();
QDialog::close();
}
void KevaNewNamespaceDialog::reject()
void KevaNewNamespaceDialog::close()
{
QDialog::close();
}
KevaNewNamespaceDialog::~KevaNewNamespaceDialog()

4
src/qt/kevanewnamespacedialog.h

@ -25,8 +25,8 @@ public: @@ -25,8 +25,8 @@ public:
~KevaNewNamespaceDialog();
public Q_SLOTS:
void accept();
void reject();
void create();
void close();
void onNamespaceChanged(const QString & ns);
private:

10
src/qt/kevatablemodel.cpp

@ -48,7 +48,15 @@ QVariant KevaTableModel::data(const QModelIndex &index, int role) const @@ -48,7 +48,15 @@ QVariant KevaTableModel::data(const QModelIndex &index, int role) const
if(!index.isValid() || index.row() >= list.length())
return QVariant();
if(role == Qt::DisplayRole || role == Qt::EditRole)
if (role == Qt::TextColorRole)
{
const KevaEntry *rec = &list[index.row()];
if (rec->block < 0) {
return QVariant(QBrush (QColor(Qt::gray)));
}
return QVariant();
}
else if(role == Qt::DisplayRole || role == Qt::EditRole)
{
const KevaEntry *rec = &list[index.row()];
switch(index.column())

112
src/qt/locale/bitcoin_en.ts

@ -1167,7 +1167,7 @@ @@ -1167,7 +1167,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../kevadetaildialog.cpp" line="+17"/>
<location filename="../kevadetaildialog.cpp" line="+19"/>
<source>Value for %1</source>
<translation type="unfinished"></translation>
</message>
@ -1175,18 +1175,18 @@ @@ -1175,18 +1175,18 @@
<context>
<name>KevaDialog</name>
<message>
<location filename="../forms/kevadialog.ui" line="+215"/>
<location filename="../forms/kevadialog.ui" line="+235"/>
<source>Show the selected request (does the same as double clicking an entry)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-140"/>
<location line="+143"/>
<location line="-160"/>
<location line="+163"/>
<source>Show</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-184"/>
<location line="-204"/>
<location line="+14"/>
<source>The namespace ID with a prefix &quot;N&quot;.</source>
<translation type="unfinished"></translation>
@ -1208,22 +1208,32 @@ @@ -1208,22 +1208,32 @@
</message>
<message>
<location line="+23"/>
<source>Bookmark this namespace</source>
<source>Create a new namespace</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>&amp;Bookmark</source>
<source>&amp;Create namespace</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+17"/>
<source>Create a new namespace</source>
<source>List my namepsaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>&amp;Create</source>
<source>&amp;My Namespaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+17"/>
<source>Show bookmarks</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>&amp;Bookmarks</source>
<translation type="unfinished"></translation>
</message>
<message>
@ -1242,7 +1252,7 @@ @@ -1242,7 +1252,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../kevadialog.cpp" line="+47"/>
<location filename="../kevadialog.cpp" line="+50"/>
<source>Copy URI</source>
<translation type="unfinished"></translation>
</message>
@ -1261,6 +1271,82 @@ @@ -1261,6 +1271,82 @@
<source>Copy amount</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+162"/>
<source>Warning</source>
<translation type="unfinished">Warning</translation>
</message>
<message>
<location line="+0"/>
<source>Delete the key &quot;%1&quot;?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+15"/>
<source>Invalid namespace &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Key not found: &quot;%1&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<location line="+114"/>
<source>Unknown error.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-112"/>
<location line="+114"/>
<source>Error</source>
<translation type="unfinished">Error</translation>
</message>
<message>
<location line="-5"/>
<source>Namespace too long &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KevaMyNamespacesDialog</name>
<message>
<location filename="../kevamynamespacesdialog.cpp" line="+20"/>
<source>Show</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KevaNamespaceModel</name>
<message>
<location filename="../kevanamespacemodel.cpp" line="+21"/>
<source>Id</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+0"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KevaNewNamespaceDialog</name>
<message>
<location filename="../forms/kevanewnamespacedialog.ui" line="+22"/>
<source>The name of the namespace.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Name:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+13"/>
<source>This pane allows the creation of a new Keva namespace</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KevaTableModel</name>
@ -1285,7 +1371,7 @@ @@ -1285,7 +1371,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+73"/>
<location line="+81"/>
<source>Requested</source>
<translation type="unfinished"></translation>
</message>
@ -4020,12 +4106,12 @@ @@ -4020,12 +4106,12 @@
<context>
<name>WalletModel</name>
<message>
<location filename="../walletmodel.cpp" line="+296"/>
<location filename="../walletmodel.cpp" line="+301"/>
<source>Send Coins</source>
<translation type="unfinished">Send Coins</translation>
</message>
<message>
<location line="+389"/>
<location line="+394"/>
<location line="+39"/>
<location line="+6"/>
<source>Fee bump error</source>

17
src/qt/walletmodel.cpp

@ -863,7 +863,7 @@ void WalletModel::getNamespaceEntries(std::vector<NamespaceEntry>& vNamespaceEnt @@ -863,7 +863,7 @@ void WalletModel::getNamespaceEntries(std::vector<NamespaceEntry>& vNamespaceEnt
for (auto ns: unconfirmedNamespaces) {
NamespaceEntry entry;
entry.id = ValtypeToString(std::get<0>(ns));
entry.id = EncodeBase58Check(std::get<0>(ns));
entry.name = ValtypeToString(std::get<1>(ns));
entry.confirmed = false;
vNamespaceEntries.push_back(std::move(entry));
@ -886,7 +886,7 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp @@ -886,7 +886,7 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp
{
const valtype displayName = ValtypeFromString (displayNameStr);
if (displayName.size() > MAX_NAMESPACE_LENGTH) {
return 0;
return NamespaceTooLong;
}
CReserveKey keyName(wallet);
@ -915,7 +915,7 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp @@ -915,7 +915,7 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp
keyName.KeepKey();
namespaceId = EncodeBase58Check(kevaNamespace);
return 1;
return 0;
}
@ -923,14 +923,12 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr) @@ -923,14 +923,12 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr)
{
valtype nameSpace;
if (!DecodeKevaNamespace(namespaceStr, Params(), nameSpace)) {
//TODO: show error message.
return 0;
return InvalidNamespace;
}
const valtype key = ValtypeFromString(keyStr);
if (key.size() > MAX_KEY_LENGTH) {
//TODO: show error message.
return 0;
return KeyTooLong;
}
bool hasKey = false;
@ -949,8 +947,7 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr) @@ -949,8 +947,7 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr)
}
if (!hasKey) {
//TODO: show error message.
return 0;
return KeyNotFound;
}
COutput output;
@ -980,5 +977,5 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr) @@ -980,5 +977,5 @@ int WalletModel::deleteKevaEntry(std::string namespaceStr, std::string keyStr)
KEVA_LOCKED_AMOUNT, false, wtx, coinControl);
keyName.KeepKey();
return 1;
return 0;
}

8
src/qt/walletmodel.h

@ -120,7 +120,13 @@ public: @@ -120,7 +120,13 @@ public:
TransactionCreationFailed, // Error returned when wallet is still locked
TransactionCommitFailed,
AbsurdFee,
PaymentRequestExpired
PaymentRequestExpired,
// Keva status
InvalidNamespace,
KeyTooLong,
NamespaceTooLong,
KeyNotFound
};
enum EncryptionStatus

Loading…
Cancel
Save