Save/Restore window positions
- #29 - Settings window - #28 - zboard - #27 - turnstile - turnstile progress - import keys - export keys
This commit is contained in:
@@ -117,6 +117,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) {
|
|||||||
QDialog d(parent);
|
QDialog d(parent);
|
||||||
Ui_addressBook ab;
|
Ui_addressBook ab;
|
||||||
ab.setupUi(&d);
|
ab.setupUi(&d);
|
||||||
|
Settings::saveRestore(&d);
|
||||||
|
|
||||||
AddressBookModel model(ab.addresses);
|
AddressBookModel model(ab.addresses);
|
||||||
ab.addresses->setModel(&model);
|
ab.addresses->setModel(&model);
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ void MainWindow::turnstileProgress() {
|
|||||||
Ui_TurnstileProgress progress;
|
Ui_TurnstileProgress progress;
|
||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
progress.setupUi(&d);
|
progress.setupUi(&d);
|
||||||
|
Settings::saveRestore(&d);
|
||||||
|
|
||||||
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
|
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
|
||||||
progress.msgIcon->setPixmap(icon.pixmap(64, 64));
|
progress.msgIcon->setPixmap(icon.pixmap(64, 64));
|
||||||
@@ -184,6 +185,7 @@ void MainWindow::turnstileDoMigration(QString fromAddr) {
|
|||||||
Ui_Turnstile turnstile;
|
Ui_Turnstile turnstile;
|
||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
turnstile.setupUi(&d);
|
turnstile.setupUi(&d);
|
||||||
|
Settings::saveRestore(&d);
|
||||||
|
|
||||||
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation);
|
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation);
|
||||||
turnstile.msgIcon->setPixmap(icon.pixmap(64, 64));
|
turnstile.msgIcon->setPixmap(icon.pixmap(64, 64));
|
||||||
@@ -235,8 +237,7 @@ void MainWindow::turnstileDoMigration(QString fromAddr) {
|
|||||||
if (!fromAddr.isEmpty())
|
if (!fromAddr.isEmpty())
|
||||||
turnstile.migrateZaddList->setCurrentText(fromAddr);
|
turnstile.migrateZaddList->setCurrentText(fromAddr);
|
||||||
|
|
||||||
fnUpdateSproutBalance(turnstile.migrateZaddList->currentText());
|
fnUpdateSproutBalance(turnstile.migrateZaddList->currentText());
|
||||||
|
|
||||||
|
|
||||||
// Combo box selection event
|
// Combo box selection event
|
||||||
QObject::connect(turnstile.migrateZaddList, &QComboBox::currentTextChanged, fnUpdateSproutBalance);
|
QObject::connect(turnstile.migrateZaddList, &QComboBox::currentTextChanged, fnUpdateSproutBalance);
|
||||||
@@ -344,6 +345,7 @@ void MainWindow::setupSettingsModal() {
|
|||||||
QDialog settingsDialog(this);
|
QDialog settingsDialog(this);
|
||||||
Ui_Settings settings;
|
Ui_Settings settings;
|
||||||
settings.setupUi(&settingsDialog);
|
settings.setupUi(&settingsDialog);
|
||||||
|
Settings::saveRestore(&settingsDialog);
|
||||||
|
|
||||||
// Setup save sent check box
|
// Setup save sent check box
|
||||||
QObject::connect(settings.chkSaveTxs, &QCheckBox::stateChanged, [=](auto checked) {
|
QObject::connect(settings.chkSaveTxs, &QCheckBox::stateChanged, [=](auto checked) {
|
||||||
@@ -407,7 +409,7 @@ void MainWindow::setupSettingsModal() {
|
|||||||
auto cl = new ConnectionLoader(this, rpc);
|
auto cl = new ConnectionLoader(this, rpc);
|
||||||
cl->loadConnection();
|
cl->loadConnection();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,6 +446,7 @@ void MainWindow::postToZBoard() {
|
|||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
Ui_zboard zb;
|
Ui_zboard zb;
|
||||||
zb.setupUi(&d);
|
zb.setupUi(&d);
|
||||||
|
Settings::saveRestore(&d);
|
||||||
|
|
||||||
if (rpc->getConnection() == nullptr)
|
if (rpc->getConnection() == nullptr)
|
||||||
return;
|
return;
|
||||||
@@ -556,6 +559,7 @@ void MainWindow::importPrivKey() {
|
|||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
Ui_PrivKey pui;
|
Ui_PrivKey pui;
|
||||||
pui.setupUi(&d);
|
pui.setupUi(&d);
|
||||||
|
Settings::saveRestore(&d);
|
||||||
|
|
||||||
pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(false);
|
pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(false);
|
||||||
pui.helpLbl->setText(QString() %
|
pui.helpLbl->setText(QString() %
|
||||||
@@ -588,11 +592,14 @@ void MainWindow::exportAllKeys() {
|
|||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
Ui_PrivKey pui;
|
Ui_PrivKey pui;
|
||||||
pui.setupUi(&d);
|
pui.setupUi(&d);
|
||||||
|
|
||||||
|
// Make the window big by default
|
||||||
auto ps = this->geometry();
|
auto ps = this->geometry();
|
||||||
QMargins margin = QMargins() + 50;
|
QMargins margin = QMargins() + 50;
|
||||||
d.setGeometry(ps.marginsRemoved(margin));
|
d.setGeometry(ps.marginsRemoved(margin));
|
||||||
|
|
||||||
|
Settings::saveRestore(&d);
|
||||||
|
|
||||||
pui.privKeyTxt->setPlainText("Loading...");
|
pui.privKeyTxt->setPlainText("Loading...");
|
||||||
pui.privKeyTxt->setReadOnly(true);
|
pui.privKeyTxt->setReadOnly(true);
|
||||||
pui.privKeyTxt->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap);
|
pui.privKeyTxt->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap);
|
||||||
|
|||||||
@@ -122,4 +122,13 @@ QString Settings::getZECUSDDisplayFormat(double bal) {
|
|||||||
return getZECDisplayFormat(bal) % " (" % getUSDFormat(bal) % ")";
|
return getZECDisplayFormat(bal) % " (" % getUSDFormat(bal) % ")";
|
||||||
else
|
else
|
||||||
return getZECDisplayFormat(bal);
|
return getZECDisplayFormat(bal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Settings::saveRestore(QDialog* d) {
|
||||||
|
d->restoreGeometry(QSettings().value(d->objectName() % "geometry").toByteArray());
|
||||||
|
|
||||||
|
QObject::connect(d, &QDialog::finished, [=](auto) {
|
||||||
|
QSettings().setValue(d->objectName() % "geometry", d->saveGeometry());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,8 @@ public:
|
|||||||
static Settings* init();
|
static Settings* init();
|
||||||
static Settings* getInstance();
|
static Settings* getInstance();
|
||||||
|
|
||||||
|
static void saveRestore(QDialog* d);
|
||||||
|
|
||||||
Config getSettings();
|
Config getSettings();
|
||||||
void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password);
|
void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password);
|
||||||
|
|
||||||
@@ -42,8 +44,7 @@ public:
|
|||||||
|
|
||||||
void setZECPrice(double p) { zecPrice = p; }
|
void setZECPrice(double p) { zecPrice = p; }
|
||||||
double getZECPrice();
|
double getZECPrice();
|
||||||
|
|
||||||
|
|
||||||
QString getUSDFormat (double bal);
|
QString getUSDFormat (double bal);
|
||||||
QString getZECDisplayFormat (double bal);
|
QString getZECDisplayFormat (double bal);
|
||||||
QString getZECUSDDisplayFormat(double bal);
|
QString getZECUSDDisplayFormat(double bal);
|
||||||
|
|||||||
Reference in New Issue
Block a user