Permalink
Browse files

Fix saving geometry and fancytab settings (#6217)

  • Loading branch information...
jonaski authored and hatstand committed Nov 28, 2018
1 parent 122d28e commit 289ea31f8cf43e11921e525e87323158f831796c
Showing with 19 additions and 2 deletions.
  1. +16 −1 src/ui/mainwindow.cpp
  2. +3 −1 src/ui/mainwindow.h
@@ -221,6 +221,7 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
library_sort_model_(new QSortFilterProxyModel(this)),
track_position_timer_(new QTimer(this)),
track_slider_timer_(new QTimer(this)),
initialized_(false),
saved_playback_position_(0),
saved_playback_state_(Engine::Empty),
doubleclick_addmode_(AddBehaviour_Append),
@@ -1066,6 +1067,9 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,

if (!options.contains_play_options()) LoadPlaybackStatus();

initialized_ = true;
SaveGeometry();

qLog(Debug) << "Started";
}

@@ -1278,9 +1282,19 @@ void MainWindow::ScrobbleButtonVisibilityChanged(bool value) {
}
}

void MainWindow::resizeEvent(QResizeEvent*) { SaveGeometry(); }
void MainWindow::changeEvent(QEvent*) {
if (!initialized_) return;
SaveGeometry();
}

void MainWindow::resizeEvent(QResizeEvent*) {
if (!initialized_) return;
SaveGeometry();
}

void MainWindow::SaveGeometry() {
if (!initialized_) return;

was_maximized_ = isMaximized();
settings_.setValue("maximized", was_maximized_);
// Save the geometry only when mainwindow is not in maximized state
@@ -2790,6 +2804,7 @@ bool MainWindow::winEvent(MSG* msg, long*) {
#endif // Q_OS_WIN32

void MainWindow::Exit() {
SaveGeometry();
SavePlaybackStatus();
settings_.setValue("show_sidebar",
ui_->action_toggle_show_sidebar->isChecked());
@@ -131,7 +131,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {

protected:
void keyPressEvent(QKeyEvent* event);
void resizeEvent(QResizeEvent* event);
void changeEvent(QEvent*);
void resizeEvent(QResizeEvent*);
void closeEvent(QCloseEvent* event);

#ifdef Q_OS_WIN32
@@ -378,6 +379,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
QTimer* track_slider_timer_;
QSettings settings_;

bool initialized_;
bool was_maximized_;
int saved_playback_position_;
Engine::State saved_playback_state_;

0 comments on commit 289ea31

Please sign in to comment.