/
erhoof
/
telegraf
Обзор
Документация
Войти
/
erhoof
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/util/telegrafutils.h
61 строка
2 KB
mbarashkov
Рефакторино части зависимостей qml
04 июн 2025, 13:53
04 июн 2025, 13:53
c8e186b
Код
Авторство
О чём код?
#pragma once #include <QObject> #include <QAudioRecorder> #include <QGeoPositionInfo> #include <QGeoPositionInfoSource> #include <QNetworkAccessManager> #include "../tdlib/tdlibresponsehandler.h" class TelegrafUtils : public QObject { Q_OBJECT public: explicit TelegrafUtils(QObject *parent = nullptr); ~TelegrafUtils(); static QObject* createSingleton(QQmlEngine*, QJSEngine*) { return new TelegrafUtils(); } enum VoiceNoteRecordingState { Unavailable, Ready, Starting, Recording, Stopping }; Q_ENUM(VoiceNoteRecordingState) static QString getMessageShortText(TDLibDataRepository *tdLibDataRepository, const QVariantMap &messageContent, const bool isChannel, const qlonglong currentUserId, const QVariantMap &messageSender); static QString getUserName(const QVariantMap &userInformation); Q_INVOKABLE void startRecordingVoiceNote(); Q_INVOKABLE void stopRecordingVoiceNote(); Q_INVOKABLE QString voiceNotePath(); Q_INVOKABLE TelegrafUtils::VoiceNoteRecordingState getVoiceNoteRecordingState(); Q_INVOKABLE void startGeoLocationUpdates(); Q_INVOKABLE void stopGeoLocationUpdates(); Q_INVOKABLE bool supportsGeoLocation(); Q_INVOKABLE QString getOSVersion(); Q_INVOKABLE void initiateReverseGeocode(double latitude, double longitude); signals: void voiceNoteDurationChanged(qlonglong duration); void voiceNoteRecordingStateChanged(TelegrafUtils::VoiceNoteRecordingState state); void newPositionInformation(const QVariantMap &positionInformation); void newGeocodedAddress(const QString &geocodedAddress); private slots: void handleAudioRecorderStatusChanged(QMediaRecorder::Status status); void handleGeoPositionUpdated(const QGeoPositionInfo &info); void handleReverseGeocodeFinished(); private: QAudioRecorder audioRecorder; VoiceNoteRecordingState voiceNoteRecordingState; QGeoPositionInfoSource *geoPositionInfoSource; QNetworkAccessManager *manager; void cleanUp(); QString getTemporaryDirectoryPath(); };