]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/kcm/kcmdolphinviewmodes.cpp
a7a9db36dcb0554f7a139e18f843841c19981878
[dolphin.git] / src / settings / kcm / kcmdolphinviewmodes.cpp
1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com> *
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 "kcmdolphinviewmodes.h"
21
22 #include <KTabWidget>
23 #include <KDialog>
24 #include <KLocale>
25 #include <KPluginFactory>
26 #include <KPluginLoader>
27 #include <KIcon>
28
29 #include <settings/viewmodes/viewsettingstab.h>
30
31 #include <QDBusConnection>
32 #include <QDBusMessage>
33 #include <QDir>
34 #include <QPushButton>
35 #include <QVBoxLayout>
36
37 K_PLUGIN_FACTORY(KCMDolphinViewModesConfigFactory, registerPlugin<DolphinViewModesConfigModule>("dolphinviewmodes");)
38 K_EXPORT_PLUGIN(KCMDolphinViewModesConfigFactory("kcmdolphinviewmodes"))
39
40 DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, const QVariantList& args) :
41 KCModule(KCMDolphinViewModesConfigFactory::componentData(), parent),
42 m_tabs()
43 {
44 Q_UNUSED(args);
45
46 KGlobal::locale()->insertCatalog("dolphin");
47
48 setButtons(KCModule::Default | KCModule::Help);
49
50 QVBoxLayout* topLayout = new QVBoxLayout(this);
51 topLayout->setMargin(0);
52 topLayout->setSpacing(KDialog::spacingHint());
53
54 KTabWidget* tabWidget = new KTabWidget(this);
55
56 // Initialize 'Icons' tab
57 ViewSettingsTab* iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);
58 tabWidget->addTab(iconsTab, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
59 connect(iconsTab, SIGNAL(changed()), this, SLOT(viewModeChanged()));
60
61 // Initialize 'Compact' tab
62 ViewSettingsTab* compactTab = new ViewSettingsTab(ViewSettingsTab::CompactMode, tabWidget);
63 tabWidget->addTab(compactTab, KIcon("view-list-details"), i18nc("@title:tab", "Compact"));
64 connect(compactTab, SIGNAL(changed()), this, SLOT(viewModeChanged()));
65
66 // Initialize 'Details' tab
67 ViewSettingsTab* detailsTab = new ViewSettingsTab(ViewSettingsTab::DetailsMode, tabWidget);
68 tabWidget->addTab(detailsTab, KIcon("view-list-tree"), i18nc("@title:tab", "Details"));
69 connect(detailsTab, SIGNAL(changed()), this, SLOT(viewModeChanged()));
70
71 m_tabs.append(iconsTab);
72 m_tabs.append(compactTab);
73 m_tabs.append(detailsTab);
74
75 topLayout->addWidget(tabWidget, 0, 0);
76 }
77
78 DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
79 {
80 }
81
82 void DolphinViewModesConfigModule::save()
83 {
84 foreach (ViewSettingsTab* tab, m_tabs) {
85 tab->applySettings();
86 }
87 reparseConfiguration();
88 }
89
90 void DolphinViewModesConfigModule::defaults()
91 {
92 foreach (ViewSettingsTab* tab, m_tabs) {
93 tab->restoreDefaultSettings();
94 }
95 reparseConfiguration();
96 }
97
98 void DolphinViewModesConfigModule::reparseConfiguration()
99 {
100 QDBusMessage message = QDBusMessage::createSignal("/KonqMain", "org.kde.Konqueror.Main", "reparseConfiguration");
101 QDBusConnection::sessionBus().send(message);
102 }
103
104 void DolphinViewModesConfigModule::viewModeChanged()
105 {
106 emit changed(true);
107 }
108
109 #include "kcmdolphinviewmodes.moc"