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 <KLocalizedString>
23 #include <KPluginFactory>
24 #include <KPluginLoader>
27 #include <settings/viewmodes/viewsettingstab.h>
29 #include <QDBusConnection>
30 #include <QDBusMessage>
31 #include <QPushButton>
32 #include <QVBoxLayout>
35 K_PLUGIN_FACTORY(KCMDolphinViewModesConfigFactory
, registerPlugin
<DolphinViewModesConfigModule
>(QStringLiteral("dolphinviewmodes"));)
36 K_EXPORT_PLUGIN(KCMDolphinViewModesConfigFactory("kcmdolphinviewmodes"))
38 DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget
* parent
, const QVariantList
& args
) :
44 setButtons(KCModule::Default
| KCModule::Help
);
46 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
47 topLayout
->setMargin(0);
49 QTabWidget
* tabWidget
= new QTabWidget(this);
51 // Initialize 'Icons' tab
52 ViewSettingsTab
* iconsTab
= new ViewSettingsTab(ViewSettingsTab::IconsMode
, tabWidget
);
53 tabWidget
->addTab(iconsTab
, QIcon::fromTheme(QStringLiteral("view-list-icons")), i18nc("@title:tab", "Icons"));
54 connect(iconsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
56 // Initialize 'Compact' tab
57 ViewSettingsTab
* compactTab
= new ViewSettingsTab(ViewSettingsTab::CompactMode
, tabWidget
);
58 tabWidget
->addTab(compactTab
, QIcon::fromTheme(QStringLiteral("view-list-details")), i18nc("@title:tab", "Compact"));
59 connect(compactTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
61 // Initialize 'Details' tab
62 ViewSettingsTab
* detailsTab
= new ViewSettingsTab(ViewSettingsTab::DetailsMode
, tabWidget
);
63 tabWidget
->addTab(detailsTab
, QIcon::fromTheme(QStringLiteral("view-list-tree")), i18nc("@title:tab", "Details"));
64 connect(detailsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
66 m_tabs
.append(iconsTab
);
67 m_tabs
.append(compactTab
);
68 m_tabs
.append(detailsTab
);
70 topLayout
->addWidget(tabWidget
, 0, 0);
73 DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
77 void DolphinViewModesConfigModule::save()
79 foreach (ViewSettingsTab
* tab
, m_tabs
) {
82 reparseConfiguration();
85 void DolphinViewModesConfigModule::defaults()
87 foreach (ViewSettingsTab
* tab
, m_tabs
) {
88 tab
->restoreDefaultSettings();
90 reparseConfiguration();
93 void DolphinViewModesConfigModule::reparseConfiguration()
95 QDBusMessage message
= QDBusMessage::createSignal(QStringLiteral("/KonqMain"), QStringLiteral("org.kde.Konqueror.Main"), QStringLiteral("reparseConfiguration"));
96 QDBusConnection::sessionBus().send(message
);
99 void DolphinViewModesConfigModule::viewModeChanged()
104 #include "kcmdolphinviewmodes.moc"