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);
|
||||
|
||||
readSettings();
|
||||
|
||||
modelFrames = frames;
|
||||
|
||||
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()
|
||||
{
|
||||
QString filename;
|
||||
|
||||
+5
-1
@@ -17,6 +17,7 @@ class ScriptingWindow : public QDialog
|
||||
|
||||
public:
|
||||
explicit ScriptingWindow(const QVector<CANFrame> *frames, QWidget *parent = 0);
|
||||
void showEvent(QShowEvent*);
|
||||
~ScriptingWindow();
|
||||
|
||||
private slots:
|
||||
@@ -35,8 +36,11 @@ signals:
|
||||
void sendCANFrame(const CANFrame *, int);
|
||||
|
||||
private:
|
||||
Ui::ScriptingWindow *ui;
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
Ui::ScriptingWindow *ui;
|
||||
QList<ScriptContainer *> scripts;
|
||||
ScriptContainer *currentScript;
|
||||
const QVector<CANFrame> *modelFrames;
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>994</width>
|
||||
<height>858</height>
|
||||
<width>862</width>
|
||||
<height>651</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
||||
Reference in New Issue
Block a user