]>
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 "dolphin_generalsettings.h"
26 #include "general/generalsettingspage.h"
27 #include "navigation/navigationsettingspage.h"
28 #include "services/servicessettingspage.h"
29 #include "startup/startupsettingspage.h"
30 #include "viewmodes/viewsettingspage.h"
31 #include "trash/trashsettingspage.h"
34 #include <KMessageBox>
37 #include <QPushButton>
38 #include <QDialogButtonBox>
40 DolphinSettingsDialog::DolphinSettingsDialog(const KUrl
& url
, QWidget
* parent
) :
45 const QSize minSize
= minimumSize();
46 setMinimumSize(QSize(512, minSize
.height()));
49 setWindowTitle(i18nc("@title:window", "Dolphin Preferences"));
50 QDialogButtonBox
* box
= new QDialogButtonBox(QDialogButtonBox::Ok
51 | QDialogButtonBox::Apply
| QDialogButtonBox::Cancel
| QDialogButtonBox::RestoreDefaults
);
52 box
->button(QDialogButtonBox::Apply
)->setEnabled(false);
53 box
->button(QDialogButtonBox::Ok
)->setDefault(true);
57 StartupSettingsPage
* startupSettingsPage
= new StartupSettingsPage(url
, this);
58 KPageWidgetItem
* startupSettingsFrame
= addPage(startupSettingsPage
,
59 i18nc("@title:group", "Startup"));
60 startupSettingsFrame
->setIcon(KIcon("go-home"));
61 connect(startupSettingsPage
, &StartupSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
64 ViewSettingsPage
* viewSettingsPage
= new ViewSettingsPage(this);
65 KPageWidgetItem
* viewSettingsFrame
= addPage(viewSettingsPage
,
66 i18nc("@title:group", "View Modes"));
67 viewSettingsFrame
->setIcon(KIcon("view-choose"));
68 connect(viewSettingsPage
, &ViewSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
71 NavigationSettingsPage
* navigationSettingsPage
= new NavigationSettingsPage(this);
72 KPageWidgetItem
* navigationSettingsFrame
= addPage(navigationSettingsPage
,
73 i18nc("@title:group", "Navigation"));
74 navigationSettingsFrame
->setIcon(KIcon("input-mouse"));
75 connect(navigationSettingsPage
, &NavigationSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
78 ServicesSettingsPage
* servicesSettingsPage
= new ServicesSettingsPage(this);
79 KPageWidgetItem
* servicesSettingsFrame
= addPage(servicesSettingsPage
,
80 i18nc("@title:group", "Services"));
81 servicesSettingsFrame
->setIcon(KIcon("services"));
82 connect(servicesSettingsPage
, &ServicesSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
85 TrashSettingsPage
* trashSettingsPage
= new TrashSettingsPage(this);
86 KPageWidgetItem
* trashSettingsFrame
= addPage(trashSettingsPage
,
87 i18nc("@title:group", "Trash"));
88 trashSettingsFrame
->setIcon(KIcon("user-trash"));
89 connect(trashSettingsPage
, &TrashSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
92 GeneralSettingsPage
* generalSettingsPage
= new GeneralSettingsPage(url
, this);
93 KPageWidgetItem
* generalSettingsFrame
= addPage(generalSettingsPage
,
94 i18nc("@title:group General settings", "General"));
95 generalSettingsFrame
->setIcon(KIcon("system-run"));
96 connect(generalSettingsPage
, &GeneralSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
98 const KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
99 #pragma message("TODO: port")
100 //restoreDialogSize(dialogConfig);
102 m_pages
.append(startupSettingsPage
);
103 m_pages
.append(viewSettingsPage
);
104 m_pages
.append(navigationSettingsPage
);
105 m_pages
.append(servicesSettingsPage
);
106 m_pages
.append(trashSettingsPage
);
107 m_pages
.append(generalSettingsPage
);
110 DolphinSettingsDialog::~DolphinSettingsDialog()
112 KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
113 #pragma message("TODO: port")
114 //saveDialogSize(dialogConfig);
117 void DolphinSettingsDialog::slotButtonClicked(int button
)
119 if ((button
== QDialogButtonBox::Ok
) || (button
== QDialogButtonBox::Apply
)) {
121 } else if (button
== QDialogButtonBox::RestoreDefaults
) {
125 #pragma message("TODO: port")
126 //KPageDialog::slotButtonClicked(button);
129 void DolphinSettingsDialog::enableApply()
131 buttonBox()->button(QDialogButtonBox::Apply
)->setEnabled(true);
134 void DolphinSettingsDialog::applySettings()
136 foreach (SettingsPageBase
* page
, m_pages
) {
137 page
->applySettings();
140 emit
settingsChanged();
142 GeneralSettings
* settings
= GeneralSettings::self();
143 if (settings
->modifiedStartupSettings()) {
144 // Reset the modified startup settings hint. The changed startup settings
145 // have been applied already due to emitting settingsChanged().
146 settings
->setModifiedStartupSettings(false);
147 settings
->writeConfig();
149 buttonBox()->button(QDialogButtonBox::Apply
)->setEnabled(false);
152 void DolphinSettingsDialog::restoreDefaults()
154 foreach (SettingsPageBase
* page
, m_pages
) {
155 page
->restoreDefaults();
159 #include "dolphinsettingsdialog.moc"