chore(@desktop): Expose QTimer functions

Issue #6179
This commit is contained in:
Michal Iskierko 2022-09-27 11:00:30 +02:00 committed by Michał
parent b1823f12e5
commit b8fc19d38f
3 changed files with 84 additions and 0 deletions

View File

@ -1021,6 +1021,20 @@ DOS_API void dos_qsettings_delete(DosQSettings* vptr);
#pragma endregion
#pragma region QTimer
DOS_API DosQTimer *dos_qtimer_create();
DOS_API void dos_qtimer_delete(DosQTimer *vptr);
DOS_API void dos_qtimer_set_interval(DosQTimer *vptr, int interval);
DOS_API int dos_qtimer_interval(DosQTimer *vptr);
DOS_API void dos_qtimer_start(DosQTimer *vptr);
DOS_API void dos_qtimer_stop(DosQTimer *vptr);
DOS_API void dos_qtimer_set_single_shot(DosQTimer *vptr, bool singleShot);
DOS_API bool dos_qtimer_is_single_shot(DosQTimer *vptr);
DOS_API bool dos_qtimer_is_active(DosQTimer *vptr);
#pragma endregion
#pragma region KeychainManager exposed methods
DOS_API DosKeychainManager* dos_keychainmanager_create(const char* service,

View File

@ -92,6 +92,9 @@ typedef void DosQObject;
/// A pointer to a QSettings
typedef void DosQSettings;
/// A pointer to a QTimer
typedef void DosQTimer;
/// A pointer to a QQuickImageProvider
typedef void DosQQuickImageProvider;

View File

@ -51,6 +51,7 @@
#include <QtQuick/QQuickImageProvider>
#include <QTranslator>
#include <QSettings>
#include <QTimer>
#ifdef QT_QUICKCONTROLS2_LIB
#include <QtQuickControls2/QQuickStyle>
#endif
@ -1582,6 +1583,72 @@ void dos_qsettings_delete(DosQSettings* vptr)
}
#pragma endregion
#pragma region QTimer
DosQTimer *dos_qtimer_create()
{
return new QTimer();
}
void dos_qtimer_delete(DosQTimer *vptr)
{
auto qobject = static_cast<QObject*>(vptr);
if(qobject)
qobject->deleteLater();
}
void dos_qtimer_set_interval(DosQTimer *vptr, int interval)
{
auto timer = static_cast<QTimer*>(vptr);
if (timer) {
timer->setInterval(interval);
}
}
int dos_qtimer_interval(DosQTimer *vptr)
{
auto timer = static_cast<QTimer*>(vptr);
return timer ? timer->interval() : -1;
}
void dos_qtimer_start(DosQTimer *vptr)
{
auto timer = static_cast<QTimer*>(vptr);
if (timer) {
timer->start();
}
}
void dos_qtimer_stop(DosQTimer *vptr)
{
auto timer = static_cast<QTimer*>(vptr);
if (timer) {
timer->stop();
}
}
void dos_qtimer_set_single_shot(DosQTimer *vptr, bool singleShot)
{
auto timer = static_cast<QTimer*>(vptr);
if (timer) {
timer->setSingleShot(singleShot);
}
}
bool dos_qtimer_is_single_shot(DosQTimer *vptr)
{
auto timer = static_cast<QTimer*>(vptr);
return timer ? timer->isSingleShot() : false;
}
bool dos_qtimer_is_active(DosQTimer *vptr)
{
auto timer = static_cast<QTimer*>(vptr);
return timer ? timer->isActive() : false;
}
#pragma endregion
#pragma region KeychainManager
DosKeychainManager* dos_keychainmanager_create(const char* service,
const char* authenticationReason)