mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-02 09:46:38 +00:00
feat(@desktop/general): QSettings class exposed to nim
This commit is contained in:
parent
ca536cf714
commit
4d10692572
@ -1015,6 +1015,18 @@ DOS_API void dos_osnotification_delete(DosOSNotification* vptr);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region QSettings
|
||||
|
||||
DOS_API DosQSettings* dos_qsettings_create(const char* fileName, int format);
|
||||
DOS_API DosQVariant* dos_qsettings_value(DosQSettings* vptr, const char* key,
|
||||
DosQVariant* defaultValue);
|
||||
DOS_API void dos_qsettings_set_value(DosQSettings* vptr, const char* key,
|
||||
DosQVariant* value);
|
||||
DOS_API void dos_qsettings_remove(DosQSettings* vptr, const char* key);
|
||||
DOS_API void dos_qsettings_delete(DosQSettings* vptr);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
@ -89,6 +89,9 @@ typedef void DosQMetaObject;
|
||||
/// A pointer to a QObject
|
||||
typedef void DosQObject;
|
||||
|
||||
/// A pointer to a QSettings
|
||||
typedef void DosQSettings;
|
||||
|
||||
/// A pointer to a QQuickImageProvider
|
||||
typedef void DosQQuickImageProvider;
|
||||
|
||||
|
62
vendor/DOtherSide/lib/src/DOtherSide.cpp
vendored
62
vendor/DOtherSide/lib/src/DOtherSide.cpp
vendored
@ -46,6 +46,7 @@
|
||||
#include <QtQuick/QQuickView>
|
||||
#include <QtQuick/QQuickImageProvider>
|
||||
#include <QTranslator>
|
||||
#include <QSettings>
|
||||
#ifdef QT_QUICKCONTROLS2_LIB
|
||||
#include <QtQuickControls2/QQuickStyle>
|
||||
#endif
|
||||
@ -1399,6 +1400,65 @@ void dos_osnotification_delete(DosOSNotification* vptr)
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region QSettings
|
||||
|
||||
DosQSettings* dos_qsettings_create(const char* fileName, int format)
|
||||
{
|
||||
QSettings::Format fileFormat = QSettings::NativeFormat;
|
||||
if(format == 1)
|
||||
fileFormat = QSettings::IniFormat;
|
||||
|
||||
return new QSettings(QString(fileName), fileFormat);
|
||||
}
|
||||
|
||||
DosQVariant* dos_qsettings_value(DosQSettings* vptr, const char* key,
|
||||
DosQVariant* defaultValue)
|
||||
{
|
||||
auto defaultValuePtr = static_cast<QVariant*>(defaultValue);
|
||||
auto settings = static_cast<QSettings*>(vptr);
|
||||
if(settings)
|
||||
{
|
||||
if(defaultValuePtr)
|
||||
{
|
||||
auto result = new QVariant(settings->value(QString(key), *defaultValuePtr));
|
||||
return static_cast<DosQVariant*>(result);
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
void dos_qsettings_set_value(DosQSettings* vptr, const char* key,
|
||||
DosQVariant* value)
|
||||
{
|
||||
auto settings = static_cast<QSettings*>(vptr);
|
||||
if(settings)
|
||||
{
|
||||
auto valuePtr = static_cast<QVariant*>(value);
|
||||
if(valuePtr)
|
||||
{
|
||||
return settings->setValue(QString(key), *valuePtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dos_qsettings_remove(DosQSettings* vptr, const char* key)
|
||||
{
|
||||
auto settings = static_cast<QSettings*>(vptr);
|
||||
if(settings)
|
||||
{
|
||||
return settings->remove(QString(key));
|
||||
}
|
||||
}
|
||||
|
||||
void dos_qsettings_delete(DosQSettings* vptr)
|
||||
{
|
||||
auto qobject = static_cast<QObject*>(vptr);
|
||||
if(qobject)
|
||||
qobject->deleteLater();
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
char* dos_to_local_file(const char* fileUrl)
|
||||
{
|
||||
return convert_to_cstring(QUrl(QString::fromUtf8(fileUrl)).toLocalFile());
|
||||
@ -1407,4 +1467,4 @@ char* dos_to_local_file(const char* fileUrl)
|
||||
char* dos_from_local_file(const char* filePath)
|
||||
{
|
||||
return convert_to_cstring(QUrl::fromLocalFile(QString::fromUtf8(filePath)).toString());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user