It adds a configuration setting that makes it possible to generate Q_PROPERTY instances out of each variable exposed by the configuration class. Especially useful when it comes to exposing these classes to QtQuick interfaces. REVIEW: 123367 CHANGELOG: Generate QML-proof classes using the kconfigcompilerwilder
parent
611ab289b1
commit
97552ff2ec
10 changed files with 289 additions and 61 deletions
@ -0,0 +1,34 @@ |
||||
// This file is generated by kconfig_compiler_kf5 from test13.kcfg. |
||||
// All changes you do to this file will be lost. |
||||
|
||||
#include "test13.h" |
||||
|
||||
Test13::Test13( ) |
||||
: KConfigSkeleton( QLatin1String( "muondatasourcesrc" ) ) |
||||
{ |
||||
KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&Test13::itemChanged); |
||||
|
||||
setCurrentGroup( QLatin1String( "kamoso" ) ); |
||||
|
||||
KConfigSkeleton::ItemUrl *itemPicturesDir; |
||||
itemPicturesDir = new KConfigSkeleton::ItemUrl( currentGroup(), QLatin1String( "picturesDir" ), mPicturesDir ); |
||||
addItem( itemPicturesDir, QLatin1String( "picturesDir" ) ); |
||||
KConfigCompilerSignallingItem *itemBrightness; |
||||
itemBrightness = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemDouble( currentGroup(), QLatin1String( "brightness" ), mBrightness ), this, notifyFunction, signalBrightnessChanged); |
||||
addItem( itemBrightness, QLatin1String( "brightness" ) ); |
||||
} |
||||
|
||||
Test13::~Test13() |
||||
{ |
||||
} |
||||
|
||||
|
||||
void Test13::itemChanged(quint64 flags) { |
||||
|
||||
if ( flags & signalBrightnessChanged ) { |
||||
Q_EMIT brightnessChanged(); |
||||
} |
||||
} |
||||
|
||||
#include "test13.moc" |
||||
|
||||
@ -0,0 +1,70 @@ |
||||
// This file is generated by kconfig_compiler_kf5 from test13.kcfg. |
||||
// All changes you do to this file will be lost. |
||||
#ifndef TEST13_H |
||||
#define TEST13_H |
||||
|
||||
#include <qglobal.h> |
||||
#include <kconfigskeleton.h> |
||||
#include <QCoreApplication> |
||||
#include <QDebug> |
||||
|
||||
class Test13 : public KConfigSkeleton |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
|
||||
Test13( ); |
||||
~Test13(); |
||||
|
||||
|
||||
Q_PROPERTY(QUrl picturesDir READ picturesDir CONSTANT) |
||||
/** |
||||
Get picturesDir |
||||
*/ |
||||
QUrl picturesDir() const |
||||
{ |
||||
return mPicturesDir; |
||||
} |
||||
|
||||
/** |
||||
Set brightness |
||||
*/ |
||||
void setBrightness( double v ) |
||||
{ |
||||
if (v != mBrightness && !isImmutable( QString::fromLatin1( "brightness" ) )) { |
||||
mBrightness = v; |
||||
Q_EMIT brightnessChanged(); |
||||
} |
||||
} |
||||
|
||||
Q_PROPERTY(double brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) |
||||
/** |
||||
Get brightness |
||||
*/ |
||||
double brightness() const |
||||
{ |
||||
return mBrightness; |
||||
} |
||||
|
||||
|
||||
enum { |
||||
signalBrightnessChanged = 0x1 |
||||
}; |
||||
|
||||
Q_SIGNALS: |
||||
void brightnessChanged(); |
||||
|
||||
private: |
||||
void itemChanged(quint64 flags); |
||||
|
||||
protected: |
||||
|
||||
// kamoso |
||||
QUrl mPicturesDir; |
||||
double mBrightness; |
||||
|
||||
private: |
||||
}; |
||||
|
||||
#endif |
||||
|
||||
@ -0,0 +1,11 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 |
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > |
||||
<kcfgfile name="muondatasourcesrc"/> |
||||
<group name="kamoso"> |
||||
<entry name="picturesDir" type="Url" /> |
||||
<entry name="brightness" type="double" /> |
||||
</group> |
||||
</kcfg> |
||||
@ -0,0 +1,3 @@ |
||||
ClassName=Test13 |
||||
GenerateProperties=true |
||||
Mutators=brightness |
||||
@ -0,0 +1,28 @@ |
||||
/*
|
||||
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
#include "test13.h" |
||||
|
||||
int main(int, char **) |
||||
{ |
||||
Test13 *t = new Test13(); |
||||
delete t; |
||||
return 0; |
||||
} |
||||
Loading…
Reference in new issue