Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save main-geometry and some header data before closing the GUI #458

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QLocale>
#include <QTranslator>
#include <QLibraryInfo>
#include <QSettings>

#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/algorithm/string/predicate.hpp>
Expand Down Expand Up @@ -309,6 +310,11 @@ int main(int argc, char *argv[])
}
// Shutdown the core and it's threads, but don't exit Bitcoin-Qt here
Shutdown(NULL);

// Do this last to make sure all settings are written
QSettings settings;
if (settings.value("settings-version").toInt() != SETTINGS_VERSION)
settings.setValue("settings-version", SETTINGS_VERSION);
}
else
{
Expand Down
9 changes: 9 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <QDragEnterEvent>
#include <QUrl>
#include <QStyle>
#include <QSettings>

#include <iostream>

Expand All @@ -74,7 +75,13 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
spinnerFrame(0)
{
resize(850, 550);
// Restore previous geometry (if any)
QSettings settings;
if (settings.contains("main-geometry"))
restoreGeometry(settings.value("main-geometry").toByteArray());

setWindowTitle(tr("Paycoin") + " - " + tr("Wallet"));

#ifndef Q_OS_MAC
setWindowIcon(QIcon(":icons/paycoin_icon"));
#else
Expand Down Expand Up @@ -193,6 +200,8 @@ BitcoinGUI::~BitcoinGUI()
#ifdef Q_OS_MAC
delete appMenuBar;
#endif
QSettings settings;
settings.setValue("main-geometry", saveGeometry());
}

void BitcoinGUI::createActions()
Expand Down
2 changes: 2 additions & 0 deletions src/qt/guiconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80;
/* Number of frames in spinner animation */
#define SPINNER_FRAMES 35

static const int SETTINGS_VERSION = 1;

#endif // GUICONSTANTS_H
23 changes: 17 additions & 6 deletions src/qt/mintingview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <QLineEdit>
#include <QComboBox>
#include <QMessageBox>
#include <QSettings>

MintingView::MintingView(QWidget *parent) :
QWidget(parent), model(0), mintingView(0)
Expand Down Expand Up @@ -98,6 +99,11 @@ MintingView::MintingView(QWidget *parent) :

}

MintingView::~MintingView()
{
QSettings settings;
settings.setValue("minting-headers", mintingView->horizontalHeader()->saveState());
}

void MintingView::setModel(WalletModel *model)
{
Expand All @@ -117,18 +123,23 @@ void MintingView::setModel(WalletModel *model)
mintingView->sortByColumn(MintingTableModel::CoinDay, Qt::DescendingOrder);
mintingView->verticalHeader()->hide();

mintingView->horizontalHeader()->resizeSection(
QSettings settings;
if (settings.value("settings-version").toInt() == SETTINGS_VERSION) {
mintingView->horizontalHeader()->restoreState(settings.value("minting-headers").toByteArray());
} else {
mintingView->horizontalHeader()->resizeSection(
MintingTableModel::Address, 420);
mintingView->horizontalHeader()->setResizeMode(
mintingView->horizontalHeader()->setResizeMode(
MintingTableModel::TxHash, QHeaderView::Stretch);
mintingView->horizontalHeader()->resizeSection(
mintingView->horizontalHeader()->resizeSection(
MintingTableModel::Age, 120);
mintingView->horizontalHeader()->resizeSection(
mintingView->horizontalHeader()->resizeSection(
MintingTableModel::Balance, 120);
mintingView->horizontalHeader()->resizeSection(
mintingView->horizontalHeader()->resizeSection(
MintingTableModel::CoinDay,120);
mintingView->horizontalHeader()->resizeSection(
mintingView->horizontalHeader()->resizeSection(
MintingTableModel::MintProbability, 160);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/qt/mintingview.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MintingView : public QWidget
Q_OBJECT
public:
explicit MintingView(QWidget *parent = 0);
~MintingView();
void setModel(WalletModel *model);

enum MintingEnum
Expand Down
23 changes: 18 additions & 5 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "editaddressdialog.h"
#include "optionsmodel.h"
#include "guiutil.h"
#include "guiconstants.h"
#include "wallet.h"

#include <QScrollBar>
Expand All @@ -30,6 +31,7 @@
#include <QDateTimeEdit>
#include <QDesktopServices>
#include <QUrl>
#include <QSettings>

TransactionView::TransactionView(QWidget *parent) :
QWidget(parent), model(0), transactionProxyModel(0),
Expand Down Expand Up @@ -165,6 +167,12 @@ TransactionView::TransactionView(QWidget *parent) :
connect(clearOrphansAction, SIGNAL(triggered()), this, SLOT(clearOrphans()));
}

TransactionView::~TransactionView()
{
QSettings settings;
settings.setValue("transaction-headers", transactionView->horizontalHeader()->saveState());
}

void TransactionView::setModel(WalletModel *model)
{
this->model = model;
Expand All @@ -186,16 +194,21 @@ void TransactionView::setModel(WalletModel *model)
transactionView->sortByColumn(TransactionTableModel::Date, Qt::DescendingOrder);
transactionView->verticalHeader()->hide();

transactionView->horizontalHeader()->resizeSection(
QSettings settings;
if (settings.value("settings-version").toInt() == SETTINGS_VERSION) {
transactionView->horizontalHeader()->restoreState(settings.value("transaction-headers").toByteArray());
} else {
transactionView->horizontalHeader()->resizeSection(
TransactionTableModel::Status, 23);
transactionView->horizontalHeader()->resizeSection(
transactionView->horizontalHeader()->resizeSection(
TransactionTableModel::Date, 120);
transactionView->horizontalHeader()->resizeSection(
transactionView->horizontalHeader()->resizeSection(
TransactionTableModel::Type, 120);
transactionView->horizontalHeader()->setResizeMode(
transactionView->horizontalHeader()->setResizeMode(
TransactionTableModel::ToAddress, QHeaderView::Stretch);
transactionView->horizontalHeader()->resizeSection(
transactionView->horizontalHeader()->resizeSection(
TransactionTableModel::Amount, 100);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TransactionView : public QWidget
Q_OBJECT
public:
explicit TransactionView(QWidget *parent = 0);
~TransactionView();

void setModel(WalletModel *model);

Expand Down