mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-20 20:23:03 +02:00
Save / load preferred editor size
This commit is contained in:
parent
aa1cf5e16c
commit
c058d5dd96
@ -51,17 +51,45 @@ QPixmap pixmapFromJson(const QJsonValue &val)
|
||||
|
||||
void init()
|
||||
{
|
||||
|
||||
loadDLLClasses();
|
||||
const_cast<CGameInfo*>(CGI)->setFromLib();
|
||||
logGlobal->info("Initializing VCMI_Lib");
|
||||
}
|
||||
|
||||
void MainWindow::loadUserSettings()
|
||||
{
|
||||
//load window settings
|
||||
QSettings s(Ui::teamName, Ui::appName);
|
||||
|
||||
auto size = s.value(mainWindowSizeSetting).toSize();
|
||||
if (size.isValid())
|
||||
{
|
||||
resize(size);
|
||||
}
|
||||
auto position = s.value(mainWindowPositionSetting).toPoint();
|
||||
if (!position.isNull())
|
||||
{
|
||||
move(position);
|
||||
}
|
||||
|
||||
//TODO: New map / random template settings
|
||||
}
|
||||
|
||||
void MainWindow::saveUserSettings()
|
||||
{
|
||||
QSettings s(Ui::teamName, Ui::appName);
|
||||
s.setValue(mainWindowSizeSetting, size());
|
||||
s.setValue(mainWindowPositionSetting, pos());
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
controller(this)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
loadUserSettings(); //For example window size
|
||||
setTitle();
|
||||
|
||||
// Set current working dir to executable folder.
|
||||
@ -141,6 +169,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
saveUserSettings(); //save window size etc.
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,20 @@ class CMap;
|
||||
class ObjectBrowser;
|
||||
class CGObjectInstance;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
const QString teamName = "VCMI Team";
|
||||
const QString appName = "VCMI Map Editor";
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
const QString mainWindowSizeSetting = "MainWindow/Size";
|
||||
const QString mainWindowPositionSetting = "MainWindow/Position";
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
@ -108,6 +114,9 @@ private:
|
||||
void changeBrushState(int idx);
|
||||
void setTitle();
|
||||
|
||||
void loadUserSettings();
|
||||
void saveUserSettings();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
ObjectBrowser * objectBrowser = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user