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
) :
37 KCModule(parent
, args
),
40 setButtons(KCModule::Default
| KCModule::Help
);
42 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
43 topLayout
->setContentsMargins(0, 0, 0, 0);
45 QTabWidget
* tabWidget
= new QTabWidget(this);
47 // Initialize 'Icons' tab
48 ViewSettingsTab
* iconsTab
= new ViewSettingsTab(ViewSettingsTab::IconsMode
, tabWidget
);
49 tabWidget
->addTab(iconsTab
, QIcon::fromTheme(QStringLiteral("view-list-icons")), i18nc("@title:tab", "Icons"));
50 connect(iconsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
52 // Initialize 'Compact' tab
53 ViewSettingsTab
* compactTab
= new ViewSettingsTab(ViewSettingsTab::CompactMode
, tabWidget
);
54 tabWidget
->addTab(compactTab
, QIcon::fromTheme(QStringLiteral("view-list-details")), i18nc("@title:tab", "Compact"));
55 connect(compactTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
57 // Initialize 'Details' tab
58 ViewSettingsTab
* detailsTab
= new ViewSettingsTab(ViewSettingsTab::DetailsMode
, tabWidget
);
59 tabWidget
->addTab(detailsTab
, QIcon::fromTheme(QStringLiteral("view-list-tree")), i18nc("@title:tab", "Details"));
60 connect(detailsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
62 m_tabs
.append(iconsTab
);
63 m_tabs
.append(compactTab
);
64 m_tabs
.append(detailsTab
);
66 topLayout
->addWidget(tabWidget
, 0, {});
69 DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
73 void DolphinViewModesConfigModule::save()
75 for (ViewSettingsTab
*tab
: qAsConst(m_tabs
)) {
78 reparseConfiguration();
81 void DolphinViewModesConfigModule::defaults()
83 for (ViewSettingsTab
*tab
: qAsConst(m_tabs
)) {
84 tab
->restoreDefaultSettings();
86 reparseConfiguration();
89 void DolphinViewModesConfigModule::reparseConfiguration()
91 QDBusMessage message
= QDBusMessage::createSignal(QStringLiteral("/KonqMain"),
92 QStringLiteral("org.kde.Konqueror.Main"),
93 QStringLiteral("reparseConfiguration"));
94 QDBusConnection::sessionBus().send(message
);
97 void DolphinViewModesConfigModule::viewModeChanged()
102 #include "kcmdolphinviewmodes.moc"