]> cloud.milkyroute.net Git - dolphin.git/blob - src/kcmdolphin.cpp
the kcm needs the dolphin catalog, otherwise konqueror shows it untranslated, kudos...
[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 "columnviewsettingspage.h"
23 #include "detailsviewsettingspage.h"
24 #include "generalviewsettingspage.h"
25 #include "iconsviewsettingspage.h"
26
27 #include <kdialog.h>
28 #include <klocale.h>
29 #include <kpluginfactory.h>
30 #include <kpluginloader.h>
31
32 #include <QDBusConnection>
33 #include <QDBusMessage>
34 #include <QDir>
35 #include <QPushButton>
36 #include <QVBoxLayout>
37
38 K_PLUGIN_FACTORY(KCMDolphinConfigFactory, registerPlugin<DolphinConfigModule>("dolphin");)
39 K_EXPORT_PLUGIN(KCMDolphinConfigFactory("kcmdolphin"))
40
41 DolphinConfigModule::DolphinConfigModule(QWidget* parent, const QVariantList& args) :
42 KCModule(KCMDolphinConfigFactory::componentData(), parent),
43 m_pages()
44 {
45 Q_UNUSED(args);
46
47 KGlobal::locale()->insertCatalog("dolphin");
48
49 setButtons(KCModule::Default | KCModule::Help);
50
51 QVBoxLayout* topLayout = new QVBoxLayout(this);
52 topLayout->setMargin(0);
53 topLayout->setSpacing(KDialog::spacingHint());
54
55 QTabWidget* tabWidget = new QTabWidget(this);
56
57 // initialize 'General' tab
58 GeneralViewSettingsPage* generalPage = new GeneralViewSettingsPage(QDir::homePath(), tabWidget);
59 tabWidget->addTab(generalPage, KIcon("view-choose"), i18nc("@title:tab General settings", "General"));
60 connect(generalPage, SIGNAL(changed()), this, SLOT(changed()));
61
62 // initialize 'Icons' tab
63 IconsViewSettingsPage* iconsPage = new IconsViewSettingsPage(tabWidget);
64 tabWidget->addTab(iconsPage, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
65 connect(iconsPage, SIGNAL(changed()), this, SLOT(changed()));
66
67 // initialize 'Details' tab
68 DetailsViewSettingsPage* detailsPage = new DetailsViewSettingsPage(tabWidget);
69 tabWidget->addTab(detailsPage, KIcon("view-list-details"), i18nc("@title:tab", "Details"));
70 connect(detailsPage, SIGNAL(changed()), this, SLOT(changed()));
71
72 // initialize 'Column' tab
73 ColumnViewSettingsPage* columnPage = new ColumnViewSettingsPage(tabWidget);
74 tabWidget->addTab(columnPage, KIcon("view-file-columns"), i18nc("@title:tab", "Column"));
75 connect(columnPage, SIGNAL(changed()), this, SLOT(changed()));
76
77 m_pages.append(generalPage);
78 m_pages.append(iconsPage);
79 m_pages.append(detailsPage);
80 m_pages.append(columnPage);
81
82 topLayout->addWidget(tabWidget, 0, 0);
83 }
84
85 DolphinConfigModule::~DolphinConfigModule()
86 {
87 }
88
89 void DolphinConfigModule::save()
90 {
91 foreach (ViewSettingsPageBase* page, m_pages) {
92 page->applySettings();
93 }
94 reparseConfiguration();
95 }
96
97 void DolphinConfigModule::defaults()
98 {
99 foreach (ViewSettingsPageBase* page, m_pages) {
100 page->restoreDefaults();
101 }
102 reparseConfiguration();
103 }
104
105 void DolphinConfigModule::reparseConfiguration()
106 {
107 QDBusMessage message = QDBusMessage::createSignal("/KonqMain", "org.kde.Konqueror.Main", "reparseConfiguration");
108 QDBusConnection::sessionBus().send(message);
109 }
110
111 #include "kcmdolphin.moc"