Added ability to save/restore scripting window size and location
This commit is contained in:
@@ -12,6 +12,8 @@ ScriptingWindow::ScriptingWindow(const QVector<CANFrame> *frames, QWidget *paren
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
readSettings();
|
||||||
|
|
||||||
modelFrames = frames;
|
modelFrames = frames;
|
||||||
|
|
||||||
connect(ui->btnLoadScript, &QAbstractButton::pressed, this, &ScriptingWindow::loadNewScript);
|
connect(ui->btnLoadScript, &QAbstractButton::pressed, this, &ScriptingWindow::loadNewScript);
|
||||||
@@ -48,6 +50,38 @@ void ScriptingWindow::updatedFrames(int numFrames)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptingWindow::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptingWindow::readSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
if (settings.value("Main/SaveRestorePositions", false).toBool())
|
||||||
|
{
|
||||||
|
resize(settings.value("ScriptingWindow/WindowSize", QSize(860, 650)).toSize());
|
||||||
|
move(settings.value("ScriptingWindow/WindowPos", QPoint(100, 100)).toPoint());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptingWindow::writeSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
if (settings.value("Main/SaveRestorePositions", false).toBool())
|
||||||
|
{
|
||||||
|
settings.setValue("ScriptingWindow/WindowSize", size());
|
||||||
|
settings.setValue("ScriptingWindow/WindowPos", pos());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptingWindow::showEvent(QShowEvent* event)
|
||||||
|
{
|
||||||
|
QDialog::showEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptingWindow::loadNewScript()
|
void ScriptingWindow::loadNewScript()
|
||||||
{
|
{
|
||||||
QString filename;
|
QString filename;
|
||||||
|
|||||||
+5
-1
@@ -17,6 +17,7 @@ class ScriptingWindow : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScriptingWindow(const QVector<CANFrame> *frames, QWidget *parent = 0);
|
explicit ScriptingWindow(const QVector<CANFrame> *frames, QWidget *parent = 0);
|
||||||
|
void showEvent(QShowEvent*);
|
||||||
~ScriptingWindow();
|
~ScriptingWindow();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -35,8 +36,11 @@ signals:
|
|||||||
void sendCANFrame(const CANFrame *, int);
|
void sendCANFrame(const CANFrame *, int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ScriptingWindow *ui;
|
void closeEvent(QCloseEvent *event);
|
||||||
|
void readSettings();
|
||||||
|
void writeSettings();
|
||||||
|
|
||||||
|
Ui::ScriptingWindow *ui;
|
||||||
QList<ScriptContainer *> scripts;
|
QList<ScriptContainer *> scripts;
|
||||||
ScriptContainer *currentScript;
|
ScriptContainer *currentScript;
|
||||||
const QVector<CANFrame> *modelFrames;
|
const QVector<CANFrame> *modelFrames;
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>994</width>
|
<width>862</width>
|
||||||
<height>858</height>
|
<height>651</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|||||||
Reference in New Issue
Block a user