Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
utility.h
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
#pragma once
17
#include <QObject>
18
#include <QString>
19
20
class
QQmlContext;
21
class
QQmlEngine;
22
23
#include "
./common_autoport.h
"
24
25
class
Random
;
26
45
class
COMMON_AUTOPORT
Utility :
public
QObject
46
{
47
Q_OBJECT
48
Q_PROPERTY(
Random
*
random
READ
random
CONSTANT)
49
50
public
:
52
static
Utility*
inst
();
53
55
Random
*
random
();
56
65
Q_INVOKABLE
const
QString
encodeBeforeUrl
(
const
QString beforeStr)
const
;
71
Q_INVOKABLE
const
QString
decodeAfterUrl
(QString beforeStr)
const
;
72
73
// Generic utility for any of the databases to use
83
static
void
qmlProtectUtil
(
const
QObject*
const
obj,
const
QQmlEngine*
const
engine);
84
85
public
slots:
90
void
qmlProtect
(
const
QQmlEngine*
const
engine)
const
;
95
void
qmlHook
(QQmlContext*
const
context)
const
;
96
97
private
slots:
99
void
qmlRegister()
const
;
100
101
private
:
103
Utility();
104
};
Random
Project-wide source of randomness, usable from both C++ and QML.
Definition
random.h:50
Utility::decodeAfterUrl
const QString decodeAfterUrl(QString beforeStr) const
Decode the space-separated hex produced by encodeBeforeUrl() back to text.
Definition
utility.cpp:57
Utility::qmlProtectUtil
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
Utility::inst
static Utility * inst()
< The shared Random instance, reachable from QML as pseCommon.random.
Definition
utility.cpp:31
Utility::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Protect this Utility (and the Random it owns) from QML GC.
Definition
utility.cpp:69
Utility::random
Random * random()
Accessor for the shared Random singleton (also backs the random property).
Definition
utility.cpp:37
Utility::qmlHook
void qmlHook(QQmlContext *const context) const
Install this object into a QML context as the pseCommon property.
Definition
utility.cpp:76
Utility::encodeBeforeUrl
const QString encodeBeforeUrl(const QString beforeStr) const
Encode a string into space-separated hex of each character's code point.
Definition
utility.cpp:44
common_autoport.h
Shared-library import/export macro for the common library.
COMMON_AUTOPORT
#define COMMON_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition
common_autoport.h:38
projects
common
src
pse-common
utility.h
Generated by
1.17.0