1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "dolphinsettingsdialog.h"
23 #include <dolphinapplication.h>
24 #include <dolphinmainwindow.h>
25 #include "generalsettingspage.h"
26 #include "navigationsettingspage.h"
27 #include "servicessettingspage.h"
28 #include "startupsettingspage.h"
29 #include "viewsettingspage.h"
32 #include <kmessagebox.h>
35 DolphinSettingsDialog::DolphinSettingsDialog(const KUrl
& url
, QWidget
* parent
) :
40 const QSize minSize
= minimumSize();
41 setMinimumSize(QSize(512, minSize
.height()));
44 setCaption(i18nc("@title:window", "Dolphin Preferences"));
45 setButtons(Ok
| Apply
| Cancel
| Default
);
46 enableButtonApply(false);
50 StartupSettingsPage
* startupSettingsPage
= new StartupSettingsPage(url
, this);
51 KPageWidgetItem
* startupSettingsFrame
= addPage(startupSettingsPage
,
52 i18nc("@title:group", "Startup"));
53 startupSettingsFrame
->setIcon(KIcon("go-home"));
54 connect(startupSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
57 ViewSettingsPage
* viewSettingsPage
= new ViewSettingsPage(this);
58 KPageWidgetItem
* viewSettingsFrame
= addPage(viewSettingsPage
,
59 i18nc("@title:group", "View Modes"));
60 viewSettingsFrame
->setIcon(KIcon("view-choose"));
61 connect(viewSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
64 NavigationSettingsPage
* navigationSettingsPage
= new NavigationSettingsPage(this);
65 KPageWidgetItem
* navigationSettingsFrame
= addPage(navigationSettingsPage
,
66 i18nc("@title:group", "Navigation"));
67 navigationSettingsFrame
->setIcon(KIcon("input-mouse"));
68 connect(navigationSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
71 ServicesSettingsPage
* servicesSettingsPage
= new ServicesSettingsPage(this);
72 KPageWidgetItem
* servicesSettingsFrame
= addPage(servicesSettingsPage
,
73 i18nc("@title:group", "Services"));
74 servicesSettingsFrame
->setIcon(KIcon("services"));
75 connect(servicesSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
78 GeneralSettingsPage
* generalSettingsPage
= new GeneralSettingsPage(url
, this);
79 KPageWidgetItem
* generalSettingsFrame
= addPage(generalSettingsPage
,
80 i18nc("@title:group General settings", "General"));
81 generalSettingsFrame
->setIcon(KIcon("system-run"));
82 connect(generalSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
84 const KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
85 restoreDialogSize(dialogConfig
);
87 m_pages
.append(startupSettingsPage
);
88 m_pages
.append(viewSettingsPage
);
89 m_pages
.append(navigationSettingsPage
);
90 m_pages
.append(servicesSettingsPage
);
91 m_pages
.append(generalSettingsPage
);
94 DolphinSettingsDialog::~DolphinSettingsDialog()
96 KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
97 saveDialogSize(dialogConfig
);
100 void DolphinSettingsDialog::slotButtonClicked(int button
)
102 if ((button
== Ok
) || (button
== Apply
)) {
104 } else if (button
== Default
) {
105 const QString
text(i18nc("@info", "All settings will be reset to default values. Do you want to continue?"));
106 if (KMessageBox::questionYesNo(this, text
) == KMessageBox::Yes
) {
111 KPageDialog::slotButtonClicked(button
);
114 void DolphinSettingsDialog::enableApply()
116 enableButtonApply(true);
119 void DolphinSettingsDialog::applySettings()
121 foreach (SettingsPageBase
* page
, m_pages
) {
122 page
->applySettings();
124 DolphinApplication::app()->refreshMainWindows();
127 void DolphinSettingsDialog::restoreDefaults()
129 foreach (SettingsPageBase
* page
, m_pages
) {
130 page
->restoreDefaults();
132 DolphinApplication::app()->refreshMainWindows();
135 #include "dolphinsettingsdialog.moc"