Bitcoin-Qt: save and restore position of debug window
- move the code for saving and restoring window positions from BitcoinGUI to GUIUtil, make it more generic and also use it for saving/restoring debug window positions
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include <QFileDialog>
|
||||
#include <QDesktopServices>
|
||||
#include <QThread>
|
||||
#include <QSettings>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
@@ -487,6 +489,29 @@ bool SetStartOnSystemStartup(bool fAutoStart) { return false; }
|
||||
|
||||
#endif
|
||||
|
||||
void saveWindowGeometry(const QString& strSetting, QWidget *parent)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue(strSetting + "Pos", parent->pos());
|
||||
settings.setValue(strSetting + "Size", parent->size());
|
||||
}
|
||||
|
||||
void restoreWindowGeometry(const QString& strSetting, const QSize& defaultSize, QWidget *parent)
|
||||
{
|
||||
QSettings settings;
|
||||
QPoint pos = settings.value(strSetting + "Pos").toPoint();
|
||||
QSize size = settings.value(strSetting + "Size", defaultSize).toSize();
|
||||
|
||||
if (!pos.x() && !pos.y()) {
|
||||
QRect screen = QApplication::desktop()->screenGeometry();
|
||||
pos.setX((screen.width() - size.width()) / 2);
|
||||
pos.setY((screen.height() - size.height()) / 2);
|
||||
}
|
||||
|
||||
parent->resize(size);
|
||||
parent->move(pos);
|
||||
}
|
||||
|
||||
HelpMessageBox::HelpMessageBox(QWidget *parent) :
|
||||
QMessageBox(parent)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user