This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsc_WelcomeTab.cpp
81 lines (69 loc) · 2.23 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// ==========================================================================
// 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 = "";
for(const auto& path : SC_PATHS::getDataPaths())
{
QFile welcome_path(path + "/Welcome.html");
if (welcome_path.exists())
{
welcomeFile = welcome_path.fileName();
break;
}
}
QString welcome_uri = "file:///" + welcomeFile;
setUrl( welcome_uri );
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("");
for(const auto& path : SC_PATHS::getDataPaths())
{
QFile welcome_path(path + "/Welcome.html");
if (welcome_path.exists())
{
welcomeFile = welcome_path.fileName();
break;
}
}
welcome_uri = "file:///" + welcomeFile;
qDebug() << "welcome_uri: " << welcome_uri << "\n";
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