summaryrefslogtreecommitdiffstats
path: root/kget/dlgPreferences.cpp
blob: f35b8add4fed2623eb4bd7ffa43228f46620918e (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/***************************************************************************
*                               dlgPreferences.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        : [email protected]
*
****************************************************************************/

/***************************************************************************
 *
 *   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 <qlayout.h>

#include <kapplication.h>
#include <klocale.h>
#include <kaction.h>
#include <kcombobox.h>

#include "dlgConnection.h"
#include "dlgAutomation.h"
#include "dlgLimits.h"
#include "dlgAdvanced.h"
#include "dlgDirectories.h"
#include "dlgSystem.h"

#include "settings.h"

#ifdef index
#undef index
#endif

#include "kmainwidget.h"
#include "dlgPreferences.h"


DlgPreferences::DlgPreferences(QWidget * parent):
        KDialogBase(Tabbed, i18n("Configure"), Ok|Apply|Help|Cancel, Ok, parent, "DlgPreferences", true)
{
    // add pages
    QFrame *page = addPage(i18n("Connection"));
    QVBoxLayout *topLayout = new QVBoxLayout(page, 0, spacingHint());

    conDlg = new DlgConnection(page);
    topLayout->addWidget(conDlg);

    page = addPage(i18n("Automation"));
    topLayout = new QVBoxLayout(page, 0, spacingHint());
    autDlg = new DlgAutomation(page);
    topLayout->addWidget(autDlg);
    topLayout->addStretch();

    page = addPage(i18n("Limits"));
    topLayout = new QVBoxLayout(page, 0, spacingHint());
    limDlg = new DlgLimits(page);
    topLayout->addWidget(limDlg);
    topLayout->addStretch();

    page = addPage(i18n("Advanced"));
    topLayout = new QVBoxLayout(page, 0, spacingHint());
    advDlg = new DlgAdvanced(page);
    topLayout->addWidget(advDlg);
    topLayout->addStretch();

    // page = addPage(i18n("Search"));
    // topLayout = new QVBoxLayout(page, 0, spacingHint());
    //        seaDlg = new DlgSearch(page);
    // topLayout->addWidget(seaDlg);

    page = addPage(i18n("Folders"));
    topLayout = new QVBoxLayout(page, 0, spacingHint());
    dirDlg = new DlgDirectories(page);
    topLayout->addWidget(dirDlg);
    topLayout->addStretch();

    page = addPage(i18n("System"));
    topLayout = new QVBoxLayout(page, 0, spacingHint());
    sysDlg = new DlgSystem(page);
    topLayout->addWidget(sysDlg);
    topLayout->addStretch();

    // type of connection influences autoDisconnect & timedDisconnect features
    connect(conDlg, SIGNAL(typeChanged(int)), autDlg, SLOT(slotTypeChanged(int)));

    loadAllData();

    connect( conDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
    connect( autDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
    connect( limDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
    connect( advDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
    connect( dirDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
    connect( sysDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) );
}


void DlgPreferences::slotChanged()
{
    changed = true;
    enableButton( Apply, true );
}

void DlgPreferences::applySettings()
{
    conDlg->applyData();
    autDlg->applyData();
    limDlg->applyData();
    advDlg->applyData();
    //        seaDlg->applyData();
    dirDlg->applyData();
    sysDlg->applyData();

    ksettings.save();
    changed = false;
    enableButton( Apply, false );
}

void DlgPreferences::slotOk()
{
    if ( changed )
        applySettings();
    accept();
}

void DlgPreferences::slotCancel()
{
    if ( changed )
        loadAllData();
    reject();
}

void DlgPreferences::slotApply()
{
    applySettings();
}

void DlgPreferences::loadAllData()
{
    conDlg->setData();
    autDlg->setData();
    limDlg->setData();
    advDlg->setData();
    //        seaDlg->setData();
    dirDlg->setData();
    sysDlg->setData();
    changed = false;
    enableButton( Apply, false );
}

#include "dlgPreferences.moc"