1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #include "kcmdolphinviewmodes.h"
22 #include "settings/viewmodes/viewsettingstab.h"
24 #include <KLocalizedString>
25 #include <KPluginFactory>
26 #include <KPluginLoader>
28 #include <QDBusConnection>
29 #include <QDBusMessage>
32 #include <QVBoxLayout>
34 K_PLUGIN_FACTORY(KCMDolphinViewModesConfigFactory
, registerPlugin
<DolphinViewModesConfigModule
>(QStringLiteral("dolphinviewmodes"));)
36 DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget
* parent
, const QVariantList
& args
) :
42 setButtons(KCModule::Default
| KCModule::Help
);
44 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
45 topLayout
->setContentsMargins(0, 0, 0, 0);
47 QTabWidget
* tabWidget
= new QTabWidget(this);
49 // Initialize 'Icons' tab
50 ViewSettingsTab
* iconsTab
= new ViewSettingsTab(ViewSettingsTab::IconsMode
, tabWidget
);
51 tabWidget
->addTab(iconsTab
, QIcon::fromTheme(QStringLiteral("view-list-icons")), i18nc("@title:tab", "Icons"));
52 connect(iconsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
54 // Initialize 'Compact' tab
55 ViewSettingsTab
* compactTab
= new ViewSettingsTab(ViewSettingsTab::CompactMode
, tabWidget
);
56 tabWidget
->addTab(compactTab
, QIcon::fromTheme(QStringLiteral("view-list-details")), i18nc("@title:tab", "Compact"));
57 connect(compactTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
59 // Initialize 'Details' tab
60 ViewSettingsTab
* detailsTab
= new ViewSettingsTab(ViewSettingsTab::DetailsMode
, tabWidget
);
61 tabWidget
->addTab(detailsTab
, QIcon::fromTheme(QStringLiteral("view-list-tree")), i18nc("@title:tab", "Details"));
62 connect(detailsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
64 m_tabs
.append(iconsTab
);
65 m_tabs
.append(compactTab
);
66 m_tabs
.append(detailsTab
);
68 topLayout
->addWidget(tabWidget
, 0, {});
71 DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
75 void DolphinViewModesConfigModule::save()
77 foreach (ViewSettingsTab
* tab
, m_tabs
) {
80 reparseConfiguration();
83 void DolphinViewModesConfigModule::defaults()
85 foreach (ViewSettingsTab
* tab
, m_tabs
) {
86 tab
->restoreDefaultSettings();
88 reparseConfiguration();
91 void DolphinViewModesConfigModule::reparseConfiguration()
93 QDBusMessage message
= QDBusMessage::createSignal(QStringLiteral("/KonqMain"), QStringLiteral("org.kde.Konqueror.Main"), QStringLiteral("reparseConfiguration"));
94 QDBusConnection::sessionBus().send(message
);
97 void DolphinViewModesConfigModule::viewModeChanged()
102 #include "kcmdolphinviewmodes.moc"