Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
shortcutdefs.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
31
32
#include <QHash>
33
#include <QString>
34
#include <QKeySequence>
35
#include <Qt>
36
#include <functional>
37
38
#include <
pse-savefile/filemanagement.h
>
39
#include <
pse-savefile/savefile.h
>
40
41
namespace
pse
{
42
45
inline
QHash<QString, QKeySequence>
shortcutKeyMap
()
46
{
47
return
{
48
{ QStringLiteral(
"new"
), QKeySequence(Qt::CTRL | Qt::Key_N) },
49
{ QStringLiteral(
"open"
), QKeySequence(Qt::CTRL | Qt::Key_O) },
50
{ QStringLiteral(
"reopen"
), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_O) },
51
{ QStringLiteral(
"save"
), QKeySequence(Qt::CTRL | Qt::Key_S) },
52
{ QStringLiteral(
"saveas"
), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_S) },
53
{ QStringLiteral(
"savecopyas"
), QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_S) },
54
{ QStringLiteral(
"scrub"
), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_W) },
55
{ QStringLiteral(
"clear-recentfiles"
), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Minus) },
56
{ QStringLiteral(
"exit"
), QKeySequence(Qt::CTRL | Qt::Key_Q) },
57
{ QStringLiteral(
"exit2"
), QKeySequence(Qt::ALT | Qt::Key_F4) },
58
{ QStringLiteral(
"random"
), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_R) },
59
};
60
}
61
64
inline
QKeySequence
recentFileShortcutKey
(
int
i)
65
{
66
return
QKeySequence(Qt::CTRL | Qt::SHIFT |
static_cast<
Qt::Key
>
(0x30 + i));
67
}
68
75
inline
QHash<QString, std::function<void()>>
shortcutActions
(
FileManagement
* file,
76
std::function<
void
()> onExit)
77
{
78
return
{
79
{ QStringLiteral(
"new"
), [file]{ file->
newFile
(); } },
80
{ QStringLiteral(
"open"
), [file]{ file->
openFile
(); } },
81
{ QStringLiteral(
"reopen"
), [file]{ file->
reopenFile
(); } },
82
{ QStringLiteral(
"save"
), [file]{ file->
saveFile
(); } },
83
{ QStringLiteral(
"saveas"
), [file]{ file->
saveFileAs
(); } },
84
{ QStringLiteral(
"savecopyas"
), [file]{ file->
saveFileCopy
(); } },
85
{ QStringLiteral(
"scrub"
), [file]{ file->
wipeUnusedSpace
(); } },
86
{ QStringLiteral(
"clear-recentfiles"
), [file]{ file->
clearRecentFiles
(); } },
87
{ QStringLiteral(
"exit"
), [onExit]{
if
(onExit) onExit(); } },
88
{ QStringLiteral(
"exit2"
), [onExit]{
if
(onExit) onExit(); } },
89
{ QStringLiteral(
"random"
), [file]{ file->
data
->
randomizeExpansion
(); } },
90
};
91
}
92
93
}
// namespace pse
FileManagement
Owns the on-disk side of a save: the current path, the recent-files list, and the live SaveFile.
Definition
filemanagement.h:46
FileManagement::newFile
void newFile()
Start a fresh blank save.
Definition
filemanagement.cpp:91
FileManagement::clearRecentFiles
void clearRecentFiles()
Forget the entire recent-files list.
Definition
filemanagement.cpp:255
FileManagement::data
SaveFile * data
The live save file these operations load into / save from.
Definition
filemanagement.h:72
FileManagement::saveFileAs
bool saveFileAs()
Prompt for a new path and save there.
Definition
filemanagement.cpp:227
FileManagement::wipeUnusedSpace
void wipeUnusedSpace()
Zero out save regions that aren't meaningfully used.
Definition
filemanagement.cpp:250
FileManagement::reopenFile
void reopenFile()
Reload the current path from disk, discarding edits.
Definition
filemanagement.cpp:125
FileManagement::saveFile
bool saveFile()
Save to the current path.
Definition
filemanagement.cpp:216
FileManagement::saveFileCopy
bool saveFileCopy()
Save a copy elsewhere without changing the active path.
Definition
filemanagement.cpp:239
FileManagement::openFile
bool openFile()
Prompt for and open a save.
Definition
filemanagement.cpp:97
SaveFile::randomizeExpansion
void randomizeExpansion()
Fully randomizes the expansion data, doesn't change save file data.
Definition
savefile.cpp:104
filemanagement.h
pse
Definition
shortcutdefs.h:41
pse::shortcutKeyMap
QHash< QString, QKeySequence > shortcutKeyMap()
Named global shortcuts: action id -> key sequence.
Definition
shortcutdefs.h:45
pse::shortcutActions
QHash< QString, std::function< void()> > shortcutActions(FileManagement *file, std::function< void()> onExit)
What each named shortcut DOES, action id -> callable, over a live FileManagement.
Definition
shortcutdefs.h:75
pse::recentFileShortcutKey
QKeySequence recentFileShortcutKey(int i)
Recent-file shortcut i (0..MAX_RECENT_FILES-1) == Ctrl+Shift+(0+i), i.e.
Definition
shortcutdefs.h:64
savefile.h
projects
app
src
boot
shortcutdefs.h
Generated by
1.17.0