163 lines
4.8 KiB
C++
163 lines
4.8 KiB
C++
#ifndef RM_WEBVIEW2_H
|
|
#define RM_WEBVIEW2_H
|
|
|
|
#if (USE_WEBVIEW2)
|
|
|
|
#include <QDialog>
|
|
#include <QObject>
|
|
#include <QWidget>
|
|
#include <QMainWindow>
|
|
#include <QBoxLayout>
|
|
|
|
#include "../rm_app.h"
|
|
#include "../fm_event_types.h"
|
|
|
|
|
|
// 디버그 모드
|
|
#define DEBUG_WEBVIEW2 0
|
|
#define REMOVE_MAP_SWITCH_MODE 1 // 스위치로 ON/OFF 하는 모드 ->제거
|
|
//#define USE_WEBVIEW2_ORDER_VISIBLE 1
|
|
|
|
// , public QAbstractNativeEventFilter
|
|
//class QTemporaryFile;
|
|
class QFile;
|
|
class QLabel;
|
|
class RMVideoItem;
|
|
class RMSensorData;
|
|
|
|
#if (RM_MODEL == RM_MODEL_TYPE_TB4000)
|
|
//#include <QSslError>
|
|
class QNetworkReply;
|
|
#endif
|
|
|
|
#if !(TOGGLE_PLAYER || FIXED_MAP_FRAME)
|
|
class TitleWidget;
|
|
class RMWidgetDrag;
|
|
#endif // TOGGLE_PLAYER
|
|
|
|
class RMWebView : public QDialog // QMainWindow //
|
|
{
|
|
Q_OBJECT
|
|
private:
|
|
QBoxLayout* _pbox;
|
|
QWidget* _pwin; // 종료시 상위 윈도우 제거하고 webview 2 제거해야함
|
|
QWidget* snapTarget;
|
|
QString afterLoadingURL; // 실제 표시할 시점에서 로딩하도록 변경
|
|
|
|
bool _isLoaded; // 페이지 로딩 완료됨
|
|
QStringList _scripts; // 페이지 로딩 완료 후 실행할 스크립트
|
|
QFile* tempFile;
|
|
|
|
QLabel* _downloadLink; // 다운로드 페이지 표시
|
|
|
|
#if (RM_MODEL == RM_MODEL_TYPE_TB4000)
|
|
double _addressLon; // 주소 검색 좌표
|
|
double _addressLat;
|
|
int _isAddress; // 주소 검색:0 또는 행정구역 검색:1 종료:-1여부
|
|
void requestBoundary();
|
|
#endif
|
|
|
|
double lonX;
|
|
double latY;
|
|
double speed;
|
|
qint64 _lastPosition;
|
|
RMSensorData* sensor;
|
|
#if !(TOGGLE_PLAYER || FIXED_MAP_FRAME)
|
|
TitleWidget* _title;
|
|
RMWidgetDrag* _drag;
|
|
#endif
|
|
|
|
|
|
bool _hideOnFullScreen; //
|
|
//bool _bToggleFullScreen; // FULL SCREEN 모드에서 toggle 처리 시 백업
|
|
#if (LIVE_LANGUAGE_CHANGE && MODEL_STANDARD)
|
|
void refreshLanguage();
|
|
#endif
|
|
// SWITCH 로 ON OFF 하는 모드 -> 제거
|
|
#if !(REMOVE_MAP_SWITCH_MODE)
|
|
// 지도가 없는 상태에서 표시 요청할 경우 ToggleSwitch 는 true 이나 Toggle 는 false 가 되며
|
|
// updateMap 요청시 _bToggleSwitch 가 true, _bToggle 이 off 일 경우 강제 표시함
|
|
bool _bToggle; // 표시, 감추기
|
|
bool _bToggleSwitch; // toggle switch ON/OFF 상태 (_bToggle 의 경우 지도가 없는 경우 표시하지 않는 경우도 있음)
|
|
bool _bMapExist; // 지도 존재하는 상태
|
|
bool _bIsFullScreen; // 현재 FULL SCREEN 인 상태
|
|
#endif // REMOVE_SWITCH_MODE
|
|
void _loadPage(); // setVisible 에서 필요시 호출됨
|
|
void _load(QString url); // HTML 생성 및 로딩
|
|
|
|
#if (USE_GOOGLE_MAP_AND_OSM)
|
|
bool _bGoogleMap;
|
|
#endif
|
|
|
|
public:
|
|
typedef enum {
|
|
ON_FULL_SCREEN = 0,
|
|
ON_NORMAL_SCREEN = 1,
|
|
ON_UPDATE_MAP = 2,
|
|
ON_USER_SWITCH = 3,
|
|
ON_NETWORK_ON = 4,
|
|
} TOGGLE_EVENT;
|
|
static bool isWebView2Installed(); // webview2 runtime 설치되지 않은 경우
|
|
#if (USE_GOOGLE_MAP_AND_OSM)
|
|
explicit RMWebView(QWidget *parent = nullptr,bool bGoogleMap = true);
|
|
#else
|
|
explicit RMWebView(QWidget *parent = nullptr);
|
|
#endif
|
|
static RMWebView* instance(QWidget* parent = nullptr);
|
|
|
|
#if (USE_GOOGLE_MAP_AND_OSM)
|
|
static RMWebView* instance2(QWidget* parent = nullptr);
|
|
#endif // USE_GOOGLE_MAP_AND_OSM
|
|
|
|
bool isHiddenReal();
|
|
|
|
void closeWebView2();
|
|
void clearScripts();
|
|
|
|
void processMessage(QString msg);
|
|
void saveHTML(QString src);
|
|
//void removeHTML();
|
|
void runScript(QString script);
|
|
void snapTo(QWidget* target);
|
|
void resizeEvent(QResizeEvent* event) override;
|
|
|
|
#if !(REMOVE_MAP_SWITCH_MODE)
|
|
void toggle(bool bVisible,TOGGLE_EVENT event); // bool onFullScreen = false
|
|
void updateMap(bool bExist);
|
|
#endif // REMOVE_SWITCH_MODE
|
|
|
|
void setVisible(bool bVisible) override;
|
|
private:
|
|
//bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
|
|
signals:
|
|
void webviewLoading(bool done);
|
|
public slots:
|
|
//void onLoaded();
|
|
//void onStartLoad();
|
|
void onClose();
|
|
|
|
void onAppEvent(RMApp::Event event,int param);
|
|
|
|
#if (TEST_MAP_MOVE_THREAD)
|
|
void onMoveToProcess(double lon, double lat, double speed, bool drawLine);
|
|
#endif
|
|
|
|
void onPlayEvent(PLAY_EVENT event,RMVideoItem* item);
|
|
void onPositionChanged(qint64 position,qint64 duration);
|
|
|
|
#if (KMH_MPH_TOGGLE)
|
|
void onSpeedUnitChange();
|
|
#endif
|
|
|
|
#if (LIVE_LANGUAGE_CHANGE)
|
|
void onLanguageChange(RMLanguage::LANGUAGE_TYPE language);
|
|
#endif
|
|
#if (RM_MODEL == RM_MODEL_TYPE_TB4000)
|
|
void onNetworkReply(QNetworkReply* reply);
|
|
//void onSslErrors(QNetworkReply* reply, const QList<QSslError> &errors);
|
|
|
|
#endif
|
|
};
|
|
#endif // USE_WEBVIEW2
|
|
#endif // RM_WEBVIEW2_H
|