mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-23 23:21:08 +01:00
Weather: Show "Reload" link when data fails to load
This commit is contained in:
parent
5093e7de37
commit
dbdc1b80f8
@ -69,7 +69,7 @@ DEFINE_GUID(IID_IEPWeather,
|
||||
#define EP_WEATHER_WM_SETDEVMODE (WM_USER + 13)
|
||||
#define EP_WEATHER_WM_SETZOOMFACTOR (WM_USER + 14)
|
||||
|
||||
#define EP_WEATHER_HEIGHT_ERROR 260
|
||||
#define EP_WEATHER_HEIGHT_ERROR 280
|
||||
#define EP_WEATHER_HEIGHT 353
|
||||
#define EP_WEATHER_WIDTH 673
|
||||
|
||||
|
@ -19,6 +19,24 @@ body {\n\
|
||||
justify-content: center;\n\
|
||||
align-items: center;\n\
|
||||
}\n\
|
||||
@media (prefers-color-scheme: dark) {\n\
|
||||
.refreshLink { color: #43a7ff; }\n\
|
||||
}\n\
|
||||
@media (prefers-color-scheme: light) {\n\
|
||||
.refreshLink { color: #096bda; }\n\
|
||||
}\n\
|
||||
a:link {\n\
|
||||
text-decoration: none;\n\
|
||||
}\n\
|
||||
a:visited {\n\
|
||||
text-decoration: none;\n\
|
||||
}\n\
|
||||
a:hover {\n\
|
||||
text-decoration: underline;\n\
|
||||
}\n\
|
||||
a:active {\n\
|
||||
text-decoration: underline;\n\
|
||||
}\n\
|
||||
</style>\n\
|
||||
</head>\n\
|
||||
<body><center>\n\
|
||||
@ -26,6 +44,7 @@ body {\n\
|
||||
<h2>Unable to load weather information</h2>\n\
|
||||
<p>Make sure that the location you have entered is correct.<br/>\n\
|
||||
Verify that you are connected to the Internet.</p>\n\
|
||||
<a class=\"refreshLink\" href=\"epweather://refresh\">Reload</a>\n\
|
||||
</center></body>\n\
|
||||
</html>";
|
||||
#endif
|
||||
|
@ -351,9 +351,9 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2ControllerCompleted(IC
|
||||
LONG64 dwDarkMode = InterlockedAdd64(&_this->g_darkModeEnabled, 0);
|
||||
epw_Weather_SetDarkMode(_this, dwDarkMode, FALSE);
|
||||
|
||||
_this->pCoreWebView2->lpVtbl->add_PermissionRequested(_this->pCoreWebView2, &EPWeather_ICoreWebView2PermissionRequestedEventHandler, &_this->tkOnPermissionRequested);
|
||||
|
||||
_this->pCoreWebView2->lpVtbl->add_NavigationStarting(_this->pCoreWebView2, &EPWeather_ICoreWebView2NavigationStartingEventHandler, &_this->tkOnNavigationStarting);
|
||||
_this->pCoreWebView2->lpVtbl->add_NavigationCompleted(_this->pCoreWebView2, &EPWeather_ICoreWebView2NavigationCompletedEventHandler, &_this->tkOnNavigationCompleted);
|
||||
_this->pCoreWebView2->lpVtbl->add_PermissionRequested(_this->pCoreWebView2, &EPWeather_ICoreWebView2PermissionRequestedEventHandler, &_this->tkOnPermissionRequested);
|
||||
|
||||
_epw_Weather_NavigateToProvider(_this);
|
||||
|
||||
@ -384,8 +384,28 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_CallDevToolsProtocolMethodCompleted(ICor
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationStarting(ICoreWebView2NavigationStartingEventHandler* _this2, ICoreWebView2* pCoreWebView2, ICoreWebView2NavigationStartingEventArgs* pCoreWebView2NavigationStartingEventArgs)
|
||||
{
|
||||
EPWeather* _this = EPWeather_Instance; // GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
LPWSTR wszUri = NULL;
|
||||
pCoreWebView2NavigationStartingEventArgs->lpVtbl->get_Uri(pCoreWebView2NavigationStartingEventArgs, &wszUri);
|
||||
if (wszUri)
|
||||
{
|
||||
if (!_wcsicmp(wszUri, L"epweather://refresh"))
|
||||
{
|
||||
pCoreWebView2NavigationStartingEventArgs->lpVtbl->put_Cancel(pCoreWebView2NavigationStartingEventArgs, TRUE);
|
||||
PostMessageW(_this->hWnd, EP_WEATHER_WM_FETCH_DATA, 0, 0);
|
||||
}
|
||||
CoTaskMemFree(wszUri);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationCompleted(ICoreWebView2NavigationCompletedEventHandler* _this2, ICoreWebView2* pCoreWebView2, ICoreWebView2NavigationCompletedEventArgs* pCoreWebView2NavigationCompletedEventArgs)
|
||||
{
|
||||
COREWEBVIEW2_WEB_ERROR_STATUS dwStatus = COREWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN;
|
||||
pCoreWebView2NavigationCompletedEventArgs->lpVtbl->get_WebErrorStatus(pCoreWebView2NavigationCompletedEventArgs, &dwStatus);
|
||||
if (dwStatus == COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED) return S_OK;
|
||||
AcquireSRWLockShared(&Lock_EPWeather_Instance);
|
||||
EPWeather* _this = EPWeather_Instance; // GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
BOOL bIsSuccess = FALSE;
|
||||
@ -1375,6 +1395,10 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this)
|
||||
|
||||
cleanup:
|
||||
|
||||
if (_this->tkOnNavigationStarting.value)
|
||||
{
|
||||
_this->pCoreWebView2->lpVtbl->remove_NavigationStarting(_this->pCoreWebView2, _this->tkOnNavigationStarting);
|
||||
}
|
||||
if (_this->tkOnNavigationCompleted.value)
|
||||
{
|
||||
_this->pCoreWebView2->lpVtbl->remove_NavigationCompleted(_this->pCoreWebView2, _this->tkOnNavigationCompleted);
|
||||
|
@ -78,6 +78,7 @@ typedef interface EPWeather
|
||||
ITaskbarList* pTaskList;
|
||||
ICoreWebView2Controller* pCoreWebView2Controller;
|
||||
ICoreWebView2* pCoreWebView2;
|
||||
EventRegistrationToken tkOnNavigationStarting;
|
||||
EventRegistrationToken tkOnNavigationCompleted;
|
||||
EventRegistrationToken tkOnPermissionRequested;
|
||||
RECT rc;
|
||||
@ -168,6 +169,7 @@ HRESULT STDMETHODCALLTYPE epw_Weather_static_QueryInterface(EPWeather* _this, RE
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2EnvironmentCompleted(ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler* _this, HRESULT errorCode, ICoreWebView2Environment* pCoreWebView2Environment);
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2ControllerCompleted(ICoreWebView2CreateCoreWebView2ControllerCompletedHandler* _this, HRESULT hr, ICoreWebView2Controller* pCoreWebView2Controller);
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationStarting(ICoreWebView2NavigationStartingEventHandler* _this, ICoreWebView2* pCoreWebView2, ICoreWebView2NavigationStartingEventArgs* pCoreWebView2NavigationStartingEventArgs);
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationCompleted(ICoreWebView2NavigationCompletedEventHandler* _this, ICoreWebView2* pCoreWebView2, ICoreWebView2NavigationCompletedEventArgs* pCoreWebView2NavigationCompletedEventArgs);
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2ExecuteScriptCompletedHandler* _this, HRESULT hr, LPCWSTR pResultObjectAsJson);
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_get_AdditionalBrowserArguments(ICoreWebView2EnvironmentOptions* _this, LPWSTR* value);
|
||||
@ -201,6 +203,17 @@ static const ICoreWebView2CreateCoreWebView2ControllerCompletedHandler EPWeather
|
||||
.lpVtbl = &EPWeather_ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVtbl
|
||||
};
|
||||
|
||||
static const ICoreWebView2NavigationStartingEventHandlerVtbl EPWeather_ICoreWebView2NavigationStartingEventHandlerVtbl = {
|
||||
.QueryInterface = epw_Weather_static_QueryInterface,
|
||||
.AddRef = epw_Weather_static_AddRefRelease,
|
||||
.Release = epw_Weather_static_AddRefRelease,
|
||||
.Invoke = ICoreWebView2_NavigationStarting,
|
||||
};
|
||||
|
||||
static const ICoreWebView2NavigationStartingEventHandler EPWeather_ICoreWebView2NavigationStartingEventHandler = {
|
||||
.lpVtbl = &EPWeather_ICoreWebView2NavigationStartingEventHandlerVtbl
|
||||
};
|
||||
|
||||
static const ICoreWebView2NavigationCompletedEventHandlerVtbl EPWeather_ICoreWebView2NavigationCompletedEventHandlerVtbl = {
|
||||
.QueryInterface = epw_Weather_static_QueryInterface,
|
||||
.AddRef = epw_Weather_static_AddRefRelease,
|
||||
|
Loading…
Reference in New Issue
Block a user