1 /***************************************************************************
2 * Copyright (C) 2005-2020 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)
30 connect(ui.useQNetworkConfigurationManager, &QAbstractButton::toggled, this, &CoreConnectionSettingsPage::widgetHasChanged);
31 connect(ui.usePingTimeout, &QAbstractButton::toggled, this, &CoreConnectionSettingsPage::widgetHasChanged);
32 connect(ui.useNoTimeout, &QAbstractButton::toggled, this, &CoreConnectionSettingsPage::widgetHasChanged);
35 void CoreConnectionSettingsPage::widgetHasChanged()
37 bool hasChanged = false;
38 CoreConnectionSettings::NetworkDetectionMode mode = modeFromRadioButtons();
39 if (mode != _detectionMode)
42 setChangedState(hasChanged);
45 void CoreConnectionSettingsPage::defaults()
47 setRadioButtons(CoreConnectionSettings::UseQNetworkConfigurationManager);
49 SettingsPage::defaults();
52 void CoreConnectionSettingsPage::load()
54 CoreConnectionSettings s;
55 _detectionMode = s.networkDetectionMode();
56 setRadioButtons(_detectionMode);
60 void CoreConnectionSettingsPage::save()
62 _detectionMode = modeFromRadioButtons();
63 CoreConnectionSettings s;
64 s.setNetworkDetectionMode(_detectionMode);
68 void CoreConnectionSettingsPage::setRadioButtons(CoreConnectionSettings::NetworkDetectionMode mode)
71 case CoreConnectionSettings::UseQNetworkConfigurationManager:
72 ui.useQNetworkConfigurationManager->setChecked(true);
74 case CoreConnectionSettings::UsePingTimeout:
75 ui.usePingTimeout->setChecked(true);
78 ui.useNoTimeout->setChecked(true);
82 CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettingsPage::modeFromRadioButtons() const
84 if (ui.useQNetworkConfigurationManager->isChecked())
85 return CoreConnectionSettings::UseQNetworkConfigurationManager;
86 if (ui.usePingTimeout->isChecked())
87 return CoreConnectionSettings::UsePingTimeout;
89 return CoreConnectionSettings::NoActiveDetection;