mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
core: make command texts available for C code
Create a C string (which the caller needs to free) with the executed commands in this session. The detour via the callback allows us to not make the corelib depend on the commands, which is nice for tests, export-html, and smtk2ssrf. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
626a149b7c
commit
160d2ab071
3 changed files with 19 additions and 2 deletions
|
@ -8,10 +8,14 @@ namespace Command {
|
||||||
|
|
||||||
static QUndoStack undoStack;
|
static QUndoStack undoStack;
|
||||||
|
|
||||||
|
// forward declaration
|
||||||
|
QString changesMade();
|
||||||
|
|
||||||
// General commands
|
// General commands
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
QObject::connect(&undoStack, &QUndoStack::cleanChanged, &updateWindowTitle);
|
QObject::connect(&undoStack, &QUndoStack::cleanChanged, &updateWindowTitle);
|
||||||
|
changesCallback = &changesMade;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
|
|
|
@ -46,7 +46,7 @@ static QLocale loc;
|
||||||
|
|
||||||
static inline QString degreeSigns()
|
static inline QString degreeSigns()
|
||||||
{
|
{
|
||||||
return QStringLiteral("dD\u00b0");
|
return QStringLiteral("dD\u00b0");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString weight_string(int weight_in_grams)
|
QString weight_string(int weight_in_grams)
|
||||||
|
@ -1644,3 +1644,14 @@ char *copy_qstring(const QString &s)
|
||||||
{
|
{
|
||||||
return strdup(qPrintable(s));
|
return strdup(qPrintable(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function to call to get changes for a git commit
|
||||||
|
QString (*changesCallback)() = nullptr;
|
||||||
|
|
||||||
|
extern "C" char *get_changes_made()
|
||||||
|
{
|
||||||
|
if (changesCallback != nullptr)
|
||||||
|
return copy_qstring(changesCallback());
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -83,6 +83,8 @@ QVector<QPair<QString, int>> selectedDivesGasUsed();
|
||||||
QString getUserAgent();
|
QString getUserAgent();
|
||||||
QString printGPSCoords(const location_t *loc);
|
QString printGPSCoords(const location_t *loc);
|
||||||
|
|
||||||
|
extern QString (*changesCallback)();
|
||||||
|
|
||||||
#if defined __APPLE__
|
#if defined __APPLE__
|
||||||
#define TITLE_OR_TEXT(_t, _m) "", _t + "\n" + _m
|
#define TITLE_OR_TEXT(_t, _m) "", _t + "\n" + _m
|
||||||
#else
|
#else
|
||||||
|
@ -150,7 +152,7 @@ depth_t string_to_depth(const char *str);
|
||||||
pressure_t string_to_pressure(const char *str);
|
pressure_t string_to_pressure(const char *str);
|
||||||
volume_t string_to_volume(const char *str, pressure_t workp);
|
volume_t string_to_volume(const char *str, pressure_t workp);
|
||||||
fraction_t string_to_fraction(const char *str);
|
fraction_t string_to_fraction(const char *str);
|
||||||
|
char *get_changes_made();
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue