|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
Grab-bag of shared helpers, and the QML entry point for the common layer. More...
#include <utility.h>
Public Member Functions | |
| Random * | random () |
Accessor for the shared Random singleton (also backs the random property). | |
| const QString | encodeBeforeUrl (const QString beforeStr) const |
| Encode a string into space-separated hex of each character's code point. | |
| const QString | decodeAfterUrl (QString beforeStr) const |
| Decode the space-separated hex produced by encodeBeforeUrl() back to text. | |
| void | qmlProtect (const QQmlEngine *const engine) const |
| Protect this Utility (and the Random it owns) from QML GC. | |
| void | qmlHook (QQmlContext *const context) const |
| Install this object into a QML context as the pseCommon property. | |
Static Public Member Functions | |
| static Utility * | inst () |
| < The shared Random instance, reachable from QML as pseCommon.random. | |
| static void | qmlProtectUtil (const QObject *const obj, const QQmlEngine *const engine) |
Pin obj to C++ ownership so the QML engine never garbage-collects it. | |
Grab-bag of shared helpers, and the QML entry point for the common layer.
Utility is a QObject singleton exposed to QML under the context name pseCommon. Through it, QML reaches the shared Random instance (pseCommon.random) and a couple of string helpers used by the name editors.
It also hosts qmlProtectUtil() - the one-liner every database and save object in the project calls to keep its C++ QObjects from being garbage-collected by the QML engine. Centralising that here means there is exactly one place that knows the GC-ownership incantation.
| const QString Utility::decodeAfterUrl | ( | QString | beforeStr | ) | const |
Decode the space-separated hex produced by encodeBeforeUrl() back to text.
| beforeStr | The encoded hex string (spaces are stripped before decoding). |
Definition at line 57 of file utility.cpp.
Referenced by FontPreviewInstance::getInputStr(), and FontPreviewInstance::setup().
| const QString Utility::encodeBeforeUrl | ( | const QString | beforeStr | ) | const |
Encode a string into space-separated hex of each character's code point.
Used to pass arbitrary name text safely through a URL/route fragment.
| beforeStr | The text to encode. |
Definition at line 44 of file utility.cpp.
|
static |
< The shared Random instance, reachable from QML as pseCommon.random.
Returns the process-wide Utility singleton, constructing it on first call.
Definition at line 31 of file utility.cpp.
Referenced by FontPreviewInstance::getInputStr(), and FontPreviewInstance::setup().
| void Utility::qmlHook | ( | QQmlContext *const | context | ) | const |
Install this object into a QML context as the pseCommon property.
| context | The QML context to inject into. |
Definition at line 76 of file utility.cpp.
| void Utility::qmlProtect | ( | const QQmlEngine *const | engine | ) | const |
Protect this Utility (and the Random it owns) from QML GC.
| engine | The active QML engine. |
Definition at line 69 of file utility.cpp.
References Random::inst(), Random::qmlProtect(), and qmlProtectUtil().
|
static |
Pin obj to C++ ownership so the QML engine never garbage-collects it.
The shared building block behind every qmlProtect() in the project. Static so any class can call it without a Utility instance.
| obj | The C++ QObject to protect (kept alive on the C++ side). |
| engine | The QML engine that would otherwise claim ownership. |
Definition at line 63 of file utility.cpp.
Referenced by AbstractHiddenItemDB::qmlProtect(), AbstractRandomString::qmlProtect(), CreditDBEntry::qmlProtect(), CreditsDB::qmlProtect(), DB::qmlProtect(), EventDBEntry::qmlProtect(), EventPokemonDB::qmlProtect(), EventPokemonDBEntry::qmlProtect(), EventsDB::qmlProtect(), Examples::qmlProtect(), FlyDB::qmlProtect(), FlyDBEntry::qmlProtect(), FontDBEntry::qmlProtect(), FontsDB::qmlProtect(), FontSearch::qmlProtect(), GameCornerDB::qmlProtect(), GameCornerDBEntry::qmlProtect(), GameData::qmlProtect(), HiddenItemDBEntry::qmlProtect(), ItemDBEntry::qmlProtect(), ItemsDB::qmlProtect(), MapDBEntry::qmlProtect(), MapDBEntryConnect::qmlProtect(), MapDBEntrySign::qmlProtect(), MapDBEntrySprite::qmlProtect(), MapDBEntryWarpIn::qmlProtect(), MapDBEntryWarpOut::qmlProtect(), MapDBEntryWildMon::qmlProtect(), MapsDB::qmlProtect(), MapSearch::qmlProtect(), MissableDBEntry::qmlProtect(), MissablesDB::qmlProtect(), MovesDB::qmlProtect(), MusicDB::qmlProtect(), Names::qmlProtect(), PokemonDB::qmlProtect(), Random::qmlProtect(), ScriptsDB::qmlProtect(), SpritesDB::qmlProtect(), SpriteSetDB::qmlProtect(), StarterPokemonDB::qmlProtect(), TilesetDB::qmlProtect(), TmHmsDB::qmlProtect(), TradesDB::qmlProtect(), TrainersDB::qmlProtect(), TypesDB::qmlProtect(), and qmlProtect().
| Random * Utility::random | ( | ) |
Accessor for the shared Random singleton (also backs the random property).
Definition at line 37 of file utility.cpp.
References Random::inst().