diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index de442f7f93..6e67219bec 100755 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -82,6 +82,7 @@ QT_FORMS_UI = \ qt/forms/consolidateunspentwizardsendpage.ui \ qt/forms/diagnosticsdialog.ui \ qt/forms/editaddressdialog.ui \ + qt/forms/editsidestakedialog.ui \ qt/forms/favoritespage.ui \ qt/forms/intro.ui \ qt/forms/mrcrequestpage.ui \ @@ -143,6 +144,7 @@ QT_MOC_CPP = \ qt/moc_csvmodelwriter.cpp \ qt/moc_diagnosticsdialog.cpp \ qt/moc_editaddressdialog.cpp \ + qt/moc_editsidestakedialog.cpp \ qt/moc_favoritespage.cpp \ qt/moc_guiutil.cpp \ qt/moc_intro.cpp \ @@ -250,6 +252,7 @@ GRIDCOINRESEARCH_QT_H = \ qt/decoration.h \ qt/diagnosticsdialog.h \ qt/editaddressdialog.h \ + qt/editsidestakedialog.h \ qt/favoritespage.h \ qt/guiconstants.h \ qt/guiutil.h \ @@ -342,6 +345,7 @@ GRIDCOINRESEARCH_QT_CPP = \ qt/decoration.cpp \ qt/diagnosticsdialog.cpp \ qt/editaddressdialog.cpp \ + qt/editsidestakedialog.cpp \ qt/favoritespage.cpp \ qt/guiutil.cpp \ qt/intro.cpp \ diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 03b06569f7..b62d55953b 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -29,6 +29,7 @@ add_library(gridcoinqt STATIC decoration.cpp diagnosticsdialog.cpp editaddressdialog.cpp + editsidestakedialog.cpp favoritespage.cpp guiutil.cpp intro.cpp diff --git a/src/qt/editsidestakedialog.cpp b/src/qt/editsidestakedialog.cpp new file mode 100644 index 0000000000..5252f8a3aa --- /dev/null +++ b/src/qt/editsidestakedialog.cpp @@ -0,0 +1,138 @@ +// Copyright (c) 2014-2023 The Gridcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or https://opensource.org/licenses/mit-license.php. + +#include "editsidestakedialog.h" +#include "ui_editsidestakedialog.h" +#include "sidestaketablemodel.h" +#include "guiutil.h" +#include "qt/decoration.h" + +#include +#include + +EditSideStakeDialog::EditSideStakeDialog(Mode mode, QWidget* parent) + : QDialog(parent) + , ui(new Ui::EditSideStakeDialog) + , mapper(nullptr) + , mode(mode) + , model(nullptr) +{ + ui->setupUi(this); + + resize(GRC::ScaleSize(this, width(), height())); + + //GUIUtil::setupAddressWidget(ui->addressEdit, this); + + switch(mode) + { + case NewSideStake: + setWindowTitle(tr("New SideStake")); + //ui->addressEdit->setEnabled(false); + break; + case EditSideStake: + setWindowTitle(tr("Edit SideStake")); + //ui->addressEdit->setEnabled(false); + break; + } + assert(false); + + mapper = new QDataWidgetMapper(this); + mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); +} + +EditSideStakeDialog::~EditSideStakeDialog() +{ + delete ui; +} + +void EditSideStakeDialog::setModel(SideStakeTableModel *model) +{ + this->model = model; + if (!model) { + return; + } + + //mapper->setModel(model); + //mapper->addMapping(ui->labelEdit, AddressTableModel::Label); + //mapper->addMapping(ui->addressEdit, AddressTableModel::Address); +} + +void EditSideStakeDialog::loadRow(int row) +{ + mapper->setCurrentIndex(row); +} + +bool EditSideStakeDialog::saveCurrentRow() +{ + if(!model) + return false; + + switch(mode) + { + case NewSideStake: + break; + case EditSideStake: + break; + } + return false; +} + +void EditSideStakeDialog::accept() +{ + if (!model) { + return; + } + + /* + if(!saveCurrentRow()) + { + switch(model->getEditStatus()) + { + case AddressTableModel::OK: + // Failed with unknown reason. Just reject. + break; + case AddressTableModel::NO_CHANGES: + // No changes were made during edit operation. Just reject. + break; + case AddressTableModel::INVALID_ADDRESS: + QMessageBox::warning(this, windowTitle(), + tr("The entered address \"%1\" is not a valid Gridcoin address.").arg(ui->addressEdit->text()), + QMessageBox::Ok, QMessageBox::Ok); + break; + case AddressTableModel::DUPLICATE_ADDRESS: + QMessageBox::warning(this, windowTitle(), + tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()), + QMessageBox::Ok, QMessageBox::Ok); + break; + case AddressTableModel::WALLET_UNLOCK_FAILURE: + QMessageBox::critical(this, windowTitle(), + tr("Could not unlock wallet."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case AddressTableModel::KEY_GENERATION_FAILURE: + QMessageBox::critical(this, windowTitle(), + tr("New key generation failed."), + QMessageBox::Ok, QMessageBox::Ok); + break; + + } + return; + } + */ + + QDialog::accept(); +} + +/* +QString EditSideStakeDialog::getAddress() const +{ + return address; +} + +void EditSideStakeDialog::setAddress(const QString &address) +{ + this->address = address; + ui->addressEdit->setText(address); +} +*/ diff --git a/src/qt/editsidestakedialog.h b/src/qt/editsidestakedialog.h new file mode 100644 index 0000000000..63c2c1f5bf --- /dev/null +++ b/src/qt/editsidestakedialog.h @@ -0,0 +1,53 @@ +// Copyright (c) 2014-2023 The Gridcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or https://opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_EDITSIDESTAKEDIALOG_H +#define BITCOIN_QT_EDITSIDESTAKEDIALOG_H + +#include + +QT_BEGIN_NAMESPACE +class QDataWidgetMapper; +QT_END_NAMESPACE + +namespace Ui { +class EditSideStakeDialog; +} +class SideStakeTableModel; + +/** Dialog for editing an address and associated information. + */ +class EditSideStakeDialog : public QDialog +{ + Q_OBJECT + +public: + enum Mode { + NewSideStake, + EditSideStake + }; + + explicit EditSideStakeDialog(Mode mode, QWidget* parent = nullptr); + ~EditSideStakeDialog(); + + void setModel(SideStakeTableModel *model); + void loadRow(int row); + + //QString getAddress() const; + //void setAddress(const QString &address); + +public slots: + void accept(); + +private: + bool saveCurrentRow(); + + Ui::EditSideStakeDialog *ui; + QDataWidgetMapper *mapper; + Mode mode; + SideStakeTableModel *model; + + QString address; +}; +#endif // BITCOIN_QT_EDITSIDESTAKEDIALOG_H diff --git a/src/qt/forms/editsidestakedialog.ui b/src/qt/forms/editsidestakedialog.ui new file mode 100644 index 0000000000..ee05e65296 --- /dev/null +++ b/src/qt/forms/editsidestakedialog.ui @@ -0,0 +1,68 @@ + + + EditSideStakeDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 30 + 240 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + buttonBox + accepted() + EditSideStakeDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + EditSideStakeDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 25a92ba0d7..93dff3beeb 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -270,6 +270,10 @@ void OptionsDialog::on_applyButton_clicked() void OptionsDialog::newSideStakeButton_clicked() { + if (!model) { + return; + } + }