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"
24 #include <KLocalizedString>
25 #include <KPluginFactory>
26 #include <KPluginLoader>
30 #include <settings/viewmodes/viewsettingstab.h>
32 #include <QDBusConnection>
33 #include <QDBusMessage>
35 #include <QPushButton>
36 #include <QVBoxLayout>
38 K_PLUGIN_FACTORY(KCMDolphinViewModesConfigFactory
, registerPlugin
<DolphinViewModesConfigModule
>("dolphinviewmodes");)
39 K_EXPORT_PLUGIN(KCMDolphinViewModesConfigFactory("kcmdolphinviewmodes"))
41 DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget
* parent
, const QVariantList
& args
) :
47 //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead
48 //KLocale::global()->insertCatalog("dolphin");
50 setButtons(KCModule::Default
| KCModule::Help
);
52 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
53 topLayout
->setMargin(0);
54 topLayout
->setSpacing(KDialog::spacingHint());
56 KTabWidget
* tabWidget
= new KTabWidget(this);
58 // Initialize 'Icons' tab
59 ViewSettingsTab
* iconsTab
= new ViewSettingsTab(ViewSettingsTab::IconsMode
, tabWidget
);
60 tabWidget
->addTab(iconsTab
, QIcon::fromTheme("view-list-icons"), i18nc("@title:tab", "Icons"));
61 connect(iconsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
63 // Initialize 'Compact' tab
64 ViewSettingsTab
* compactTab
= new ViewSettingsTab(ViewSettingsTab::CompactMode
, tabWidget
);
65 tabWidget
->addTab(compactTab
, QIcon::fromTheme("view-list-details"), i18nc("@title:tab", "Compact"));
66 connect(compactTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
68 // Initialize 'Details' tab
69 ViewSettingsTab
* detailsTab
= new ViewSettingsTab(ViewSettingsTab::DetailsMode
, tabWidget
);
70 tabWidget
->addTab(detailsTab
, QIcon::fromTheme("view-list-tree"), i18nc("@title:tab", "Details"));
71 connect(detailsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
73 m_tabs
.append(iconsTab
);
74 m_tabs
.append(compactTab
);
75 m_tabs
.append(detailsTab
);
77 topLayout
->addWidget(tabWidget
, 0, 0);
80 DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
84 void DolphinViewModesConfigModule::save()
86 foreach (ViewSettingsTab
* tab
, m_tabs
) {
89 reparseConfiguration();
92 void DolphinViewModesConfigModule::defaults()
94 foreach (ViewSettingsTab
* tab
, m_tabs
) {
95 tab
->restoreDefaultSettings();
97 reparseConfiguration();
100 void DolphinViewModesConfigModule::reparseConfiguration()
102 QDBusMessage message
= QDBusMessage::createSignal("/KonqMain", "org.kde.Konqueror.Main", "reparseConfiguration");
103 QDBusConnection::sessionBus().send(message
);
106 void DolphinViewModesConfigModule::viewModeChanged()
111 #include "kcmdolphinviewmodes.moc"