]>
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);
56 connect(box
->button(QDialogButtonBox::Ok
), &QAbstractButton::clicked
, this, &DolphinSettingsDialog::applySettings
);
57 connect(box
->button(QDialogButtonBox::Apply
), &QAbstractButton::clicked
, this, &DolphinSettingsDialog::applySettings
);
58 connect(box
->button(QDialogButtonBox::RestoreDefaults
), &QAbstractButton::clicked
, this, &DolphinSettingsDialog::restoreDefaults
);
61 StartupSettingsPage
* startupSettingsPage
= new StartupSettingsPage(url
, this);
62 KPageWidgetItem
* startupSettingsFrame
= addPage(startupSettingsPage
,
63 i18nc("@title:group", "Startup"));
64 startupSettingsFrame
->setIcon(QIcon::fromTheme("go-home"));
65 connect(startupSettingsPage
, &StartupSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
68 ViewSettingsPage
* viewSettingsPage
= new ViewSettingsPage(this);
69 KPageWidgetItem
* viewSettingsFrame
= addPage(viewSettingsPage
,
70 i18nc("@title:group", "View Modes"));
71 viewSettingsFrame
->setIcon(QIcon::fromTheme("view-choose"));
72 connect(viewSettingsPage
, &ViewSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
75 NavigationSettingsPage
* navigationSettingsPage
= new NavigationSettingsPage(this);
76 KPageWidgetItem
* navigationSettingsFrame
= addPage(navigationSettingsPage
,
77 i18nc("@title:group", "Navigation"));
78 navigationSettingsFrame
->setIcon(QIcon::fromTheme("input-mouse"));
79 connect(navigationSettingsPage
, &NavigationSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
82 ServicesSettingsPage
* servicesSettingsPage
= new ServicesSettingsPage(this);
83 KPageWidgetItem
* servicesSettingsFrame
= addPage(servicesSettingsPage
,
84 i18nc("@title:group", "Services"));
85 servicesSettingsFrame
->setIcon(QIcon::fromTheme("services"));
86 connect(servicesSettingsPage
, &ServicesSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
89 TrashSettingsPage
* trashSettingsPage
= new TrashSettingsPage(this);
90 KPageWidgetItem
* trashSettingsFrame
= addPage(trashSettingsPage
,
91 i18nc("@title:group", "Trash"));
92 trashSettingsFrame
->setIcon(QIcon::fromTheme("user-trash"));
93 connect(trashSettingsPage
, &TrashSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
96 GeneralSettingsPage
* generalSettingsPage
= new GeneralSettingsPage(url
, this);
97 KPageWidgetItem
* generalSettingsFrame
= addPage(generalSettingsPage
,
98 i18nc("@title:group General settings", "General"));
99 generalSettingsFrame
->setIcon(QIcon::fromTheme("system-run"));
100 connect(generalSettingsPage
, &GeneralSettingsPage::changed
, this, &DolphinSettingsDialog::enableApply
);
102 const KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
103 #pragma message("TODO: port")
104 //restoreDialogSize(dialogConfig);
106 m_pages
.append(startupSettingsPage
);
107 m_pages
.append(viewSettingsPage
);
108 m_pages
.append(navigationSettingsPage
);
109 m_pages
.append(servicesSettingsPage
);
110 m_pages
.append(trashSettingsPage
);
111 m_pages
.append(generalSettingsPage
);
114 DolphinSettingsDialog::~DolphinSettingsDialog()
116 KConfigGroup
dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
117 #pragma message("TODO: port")
118 //saveDialogSize(dialogConfig);
121 void DolphinSettingsDialog::enableApply()
123 buttonBox()->button(QDialogButtonBox::Apply
)->setEnabled(true);
126 void DolphinSettingsDialog::applySettings()
128 foreach (SettingsPageBase
* page
, m_pages
) {
129 page
->applySettings();
132 emit
settingsChanged();
134 GeneralSettings
* settings
= GeneralSettings::self();
135 if (settings
->modifiedStartupSettings()) {
136 // Reset the modified startup settings hint. The changed startup settings
137 // have been applied already due to emitting settingsChanged().
138 settings
->setModifiedStartupSettings(false);
139 settings
->writeConfig();
141 buttonBox()->button(QDialogButtonBox::Apply
)->setEnabled(false);
144 void DolphinSettingsDialog::restoreDefaults()
146 foreach (SettingsPageBase
* page
, m_pages
) {
147 page
->restoreDefaults();