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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
/* ============================================================
*
* This file is a part of the rekonq project
*
* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved
* Copyright (C) 2008 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* 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, 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.
*
* ============================================================ */
// Self Includes
#include "settings.h"
#include "settings.moc"
// Auto Includes
#include "rekonq.h"
// Local Includes
#include "application.h"
#include "mainwindow.h"
#include "cookiejar.h"
#include "history.h"
#include "networkaccessmanager.h"
#include "webview.h"
//Ui Includes
#include "ui_settings_general.h"
#include "ui_settings_fonts.h"
#include "ui_settings_privacy.h"
#include "ui_settings_proxy.h"
// KDE Includes
#include <KConfig>
#include <KConfigSkeleton>
#include <KPageWidgetItem>
#include <KFontDialog>
#include <KUrl>
// Qt Includes
#include <QtGui>
#include <QtWebKit>
class Private
{
private:
Ui::general generalUi;
Ui::fonts fontsUi;
Ui::privacy privacyUi;
Ui::proxy proxyUi;
Private(SettingsDialog *parent);
friend class SettingsDialog;
};
Private::Private(SettingsDialog *parent)
{
QWidget *widget;
KPageWidgetItem *pageItem;
widget = new QWidget;
generalUi.setupUi(widget);
widget->layout()->setMargin(0);
pageItem = parent->addPage(widget , i18n("General"));
pageItem->setIcon(KIcon("rekonq"));
widget = new QWidget;
fontsUi.setupUi(widget);
widget->layout()->setMargin(0);
pageItem = parent->addPage(widget , i18n("Fonts"));
pageItem->setIcon(KIcon("preferences-desktop-font"));
widget = new QWidget;
privacyUi.setupUi(widget);
widget->layout()->setMargin(0);
pageItem = parent->addPage(widget , i18n("Privacy"));
pageItem->setIcon(KIcon("preferences-desktop-personal"));
widget = new QWidget;
proxyUi.setupUi(widget);
widget->layout()->setMargin(0);
pageItem = parent->addPage(widget , i18n("Proxy"));
pageItem->setIcon(KIcon("preferences-system-network"));
}
// -----------------------------------------------------------------------------------------------------
SettingsDialog::SettingsDialog(QWidget *parent)
: KConfigDialog(parent, "rekonfig", ReKonfig::self())
, d(new Private(this))
{
setFaceType(KPageDialog::List);
showButtonSeparator(true);
setWindowTitle(i18n("rekonfig.."));
setModal(true);
readConfig();
connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage()));
connect(d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT(showExceptions()));
connect(d->privacyUi.cookiesButton, SIGNAL(clicked()), this, SLOT(showCookies()));
}
SettingsDialog::~SettingsDialog()
{
delete d;
}
// we need this function to UPDATE the config widget data..
void SettingsDialog::readConfig()
{
// ======= General
d->generalUi.downloadDirUrlRequester->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
d->generalUi.downloadDirUrlRequester->setUrl(ReKonfig::downloadDir());
connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)), this, SLOT(saveSettings()));
// ======= Fonts
// QFont stdFont = ReKonfig::standardFont();
// d->fontsUi.standardFont->setCurrentFont(stdFont);
//
// QFont fxFont = ReKonfig::fixedFont();
d->fontsUi.kcfg_fixedFont->setOnlyFixed(true);
// d->fontsUi.fixedFont->setCurrentFont(fxFont);
// ======= Proxy
bool proxyEnabled = ReKonfig::isProxyEnabled();
d->proxyUi.groupBox->setEnabled(proxyEnabled);
connect(d->proxyUi.kcfg_isProxyEnabled, SIGNAL(clicked(bool)), d->proxyUi.groupBox, SLOT(setEnabled(bool)));
}
// we need this function to SAVE settings in rc file..
void SettingsDialog::saveSettings()
{
// General
ReKonfig::setDownloadDir(d->generalUi.downloadDirUrlRequester->url().prettyUrl());
// Fonts
// ReKonfig::setStandardFont( d->fontsUi.standardFont->currentFont() );
// ReKonfig::setFixedFont( d->fontsUi.fixedFont->currentFont() );
// Save
ReKonfig::self()->writeConfig();
}
// ----------------------------------------------------------------------------------------------
void SettingsDialog::showCookies()
{
CookiesDialog *dialog = new CookiesDialog(Application::cookieJar(), this);
dialog->exec();
}
void SettingsDialog::showExceptions()
{
CookiesExceptionsDialog *dialog = new CookiesExceptionsDialog(Application::cookieJar(), this);
dialog->exec();
}
void SettingsDialog::setHomeToCurrentPage()
{
MainWindow *mw = static_cast<MainWindow*>(parent());
WebView *webView = mw->currentTab();
if (webView)
{
d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl());
}
}
|