1 /***************************************************************************
2 * Copyright (C) 2005-2013 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "coreconnectionsettingspage.h"
23 CoreConnectionSettingsPage::CoreConnectionSettingsPage(QWidget *parent)
24 : SettingsPage(tr("Remote Cores"), tr("Connection"), parent)
33 connect(ui.useSolid, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
34 connect(ui.usePingTimeout, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
35 connect(ui.useNoTimeout, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
39 void CoreConnectionSettingsPage::widgetHasChanged()
41 bool hasChanged = false;
42 CoreConnectionSettings::NetworkDetectionMode mode = modeFromRadioButtons();
43 if (mode != _detectionMode)
46 setChangedState(hasChanged);
50 void CoreConnectionSettingsPage::defaults()
53 setRadioButtons(CoreConnectionSettings::UseSolid);
55 setRadioButtons(CoreConnectionSettings::UsePingTimeout);
58 SettingsPage::defaults();
62 void CoreConnectionSettingsPage::load()
64 CoreConnectionSettings s;
65 _detectionMode = s.networkDetectionMode();
66 setRadioButtons(_detectionMode);
71 void CoreConnectionSettingsPage::save()
73 _detectionMode = modeFromRadioButtons();
74 CoreConnectionSettings s;
75 s.setNetworkDetectionMode(_detectionMode);
80 void CoreConnectionSettingsPage::setRadioButtons(CoreConnectionSettings::NetworkDetectionMode mode)
84 case CoreConnectionSettings::UseSolid:
85 ui.useSolid->setChecked(true);
88 case CoreConnectionSettings::UsePingTimeout:
89 ui.usePingTimeout->setChecked(true);
92 ui.useNoTimeout->setChecked(true);
97 CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettingsPage::modeFromRadioButtons() const
100 if (ui.useSolid->isChecked())
101 return CoreConnectionSettings::UseSolid;
103 if (ui.usePingTimeout->isChecked())
104 return CoreConnectionSettings::UsePingTimeout;
106 return CoreConnectionSettings::NoActiveDetection;