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

34
src/qt/forms/kevanewnamespacedialog.ui

@ -57,38 +57,4 @@
</layout> </layout>
</widget> </widget>
<resources/> <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> </ui>

34
src/qt/kevadialog.cpp

@ -222,12 +222,27 @@ void KevaDialog::on_removeButton_clicked()
std::string nameSpace = ui->nameSpace->text().toStdString(); std::string nameSpace = ui->nameSpace->text().toStdString();
std::string key = keyStr.toStdString(); std::string key = keyStr.toStdString();
if (this->model->deleteKevaEntry(nameSpace, key)) { 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 // correct for selection mode ContiguousSelection
QModelIndex firstIndex = selection.at(0); QModelIndex firstIndex = selection.at(0);
model->getKevaTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent()); model->getKevaTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent());
} }
}
// We override the virtual resizeEvent of the QWidget to adjust tables column // We override the virtual resizeEvent of the QWidget to adjust tables column
// sizes as the tables width is proportional to the dialogs width. // sizes as the tables width is proportional to the dialogs width.
@ -324,9 +339,18 @@ int KevaDialog::createNamespace(std::string displayName, std::string& namespaceI
return 0; return 0;
} }
if (!this->model->createNamespace(displayName, namespaceId)) { int ret = this->model->createNamespace(displayName, namespaceId);
// TODO: show error message. if (ret > 0) {
return 1; 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; return 1;
} }

1
src/qt/kevamynamespacesdialog.cpp

@ -17,6 +17,7 @@ KevaMyNamespacesDialog::KevaMyNamespacesDialog(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); 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::Close), SIGNAL(clicked()), this, SLOT(reject()));
connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
} }

15
src/qt/kevanamespacemodel.cpp

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

13
src/qt/kevanewnamespacedialog.cpp

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

4
src/qt/kevanewnamespacedialog.h

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

10
src/qt/kevatablemodel.cpp

@ -48,7 +48,15 @@ QVariant KevaTableModel::data(const QModelIndex &index, int role) const
if(!index.isValid() || index.row() >= list.length()) if(!index.isValid() || index.row() >= list.length())
return QVariant(); 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()]; const KevaEntry *rec = &list[index.row()];
switch(index.column()) switch(index.column())

112
src/qt/locale/bitcoin_en.ts

@ -1167,7 +1167,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../kevadetaildialog.cpp" line="+17"/> <location filename="../kevadetaildialog.cpp" line="+19"/>
<source>Value for %1</source> <source>Value for %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1175,18 +1175,18 @@
<context> <context>
<name>KevaDialog</name> <name>KevaDialog</name>
<message> <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> <source>Show the selected request (does the same as double clicking an entry)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-140"/> <location line="-160"/>
<location line="+143"/> <location line="+163"/>
<source>Show</source> <source>Show</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-184"/> <location line="-204"/>
<location line="+14"/> <location line="+14"/>
<source>The namespace ID with a prefix &quot;N&quot;.</source> <source>The namespace ID with a prefix &quot;N&quot;.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -1208,22 +1208,32 @@
</message> </message>
<message> <message>
<location line="+23"/> <location line="+23"/>
<source>Bookmark this namespace</source> <source>Create a new namespace</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+3"/> <location line="+3"/>
<source>&amp;Bookmark</source> <source>&amp;Create namespace</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+17"/> <location line="+17"/>
<source>Create a new namespace</source> <source>List my namepsaces</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+3"/> <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> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
@ -1242,7 +1252,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../kevadialog.cpp" line="+47"/> <location filename="../kevadialog.cpp" line="+50"/>
<source>Copy URI</source> <source>Copy URI</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1261,6 +1271,82 @@
<source>Copy amount</source> <source>Copy amount</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>KevaTableModel</name> <name>KevaTableModel</name>
@ -1285,7 +1371,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+73"/> <location line="+81"/>
<source>Requested</source> <source>Requested</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -4020,12 +4106,12 @@
<context> <context>
<name>WalletModel</name> <name>WalletModel</name>
<message> <message>
<location filename="../walletmodel.cpp" line="+296"/> <location filename="../walletmodel.cpp" line="+301"/>
<source>Send Coins</source> <source>Send Coins</source>
<translation type="unfinished">Send Coins</translation> <translation type="unfinished">Send Coins</translation>
</message> </message>
<message> <message>
<location line="+389"/> <location line="+394"/>
<location line="+39"/> <location line="+39"/>
<location line="+6"/> <location line="+6"/>
<source>Fee bump error</source> <source>Fee bump error</source>

17
src/qt/walletmodel.cpp

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

8
src/qt/walletmodel.h

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

Loading…
Cancel
Save