2011-09-23 22:06:21 +02:00
/* ============================================================
* QupZilla - WebKit based browser
2012-01-01 15:29:55 +01:00
* Copyright ( C ) 2010 - 2012 David Rosca < nowrep @ gmail . com >
2011-09-23 22:06:21 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
2011-09-18 15:35:44 +02:00
# include "qupzillaschemehandler.h"
# include "globalfunctions.h"
# include "qupzilla.h"
# include "mainapplication.h"
2012-02-07 18:37:44 +01:00
# include "tabbedwebview.h"
2011-09-18 15:35:44 +02:00
# include "webpage.h"
2011-12-02 23:25:27 +01:00
# include "speeddial.h"
2011-12-09 21:56:01 +01:00
# include "pluginproxy.h"
2012-02-13 19:09:02 +01:00
# include "plugininterface.h"
# include "settings.h"
2011-09-18 15:35:44 +02:00
2012-02-29 18:33:50 +01:00
# include <QTextDocument>
# include <QTextStream>
# include <QTimer>
# include <QSettings>
2012-01-21 20:27:45 +01:00
QString authorString ( const char * name , const QString & mail )
{
2012-01-26 16:22:09 +01:00
return QString ( " %1 <<a href= \" mailto:%2 \" >%2</a>> " ) . arg ( QString : : fromUtf8 ( name ) , mail ) ;
2012-01-21 20:27:45 +01:00
}
QupZillaSchemeHandler : : QupZillaSchemeHandler ( )
2011-09-18 15:35:44 +02:00
{
}
QNetworkReply * QupZillaSchemeHandler : : createRequest ( QNetworkAccessManager : : Operation op , const QNetworkRequest & request , QIODevice * outgoingData )
{
Q_UNUSED ( outgoingData )
2011-11-06 17:01:23 +01:00
if ( op ! = QNetworkAccessManager : : GetOperation ) {
2011-09-18 15:35:44 +02:00
return 0 ;
2011-11-06 17:01:23 +01:00
}
2011-09-18 15:35:44 +02:00
QupZillaSchemeReply * reply = new QupZillaSchemeReply ( request ) ;
return reply ;
}
2011-11-06 17:01:23 +01:00
QupZillaSchemeReply : : QupZillaSchemeReply ( const QNetworkRequest & req , QObject * parent )
2011-09-18 15:35:44 +02:00
: QNetworkReply ( parent )
{
setOperation ( QNetworkAccessManager : : GetOperation ) ;
setRequest ( req ) ;
setUrl ( req . url ( ) ) ;
m_pageName = req . url ( ) . path ( ) ;
2012-03-16 16:57:24 +01:00
QStringList knownPages ;
knownPages < < " about " < < " reportbug " < < " start " < < " speeddial " < < " config " ;
if ( knownPages . contains ( m_pageName ) ) {
2011-09-18 15:35:44 +02:00
m_buffer . open ( QIODevice : : ReadWrite ) ;
setError ( QNetworkReply : : NoError , tr ( " No Error " ) ) ;
QTimer : : singleShot ( 0 , this , SLOT ( loadPage ( ) ) ) ;
open ( QIODevice : : ReadOnly ) ;
2011-11-06 17:01:23 +01:00
}
else {
2011-09-18 15:35:44 +02:00
setError ( QNetworkReply : : HostNotFoundError , tr ( " Not Found " ) ) ;
QTimer : : singleShot ( 0 , this , SLOT ( delayedFinish ( ) ) ) ;
}
}
2011-09-19 20:49:39 +02:00
2011-09-18 15:35:44 +02:00
void QupZillaSchemeReply : : loadPage ( )
{
QTextStream stream ( & m_buffer ) ;
2012-01-28 12:02:37 +01:00
stream . setCodec ( " UTF-8 " ) ;
2011-12-02 23:25:27 +01:00
2011-11-06 17:01:23 +01:00
if ( m_pageName = = " about " ) {
2011-09-18 15:35:44 +02:00
stream < < aboutPage ( ) ;
2011-11-06 17:01:23 +01:00
}
else if ( m_pageName = = " reportbug " ) {
2011-09-19 20:49:39 +02:00
stream < < reportbugPage ( ) ;
2011-11-06 17:01:23 +01:00
}
else if ( m_pageName = = " start " ) {
2011-10-01 20:06:38 +02:00
stream < < startPage ( ) ;
2011-11-06 17:01:23 +01:00
}
2011-12-02 23:25:27 +01:00
else if ( m_pageName = = " speeddial " ) {
stream < < speeddialPage ( ) ;
}
2012-02-13 19:09:02 +01:00
else if ( m_pageName = = " config " ) {
stream < < configPage ( ) ;
}
2011-09-18 15:35:44 +02:00
stream . flush ( ) ;
m_buffer . reset ( ) ;
setHeader ( QNetworkRequest : : ContentTypeHeader , QByteArray ( " text/html " ) ) ;
setHeader ( QNetworkRequest : : ContentLengthHeader , m_buffer . bytesAvailable ( ) ) ;
setAttribute ( QNetworkRequest : : HttpStatusCodeAttribute , 200 ) ;
setAttribute ( QNetworkRequest : : HttpReasonPhraseAttribute , QByteArray ( " Ok " ) ) ;
emit metaDataChanged ( ) ;
emit downloadProgress ( m_buffer . size ( ) , m_buffer . size ( ) ) ;
emit readyRead ( ) ;
emit finished ( ) ;
}
void QupZillaSchemeReply : : delayedFinish ( )
{
emit error ( QNetworkReply : : HostNotFoundError ) ;
emit finished ( ) ;
}
qint64 QupZillaSchemeReply : : bytesAvailable ( ) const
{
return m_buffer . bytesAvailable ( ) + QNetworkReply : : bytesAvailable ( ) ;
}
2011-11-06 17:01:23 +01:00
qint64 QupZillaSchemeReply : : readData ( char * data , qint64 maxSize )
2011-09-18 15:35:44 +02:00
{
return m_buffer . read ( data , maxSize ) ;
}
2011-09-19 20:49:39 +02:00
QString QupZillaSchemeReply : : reportbugPage ( )
{
2011-12-24 12:21:23 +01:00
static QString bPage ;
if ( ! bPage . isEmpty ( ) ) {
return bPage ;
}
bPage . append ( qz_readAllFileContents ( " :html/reportbug.html " ) ) ;
bPage . replace ( " %FAVICON% " , " qrc:icons/qupzilla.png " ) ;
bPage . replace ( " %BOX-BORDER% " , " qrc:html/box-border.png " ) ;
bPage . replace ( " %TITLE% " , tr ( " Report Issue " ) ) ;
bPage . replace ( " %REPORT-ISSUE% " , tr ( " Report Issue " ) ) ;
2012-01-08 20:08:28 +01:00
bPage . replace ( " %PLUGINS-TEXT% " , tr ( " If you are experiencing problems with QupZilla, please try to disable "
2012-03-17 13:19:43 +01:00
" all extensions first. <br/>If this does not fix it, then please fill out this form: " ) ) ;
2011-12-24 12:21:23 +01:00
bPage . replace ( " %EMAIL% " , tr ( " Your E-mail " ) ) ;
bPage . replace ( " %TYPE% " , tr ( " Issue type " ) ) ;
bPage . replace ( " %DESCRIPTION% " , tr ( " Issue description " ) ) ;
bPage . replace ( " %SEND% " , tr ( " Send " ) ) ;
2012-04-16 15:11:31 +02:00
bPage . replace ( " %E-MAIL-OPTIONAL% " , tr ( " E-mail is optional<br/><b>Note: </b>Please read how to make a bug report <a href=%1>here</a> first. " ) . arg ( " https://github.com/QupZilla/QupZilla/wiki/Bug-Reports target=_blank " ) ) ;
2012-01-08 20:08:28 +01:00
bPage . replace ( " %FIELDS-ARE-REQUIRED% " , tr ( " Please fill out all required fields! " ) ) ;
2011-12-24 12:21:23 +01:00
return bPage ;
2011-09-19 20:49:39 +02:00
}
2011-10-01 20:06:38 +02:00
QString QupZillaSchemeReply : : startPage ( )
{
2011-12-24 12:21:23 +01:00
static QString sPage ;
2011-10-01 20:06:38 +02:00
2011-12-24 12:21:23 +01:00
if ( ! sPage . isEmpty ( ) ) {
return sPage ;
}
sPage . append ( qz_readAllFileContents ( " :html/start.html " ) ) ;
sPage . replace ( " %FAVICON% " , " qrc:icons/qupzilla.png " ) ;
sPage . replace ( " %BOX-BORDER% " , " qrc:html/box-border.png " ) ;
sPage . replace ( " %ABOUT-IMG% " , " qrc:icons/other/about.png " ) ;
sPage . replace ( " %TITLE% " , tr ( " Start Page " ) ) ;
sPage . replace ( " %BUTTON-LABEL% " , tr ( " Google Search " ) ) ;
sPage . replace ( " %SEARCH-BY-GOOGLE% " , tr ( " Search results provided by Google " ) ) ;
sPage . replace ( " %WWW% " , QupZilla : : WIKIADDRESS ) ;
sPage . replace ( " %ABOUT-QUPZILLA% " , tr ( " About QupZilla " ) ) ;
return sPage ;
2011-10-01 20:06:38 +02:00
}
2011-09-18 15:35:44 +02:00
QString QupZillaSchemeReply : : aboutPage ( )
{
2011-12-24 12:21:23 +01:00
static QString aPage ;
2012-02-07 18:37:44 +01:00
if ( aPage . isEmpty ( ) ) {
aPage . append ( qz_readAllFileContents ( " :html/about.html " ) ) ;
aPage . replace ( " %FAVICON% " , " qrc:icons/qupzilla.png " ) ;
aPage . replace ( " %BOX-BORDER% " , " qrc:html/box-border.png " ) ;
aPage . replace ( " %ABOUT-IMG% " , " qrc:icons/other/about.png " ) ;
aPage . replace ( " %COPYRIGHT-INCLUDE% " , Qt : : escape ( qz_readAllFileContents ( " :html/copyright " ) ) ) ;
aPage . replace ( " %TITLE% " , tr ( " About QupZilla " ) ) ;
aPage . replace ( " %ABOUT-QUPZILLA% " , tr ( " About QupZilla " ) ) ;
aPage . replace ( " %INFORMATIONS-ABOUT-VERSION% " , tr ( " Information about version " ) ) ;
aPage . replace ( " %COPYRIGHT% " , tr ( " Copyright " ) ) ;
aPage . replace ( " %VERSION-INFO% " ,
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Version " ) , QupZilla : : VERSION
2012-02-20 18:28:09 +01:00
# ifdef GIT_REVISION
+ " ( " + GIT_REVISION + " ) "
# endif
) +
2012-02-16 20:17:39 +01:00
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " WebKit version " ) , QupZilla : : WEBKITVERSION ) ) ;
2012-02-07 18:37:44 +01:00
aPage . replace ( " %MAIN-DEVELOPER% " , tr ( " Main developer " ) ) ;
aPage . replace ( " %MAIN-DEVELOPER-TEXT% " , authorString ( QupZilla : : AUTHOR . toUtf8 ( ) , " nowrep@gmail.com " ) ) ;
aPage . replace ( " %CONTRIBUTORS% " , tr ( " Contributors " ) ) ;
aPage . replace ( " %CONTRIBUTORS-TEXT% " ,
authorString ( " Mladen Pejaković " , " pejakm@gmail.com " ) + " <br/> " +
2012-04-09 19:45:00 +02:00
authorString ( " Alexander Samilov " , " alexsamilovskih@gmail.com " ) + " <br/> " +
2012-02-07 18:37:44 +01:00
authorString ( " Bryan M Dunsmore " , " dunsmoreb@gmail.com " ) + " <br/> " +
authorString ( " Mariusz Fik " , " fisiu@opensuse.org " ) + " <br/> " +
authorString ( " Jan Rajnoha " , " honza.rajny@hotmail.com " ) + " <br/> " +
authorString ( " Daniele Cocca " , " jmc@chakra-project.org " )
2012-02-20 18:28:09 +01:00
) ;
2012-02-07 18:37:44 +01:00
aPage . replace ( " %TRANSLATORS% " , tr ( " Translators " ) ) ;
aPage . replace ( " %TRANSLATORS-TEXT% " ,
authorString ( " Heimen Stoffels " , " vistausss@gmail.com " ) + " (Dutch)<br/> " +
authorString ( " Peter Vacula " , " pvacula1989@gmail.com " ) + " (Slovak)<br/> " +
authorString ( " Ján Ďanovský " , " dagsoftware@yahoo.com " ) + " (Slovak)<br/> " +
authorString ( " Jonathan Hooverman " , " jonathan.hooverman@gmail.com " ) + " (German)<br/> " +
authorString ( " Federico Fabiani " , " federico.fabiani85@gmail.com " ) + " (Italian)<br/> " +
authorString ( " Francesco Marinucci " , " framarinucci@gmail.com " ) + " (Italian)<br/> " +
authorString ( " Jorge Sevilla " , " jsevi@ozu.es " ) + " (Spanish)<br/> " +
2012-03-18 22:43:39 +01:00
authorString ( " Ștefan Comănescu " , " sdfanq@gmail.com " ) + " (Romanian)<br/> " +
2012-02-07 18:37:44 +01:00
authorString ( " Michał Szymanowski " , " tylkobuba@gmail.com " ) + " (Polish)<br/> " +
authorString ( " Mariusz Fik " , " fisiu@opensuse.org " ) + " (Polish)<br/> " +
authorString ( " Jérôme Giry " , " baikalink@hotmail.fr " ) + " (French)<br/> " +
authorString ( " Nicolas Ourceau " , " lamessen@hotmail.fr " ) + " (French)<br/> " +
authorString ( " Vasilis Tsivikis " , " vasitsiv.dev@gmail.com " ) + " (Greek)<br/> " +
2012-02-11 14:59:09 +01:00
authorString ( " Rustam Salakhutdinov " , " salahutd@gmail.com " ) + " (Russian)<br/> " +
2012-02-07 18:37:44 +01:00
authorString ( " Oleg Brezhnev " , " oleg-423@yandex.ru " ) + " (Russian)<br/> " +
authorString ( " Sérgio Marques " , " smarquespt@gmail.com " ) + " (Portuguese)<br/> " +
2012-02-20 16:43:41 +01:00
authorString ( " Alexandre Carvalho " , " alexandre05@live.com " ) + " (Brazilian Portuguese)<br/> " +
2012-02-07 18:37:44 +01:00
authorString ( " Mladen Pejaković " , " pejakm@gmail.com " ) + " (Serbian)<br/> " +
authorString ( " Unink-Lio " , " unink4451@163.com " ) + " (Chinese)<br/> " +
2012-02-22 15:14:23 +01:00
authorString ( " Wu Cheng-Hong " , " stu2731652@gmail.com " ) + " (Traditional Chinese)<br/> " +
2012-03-02 12:12:00 +01:00
authorString ( " Widya Walesa " , " walecha99@gmail.com " ) + " (Indonesian)<br/> " +
2012-03-10 14:59:43 +01:00
authorString ( " Beqa Arabuli " , " arabulibeqa@gmail.com " ) + " (Georgian)<br/> " +
2012-03-25 15:03:28 +02:00
authorString ( " Daiki Noda " , " sys.pdr.pdm9@gmail.com " ) + " (Japanese)<br/> " +
2012-03-28 14:38:50 +02:00
authorString ( " Gábor Oberle " , " oberleg@myopera.com " ) + " (Hungarian)<br/> " +
authorString ( " Piccoro McKay Lenz " , " mckaygerhard@gmail.com " ) + " (Venezulean Spanish) "
2012-02-20 18:28:09 +01:00
) ;
2011-12-24 12:21:23 +01:00
}
2012-02-16 20:17:39 +01:00
return aPage ;
2011-09-18 15:35:44 +02:00
}
2011-12-02 23:25:27 +01:00
QString QupZillaSchemeReply : : speeddialPage ( )
{
2011-12-24 12:21:23 +01:00
static QString dPage ;
if ( dPage . isEmpty ( ) ) {
dPage . append ( qz_readAllFileContents ( " :html/speeddial.html " ) ) ;
dPage . replace ( " %FAVICON% " , " qrc:icons/qupzilla.png " ) ;
dPage . replace ( " %IMG_PLUS% " , " qrc:html/plus.png " ) ;
dPage . replace ( " %BOX-BORDER% " , " qrc:html/box-border-small.png " ) ;
dPage . replace ( " %IMG_CLOSE% " , " qrc:html/close.png " ) ;
dPage . replace ( " %IMG_EDIT% " , " qrc:html/edit.png " ) ;
dPage . replace ( " %IMG_RELOAD% " , " qrc:html/reload.png " ) ;
dPage . replace ( " %SITE-TITLE% " , tr ( " Speed Dial " ) ) ;
dPage . replace ( " %ADD-TITLE% " , tr ( " Add New Page " ) ) ;
2011-12-30 17:56:49 +01:00
dPage . replace ( " %TITLE-EDIT% " , tr ( " Edit " ) ) ;
2011-12-24 12:21:23 +01:00
dPage . replace ( " %TITLE-REMOVE% " , tr ( " Remove " ) ) ;
dPage . replace ( " %TITLE-RELOAD% " , tr ( " Reload " ) ) ;
dPage . replace ( " %TITLE-FETCHTITLE% " , tr ( " Load title from page " ) ) ;
dPage . replace ( " %JQUERY% " , " qrc:html/jquery.js " ) ;
dPage . replace ( " %JQUERY-UI% " , " qrc:html/jquery-ui.js " ) ;
dPage . replace ( " %LOADING-IMG% " , " qrc:html/loading.gif " ) ;
dPage . replace ( " %URL% " , tr ( " Url " ) ) ;
dPage . replace ( " %TITLE% " , tr ( " Title " ) ) ;
2012-01-18 21:09:27 +01:00
dPage . replace ( " %APPLY% " , tr ( " Apply " ) ) ;
2012-03-17 16:01:12 +01:00
dPage . replace ( " %CLOSE% " , tr ( " Close " ) ) ;
2011-12-24 12:21:23 +01:00
dPage . replace ( " %NEW-PAGE% " , tr ( " New Page " ) ) ;
2012-01-18 20:10:04 +01:00
dPage . replace ( " %IMG_SETTINGS% " , " qrc:html/setting.png " ) ;
dPage . replace ( " %SETTINGS-TITLE% " , tr ( " Speed Dial settings " ) ) ;
2012-01-18 21:09:27 +01:00
dPage . replace ( " %TXT_PLACEMENT% " , tr ( " Placement: " ) ) ;
dPage . replace ( " %TXT_AUTO% " , tr ( " Auto " ) ) ;
dPage . replace ( " %TXT_COVER% " , tr ( " Cover " ) ) ;
dPage . replace ( " %TXT_FIT% " , tr ( " Fit " ) ) ;
dPage . replace ( " %TXT_FWIDTH% " , tr ( " Fit Width " ) ) ;
dPage . replace ( " %TXT_FHEIGHT% " , tr ( " Fit Height " ) ) ;
dPage . replace ( " %TXT_NOTE% " , tr ( " Use background image " ) ) ;
dPage . replace ( " %TXT_SELECTIMAGE% " , tr ( " Select image " ) ) ;
2012-01-20 13:10:05 +01:00
dPage . replace ( " %TXT_NRROWS% " , tr ( " Maximum pages in a row: " ) ) ;
dPage . replace ( " %TXT_SDSIZE% " , tr ( " Change size of pages: " ) ) ;
2011-12-24 12:21:23 +01:00
}
QString page = dPage ;
2012-02-12 12:11:12 +01:00
SpeedDial * dial = mApp - > plugins ( ) - > speedDial ( ) ;
page . replace ( " %INITIAL-SCRIPT% " , dial - > initialScript ( ) ) ;
page . replace ( " %IMG_BACKGROUND% " , dial - > backgroundImage ( ) ) ;
page . replace ( " %B_SIZE% " , dial - > backgroundImageSize ( ) ) ;
page . replace ( " %ROW-PAGES% " , QString : : number ( dial - > pagesInRow ( ) ) ) ;
page . replace ( " %SD-SIZE% " , QString : : number ( dial - > sdSize ( ) ) ) ;
2012-02-20 16:43:41 +01:00
2011-12-02 23:25:27 +01:00
return page ;
}
2012-02-13 19:09:02 +01:00
QString QupZillaSchemeReply : : configPage ( )
{
static QString cPage ;
if ( cPage . isEmpty ( ) ) {
cPage . append ( qz_readAllFileContents ( " :html/config.html " ) ) ;
cPage . replace ( " %FAVICON% " , " qrc:icons/qupzilla.png " ) ;
cPage . replace ( " %BOX-BORDER% " , " qrc:html/box-border.png " ) ;
cPage . replace ( " %ABOUT-IMG% " , " qrc:icons/other/about.png " ) ;
2012-02-16 20:17:39 +01:00
cPage . replace ( " %TITLE% " , tr ( " Configuration Information " ) ) ;
2012-02-13 19:09:02 +01:00
cPage . replace ( " %CONFIG% " , tr ( " Configuration Information " ) ) ;
cPage . replace ( " %INFORMATIONS-ABOUT-VERSION% " , tr ( " Information about version " ) ) ;
2012-03-17 13:19:43 +01:00
cPage . replace ( " %CONFIG-ABOUT% " , tr ( " This page contains information about QupZilla's current configuration - relevant for troubleshooting. Please include this information when submitting bug reports. " ) ) ;
2012-02-16 20:17:39 +01:00
cPage . replace ( " %BROWSER-IDENTIFICATION% " , tr ( " Browser Identification " ) ) ;
cPage . replace ( " %PATHS% " , tr ( " Paths " ) ) ;
2012-03-10 15:25:54 +01:00
cPage . replace ( " %BUILD-CONFIG% " , tr ( " Build Configuration " ) ) ;
2012-02-13 19:09:02 +01:00
cPage . replace ( " %PREFS% " , tr ( " Preferences " ) ) ;
cPage . replace ( " %OPTION% " , tr ( " Option " ) ) ;
cPage . replace ( " %VALUE% " , tr ( " Value " ) ) ;
2012-03-14 14:04:20 +01:00
cPage . replace ( " %PLUGINS% " , tr ( " Extensions " ) ) ;
2012-02-13 19:09:02 +01:00
cPage . replace ( " %PL-NAME% " , tr ( " Name " ) ) ;
cPage . replace ( " %PL-VER% " , tr ( " Version " ) ) ;
cPage . replace ( " %PL-AUTH% " , tr ( " Author " ) ) ;
cPage . replace ( " %PL-DESC% " , tr ( " Description " ) ) ;
cPage . replace ( " %VERSION-INFO% " ,
2012-02-16 20:17:39 +01:00
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Application version " ) , QupZilla : : VERSION
2012-02-20 18:28:09 +01:00
# ifdef GIT_REVISION
+ " ( " + GIT_REVISION + " ) "
# endif
) +
2012-02-16 20:17:39 +01:00
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Qt version " ) , QT_VERSION_STR ) +
2012-02-13 19:09:02 +01:00
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " WebKit version " ) , QupZilla : : WEBKITVERSION ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Build time " ) , QupZilla : : BUILDTIME ) +
2012-03-10 15:25:54 +01:00
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Platform " ) , qz_buildSystem ( ) ) ) ;
cPage . replace ( " %PATHS-TEXT% " ,
2012-04-04 18:48:54 +02:00
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Profile " ) , mApp - > currentProfilePath ( ) ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Settings " ) , mApp - > currentProfilePath ( ) + " settings.ini " ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Saved session " ) , mApp - > currentProfilePath ( ) + " session.dat " ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Pinned tabs " ) , mApp - > currentProfilePath ( ) + " pinnedtabs.dat " ) +
2012-03-10 15:25:54 +01:00
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Data " ) , mApp - > DATADIR ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Themes " ) , mApp - > THEMESDIR ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Translations " ) , mApp - > TRANSLATIONSDIR ) ) ;
QString debugBuild = tr ( " Disabled " ) ;
QString webGLEnabled = tr ( " Disabled " ) ;
QString w7APIEnabled = tr ( " Disabled " ) ;
QString KDEIntegration = tr ( " Disabled " ) ;
QString portableBuild = tr ( " Disabled " ) ;
2012-03-10 14:37:05 +01:00
# ifdef QUPZILLA_DEBUG_BUILD
2012-03-10 15:25:54 +01:00
debugBuild = tr ( " <b>Enabled</b> " ) ;
2012-03-10 14:37:05 +01:00
# endif
2012-03-10 15:25:54 +01:00
# ifdef USE_WEBGL
webGLEnabled = tr ( " <b>Enabled</b> " ) ;
# endif
# if defined(Q_WS_WIN) && defined(W7API)
w7APIEnabled = tr ( " <b>Enabled</b> " ) ;
# endif
# if defined(Q_WS_X11) && defined(KDE)
KDEIntegration = tr ( " <b>Enabled</b> " ) ;
# endif
# ifdef PORTABLE_BUILD
portableBuild = tr ( " <b>Enabled</b> " ) ;
# endif
cPage . replace ( " %BUILD-CONFIG-TEXT% " ,
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Debug build " ) , debugBuild ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " WebGL support " ) , webGLEnabled ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Windows 7 API " ) , w7APIEnabled ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " KDE integration " ) , KDEIntegration ) +
QString ( " <dt>%1</dt><dd>%2<dd> " ) . arg ( tr ( " Portable build " ) , portableBuild ) ) ;
2012-02-20 16:43:41 +01:00
}
2012-02-13 19:09:02 +01:00
2012-02-20 16:43:41 +01:00
QString page = cPage ;
2012-04-03 20:23:15 +02:00
page . replace ( " %USER-AGENT% " , mApp - > getWindow ( ) - > weView ( ) - > page ( ) - > userAgentForUrl ( QUrl ( ) ) ) ;
2012-02-16 20:17:39 +01:00
2012-02-20 16:43:41 +01:00
QString pluginsString ;
const QList < Plugins : : Plugin > & availablePlugins = mApp - > plugins ( ) - > getAvailablePlugins ( ) ;
2012-02-13 19:09:02 +01:00
2012-02-20 16:43:41 +01:00
foreach ( const Plugins : : Plugin & plugin , availablePlugins ) {
PluginSpec spec = plugin . pluginSpec ;
pluginsString . append ( QString ( " <tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td></tr> " ) . arg (
spec . name , spec . version , Qt : : escape ( spec . author ) , spec . description ) ) ;
}
2012-02-13 19:09:02 +01:00
2012-02-20 16:43:41 +01:00
if ( pluginsString . isEmpty ( ) ) {
2012-03-14 14:04:20 +01:00
pluginsString = QString ( " <tr><td colspan=4 class= \" no-available-plugins \" >%1</td></tr> " ) . arg ( tr ( " No available extensions. " ) ) ;
2012-02-20 16:43:41 +01:00
}
2012-02-13 19:09:02 +01:00
2012-02-20 16:43:41 +01:00
page . replace ( " %PLUGINS-INFO% " , pluginsString ) ;
2012-02-16 20:17:39 +01:00
2012-02-20 16:43:41 +01:00
QString allGroupsString ;
QSettings * settings = Settings : : globalSettings ( ) ;
foreach ( const QString & group , settings - > childGroups ( ) ) {
2012-03-08 13:05:57 +01:00
QString groupString = QString ( " <tr><th colspan= \" 2 \" >[%1]</th></tr> " ) . arg ( group ) ;
2012-02-20 16:43:41 +01:00
settings - > beginGroup ( group ) ;
2012-02-16 20:17:39 +01:00
2012-02-20 16:43:41 +01:00
foreach ( const QString & key , settings - > childKeys ( ) ) {
const QVariant & keyValue = settings - > value ( key ) ;
QString keyString ;
2012-02-16 20:17:39 +01:00
2012-02-20 16:43:41 +01:00
switch ( keyValue . type ( ) ) {
case QVariant : : ByteArray :
keyString = " QByteArray " ;
break ;
2012-02-16 20:17:39 +01:00
2012-02-20 16:43:41 +01:00
case QVariant : : Point : {
const QPoint point = keyValue . toPoint ( ) ;
keyString = QString ( " QPoint(%1, %2) " ) . arg ( QString : : number ( point . x ( ) ) , QString : : number ( point . y ( ) ) ) ;
break ;
}
2012-02-16 20:17:39 +01:00
2012-02-20 16:43:41 +01:00
case QVariant : : StringList :
keyString = keyValue . toStringList ( ) . join ( " , " ) ;
break ;
2012-02-16 20:17:39 +01:00
2012-02-20 16:43:41 +01:00
default :
keyString = keyValue . toString ( ) ;
}
2012-02-16 20:17:39 +01:00
2012-02-20 16:43:41 +01:00
if ( keyString . isEmpty ( ) ) {
keyString = " \" empty \" " ;
2012-02-16 20:17:39 +01:00
}
2012-02-20 16:43:41 +01:00
groupString . append ( QString ( " <tr><td>%1</td><td>%2</td></tr> " ) . arg ( key , Qt : : escape ( keyString ) ) ) ;
2012-02-13 19:09:02 +01:00
}
2012-02-20 16:43:41 +01:00
settings - > endGroup ( ) ;
allGroupsString . append ( groupString ) ;
2012-02-13 19:09:02 +01:00
}
2012-02-20 16:43:41 +01:00
page . replace ( " %PREFS-INFO% " , allGroupsString ) ;
return page ;
2012-02-16 20:17:39 +01:00
}