summaryrefslogtreecommitdiffstats
path: root/kget/dlgConnection.cpp
blob: 5530953b0b4b86609322132f50882c0760ced658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***************************************************************************
*                               dlgConnection.cpp
*                             -------------------
*
*    Revision     : $Id$
*    begin        : Tue Jan 29 2002
*    copyright    : (C) 2002 by Patrick Charbonnier
*                 : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss
*    email        : pch@freeshell.org
*
****************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 ***************************************************************************/


#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <tqlayout.h>

#include <klocale.h>
#include <kprotocolmanager.h>
#include <kdialog.h>
#include <knuminput.h>
#include <kcombobox.h>


#include "kmainwidget.h"
#include "settings.h"
#include "dlgConnection.h"


DlgConnection::DlgConnection(TQWidget * parent)
        :DlgConnectionBase(parent, "", 0)
{
    // TODO: these are not supported yet, so hide them
    gb_timeout->hide();
    le_nodata->hide();
    le_noresume->hide();
}


void DlgConnection::comboActivated(int Index)
{
    if (Index == 0) {
        lb_linknum->setEnabled(false);
        le_linknum->setEnabled(false);
        cb_offlinemode->setEnabled(true);
    } else {
        lb_linknum->setEnabled(true);
        le_linknum->setEnabled(true);
        cb_offlinemode->setEnabled(false);
        cb_offlinemode->setChecked(false);
    }

    emit typeChanged(Index);
}


void DlgConnection::setData()
{
    lb_after->setEnabled(ksettings.b_reconnectOnError);
    le_after->setEnabled(ksettings.b_reconnectOnError);
//    lb_retries->setEnabled(ksettings.b_reconnectOnError);
//    le_retries->setEnabled(ksettings.b_reconnectOnError);
    cb_onerror->setChecked(ksettings.b_reconnectOnError);

    le_after->setValue(ksettings.reconnectTime);
    le_retries->setValue(ksettings.reconnectRetries);

    cb_onbroken->setChecked(ksettings.b_reconnectOnBroken);

//    cb_autoresume->setChecked(KProtocolManager::autoResume());

    le_nodata->setValue(ksettings.timeoutData);
    le_noresume->setValue(ksettings.timeoutDataNoResume);

    cmb_type->setCurrentItem(ksettings.connectionType);

    if (cmb_type->currentItem() == 0) {
        le_linknum->setValue(0);
        lb_linknum->setEnabled(false);
        le_linknum->setEnabled(false);
    } else {
        le_linknum->setValue(ksettings.linkNumber);
        lb_linknum->setEnabled(true);
        le_linknum->setEnabled(true);
    }

    cb_offlinemode->setChecked(ksettings.b_offlineMode);
    if (ksettings.connectionType == 0)
        cb_offlinemode->setChecked(ksettings.b_offlineMode);
    else {
        cb_offlinemode->setEnabled(false);
        cb_offlinemode->setChecked(false);
    }
}


void DlgConnection::applyData()
{
    ksettings.b_reconnectOnError = cb_onerror->isChecked();
    ksettings.reconnectTime = le_after->value();
    ksettings.reconnectRetries = le_retries->value();
    ksettings.b_reconnectOnBroken = cb_onbroken->isChecked();

    // KProtocolManager::setAutoResume(cb_autoresume->isChecked());

    ksettings.timeoutData = le_nodata->value();
    ksettings.timeoutDataNoResume = le_noresume->value();

    ksettings.connectionType = cmb_type->currentItem();
    ksettings.linkNumber = le_linknum->value();

    if (cb_offlinemode->isChecked() != ksettings.b_offlineMode) {
        kmain->slotToggleOfflineMode();
    }
}

void DlgConnection::slotChanged()
{
    emit configChanged();
}

#include "dlgConnection.moc"