• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/interfaces

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • interfaces
configpage.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of KDevelop
3  * Copyright 2014 Alex Richardson <[email protected]>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) version 3, or any
9  * later version accepted by the membership of KDE e.V. (or its
10  * successor approved by the membership of KDE e.V.), which shall
11  * act as a proxy defined in Section 6 of version 3 of the license.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20  */
21 #include "configpage.h"
22 
23 #include <KConfigDialogManager>
24 #include <KCoreConfigSkeleton>
25 
26 namespace KDevelop {
27 
28 class ConfigPagePrivate
29 {
30 public:
31  explicit ConfigPagePrivate(IPlugin* plugin)
32  : plugin(plugin)
33  {}
34  QScopedPointer<KConfigDialogManager> configManager;
35  KCoreConfigSkeleton* configSkeleton = nullptr;
36  IPlugin* plugin;
37 };
38 
39 ConfigPage::ConfigPage(IPlugin* plugin, KCoreConfigSkeleton* config, QWidget* parent)
40  : KTextEditor::ConfigPage(parent)
41  , d_ptr(new ConfigPagePrivate(plugin))
42 {
43  setConfigSkeleton(config);
44 }
45 
46 ConfigPage::~ConfigPage()
47 {
48 }
49 
50 void ConfigPage::apply()
51 {
52  Q_D(ConfigPage);
53 
54  // if d->configManager is null, this method must be overridden
55  Q_ASSERT_X(d->configManager, metaObject()->className(),
56  "Config page does not use a KConfigSkeleton, but doesn't override apply()");
57 
58  QSignalBlocker blockSigs(this); // we don't want to emit changed() while calling apply()
59  d->configManager->updateSettings();
60  d->configSkeleton->load();
61  d->configManager->updateWidgets();
62 }
63 
64 void ConfigPage::defaults()
65 {
66  Q_D(ConfigPage);
67 
68  // if d->configManager is null, this method must be overridden
69  Q_ASSERT_X(d->configManager, metaObject()->className(),
70  "Config page does not use a KConfigSkeleton, but doesn't override defaults()");
71  d->configManager->updateWidgetsDefault();
72 }
73 
74 void ConfigPage::reset()
75 {
76  Q_D(ConfigPage);
77 
78  // if d->configManager is null, this method must be overridden
79  Q_ASSERT_X(d->configManager, metaObject()->className(),
80  "Config page does not use a KConfigSkeleton, but doesn't override reset()");
81  d->configManager->updateWidgets();
82 }
83 
84 void ConfigPage::initConfigManager()
85 {
86  Q_D(ConfigPage);
87 
88  if (d->configManager) {
89  d->configManager->addWidget(this);
90  }
91 }
92 
93 KCoreConfigSkeleton* ConfigPage::configSkeleton() const
94 {
95  Q_D(const ConfigPage);
96 
97  return d->configSkeleton;
98 }
99 
100 void ConfigPage::setConfigSkeleton(KCoreConfigSkeleton* skel)
101 {
102  Q_D(ConfigPage);
103 
104  if (d->configSkeleton == skel) {
105  return;
106  }
107  d->configSkeleton = skel;
108  if (!skel) {
109  d->configManager.reset();
110  return;
111  }
112  // create the config dialog manager if it didn't exist or recreate it.
113  // This is needed because the used config skeleton has changed
114  // and no setter for that exists in KConfigDialogManager
115  d->configManager.reset(new KConfigDialogManager(this, d->configSkeleton));
116  connect(d->configManager.data(), &KConfigDialogManager::widgetModified, this, &ConfigPage::changed);
117  // d->configManager->addWidget(this) must be called from the config dialog,
118  // since the widget tree is probably not complete when calling this function
119 }
120 
121 
122 int ConfigPage::childPages() const
123 {
124  return 0;
125 }
126 
127 ConfigPage* ConfigPage::childPage(int number)
128 {
129  Q_UNUSED(number)
130  return nullptr;
131 }
132 
133 IPlugin* ConfigPage::plugin() const
134 {
135  Q_D(const ConfigPage);
136 
137  return d->plugin;
138 }
139 
140 ConfigPage::ConfigPageType ConfigPage::configPageType() const
141 {
142  return DefaultConfigPage;
143 }
144 
145 } // namespace KDevelop
KDevelop::ConfigPage::childPages
virtual int childPages() const
Get the number of subpages of this page.
Definition: configpage.cpp:122
QWidget
KDevelop::ConfigPage::ConfigPage
ConfigPage(IPlugin *plugin, KCoreConfigSkeleton *config=nullptr, QWidget *parent=nullptr)
Create a new config page.
Definition: configpage.cpp:39
KDevelop::ConfigPage::configSkeleton
KCoreConfigSkeleton * configSkeleton() const
Definition: configpage.cpp:93
configpage.h
KDevelop::ConfigPage::~ConfigPage
~ConfigPage() override
Definition: configpage.cpp:46
KDevelop::ConfigPage::setConfigSkeleton
void setConfigSkeleton(KCoreConfigSkeleton *skel)
Sets the config skeleton to skel and will create a KConfigDialogManager if needed.
Definition: configpage.cpp:100
KDevelop::ConfigPage::DefaultConfigPage
Definition: configpage.h:66
KDevelop::ConfigPage::initConfigManager
void initConfigManager()
Initializes the KConfigDialogManager.
Definition: configpage.cpp:84
KDevelop::ConfigPage::defaults
void defaults() override
Definition: configpage.cpp:64
KTextEditor
Definition: idocument.h:30
QScopedPointer< KConfigDialogManager >
KDevelop::ConfigPage::plugin
IPlugin * plugin() const
Definition: configpage.cpp:133
KDevelop::IPlugin
The base class for all KDevelop plugins.
Definition: iplugin.h:131
KDevelop::ConfigPage::childPage
virtual ConfigPage * childPage(int number)
Definition: configpage.cpp:127
KDevelop::ConfigPage::ConfigPageType
ConfigPageType
Definition: configpage.h:64
KDevelop::ConfigPage::apply
void apply() override
Definition: configpage.cpp:50
KDevelop
The KDevelop namespace contains all classes provided by the KDevelop platform libraries.
Definition: configpage.cpp:26
KDevelop::ConfigPage
Definition: configpage.h:35
KDevelop::ConfigPage::configPageType
virtual ConfigPageType configPageType() const
Definition: configpage.cpp:140
KDevelop::ConfigPage::reset
void reset() override
Definition: configpage.cpp:74
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Mar 3 2021 00:37:02 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/interfaces

Skip menu "kdevplatform/interfaces"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal