diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index fc8b0ff2..54cbba75 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -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 { diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index fffabbab..30500ff8 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include @@ -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 @@ -193,6 +200,8 @@ BitcoinGUI::~BitcoinGUI() #ifdef Q_OS_MAC delete appMenuBar; #endif + QSettings settings; + settings.setValue("main-geometry", saveGeometry()); } void BitcoinGUI::createActions() diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index 98502a86..5c0a613e 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -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 diff --git a/src/qt/mintingview.cpp b/src/qt/mintingview.cpp index 07505757..a09a603d 100644 --- a/src/qt/mintingview.cpp +++ b/src/qt/mintingview.cpp @@ -17,6 +17,7 @@ #include #include #include +#include MintingView::MintingView(QWidget *parent) : QWidget(parent), model(0), mintingView(0) @@ -98,6 +99,11 @@ MintingView::MintingView(QWidget *parent) : } +MintingView::~MintingView() +{ + QSettings settings; + settings.setValue("minting-headers", mintingView->horizontalHeader()->saveState()); +} void MintingView::setModel(WalletModel *model) { @@ -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); + } } } diff --git a/src/qt/mintingview.h b/src/qt/mintingview.h index 452deaa6..1024a275 100644 --- a/src/qt/mintingview.h +++ b/src/qt/mintingview.h @@ -17,6 +17,7 @@ class MintingView : public QWidget Q_OBJECT public: explicit MintingView(QWidget *parent = 0); + ~MintingView(); void setModel(WalletModel *model); enum MintingEnum diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index cc8e8dd3..b674682b 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -11,6 +11,7 @@ #include "editaddressdialog.h" #include "optionsmodel.h" #include "guiutil.h" +#include "guiconstants.h" #include "wallet.h" #include @@ -30,6 +31,7 @@ #include #include #include +#include TransactionView::TransactionView(QWidget *parent) : QWidget(parent), model(0), transactionProxyModel(0), @@ -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; @@ -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); + } } } diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 1e49c5d5..75ce4e87 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -24,6 +24,7 @@ class TransactionView : public QWidget Q_OBJECT public: explicit TransactionView(QWidget *parent = 0); + ~TransactionView(); void setModel(WalletModel *model);