1 /**
2 * \file kdeconfigdialog.cpp
3 * KDE configuration dialog.
4 *
5 * \b Project: Kid3
6 * \author Urs Fleisch
7 * \date 17 Sep 2003
8 *
9 * Copyright (C) 2003-2018 Urs Fleisch
10 *
11 * This file is part of Kid3.
12 *
13 * Kid3 is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * Kid3 is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 */
26
27 #include "kdeconfigdialog.h"
28 #include <QPushButton>
29 #include <KConfigSkeleton>
30 #include "contexthelp.h"
31 #include "configdialogpages.h"
32
33 /**
34 * Constructor.
35 *
36 * @param platformTools platform specific tools
37 * @param parent parent widget
38 * @param caption dialog title
39 * @param configSkeleton configuration skeleton
40 */
KdeConfigDialog(IPlatformTools * platformTools,QWidget * parent,QString & caption,KConfigSkeleton * configSkeleton)41 KdeConfigDialog::KdeConfigDialog(IPlatformTools* platformTools,
42 QWidget* parent, QString& caption,
43 KConfigSkeleton* configSkeleton)
44 : KConfigDialog(parent, QLatin1String("configure"), configSkeleton),
45 m_pages(new ConfigDialogPages(platformTools, this))
46 {
47 setObjectName(QLatin1String("ConfigDialog"));
48 setWindowTitle(caption);
49 setSizeGripEnabled(true);
50
51 addPage(m_pages->createTagsPage(), tr("Tags"),
52 QLatin1String("applications-multimedia"));
53 addPage(m_pages->createFilesPage(), tr("Files"),
54 QLatin1String("document-save"));
55 addPage(m_pages->createActionsPage(), tr("User Actions"),
56 QLatin1String("preferences-other"));
57 addPage(m_pages->createNetworkPage(), tr("Network"),
58 QLatin1String("preferences-system-network"));
59 addPage(m_pages->createPluginsPage(), tr("Plugins"),
60 QLatin1String("preferences-plugin"));
61
62 setStandardButtons(QDialogButtonBox::RestoreDefaults |
63 QDialogButtonBox::Ok | QDialogButtonBox::Cancel |
64 QDialogButtonBox::Help);
65 if (const QDialogButtonBox* buttons = buttonBox()) {
66 if (QPushButton* helpButton = buttons->button(QDialogButtonBox::Help)) {
67 connect(helpButton, &QAbstractButton::clicked,
68 this, &KdeConfigDialog::slotHelp);
69 }
70 if (QPushButton* defaultsButton =
71 buttons->button(QDialogButtonBox::RestoreDefaults)) {
72 connect(defaultsButton, &QAbstractButton::clicked,
73 m_pages, &ConfigDialogPages::setDefaultConfig);
74 }
75 }
76 }
77
78 /**
79 * Set values in dialog from current configuration.
80 */
setConfig()81 void KdeConfigDialog::setConfig()
82 {
83 m_pages->setConfig();
84 }
85
86 /**
87 * Get values from dialog and store them in the current configuration.
88 */
getConfig() const89 void KdeConfigDialog::getConfig() const
90 {
91 m_pages->getConfig();
92 }
93
94 /**
95 * Show help.
96 */
slotHelp()97 void KdeConfigDialog::slotHelp()
98 {
99 ContextHelp::displayHelp(QLatin1String("configure-kid3"));
100 }
101
102 /**
103 * Returns whether the current state of the dialog is
104 * the same as the default configuration.
105 * @return false
106 */
isDefault()107 bool KdeConfigDialog::isDefault()
108 {
109 // The "Defaults" button shall be always enabled.
110 return false;
111 }
112