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);
|
||||
Ui_addressBook ab;
|
||||
ab.setupUi(&d);
|
||||
Settings::saveRestore(&d);
|
||||
|
||||
AddressBookModel model(ab.addresses);
|
||||
ab.addresses->setModel(&model);
|
||||
|
||||
@@ -104,6 +104,7 @@ void MainWindow::turnstileProgress() {
|
||||
Ui_TurnstileProgress progress;
|
||||
QDialog d(this);
|
||||
progress.setupUi(&d);
|
||||
Settings::saveRestore(&d);
|
||||
|
||||
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
|
||||
progress.msgIcon->setPixmap(icon.pixmap(64, 64));
|
||||
@@ -184,6 +185,7 @@ void MainWindow::turnstileDoMigration(QString fromAddr) {
|
||||
Ui_Turnstile turnstile;
|
||||
QDialog d(this);
|
||||
turnstile.setupUi(&d);
|
||||
Settings::saveRestore(&d);
|
||||
|
||||
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation);
|
||||
turnstile.msgIcon->setPixmap(icon.pixmap(64, 64));
|
||||
@@ -235,8 +237,7 @@ void MainWindow::turnstileDoMigration(QString fromAddr) {
|
||||
if (!fromAddr.isEmpty())
|
||||
turnstile.migrateZaddList->setCurrentText(fromAddr);
|
||||
|
||||
fnUpdateSproutBalance(turnstile.migrateZaddList->currentText());
|
||||
|
||||
fnUpdateSproutBalance(turnstile.migrateZaddList->currentText());
|
||||
|
||||
// Combo box selection event
|
||||
QObject::connect(turnstile.migrateZaddList, &QComboBox::currentTextChanged, fnUpdateSproutBalance);
|
||||
@@ -344,6 +345,7 @@ void MainWindow::setupSettingsModal() {
|
||||
QDialog settingsDialog(this);
|
||||
Ui_Settings settings;
|
||||
settings.setupUi(&settingsDialog);
|
||||
Settings::saveRestore(&settingsDialog);
|
||||
|
||||
// Setup save sent check box
|
||||
QObject::connect(settings.chkSaveTxs, &QCheckBox::stateChanged, [=](auto checked) {
|
||||
@@ -407,7 +409,7 @@ void MainWindow::setupSettingsModal() {
|
||||
auto cl = new ConnectionLoader(this, rpc);
|
||||
cl->loadConnection();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -444,6 +446,7 @@ void MainWindow::postToZBoard() {
|
||||
QDialog d(this);
|
||||
Ui_zboard zb;
|
||||
zb.setupUi(&d);
|
||||
Settings::saveRestore(&d);
|
||||
|
||||
if (rpc->getConnection() == nullptr)
|
||||
return;
|
||||
@@ -556,6 +559,7 @@ void MainWindow::importPrivKey() {
|
||||
QDialog d(this);
|
||||
Ui_PrivKey pui;
|
||||
pui.setupUi(&d);
|
||||
Settings::saveRestore(&d);
|
||||
|
||||
pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(false);
|
||||
pui.helpLbl->setText(QString() %
|
||||
@@ -588,11 +592,14 @@ void MainWindow::exportAllKeys() {
|
||||
QDialog d(this);
|
||||
Ui_PrivKey pui;
|
||||
pui.setupUi(&d);
|
||||
|
||||
|
||||
// Make the window big by default
|
||||
auto ps = this->geometry();
|
||||
QMargins margin = QMargins() + 50;
|
||||
d.setGeometry(ps.marginsRemoved(margin));
|
||||
|
||||
Settings::saveRestore(&d);
|
||||
|
||||
pui.privKeyTxt->setPlainText("Loading...");
|
||||
pui.privKeyTxt->setReadOnly(true);
|
||||
pui.privKeyTxt->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap);
|
||||
|
||||
@@ -122,4 +122,13 @@ QString Settings::getZECUSDDisplayFormat(double bal) {
|
||||
return getZECDisplayFormat(bal) % " (" % getUSDFormat(bal) % ")";
|
||||
else
|
||||
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* getInstance();
|
||||
|
||||
static void saveRestore(QDialog* d);
|
||||
|
||||
Config getSettings();
|
||||
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; }
|
||||
double getZECPrice();
|
||||
|
||||
|
||||
|
||||
QString getUSDFormat (double bal);
|
||||
QString getZECDisplayFormat (double bal);
|
||||
QString getZECUSDDisplayFormat(double bal);
|
||||
|
||||
Reference in New Issue
Block a user