]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/dolphinsettingsdialog.cpp
Added the Trash KCM to Dolphin, it's visible in the Settings Dialog, in the 'Trash...
[dolphin.git] / src / settings / dolphinsettingsdialog.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20
21 #include "dolphinsettingsdialog.h"
22
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"
30 #include "trashsettingspage.h"
31
32 #include <klocale.h>
33 #include <kmessagebox.h>
34 #include <kicon.h>
35
36 DolphinSettingsDialog::DolphinSettingsDialog(const KUrl& url, QWidget* parent) :
37 KPageDialog(parent),
38 m_pages()
39
40 {
41 const QSize minSize = minimumSize();
42 setMinimumSize(QSize(512, minSize.height()));
43
44 setFaceType(List);
45 setCaption(i18nc("@title:window", "Dolphin Preferences"));
46 setButtons(Ok | Apply | Cancel | Default);
47 enableButtonApply(false);
48 setDefaultButton(Ok);
49
50 // Startup
51 StartupSettingsPage* startupSettingsPage = new StartupSettingsPage(url, this);
52 KPageWidgetItem* startupSettingsFrame = addPage(startupSettingsPage,
53 i18nc("@title:group", "Startup"));
54 startupSettingsFrame->setIcon(KIcon("go-home"));
55 connect(startupSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
56
57 // View Modes
58 ViewSettingsPage* viewSettingsPage = new ViewSettingsPage(this);
59 KPageWidgetItem* viewSettingsFrame = addPage(viewSettingsPage,
60 i18nc("@title:group", "View Modes"));
61 viewSettingsFrame->setIcon(KIcon("view-choose"));
62 connect(viewSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
63
64 // Navigation
65 NavigationSettingsPage* navigationSettingsPage = new NavigationSettingsPage(this);
66 KPageWidgetItem* navigationSettingsFrame = addPage(navigationSettingsPage,
67 i18nc("@title:group", "Navigation"));
68 navigationSettingsFrame->setIcon(KIcon("input-mouse"));
69 connect(navigationSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
70
71 // Services
72 ServicesSettingsPage* servicesSettingsPage = new ServicesSettingsPage(this);
73 KPageWidgetItem* servicesSettingsFrame = addPage(servicesSettingsPage,
74 i18nc("@title:group", "Services"));
75 servicesSettingsFrame->setIcon(KIcon("services"));
76 connect(servicesSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
77
78 // Trash
79 TrashSettingsPage* trashSettingsPage = new TrashSettingsPage(this);
80 KPageWidgetItem* trashSettingsFrame = addPage(trashSettingsPage,
81 i18nc("@title:group", "Trash"));
82 trashSettingsFrame->setIcon(KIcon("user-trash"));
83 connect(trashSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
84
85 // General
86 GeneralSettingsPage* generalSettingsPage = new GeneralSettingsPage(url, this);
87 KPageWidgetItem* generalSettingsFrame = addPage(generalSettingsPage,
88 i18nc("@title:group General settings", "General"));
89 generalSettingsFrame->setIcon(KIcon("system-run"));
90 connect(generalSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
91
92 const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
93 restoreDialogSize(dialogConfig);
94
95 m_pages.append(startupSettingsPage);
96 m_pages.append(viewSettingsPage);
97 m_pages.append(navigationSettingsPage);
98 m_pages.append(servicesSettingsPage);
99 m_pages.append(trashSettingsPage);
100 m_pages.append(generalSettingsPage);
101 }
102
103 DolphinSettingsDialog::~DolphinSettingsDialog()
104 {
105 KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
106 saveDialogSize(dialogConfig);
107 }
108
109 void DolphinSettingsDialog::slotButtonClicked(int button)
110 {
111 if ((button == Ok) || (button == Apply)) {
112 applySettings();
113 } else if (button == Default) {
114 restoreDefaults();
115 }
116
117 KPageDialog::slotButtonClicked(button);
118 }
119
120 void DolphinSettingsDialog::enableApply()
121 {
122 enableButtonApply(true);
123 }
124
125 void DolphinSettingsDialog::applySettings()
126 {
127 foreach (SettingsPageBase* page, m_pages) {
128 page->applySettings();
129 }
130 DolphinApplication::app()->refreshMainWindows();
131 enableButtonApply(false);
132 }
133
134 void DolphinSettingsDialog::restoreDefaults()
135 {
136 foreach (SettingsPageBase* page, m_pages) {
137 page->restoreDefaults();
138 }
139 }
140
141 #include "dolphinsettingsdialog.moc"