diff --git a/ChangeLog b/ChangeLog index b65062ced..d060a4f88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,7 @@ is played after beeing paused for more than 5 seconds resend now playing. 13. Rescrobble, and re-send now playing, if track is repeated. 14. Exceptions are required for all non Qt5 builds. +15. Fix crash in settings dialog when some system-tray options removed. 1.4.0 ----- diff --git a/gui/interfacesettings.cpp b/gui/interfacesettings.cpp index ac9d28aa0..9f5cf2226 100644 --- a/gui/interfacesettings.cpp +++ b/gui/interfacesettings.cpp @@ -174,9 +174,6 @@ InterfaceSettings::InterfaceSettings(QWidget *p) connect(playlistsView, SIGNAL(currentIndexChanged(int)), SLOT(playlistsViewChanged())); connect(playQueueView, SIGNAL(currentIndexChanged(int)), SLOT(playQueueViewChanged())); - connect(systemTrayCheckBox, SIGNAL(toggled(bool)), minimiseOnClose, SLOT(setEnabled(bool))); - connect(systemTrayCheckBox, SIGNAL(toggled(bool)), SLOT(enableStartupState())); - connect(minimiseOnClose, SIGNAL(toggled(bool)), SLOT(enableStartupState())); connect(forceSingleClick, SIGNAL(toggled(bool)), SLOT(forceSingleClickChanged())); connect(touchFriendly, SIGNAL(toggled(bool)), SLOT(touchFriendlyChanged())); connect(views, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(viewItemChanged(QListWidgetItem*))); @@ -216,10 +213,19 @@ InterfaceSettings::InterfaceSettings(QWidget *p) if (!enableNotifications) { REMOVE(systemTrayPopup) } - if (!enableTrayItem) { + if (enableTrayItem) { + connect(systemTrayCheckBox, SIGNAL(toggled(bool)), minimiseOnClose, SLOT(setEnabled(bool))); + connect(systemTrayCheckBox, SIGNAL(toggled(bool)), SLOT(enableStartupState())); + connect(minimiseOnClose, SIGNAL(toggled(bool)), SLOT(enableStartupState())); + } else { REMOVE(systemTrayCheckBox) + REMOVE(minimiseOnClose) + REMOVE(startupState) } + if (!enableNotifications && !enableTrayItem) { + tabWidget->removeTab(4); + } #if defined Q_OS_WIN || defined Q_OS_MAC || !defined QT_QTDBUS_FOUND if (systemTrayPopup && systemTrayCheckBox) { connect(systemTrayCheckBox, SIGNAL(toggled(bool)), SLOT(systemTrayCheckBoxToggled())); @@ -275,19 +281,23 @@ void InterfaceSettings::load() showRatingWidget->setChecked(Settings::self()->showRatingWidget()); if (systemTrayCheckBox) { systemTrayCheckBox->setChecked(Settings::self()->useSystemTray()); + if (minimiseOnClose) { + minimiseOnClose->setChecked(Settings::self()->minimiseOnClose()); + minimiseOnClose->setEnabled(systemTrayCheckBox->isChecked()); + } + if (startupState) { + switch (Settings::self()->startupState()) { + case Settings::SS_ShowMainWindow: startupStateShow->setChecked(true); break; + case Settings::SS_HideMainWindow: startupStateHide->setChecked(true); break; + case Settings::SS_Previous: startupStateRestore->setChecked(true); break; + } + + enableStartupState(); + } } if (systemTrayPopup) { systemTrayPopup->setChecked(Settings::self()->showPopups()); } - minimiseOnClose->setChecked(Settings::self()->minimiseOnClose()); - minimiseOnClose->setEnabled(systemTrayCheckBox->isChecked()); - switch (Settings::self()->startupState()) { - case Settings::SS_ShowMainWindow: startupStateShow->setChecked(true); break; - case Settings::SS_HideMainWindow: startupStateHide->setChecked(true); break; - case Settings::SS_Previous: startupStateRestore->setChecked(true); break; - } - - enableStartupState(); fetchCovers->setChecked(Settings::self()->fetchCovers()); QStringList hiddenPages=Settings::self()->hiddenPages(); @@ -355,8 +365,8 @@ void InterfaceSettings::save() Settings::self()->saveShowRatingWidget(showRatingWidget->isChecked()); Settings::self()->saveUseSystemTray(systemTrayCheckBox && systemTrayCheckBox->isChecked()); Settings::self()->saveShowPopups(systemTrayPopup && systemTrayPopup->isChecked()); - Settings::self()->saveMinimiseOnClose(minimiseOnClose->isChecked()); - if (startupStateShow->isChecked()) { + Settings::self()->saveMinimiseOnClose(minimiseOnClose && minimiseOnClose->isChecked()); + if (!startupState || startupStateShow->isChecked()) { Settings::self()->saveStartupState(Settings::SS_ShowMainWindow); } else if (startupStateHide->isChecked()) { Settings::self()->saveStartupState(Settings::SS_HideMainWindow); @@ -497,7 +507,9 @@ void InterfaceSettings::touchFriendlyChanged() void InterfaceSettings::enableStartupState() { - startupState->setEnabled(systemTrayCheckBox->isChecked() && minimiseOnClose->isChecked()); + if (systemTrayCheckBox && minimiseOnClose && startupState) { + startupState->setEnabled(systemTrayCheckBox->isChecked() && minimiseOnClose->isChecked()); + } } void InterfaceSettings::langChanged()