Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
fontdbentry.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16
21
22#include <QQmlEngine>
23#include <pse-common/utility.h>
24#include "fontdbentry.h"
25
29
31{
32 return normal;
33}
34
35void FontDBEntry::qmlProtect(const QQmlEngine* const engine) const
36{
37 Utility::qmlProtectUtil(this, engine);
38}
39
41{
42 return singleChar;
43}
44
46{
47 return variable;
48}
49
51{
52 return multiChar;
53}
54
56{
57 return control;
58}
59
60const QString FontDBEntry::getTip() const
61{
62 return tip;
63}
64
65const QString FontDBEntry::getAlias() const
66{
67 return alias;
68}
69
71{
72 return length;
73}
74
76{
77 return picture;
78}
79
81{
82 return shorthand;
83}
84
85const QString FontDBEntry::getName() const
86{
87 return name;
88}
89
91{
92 return ind;
93}
94FontDBEntry::FontDBEntry(const QJsonValue& data) {
96
97 // Set simple properties
98 name = data["name"].toString();
99 ind = data["ind"].toDouble();
100 length = data["length"].toDouble();
101
102 // Set simple optional properties
103 if(data["shorthand"].isBool())
104 shorthand = data["shorthand"].toBool();
105
106 if(data["picture"].isBool())
107 picture = data["picture"].toBool();
108
109 alias = data["alias"].toString("");
110 tip = data["tip"].toString("");
111
112 if(data["control"].isBool())
113 control = data["control"].toBool();
114
115 if(data["multiChar"].isBool())
116 multiChar = data["multiChar"].toBool();
117
118 if(data["variable"].isBool())
119 variable = data["variable"].toBool();
120
121 if(data["singleChar"].isBool())
122 singleChar = data["singleChar"].toBool();
123
124 if(data["normal"].isBool())
125 normal = data["normal"].toBool();
126}
127
129{
130 static bool once = false;
131 if(once)
132 return;
133
134 qmlRegisterUncreatableType<FontDBEntry>(
135 "PSE.DB.FontDBEntry", 1, 0, "FontDBEntry", "Can't instantiate in QML");
136 once = true;
137}
static void qmlProtectUtil(const QObject *const obj, const QQmlEngine *const engine)
Pin obj to C++ ownership so the QML engine never garbage-collects it.
Definition utility.cpp:63
bool singleChar
Definition fontdbentry.h:93
bool getPicture() const
void qmlRegister() const
Register with QML.
const QString getTip() const
int getInd() const
< Font code.
bool getControl() const
QString alias
Definition fontdbentry.h:88
QString name
Definition fontdbentry.h:84
const QString getName() const
int getLength() const
bool getNormal() const
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
bool getSingleChar() const
bool getMultiChar() const
FontDBEntry()
Empty entry (built by FontsDB).
bool getVariable() const
const QString getAlias() const
QString tip
Definition fontdbentry.h:89
bool getShorthand() const