Skip to content

Commit 8aa2965

Browse files
authored
Fix #355: do not loose state after minimizing main window (#363)
1 parent ef57bbd commit 8aa2965

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/mainwindow.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ MainWindow::MainWindow(QWidget *parent)
129129
m_shortcutEditor(new ShortcutEditor(this)), m_selectSubtitle(true),
130130
m_rowChanged(false), m_reloadEnabled(false),
131131
m_filewatcher(new QFileSystemWatcher),
132-
m_scriptProperties(new QLabel(this)), m_countDown(new QLabel(this)) {
132+
m_scriptProperties(new QLabel(this)), m_countDown(new QLabel(this)),
133+
m_windowShown(false) {
133134
ui->setupUi(this);
134135
m_defaultPalette = qApp->palette();
135136

@@ -342,6 +343,12 @@ void MainWindow::closeEvent(QCloseEvent *) {
342343
}
343344

344345
void MainWindow::showEvent(QShowEvent *) {
346+
if (m_windowShown) {
347+
// No need to restore settings on each show event.
348+
// (eg. when restoring window after minized state)
349+
return;
350+
}
351+
345352
// Restore settings
346353
QSettings settings;
347354

@@ -422,6 +429,8 @@ void MainWindow::showEvent(QShowEvent *) {
422429
}
423430
ui->actionAddDelay->setText("+" + text);
424431
ui->actionSubDelay->setText("-" + text);
432+
433+
m_windowShown = true;
425434
}
426435

427436
ConfigEditor *MainWindow::configEditor() { return m_preferences; }

src/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public slots:
156156
int m_subtitleInterval;
157157
int m_subtitleMinDuration;
158158
int m_delayMilliseconds;
159+
bool m_windowShown;
159160
};
160161

161162
#endif // MAINWINDOW_H

0 commit comments

Comments
 (0)