1 /***************************************************************************
2 * Copyright (C) 2009 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) any later version. *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "coreconnectionsettingspage.h"
23 CoreConnectionSettingsPage::CoreConnectionSettingsPage(QWidget *parent)
24 : SettingsPage(tr("Remote Cores"), tr("Connection"), parent) {
32 connect(ui.useSolid, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
33 connect(ui.usePingTimeout, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
34 connect(ui.useNoTimeout, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
37 void CoreConnectionSettingsPage::widgetHasChanged() {
38 bool hasChanged = false;
39 CoreConnectionSettings::NetworkDetectionMode mode = modeFromRadioButtons();
40 if(mode != _detectionMode)
43 setChangedState(hasChanged);
46 void CoreConnectionSettingsPage::defaults() {
48 setRadioButtons(CoreConnectionSettings::UseSolid);
50 setRadioButtons(CoreConnectionSettings::UsePingTimeout);
53 SettingsPage::defaults();
56 void CoreConnectionSettingsPage::load() {
57 CoreConnectionSettings s;
58 _detectionMode = s.networkDetectionMode();
59 setRadioButtons(_detectionMode);
63 void CoreConnectionSettingsPage::save() {
64 _detectionMode = modeFromRadioButtons();
65 CoreConnectionSettings s;
66 s.setNetworkDetectionMode(_detectionMode);
70 void CoreConnectionSettingsPage::setRadioButtons(CoreConnectionSettings::NetworkDetectionMode mode) {
73 case CoreConnectionSettings::UseSolid:
74 ui.useSolid->setChecked(true);
77 case CoreConnectionSettings::UsePingTimeout:
78 ui.usePingTimeout->setChecked(true);
81 ui.useNoTimeout->setChecked(true);
85 CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettingsPage::modeFromRadioButtons() const {
87 if(ui.useSolid->isChecked())
88 return CoreConnectionSettings::UseSolid;
90 if(ui.usePingTimeout->isChecked())
91 return CoreConnectionSettings::UsePingTimeout;
93 return CoreConnectionSettings::NoActiveDetection;