diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index c49227ab0..7adaa5e38 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -688,10 +688,10 @@ MainWindow::MainWindow( NowPlayingWidgetPositionChanged(ui_->now_playing->show_above_status_bar()); // Load theme + appearance_ = new Appearance(this); + appearance_->LoadUserTheme(); StyleSheetLoader* css_loader = new StyleSheetLoader(this); css_loader->SetStyleSheet(this, ":mainwindow.css"); - appearance_ = new Appearance(this); - appearance_->Load(); // Load playlists playlists_->Init(library_->backend(), playlist_backend_, @@ -1944,6 +1944,7 @@ void MainWindow::EnsureSettingsDialogCreated() { settings_dialog_->SetGlobalShortcutManager(global_shortcuts_); settings_dialog_->SetGlobalSearch(global_search_); settings_dialog_->SetSongInfoView(song_info_view_); + settings_dialog_->SetAppearance(appearance_); // Settings connect(settings_dialog_.get(), SIGNAL(accepted()), SLOT(ReloadAllSettings())); diff --git a/src/ui/settingsdialog.cpp b/src/ui/settingsdialog.cpp index ebb33dd26..0e01a16a5 100644 --- a/src/ui/settingsdialog.cpp +++ b/src/ui/settingsdialog.cpp @@ -227,6 +227,15 @@ void SettingsDialog::accept() { QDialog::accept(); } +void SettingsDialog::reject() { + // Notify each page that user clicks on Cancel + foreach (const PageData& data, pages_.values()) { + data.page_->Cancel(); + } + + QDialog::reject(); +} + void SettingsDialog::showEvent(QShowEvent* e) { // Load settings loading_settings_ = true; diff --git a/src/ui/settingsdialog.h b/src/ui/settingsdialog.h index a932e9d05..237c5cbb9 100644 --- a/src/ui/settingsdialog.h +++ b/src/ui/settingsdialog.h @@ -27,6 +27,7 @@ class QScrollArea; class QTreeWidgetItem; +class Appearance; class BackgroundStreams; class GlobalSearch; class GlobalShortcuts; @@ -85,6 +86,7 @@ public: void SetGstEngine(const GstEngine* engine) { gst_engine_ = engine; } void SetSongInfoView(SongInfoView* view) { song_info_view_ = view; } void SetGlobalSearch(GlobalSearch* global_search) { global_search_ = global_search; } + void SetAppearance(Appearance* appearance) { appearance_ = appearance; } bool is_loading_settings() const { return loading_settings_; } @@ -94,11 +96,13 @@ public: SongInfoView* song_info_view() const { return song_info_view_; } BackgroundStreams* background_streams() const { return streams_; } GlobalSearch* global_search() const { return global_search_; } + Appearance* appearance() const { return appearance_; } void OpenAtPage(Page page); // QDialog void accept(); + void reject(); // QWidget void showEvent(QShowEvent* e); @@ -127,6 +131,7 @@ private: SongInfoView* song_info_view_; BackgroundStreams* streams_; GlobalSearch* global_search_; + Appearance* appearance_; Ui_SettingsDialog* ui_; bool loading_settings_; diff --git a/src/ui/settingspage.h b/src/ui/settingspage.h index b2de2a791..c9499ff02 100644 --- a/src/ui/settingspage.h +++ b/src/ui/settingspage.h @@ -33,9 +33,11 @@ public: // Return false to grey out the page's item in the list. virtual bool IsEnabled() const { return true; } - // Load is called when the dialog is shown, Save when the user clicks OK. + // Load is called when the dialog is shown, Save when the user clicks OK, and + // Cancel when the user clicks on Cancel virtual void Load() = 0; virtual void Save() = 0; + virtual void Cancel() {} // The dialog that this page belongs to. SettingsDialog* dialog() const { return dialog_; }