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"
23 #include <KLocalizedString>
24 #include <KPluginFactory>
25 #include <KPluginLoader>
28 #include <settings/viewmodes/viewsettingstab.h>
30 #include <QDBusConnection>
31 #include <QDBusMessage>
32 #include <QPushButton>
33 #include <QVBoxLayout>
36 K_PLUGIN_FACTORY(KCMDolphinViewModesConfigFactory
, registerPlugin
<DolphinViewModesConfigModule
>("dolphinviewmodes");)
37 K_EXPORT_PLUGIN(KCMDolphinViewModesConfigFactory("kcmdolphinviewmodes"))
39 DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget
* parent
, const QVariantList
& args
) :
45 //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead
46 //KLocale::global()->insertCatalog("dolphin");
48 setButtons(KCModule::Default
| KCModule::Help
);
50 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
51 topLayout
->setMargin(0);
52 topLayout
->setSpacing(KDialog::spacingHint());
54 QTabWidget
* tabWidget
= new QTabWidget(this);
56 // Initialize 'Icons' tab
57 ViewSettingsTab
* iconsTab
= new ViewSettingsTab(ViewSettingsTab::IconsMode
, tabWidget
);
58 tabWidget
->addTab(iconsTab
, QIcon::fromTheme("view-list-icons"), i18nc("@title:tab", "Icons"));
59 connect(iconsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
61 // Initialize 'Compact' tab
62 ViewSettingsTab
* compactTab
= new ViewSettingsTab(ViewSettingsTab::CompactMode
, tabWidget
);
63 tabWidget
->addTab(compactTab
, QIcon::fromTheme("view-list-details"), i18nc("@title:tab", "Compact"));
64 connect(compactTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
66 // Initialize 'Details' tab
67 ViewSettingsTab
* detailsTab
= new ViewSettingsTab(ViewSettingsTab::DetailsMode
, tabWidget
);
68 tabWidget
->addTab(detailsTab
, QIcon::fromTheme("view-list-tree"), i18nc("@title:tab", "Details"));
69 connect(detailsTab
, &ViewSettingsTab::changed
, this, &DolphinViewModesConfigModule::viewModeChanged
);
71 m_tabs
.append(iconsTab
);
72 m_tabs
.append(compactTab
);
73 m_tabs
.append(detailsTab
);
75 topLayout
->addWidget(tabWidget
, 0, 0);
78 DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
82 void DolphinViewModesConfigModule::save()
84 foreach (ViewSettingsTab
* tab
, m_tabs
) {
87 reparseConfiguration();
90 void DolphinViewModesConfigModule::defaults()
92 foreach (ViewSettingsTab
* tab
, m_tabs
) {
93 tab
->restoreDefaultSettings();
95 reparseConfiguration();
98 void DolphinViewModesConfigModule::reparseConfiguration()
100 QDBusMessage message
= QDBusMessage::createSignal("/KonqMain", "org.kde.Konqueror.Main", "reparseConfiguration");
101 QDBusConnection::sessionBus().send(message
);
104 void DolphinViewModesConfigModule::viewModeChanged()
109 #include "kcmdolphinviewmodes.moc"