2026-10-17 03:53:51 +02:00
|
|
|
// gKeyMapper - GUI glue between the mappings file and the row widgets.
|
2026-10-17 02:57:21 +02:00
|
|
|
#ifndef GKEYMAPPER_MAPPINGS_H
|
|
|
|
|
#define GKEYMAPPER_MAPPINGS_H
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "keyrow.h"
|
2026-10-18 18:26:06 +02:00
|
|
|
#include "mapping.h"
|
2026-10-17 02:57:21 +02:00
|
|
|
|
|
|
|
|
namespace gkeymapper {
|
|
|
|
|
|
2026-10-18 18:26:06 +02:00
|
|
|
// The rows' current state, or a file's content put into the rows. Both are also
|
|
|
|
|
// what write/read use, so the widget <-> file mapping lives in one place; and a
|
|
|
|
|
// window that is rebuilt (language switch) carries the rows over this way
|
|
|
|
|
// without writing a file, so unsaved edits survive.
|
|
|
|
|
MappingSet collect_mappings(const std::vector<KeyRow>& rows);
|
|
|
|
|
void apply_mappings(const MappingSet& set, const std::vector<KeyRow>& rows);
|
|
|
|
|
|
2026-10-18 20:26:22 +02:00
|
|
|
// The same round trip as text (the mappings file format), for rows that have to
|
|
|
|
|
// leave the process: the window that replaces a running instance is given them by
|
|
|
|
|
// it (see src/singleinstance), so edits that were never saved survive a second
|
|
|
|
|
// start as well.
|
|
|
|
|
std::string mappings_text(const std::vector<KeyRow>& rows);
|
|
|
|
|
void apply_mappings_text(const std::string& text, const std::vector<KeyRow>& rows);
|
|
|
|
|
|
2026-10-17 03:53:51 +02:00
|
|
|
// Collects the current widget state and writes it to path.
|
2026-10-17 02:57:21 +02:00
|
|
|
bool write_mappings(const std::string& path, const std::vector<KeyRow>& rows);
|
|
|
|
|
|
2026-10-17 03:53:51 +02:00
|
|
|
// Loads path into the rows' widgets (type dropdown + target entry).
|
2026-10-17 02:57:21 +02:00
|
|
|
void read_mappings(const std::string& path, const std::vector<KeyRow>& rows);
|
|
|
|
|
|
|
|
|
|
} // namespace gkeymapper
|
|
|
|
|
|
|
|
|
|
#endif // GKEYMAPPER_MAPPINGS_H
|