1 /***************************************************************************
2 * Copyright (C) 2005-2015 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.useQNetworkConfigurationManager, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
35 connect(ui.usePingTimeout, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
36 connect(ui.useNoTimeout, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
40 void CoreConnectionSettingsPage::widgetHasChanged()
42 bool hasChanged = false;
43 CoreConnectionSettings::NetworkDetectionMode mode = modeFromRadioButtons();
44 if (mode != _detectionMode)
47 setChangedState(hasChanged);
51 void CoreConnectionSettingsPage::defaults()
54 setRadioButtons(CoreConnectionSettings::UseSolid);
56 setRadioButtons(CoreConnectionSettings::UseQNetworkConfigurationManager);
59 SettingsPage::defaults();
63 void CoreConnectionSettingsPage::load()
65 CoreConnectionSettings s;
66 _detectionMode = s.networkDetectionMode();
67 setRadioButtons(_detectionMode);
72 void CoreConnectionSettingsPage::save()
74 _detectionMode = modeFromRadioButtons();
75 CoreConnectionSettings s;
76 s.setNetworkDetectionMode(_detectionMode);
81 void CoreConnectionSettingsPage::setRadioButtons(CoreConnectionSettings::NetworkDetectionMode mode)
85 case CoreConnectionSettings::UseSolid:
86 ui.useSolid->setChecked(true);
89 case CoreConnectionSettings::UseQNetworkConfigurationManager:
90 ui.useQNetworkConfigurationManager->setChecked(true);
92 case CoreConnectionSettings::UsePingTimeout:
93 ui.usePingTimeout->setChecked(true);
96 ui.useNoTimeout->setChecked(true);
101 CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettingsPage::modeFromRadioButtons() const
104 if (ui.useSolid->isChecked())
105 return CoreConnectionSettings::UseSolid;
107 if (ui.useQNetworkConfigurationManager->isChecked())
108 return CoreConnectionSettings::UseQNetworkConfigurationManager;
109 if (ui.usePingTimeout->isChecked())
110 return CoreConnectionSettings::UsePingTimeout;
112 return CoreConnectionSettings::NoActiveDetection;