Fix crash in settings dialog when some system-tray options removed.

BUG: 518
This commit is contained in:
craig.p.drummond
2014-08-10 09:23:54 +00:00
parent 5bbb67099b
commit 4a585f64b3
2 changed files with 29 additions and 16 deletions

View File

@@ -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
-----

View File

@@ -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()