File: dplatformnativeinterface.cpp

package info (click to toggle)
dtkgui 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,340 kB
  • sloc: cpp: 19,512; ansic: 34; makefile: 15; sh: 15
file content (59 lines) | stat: -rw-r--r-- 1,520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "dtkgui_global.h"
#include "dplatformnativeinterface.h"
#include "dummysettings.h"
#include "ddynamicmetaobject.h"

#include <QColor>
#include <QDebug>
#include <QGuiApplication>

DGUI_USE_NAMESPACE

static bool buildNativeSettings(QObject *object, quint32 /*settingWindow*/)
{
    if (!qApp)
        return false;

    static QPair<QByteArray, QVariant> kvs[] = {
        {"Net/ThemeName", "deepin"},
        {"Qt/ActiveColor", QColor(Qt::red)},
        {"Net/IconThemeName", "bloom"},
        {"DTK/WindowRadius", 18}
    };

    QString domain = object->property("_d_domain").toByteArray();
    domain.replace("/", "_");
    auto settings = new DummySettings(domain);

    for (auto pair : kvs) {
        settings->setSetting(pair.first, pair.second);
    }

     // set object.metaobject to this, destroyed with object destroyed...
    DDynamicMetaObject *mj = new DDynamicMetaObject(object, settings, false);

    if (!mj->isValid()) {
        delete mj;
        return false;
    }

    return true;
}

DPlatformNativeInterface::DPlatformNativeInterface()
    :QPlatformNativeInterface()
{

}

QFunctionPointer DPlatformNativeInterface::platformFunction(const QByteArray &function) const
{
    if (!function.compare("_d_buildNativeSettings"))
        return reinterpret_cast<QFunctionPointer>(buildNativeSettings);

    return QPlatformNativeInterface::platformFunction(function);
}