]> cloud.milkyroute.net Git - dolphin.git/blob - src/kcmdolphin.cpp
Group classes into folders, Dolphin is too big in the meantime for having a flat...
[dolphin.git] / src / kcmdolphin.cpp
1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include "kcmdolphin.h"
21
22 #include "settings/columnviewsettingspage.h"
23 #include "settings/detailsviewsettingspage.h"
24 #include "settings/generalviewsettingspage.h"
25 #include "settings/iconsviewsettingspage.h"
26
27 #include <ktabwidget.h>
28 #include <kdialog.h>
29 #include <klocale.h>
30 #include <kpluginfactory.h>
31 #include <kpluginloader.h>
32
33 #include <QDBusConnection>
34 #include <QDBusMessage>
35 #include <QDir>
36 #include <QPushButton>
37 #include <QVBoxLayout>
38
39 K_PLUGIN_FACTORY(KCMDolphinConfigFactory, registerPlugin<DolphinConfigModule>("dolphin");)
40 K_EXPORT_PLUGIN(KCMDolphinConfigFactory("kcmdolphin"))
41
42 DolphinConfigModule::DolphinConfigModule(QWidget* parent, const QVariantList& args) :
43 KCModule(KCMDolphinConfigFactory::componentData(), parent),
44 m_pages()
45 {
46 Q_UNUSED(args);
47
48 KGlobal::locale()->insertCatalog("dolphin");
49
50 setButtons(KCModule::Default | KCModule::Help);
51
52 QVBoxLayout* topLayout = new QVBoxLayout(this);
53 topLayout->setMargin(0);
54 topLayout->setSpacing(KDialog::spacingHint());
55
56 KTabWidget* tabWidget = new KTabWidget(this);
57
58 // initialize 'General' tab
59 GeneralViewSettingsPage* generalPage = new GeneralViewSettingsPage(QDir::homePath(), tabWidget);
60 tabWidget->addTab(generalPage, KIcon("view-choose"), i18nc("@title:tab General settings", "General"));
61 connect(generalPage, SIGNAL(changed()), this, SLOT(changed()));
62
63 // initialize 'Icons' tab
64 IconsViewSettingsPage* iconsPage = new IconsViewSettingsPage(tabWidget);
65 tabWidget->addTab(iconsPage, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
66 connect(iconsPage, SIGNAL(changed()), this, SLOT(changed()));
67
68 // initialize 'Details' tab
69 DetailsViewSettingsPage* detailsPage = new DetailsViewSettingsPage(tabWidget);
70 tabWidget->addTab(detailsPage, KIcon("view-list-details"), i18nc("@title:tab", "Details"));
71 connect(detailsPage, SIGNAL(changed()), this, SLOT(changed()));
72
73 // initialize 'Column' tab
74 ColumnViewSettingsPage* columnPage = new ColumnViewSettingsPage(tabWidget);
75 tabWidget->addTab(columnPage, KIcon("view-file-columns"), i18nc("@title:tab", "Column"));
76 connect(columnPage, SIGNAL(changed()), this, SLOT(changed()));
77
78 m_pages.append(generalPage);
79 m_pages.append(iconsPage);
80 m_pages.append(detailsPage);
81 m_pages.append(columnPage);
82
83 topLayout->addWidget(tabWidget, 0, 0);
84 }
85
86 DolphinConfigModule::~DolphinConfigModule()
87 {
88 }
89
90 void DolphinConfigModule::save()
91 {
92 foreach (ViewSettingsPageBase* page, m_pages) {
93 page->applySettings();
94 }
95 reparseConfiguration();
96 }
97
98 void DolphinConfigModule::defaults()
99 {
100 foreach (ViewSettingsPageBase* page, m_pages) {
101 page->restoreDefaults();
102 }
103 reparseConfiguration();
104 }
105
106 void DolphinConfigModule::reparseConfiguration()
107 {
108 QDBusMessage message = QDBusMessage::createSignal("/KonqMain", "org.kde.Konqueror.Main", "reparseConfiguration");
109 QDBusConnection::sessionBus().send(message);
110 }
111
112 #include "kcmdolphin.moc"