Skip to content
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
fontkeyboard.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 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#include <QStringList>
20#include <QVariantList>
21#include <QVariantMap>
22
64class FontKeyboard : public QObject
65{
66 Q_OBJECT
67
68 Q_PROPERTY(int page READ getPage WRITE setPage NOTIFY pageChanged)
69 Q_PROPERTY(QStringList pageNames READ getPageNames CONSTANT)
70 Q_PROPERTY(QVariantList pageOrder READ getPageOrder CONSTANT)
71 Q_PROPERTY(int pageCount READ getPageCount CONSTANT)
72
73public:
81 Q_ENUM(Render)
82
83
93 Q_ENUM(Category)
94
95 explicit FontKeyboard(QObject* parent = nullptr);
96
97 static constexpr int pageTotal = 8;
101 static constexpr int keyTotal = 47;
102
103 int getPage() const;
104 void setPage(int val);
105 QStringList getPageNames() const;
106 QVariantList getPageOrder() const;
107 int getPageCount() const;
108
110 Q_INVOKABLE static QStringList keyLabels();
111
113 Q_INVOKABLE static int pageFor(bool shift, bool ctrl, bool alt);
114
121 Q_INVOKABLE static int effectivePage(bool shift, bool ctrl, bool alt, bool caps);
122
124 Q_INVOKABLE QVariantMap keyDataFor(const QString& key,
125 bool shift, bool ctrl, bool alt, bool caps) const;
126
128 Q_INVOKABLE static QString pageBadge(int page);
129
131 Q_INVOKABLE static int indFor(int page, const QString& key);
132
141 Q_INVOKABLE static QString naturalChar(const QString& key, bool shift);
142
144 Q_INVOKABLE static QString pageDescription(int page);
145
149 Q_INVOKABLE QVariantMap keyData(int page, const QString& key) const;
150
152 Q_INVOKABLE QVariantMap spaceData() const;
153
156 Q_INVOKABLE static QString chopLastToken(const QString& str);
157
158signals:
160
161private:
164 QVariantMap dataForInd(int ind, const QString& key, int page) const;
165
166 int page = 0;
167};
static QString pageDescription(int page)
The quiet line under the deck saying what this page is.
static int indFor(int page, const QString &key)
The font code on key of page, or 0 when that key is empty.
static QString chopLastToken(const QString &str)
Drop the last whole token off a code string – "RED<player>" -> "RED".
static int effectivePage(bool shift, bool ctrl, bool alt, bool caps)
Assignable keys per page: 26 letters + 10 digits + the 11 punctuation keys ( - = [ ] \ ; ' ,...
Render
< Current page = its modifier mask, 0-7.
@ RenderEmpty
No tile on this key.
@ RenderLabel
Control code: no glyph at all, so the cap shows its name.
@ RenderTile
A single 8x8 tile, clipped from the shared animated sheet.
@ RenderPreview
Multi-char/variable: render the expanded text (<poke> -> "Poke").
QVariantMap keyDataFor(const QString &key, bool shift, bool ctrl, bool alt, bool caps) const
keyData() for the page this key actually reads. What the deck binds to.
Category
Tile category. Order matches the old filter strip = the usage order.
protected::void pageChanged()
FontKeyboard(QObject *parent=nullptr)
static QString naturalChar(const QString &key, bool shift)
What a REAL keyboard (US layout) types for key with/without Shift – "a"/"A", "1"/"!...
static constexpr int pageTotal
Modifier combos: none/S/C/A/SC/SA/CA/SCA.
QVariantMap spaceData() const
The same map for the spacebar (the Space tile lives there, not on a letter).
static QString pageBadge(int page)
The modifier badge for a page, e.g. "" / "Shift" / "Ctrl+Alt".
QVariantMap keyData(int page, const QString &key) const
Everything a keycap needs: { ind, code, title, tip, category, render, empty, natural }...