Move static KDecorationOptions* to KDecorationOptions

No idea why it was in KDecoration in the first place, but creation
and deletion is done in KDecorationOptions. So it clearly belongs
there.
icc-effect-5.14.5
Martin Gräßlin 2013-08-24 10:59:52 +02:00
parent f0e8f5ee64
commit 9aeebb179f
2 changed files with 17 additions and 9 deletions

View File

@ -67,8 +67,6 @@ public:
QScopedPointer<QWidget> w;
};
KDecorationOptions* KDecoration::options_;
KDecoration::KDecoration(KDecorationBridge* bridge, KDecorationFactory* factory)
: d(new KDecorationPrivate(bridge, factory))
{
@ -87,7 +85,7 @@ KDecoration::~KDecoration()
const KDecorationOptions* KDecoration::options()
{
return options_;
return KDecorationOptions::self();
}
void KDecoration::createMainWidget(Qt::WindowFlags flags)
@ -541,12 +539,14 @@ QString KDecorationDefines::tabDragMimeType()
return QStringLiteral("text/ClientGroupItem");
}
KDecorationOptions* KDecorationOptions::s_self = nullptr;
KDecorationOptions::KDecorationOptions(QObject *parent)
: QObject(parent)
, d(new KDecorationOptionsPrivate(this))
{
assert(KDecoration::options_ == NULL);
KDecoration::options_ = this;
assert(s_self == nullptr);
s_self = this;
connect(this, &KDecorationOptions::activeFontChanged, this, &KDecorationOptions::fontsChanged);
connect(this, &KDecorationOptions::inactiveFontChanged, this, &KDecorationOptions::fontsChanged);
connect(this, &KDecorationOptions::smallActiveFontChanged, this, &KDecorationOptions::fontsChanged);
@ -558,11 +558,16 @@ KDecorationOptions::KDecorationOptions(QObject *parent)
KDecorationOptions::~KDecorationOptions()
{
assert(KDecoration::options_ == this);
KDecoration::options_ = NULL;
assert(s_self == this);
s_self = nullptr;
delete d;
}
KDecorationOptions* KDecorationOptions::self()
{
return s_self;
}
QColor KDecorationOptions::color(ColorType type, bool active) const
{
return(d->colors[type + (active ? 0 : NUM_COLORS)]);

View File

@ -359,6 +359,8 @@ public:
*/
WindowOperation operationMaxButtonClick(Qt::MouseButtons button) const;
static KDecorationOptions *self();
Q_SIGNALS:
/**
* @brief Emitted when at least one of the color settings changed.
@ -477,6 +479,7 @@ private:
* @internal
*/
KDecorationOptionsPrivate* d;
static KDecorationOptions *s_self;
};
@ -516,6 +519,8 @@ public:
/**
* Returns the KDecorationOptions object, which is used to access
* configuration settings for the decoration.
*
* @deprecated use KDecorationOptions::self()
*/
static const KDecorationOptions* options();
/**
@ -1156,8 +1161,6 @@ protected Q_SLOTS:
QRegion region(KDecorationDefines::Region r);
private:
friend class KDecorationOptions; // for options_
static KDecorationOptions* options_;
KDecorationPrivate* d;
};