1 | |
2 | /* |
3 | * kcontrolmodule_example.cpp |
4 | * |
5 | * Copyright (C) 2010 David Hubner <hubnerd@ntlworld.com> |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | * |
21 | */ |
22 | |
23 | #include "kcontrolmodule_example.h" |
24 | |
25 | /* |
26 | Register and Export the plugin |
27 | */ |
28 | K_PLUGIN_FACTORY(KControlModuleExampleFactory, registerPlugin<KControlModuleExample>();) |
29 | K_EXPORT_PLUGIN(KControlModuleExampleFactory("kcontrolmoduleexample" )) |
30 | |
31 | KControlModuleExample::KControlModuleExample(QWidget *parent, const QVariantList &args) : |
32 | KCModule(KControlModuleExampleFactory::componentData(),parent) |
33 | { |
34 | |
35 | // We do not use args in this example, so set unused so compiler does not display warning. |
36 | Q_UNUSED(args); |
37 | |
38 | // Set KInfoCenter About Data |
39 | const KAboutData *about = |
40 | new KAboutData(I18N_NOOP("KInfoCenterExample" ), 0, ki18n("KInfoCenter Example" ),"0.01" , |
41 | KLocalizedString(), KAboutData::License_GPL, ki18n("(c) 2010 David Hubner" )); |
42 | |
43 | setAboutData(about); |
44 | |
45 | // Create display |
46 | createDisplay(this); |
47 | |
48 | // Set Buttons |
49 | // There are NoAdditionalButton, Help, Default, Apply and Export |
50 | // |
51 | // NoAdditionalButton - No buttons |
52 | // Help - Display Help Button |
53 | // Default - Help and Apply are displayed |
54 | // Apply - Display Apply button, Not used in KInfoCenter |
55 | // Export - Display Export button, Not used in System Settings |
56 | setButtons(Help); |
57 | } |
58 | |
59 | /* |
60 | Create a label at the top the KCM |
61 | */ |
62 | void KControlModuleExample::createDisplay(QWidget *parent) |
63 | { |
64 | QWidget *maindisplay = new QWidget(parent); |
65 | QVBoxLayout *layout = new QVBoxLayout(maindisplay); |
66 | |
67 | m_exampleLabel = new QLabel(i18nc("Example Label" ,"Here is the Label" )); |
68 | layout->addWidget(m_exampleLabel); |
69 | } |
70 | |
71 | /* |
72 | Set the export of information, this sets the information returned |
73 | when the export button is pressed. Only in KInfoCenter, Needs KDE 4.5 |
74 | */ |
75 | void KControlModuleExample::exportInformation() |
76 | { |
77 | setExportText(m_exampleLabel->text()); |
78 | } |
79 | |
80 | |
81 | |