forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc_WelcomeTab.cpp
61 lines (49 loc) · 1.78 KB
/
sc_WelcomeTab.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ==========================================================================
// Dedmonwakeen's Raid DPS/TPS Simulator.
// Send questions to [email protected]
// ==========================================================================
#include "sc_WelcomeTab.hpp"
#if defined(SC_USE_WEBKIT)
SC_WelcomeTabWidget_WebKit::SC_WelcomeTabWidget_WebKit( SC_MainWindow* parent ) :
SC_WebEngineView( parent )
{
QString welcomeFile = SC_PATHS::getDataPath() + "/Welcome.html";
setUrl( "file:///" + welcomeFile );
page() -> setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
connect( this, SIGNAL( linkClicked( const QUrl& ) ), this, SLOT( linkClickedSlot( const QUrl& ) ) );
}
void SC_WelcomeTabWidget_WebKit::linkClickedSlot( const QUrl& url )
{
QDesktopServices::openUrl( url );
}
#endif // SC_USE_WEBKIT
#if defined ( SC_USE_WEBENGINE )
SC_WelcomeTabWidget_WebEngine::SC_WelcomeTabWidget_WebEngine( SC_MainWindow* parent ) :
SC_WebEngineView( parent ),
welcome_uri(),
welcome_timer( new QTimer( this ) )
{
QString welcomeFile = SC_PATHS::getDataPath() + "/Welcome.html";
welcome_uri = "file:///" + welcomeFile;
welcome_timer->setSingleShot( true );
welcome_timer->setInterval( 500 );
connect( welcome_timer, SIGNAL( timeout() ), this, SLOT( welcomeLoadSlot() ) );
welcome_timer->start();
connect( this, SIGNAL( urlChanged(const QUrl& ) ), this, SLOT( urlChangedSlot(const QUrl&) ) );
}
void SC_WelcomeTabWidget::welcomeLoadSlot()
{
setUrl(welcome_uri);
welcome_timer->deleteLater();
}
void SC_WelcomeTabWidget::urlChangedSlot( const QUrl& url )
{
if ( url.isLocalFile() )
{
return;
}
page() -> triggerAction( QWebEnginePage::Stop );
QDesktopServices::openUrl( url );
page() -> triggerAction( QWebEnginePage::Back );
}
#endif // SC_USE_WEBENGINE