]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/dolphinsettingsdialog.cpp
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"
30 #include "trashsettingspage.h"
33 #include <kmessagebox.h>
36 DolphinSettingsDialog::DolphinSettingsDialog(const KUrl
& url
, QWidget
* parent
) :
41 const QSize minSize
= minimumSize();
42 setMinimumSize(QSize(512, minSize
.height()));
45 setCaption(i18nc("@title:window", "Dolphin Preferences"));
46 setButtons(Ok
| Apply
| Cancel
| Default
);
47 enableButtonApply(false);
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()));
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()));
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()));
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()));
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()));
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()));
92 const KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
93 restoreDialogSize(dialogConfig
);
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
);
103 DolphinSettingsDialog::~DolphinSettingsDialog()
105 KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
106 saveDialogSize(dialogConfig
);
109 void DolphinSettingsDialog::slotButtonClicked(int button
)
111 if ((button
== Ok
) || (button
== Apply
)) {
113 } else if (button
== Default
) {
117 KPageDialog::slotButtonClicked(button
);
120 void DolphinSettingsDialog::enableApply()
122 enableButtonApply(true);
125 void DolphinSettingsDialog::applySettings()
127 foreach (SettingsPageBase
* page
, m_pages
) {
128 page
->applySettings();
130 DolphinApplication::app()->refreshMainWindows();
131 enableButtonApply(false);
134 void DolphinSettingsDialog::restoreDefaults()
136 foreach (SettingsPageBase
* page
, m_pages
) {
137 page
->restoreDefaults();
141 #include "dolphinsettingsdialog.moc"