29 #ifdef OW_FORCE_WEBKIT
34 #include <QWebEngineView>
35 #include <QWebEnginePage>
37 #include <QVBoxLayout>
39 #include <QToolButton>
40 #include <QHBoxLayout>
45 #include <QtCore/QUrl>
48 #include "core/common/WIOTools.h"
49 #include "core/common/WLogger.h"
50 #include "core/common/WPathHelper.h"
52 #include "../WQtGui.h"
53 #include "../WMainWindow.h"
55 #include "WQtModuleMetaInfo.h"
59 typedef std::vector< WModuleMetaInformation::Author > AuthorType;
60 AuthorType authors = meta->getAuthors();
61 typedef std::vector< std::string > TagType;
62 TagType tags = meta->getTags();
63 boost::filesystem::path help = meta->getHelp();
64 std::string website = meta->getWebsite();
65 std::string description = meta->getDescription();
66 typedef std::vector< WModuleMetaInformation::Online > OnlineType;
67 OnlineType online = meta->getOnlineResources();
68 typedef std::vector< WModuleMetaInformation::Screenshot > ScreenshotType;
69 ScreenshotType screenshots = meta->getScreenshots();
72 std::ostringstream ss;
77 ss <<
"<div style='font-family:sans-serif;'>"
79 <<
" <div style='padding:10px; border:0px solid #000; border-bottom-width: 10px;color:#fff;background:#0c67a8;'>"
86 ss <<
" <div style='padding:10px; background:#ddd;'>"
87 <<
" <h3>DESCRIPTION</h3>"
88 <<
" <p align='justify'>"
94 ss <<
" <div style='padding:10px;background:#f3f3f3;'>";
98 ss <<
" <h3>TAGS</h3>";
99 for( TagType::const_iterator iter = tags.begin(); iter != tags.end(); ++iter )
102 if( iter+1 != tags.end() )
110 if( !website.empty() )
112 ss <<
" <h3>WEBSITE</h3>"
113 <<
" <a href='" << website <<
"'>" << website <<
"</a>";
117 if( !help.empty() && boost::filesystem::exists( help ) )
119 ss <<
" <h3>HELP</h3>"
120 <<
" <div>" << readFileIntoString( help ) <<
"</div>";
123 if( !authors.empty() )
125 ss <<
" <h3>AUTHORS</h3>"
126 <<
" <table width='100%' style='padding:10px'>";
127 for( AuthorType::const_iterator iter = authors.begin(); iter != authors.end(); ++iter )
129 ss <<
"<tr> <td style='padding:10px; background:#ddd;'>";
131 if( !( *iter ).m_email.empty() )
133 ss <<
"<a href='mailto:" << ( *iter ).m_email <<
"'>" <<
"<img width='24px' src='" << iconPath <<
"/email.png' />" <<
"</a>";
135 if( !( *iter ).m_url.empty() )
137 ss <<
"<a href='" << ( *iter ).m_url <<
"'>" <<
"<img width='24px' src='" << iconPath <<
"website.png' />" <<
"</a>";
141 ss << ( *iter ).m_name;
142 ss <<
"</td><td style='padding:10px; background:#e7e7e7;'><p align='justify'>" << ( *iter ).m_what <<
"</p></td>";
152 if( !online.empty() )
154 ss <<
" <div style='padding:10px;background:#fff;'>"
155 <<
" <h3>ONLINE RESOURCES</h3>"
156 <<
" <table width='100%' style='padding:10px'>";
158 for( OnlineType::const_iterator iter = online.begin(); iter != online.end(); ++iter )
161 <<
" <td style='padding:10px; background:#ddd;'>";
163 ss <<
" <a href='" << ( *iter ).m_url <<
"'> " << ( *iter ).m_name <<
"</a>";
166 <<
" <td style='padding:10px; background:#e7e7e7;'>";
168 ss <<
" <p align='justify'>" << ( *iter ).m_description <<
"</p>";
179 if( !screenshots.empty() )
181 ss <<
" <div style='padding:10px;background:#f5f5f5;'>"
182 <<
" <h3>SCREENSHOTS</h3>"
183 <<
" <table width='100%' style='padding:10px'>";
185 for( ScreenshotType::const_iterator iter = screenshots.begin(); iter != screenshots.end(); ++iter )
188 <<
" <td width='1%' style='padding:10px; background:#ddd;'>";
190 ss <<
" <img src='" << ( *iter ).m_filename.string() <<
"' width=200px>";
193 <<
" <td style='padding:10px; background:#e7e7e7;'>";
195 ss <<
" <p align='justify'>" << ( *iter ).m_description <<
"</p>";
213 QVBoxLayout *layout =
new QVBoxLayout();
215 layout->setSpacing( 0 );
216 layout->setContentsMargins( 0, 0, 0, 0 );
218 #ifdef OW_FORCE_WEBKIT
220 QWebView* view =
new QWebView(
this );
223 QWebPage* page =
new QWebPage(
this );
224 page->setLinkDelegationPolicy( QWebPage::DelegateExternalLinks );
225 m_frame = page->mainFrame();
228 QWebEngineView* view =
new QWebEngineView(
this );
231 QWebEnginePage* page =
new QWebEnginePage(
this );
234 view->setPage( page );
237 QWidget* toolbar =
new QWidget(
this );
238 QHBoxLayout* tbLayout =
new QHBoxLayout( toolbar );
239 toolbar->setLayout( tbLayout );
243 QString(
"Back to " ) + QString::fromStdString( module->getName() ),
245 homeAction->setIconText( QString(
"Back to " ) + QString::fromStdString( module->getName() ) );
248 QToolButton* homeBtn =
new QToolButton( toolbar );
249 homeBtn->setDefaultAction( homeAction );
250 homeBtn->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
252 QToolButton* backBtn =
new QToolButton( toolbar );
253 #ifdef OW_FORCE_WEBKIT
254 backBtn->setDefaultAction( page->action( QWebPage::Back ) );
256 backBtn->setDefaultAction( page->action( QWebEnginePage::Back ) );
258 QToolButton* fwdBtn =
new QToolButton( toolbar );
259 #ifdef OW_FORCE_WEBKIT
260 fwdBtn->setDefaultAction( page->action( QWebPage::Forward ) );
262 fwdBtn->setDefaultAction( page->action( QWebEnginePage::Forward ) );
265 tbLayout->addWidget( backBtn );
266 tbLayout->addWidget( fwdBtn );
267 tbLayout->addStretch( 100000 );
268 tbLayout->addWidget( homeBtn );
271 layout->addWidget( toolbar );
272 layout->addWidget( view );
274 layout->setStretchFactor( toolbar, 0 );
275 layout->setStretchFactor( view, 1 );
280 connect( homeAction, SIGNAL( triggered() ),
this, SLOT(
resetContent() ) );
291 std::string moduleLocation(
m_module->getLocalPath().string() );
292 QString locationURL( QString(
"file://" ) + QString::fromStdString( moduleLocation ) +
"/" );
295 std::string processedContent = htmlify(
m_module->getMetaInformation() );
296 #ifdef OW_FORCE_WEBKIT
297 m_frame->setHtml( processedContent.c_str(), QUrl( locationURL ) );
299 m_page->setHtml( processedContent.c_str(), QUrl( locationURL ) );
std::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
static boost::filesystem::path getSharePath()
The path where shared files reside in.
static WMainWindow * getMainWindow()
Returns the current main window instance or NULL if not existent.