]>
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 "dolphinsettings.h"
26 #include "dolphin_generalsettings.h"
27 #include "general/generalsettingspage.h"
28 #include "navigation/navigationsettingspage.h"
29 #include "services/servicessettingspage.h"
30 #include "startup/startupsettingspage.h"
31 #include "viewmodes/viewsettingspage.h"
32 #include "trash/trashsettingspage.h"
35 #include <KMessageBox>
38 DolphinSettingsDialog::DolphinSettingsDialog(const KUrl
& url
, QWidget
* parent
) :
43 const QSize minSize
= minimumSize();
44 setMinimumSize(QSize(512, minSize
.height()));
47 setCaption(i18nc("@title:window", "Dolphin Preferences"));
48 setButtons(Ok
| Apply
| Cancel
| Default
);
49 enableButtonApply(false);
53 StartupSettingsPage
* startupSettingsPage
= new StartupSettingsPage(url
, this);
54 KPageWidgetItem
* startupSettingsFrame
= addPage(startupSettingsPage
,
55 i18nc("@title:group", "Startup"));
56 startupSettingsFrame
->setIcon(KIcon("go-home"));
57 connect(startupSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
60 ViewSettingsPage
* viewSettingsPage
= new ViewSettingsPage(this);
61 KPageWidgetItem
* viewSettingsFrame
= addPage(viewSettingsPage
,
62 i18nc("@title:group", "View Modes"));
63 viewSettingsFrame
->setIcon(KIcon("view-choose"));
64 connect(viewSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
67 NavigationSettingsPage
* navigationSettingsPage
= new NavigationSettingsPage(this);
68 KPageWidgetItem
* navigationSettingsFrame
= addPage(navigationSettingsPage
,
69 i18nc("@title:group", "Navigation"));
70 navigationSettingsFrame
->setIcon(KIcon("input-mouse"));
71 connect(navigationSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
74 ServicesSettingsPage
* servicesSettingsPage
= new ServicesSettingsPage(this);
75 KPageWidgetItem
* servicesSettingsFrame
= addPage(servicesSettingsPage
,
76 i18nc("@title:group", "Services"));
77 servicesSettingsFrame
->setIcon(KIcon("services"));
78 connect(servicesSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
81 TrashSettingsPage
* trashSettingsPage
= new TrashSettingsPage(this);
82 KPageWidgetItem
* trashSettingsFrame
= addPage(trashSettingsPage
,
83 i18nc("@title:group", "Trash"));
84 trashSettingsFrame
->setIcon(KIcon("user-trash"));
85 connect(trashSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
88 GeneralSettingsPage
* generalSettingsPage
= new GeneralSettingsPage(url
, this);
89 KPageWidgetItem
* generalSettingsFrame
= addPage(generalSettingsPage
,
90 i18nc("@title:group General settings", "General"));
91 generalSettingsFrame
->setIcon(KIcon("system-run"));
92 connect(generalSettingsPage
, SIGNAL(changed()), this, SLOT(enableApply()));
94 const KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
95 restoreDialogSize(dialogConfig
);
97 m_pages
.append(startupSettingsPage
);
98 m_pages
.append(viewSettingsPage
);
99 m_pages
.append(navigationSettingsPage
);
100 m_pages
.append(servicesSettingsPage
);
101 m_pages
.append(trashSettingsPage
);
102 m_pages
.append(generalSettingsPage
);
105 DolphinSettingsDialog::~DolphinSettingsDialog()
107 KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
108 saveDialogSize(dialogConfig
);
111 void DolphinSettingsDialog::slotButtonClicked(int button
)
113 if ((button
== Ok
) || (button
== Apply
)) {
115 } else if (button
== Default
) {
119 KPageDialog::slotButtonClicked(button
);
122 void DolphinSettingsDialog::enableApply()
124 enableButtonApply(true);
127 void DolphinSettingsDialog::applySettings()
129 foreach (SettingsPageBase
* page
, m_pages
) {
130 page
->applySettings();
132 DolphinApplication::app()->refreshMainWindows();
134 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
135 if (settings
->modifiedStartupSettings()) {
136 // Reset the modified startup settings hint. The changed startup settings
137 // have been applied already in app()->refreshMainWindows().
138 settings
->setModifiedStartupSettings(false);
139 settings
->writeConfig();
142 enableButtonApply(false);
145 void DolphinSettingsDialog::restoreDefaults()
147 foreach (SettingsPageBase
* page
, m_pages
) {
148 page
->restoreDefaults();
152 #include "dolphinsettingsdialog.moc"