1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Added qupzilla: scheme handler + qupzilla:about page

There is now shown license of theme in ThemesManager
This commit is contained in:
nowrep 2011-09-18 15:35:44 +02:00
parent 8f296c0f51
commit 6652b433c5
21 changed files with 1264 additions and 757 deletions

View File

@ -15,14 +15,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */ * ============================================================ */
******************************************************************
******************************************************************
Some files in 3rdparty/ folder are under different licenses
----------------------------------------------------------- -----------------------------------------------------------
lineedit.h, lineedit.cpp, squeezelabel.h, squeezelabel.cpp AdBlock, LineEdit class and SqueezeLabel class:
and all files in adblock/ folder:
----------------------------------------------------------- -----------------------------------------------------------
* Copyright (c) 2008 - 2009, Benjamin C. Meyer <ben@meyerhome.net> * Copyright (c) 2008 - 2009, Benjamin C. Meyer <ben@meyerhome.net>
* *
@ -51,8 +45,7 @@ Some files in 3rdparty/ folder are under different licenses
* SUCH DAMAGE. * SUCH DAMAGE.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
qtlocalpeer.h, qtlocalpeer.cpp, qtsingleapplication.h, qtsingleapplication.cpp, QtSingleApplication class:
qtlockedfile.h, qtlockedfile_unix.cpp, qtlockedfile_win.cpp:
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
** **
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
@ -98,7 +91,7 @@ Some files in 3rdparty/ folder are under different licenses
** contact Nokia at qt-info@nokia.com. ** contact Nokia at qt-info@nokia.com.
** **
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Files clicktoflash.cpp and clicktoflash.h: Click2Flash plugin:
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
/* ============================================================ /* ============================================================
* *
@ -124,7 +117,7 @@ Some files in 3rdparty/ folder are under different licenses
* ============================================================ */ * ============================================================ */
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Files ecwin7.cpp and ecwin7.h: EcWin7 class:
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
/* EcWin7 - Support library for integrating Windows 7 taskbar features /* EcWin7 - Support library for integrating Windows 7 taskbar features
* into any Qt application * into any Qt application
@ -146,7 +139,7 @@ Some files in 3rdparty/ folder are under different licenses
*/ */
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Files qtwin.cpp and qtwin.h are used from QtWin class from
http://labs.qt.nokia.com/2009/09/15/using-blur-behind-on-windows/ http://labs.qt.nokia.com/2009/09/15/using-blur-behind-on-windows/
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
In application are used also some icons from Faenza icon set, which are In application are used also some icons from Faenza icon set, which are

Binary file not shown.

View File

@ -131,7 +131,9 @@ SOURCES += main.cpp\
tools/toolbutton.cpp \ tools/toolbutton.cpp \
navigation/navigationbar.cpp \ navigation/navigationbar.cpp \
navigation/reloadstopbutton.cpp \ navigation/reloadstopbutton.cpp \
preferences/thememanager.cpp preferences/thememanager.cpp \
network/qupzillaschemehandler.cpp \
tools/globalfunctions.cpp
HEADERS += \ HEADERS += \
3rdparty/qtwin.h \ 3rdparty/qtwin.h \
@ -223,7 +225,9 @@ HEADERS += \
tools/toolbutton.h \ tools/toolbutton.h \
navigation/navigationbar.h \ navigation/navigationbar.h \
navigation/reloadstopbutton.h \ navigation/reloadstopbutton.h \
preferences/thememanager.h preferences/thememanager.h \
network/qupzillaschemehandler.h \
tools/globalfunctions.h
FORMS += \ FORMS += \
preferences/autofillmanager.ui \ preferences/autofillmanager.ui \
@ -276,3 +280,11 @@ win32:LIBS += User32.lib Ole32.lib Shell32.lib ShlWapi.lib Gdi32.lib ComCtl32.li

View File

@ -620,11 +620,13 @@ void QupZilla::aboutToShowClosedTabsMenu()
void QupZilla::aboutToShowHelpMenu() void QupZilla::aboutToShowHelpMenu()
{ {
m_menuHelp->clear(); m_menuHelp->clear();
m_menuHelp->addAction(tr("Report &Bug"), this, SLOT(reportBug()));
m_menuHelp->addSeparator();
mApp->plugins()->populateHelpMenu(m_menuHelp); mApp->plugins()->populateHelpMenu(m_menuHelp);
m_menuHelp->addSeparator();
m_menuHelp->addAction(QIcon(":/icons/menu/qt.png"), tr("About &Qt"), qApp, SLOT(aboutQt())); m_menuHelp->addAction(QIcon(":/icons/menu/qt.png"), tr("About &Qt"), qApp, SLOT(aboutQt()));
m_menuHelp->addAction(QIcon(":/icons/qupzilla.png"), tr("&About QupZilla"), this, SLOT(aboutQupZilla())); m_menuHelp->addAction(QIcon(":/icons/qupzilla.png"), tr("&About QupZilla"), this, SLOT(aboutQupZilla()));
m_menuHelp->addSeparator();
m_menuHelp->addAction(QIcon(":/icons/menu/informations.png"), tr("Informations about application"), this, SLOT(loadActionUrl()))->setData(QUrl("qupzilla:about"));
m_menuHelp->addAction(tr("Report &Bug"), this, SLOT(reportBug()));
} }
void QupZilla::aboutToShowToolsMenu() void QupZilla::aboutToShowToolsMenu()

View File

@ -4,5 +4,8 @@
<file>html/info.png</file> <file>html/info.png</file>
<file>html/adblock_big.png</file> <file>html/adblock_big.png</file>
<file>html/adblockPage.html</file> <file>html/adblockPage.html</file>
<file>html/about.html</file>
<file>html/box-border.png</file>
<file>html/copyright</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -63,5 +63,6 @@
<file>icons/exeicons/qupzilla64.png</file> <file>icons/exeicons/qupzilla64.png</file>
<file>icons/exeicons/qupzilla128.png</file> <file>icons/exeicons/qupzilla128.png</file>
<file>icons/exeicons/qupzilla256.png</file> <file>icons/exeicons/qupzilla256.png</file>
<file>icons/menu/informations.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -40,7 +40,7 @@ int HistoryModel::addHistoryEntry(const QString &url, QString &title)
{ {
if (!m_isSaving) if (!m_isSaving)
return -2; return -2;
if (url.contains("file://") || title.contains(tr("Failed loading page")) || url.isEmpty() || url.contains("about:blank") ) if (url.startsWith("file://") || url.startsWith("qupzilla:") || title.contains(tr("Failed loading page")) || url.isEmpty() || url.contains("about:blank") )
return -1; return -1;
if (title == "") if (title == "")
title=tr("No Named Page"); title=tr("No Named Page");

View File

@ -25,12 +25,14 @@
#include "adblockmanager.h" #include "adblockmanager.h"
#include "adblocknetwork.h" #include "adblocknetwork.h"
#include "networkproxyfactory.h" #include "networkproxyfactory.h"
#include "qupzillaschemehandler.h"
NetworkManager::NetworkManager(QupZilla* mainClass, QObject* parent) : NetworkManager::NetworkManager(QupZilla* mainClass, QObject* parent)
NetworkManagerProxy(mainClass, parent) : NetworkManagerProxy(mainClass, parent)
,m_adblockNetwork(0) , m_adblockNetwork(0)
,p_QupZilla(mainClass) , p_QupZilla(mainClass)
,m_ignoreAllWarnings(false) , m_qupzillaSchemeHandler(new QupZillaSchemeHandler)
, m_ignoreAllWarnings(false)
{ {
connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authentication(QNetworkReply*, QAuthenticator* ))); connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authentication(QNetworkReply*, QAuthenticator* )));
connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthentication(QNetworkProxy,QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthentication(QNetworkProxy,QAuthenticator*)));
@ -234,23 +236,31 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
} }
QNetworkRequest req = request; QNetworkRequest req = request;
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); QNetworkReply* reply = 0;
if (req.attribute(QNetworkRequest::CacheLoadControlAttribute).toInt() == QNetworkRequest::PreferNetwork)
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
if (m_doNotTrack) if (m_doNotTrack)
req.setRawHeader("DNT", "1"); req.setRawHeader("DNT", "1");
//SchemeHandlers
if (req.url().scheme() == "qupzilla")
reply = m_qupzillaSchemeHandler->createRequest(op, req, outgoingData);
if (reply)
return reply;
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
if (req.attribute(QNetworkRequest::CacheLoadControlAttribute).toInt() == QNetworkRequest::PreferNetwork)
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
// Adblock // Adblock
if (op == QNetworkAccessManager::GetOperation) { if (op == QNetworkAccessManager::GetOperation) {
if (!m_adblockNetwork) if (!m_adblockNetwork)
m_adblockNetwork = AdBlockManager::instance()->network(); m_adblockNetwork = AdBlockManager::instance()->network();
QNetworkReply* reply = m_adblockNetwork->block(req); reply = m_adblockNetwork->block(req);
if (reply) if (reply)
return reply; return reply;
} }
QNetworkReply* reply = QNetworkAccessManager::createRequest(op, req, outgoingData); reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
return reply; return reply;
} }

View File

@ -34,6 +34,7 @@
class QupZilla; class QupZilla;
class AdBlockNetwork; class AdBlockNetwork;
class NetworkProxyFactory; class NetworkProxyFactory;
class QupZillaSchemeHandler;
class NetworkManager : public NetworkManagerProxy class NetworkManager : public NetworkManagerProxy
{ {
Q_OBJECT Q_OBJECT
@ -65,6 +66,8 @@ private:
QNetworkDiskCache* m_diskCache; QNetworkDiskCache* m_diskCache;
NetworkProxyFactory* m_proxyFactory; NetworkProxyFactory* m_proxyFactory;
QupZillaSchemeHandler* m_qupzillaSchemeHandler;
bool m_ignoreAllWarnings; bool m_ignoreAllWarnings;
bool m_doNotTrack; bool m_doNotTrack;
}; };

View File

@ -0,0 +1,119 @@
#include "qupzillaschemehandler.h"
#include "globalfunctions.h"
#include "qupzilla.h"
#include "mainapplication.h"
#include "webpage.h"
QupZillaSchemeHandler::QupZillaSchemeHandler(QObject* parent) :
QObject(parent)
{
}
QNetworkReply* QupZillaSchemeHandler::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData)
{
Q_UNUSED(outgoingData)
if (op != QNetworkAccessManager::GetOperation)
return 0;
QupZillaSchemeReply* reply = new QupZillaSchemeReply(request);
return reply;
}
QupZillaSchemeReply::QupZillaSchemeReply(const QNetworkRequest &req, QObject *parent)
: QNetworkReply(parent)
{
setOperation(QNetworkAccessManager::GetOperation);
setRequest(req);
setUrl(req.url());
m_pageName = req.url().path();
if (m_pageName == "about") {
m_buffer.open(QIODevice::ReadWrite);
setError(QNetworkReply::NoError, tr("No Error"));
QTimer::singleShot(0, this, SLOT(loadPage()));
open(QIODevice::ReadOnly);
} else {
setError(QNetworkReply::HostNotFoundError, tr("Not Found"));
QTimer::singleShot(0, this, SLOT(delayedFinish()));
}
}
#include <QDebug>
void QupZillaSchemeReply::loadPage()
{
QTextStream stream(&m_buffer);
if (m_pageName == "about")
stream << aboutPage();
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();
}
qint64 QupZillaSchemeReply::readData(char *data, qint64 maxSize)
{
return m_buffer.read(data, maxSize);
}
QString QupZillaSchemeReply::aboutPage()
{
QString page;
page.append(qz_readAllFileContents(":html/about.html"));
page.replace("%FAVICON%", qz_pixmapToByteArray(QPixmap(":icons/qupzilla.png")));
page.replace("%BOX-BORDER%", qz_pixmapToByteArray(QPixmap(":html/box-border.png")));
page.replace("%ABOUT-IMG%", qz_pixmapToByteArray(QPixmap(":icons/other/about.png")));
page.replace("%COPYRIGHT-INCLUDE%", qz_readAllFileContents(":html/copyright"));
page.replace("%TITLE%", tr("About QupZilla"));
page.replace("%ABOUT-QUPZILLA%", tr("About QupZilla"));
page.replace("%INFORMATIONS-ABOUT-VERSION%", tr("Informations about version"));
page.replace("%BROWSER-IDENTIFICATION%", tr("Browser Identification"));
page.replace("%PATHS%", tr("Paths"));
page.replace("%COPYRIGHT%", tr("Copyright"));
QString platform;
#ifdef Q_WS_X11
platform = tr("Linux");
#endif
#ifdef Q_WS_WIN
platform = tr("Windows");
#endif
page.replace("%VERSION-INFO%",
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Version"), QupZilla::VERSION) +
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) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Platform"), platform)
);
page.replace("%USER-AGENT%", mApp->getWindow()->weView()->webPage()->userAgentForUrl(QUrl()));
page.replace("%PATHS-TEXT%",
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Settings"), mApp->getActiveProfilPath() + "settings.ini") +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Saved session"), mApp->getActiveProfilPath() + "session.dat") +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Pinned tabs"), mApp->getActiveProfilPath() + "pinnedtabs.dat") +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Themes"), mApp->THEMESDIR) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Plugins"), mApp->PLUGINSDIR) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Translations"), mApp->TRANSLATIONSDIR)
);
return page;
}

View File

@ -0,0 +1,49 @@
#ifndef QUPZILLASCHEMEHANDLER_H
#define QUPZILLASCHEMEHANDLER_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QBuffer>
#include <QTimer>
#include <QTextStream>
class QupZillaSchemeHandler : public QObject
{
Q_OBJECT
public:
explicit QupZillaSchemeHandler(QObject* parent = 0);
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData);
signals:
public slots:
};
class QupZillaSchemeReply : public QNetworkReply
{
Q_OBJECT
public:
explicit QupZillaSchemeReply(const QNetworkRequest &req, QObject* parent = 0);
virtual qint64 bytesAvailable() const;
protected:
virtual qint64 readData(char *data, qint64 maxSize);
virtual void abort() { }
private slots:
void delayedFinish();
void loadPage();
private:
QString aboutPage();
QBuffer m_buffer;
QString m_pageName;
};
#endif // QUPZILLASCHEMEHANDLER_H

View File

@ -1,12 +1,14 @@
#include "thememanager.h" #include "thememanager.h"
#include "ui_thememanager.h" #include "ui_thememanager.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "globalfunctions.h"
ThemeManager::ThemeManager(QWidget* parent) ThemeManager::ThemeManager(QWidget* parent)
: QWidget() : QWidget()
, ui(new Ui::ThemeManager) , ui(new Ui::ThemeManager)
{ {
ui->setupUi(parent); ui->setupUi(parent);
ui->license->hide();
QSettings settings(mApp->getActiveProfilPath()+"settings.ini", QSettings::IniFormat); QSettings settings(mApp->getActiveProfilPath()+"settings.ini", QSettings::IniFormat);
settings.beginGroup("Themes"); settings.beginGroup("Themes");
m_activeTheme = settings.value("activeTheme", "default").toString(); m_activeTheme = settings.value("activeTheme", "default").toString();
@ -31,10 +33,28 @@ ThemeManager::ThemeManager(QWidget* parent)
} }
connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(currentChanged())); connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(currentChanged()));
connect(ui->license, SIGNAL(clicked(QPoint)), this, SLOT(showLicense()));
currentChanged(); currentChanged();
} }
void ThemeManager::showLicense()
{
QListWidgetItem* currentItem = ui->listWidget->currentItem();
if (!currentItem)
return;
Theme currentTheme = m_themeHash[currentItem->data(Qt::UserRole).toString()];
QTextBrowser* b = new QTextBrowser();
b->setAttribute(Qt::WA_DeleteOnClose);
b->setWindowTitle(tr("License Viewer"));
// b->move(mapToGlobal(parent()->pos()));
b->resize(450, 500);
b->setText(currentTheme.license);
b->show();
}
void ThemeManager::currentChanged() void ThemeManager::currentChanged()
{ {
QListWidgetItem* currentItem = ui->listWidget->currentItem(); QListWidgetItem* currentItem = ui->listWidget->currentItem();
@ -46,6 +66,7 @@ void ThemeManager::currentChanged()
ui->name->setText(currentTheme.name); ui->name->setText(currentTheme.name);
ui->author->setText(currentTheme.author); ui->author->setText(currentTheme.author);
ui->descirption->setText(currentTheme.longDescription); ui->descirption->setText(currentTheme.longDescription);
ui->license->setHidden(currentTheme.license.isEmpty());
} }
ThemeManager::Theme ThemeManager::parseTheme(const QString &name) ThemeManager::Theme ThemeManager::parseTheme(const QString &name)
@ -64,9 +85,10 @@ ThemeManager::Theme ThemeManager::parseTheme(const QString &name)
else else
info.icon = QIcon(":icons/preferences/style-default.png"); info.icon = QIcon(":icons/preferences/style-default.png");
QFile file(path + "theme.info"); if (QFile(path + "theme.license").exists())
file.open(QFile::ReadOnly); info.license = qz_readAllFileContents(path + "theme.license");
QString theme_info = file.readAll();
QString theme_info = qz_readAllFileContents(path + "theme.info");
QRegExp rx("Name:(.*)\\n"); QRegExp rx("Name:(.*)\\n");
rx.setMinimal(true); rx.setMinimal(true);

View File

@ -6,6 +6,7 @@
#include <QDir> #include <QDir>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QHash> #include <QHash>
#include <QTextBrowser>
namespace Ui { namespace Ui {
class ThemeManager; class ThemeManager;
@ -23,6 +24,7 @@ public:
private slots: private slots:
void currentChanged(); void currentChanged();
void showLicense();
private: private:
struct Theme { struct Theme {
@ -32,6 +34,7 @@ private:
QString author; QString author;
QString shortDescription; QString shortDescription;
QString longDescription; QString longDescription;
QString license;
}; };
Theme parseTheme(const QString &name); Theme parseTheme(const QString &name);

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>512</width> <width>512</width>
<height>367</height> <height>316</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -23,6 +23,9 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="margin"> <property name="margin">
<number>4</number> <number>4</number>
</property> </property>
@ -46,26 +49,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;b&gt;Description:&lt;/b&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="name">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="author"> <widget class="QLabel" name="author">
<property name="text"> <property name="text">
@ -76,6 +59,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;b&gt;Description:&lt;/b&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLabel" name="descirption"> <widget class="QLabel" name="descirption">
<property name="text"> <property name="text">
@ -86,11 +79,48 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="name">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="ClickableLabel" name="license">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>License</string>
</property>
<property name="html-link-look" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
<header>clickablelabel.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -0,0 +1,22 @@
#include "globalfunctions.h"
QByteArray qz_pixmapToByteArray(const QPixmap &pix)
{
QByteArray bytes;
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
if (pix.save(&buffer, "PNG"))
return buffer.buffer().toBase64();
return QByteArray();
}
QByteArray qz_readAllFileContents(const QString &filename)
{
QFile file(filename);
file.open(QFile::ReadOnly);
QByteArray a = file.readAll();
file.close();
return a;
}

View File

@ -0,0 +1,12 @@
#ifndef GLOBALFUNCTIONS_H
#define GLOBALFUNCTIONS_H
#include <QByteArray>
#include <QPixmap>
#include <QBuffer>
#include <QFile>
QByteArray qz_pixmapToByteArray(const QPixmap &pix);
QByteArray qz_readAllFileContents(const QString &filename);
#endif // GLOBALFUNCTIONS_H

View File

@ -27,7 +27,7 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent) :
{ {
WebView* view = p_QupZilla->weView(); WebView* view = p_QupZilla->weView();
QUrl url = view->url(); QUrl url = view->url();
if (url.isEmpty()) if (url.isEmpty() || url.scheme() == "qupzilla")
return; return;
this->setAttribute(Qt::WA_DeleteOnClose); this->setAttribute(Qt::WA_DeleteOnClose);

View File

@ -26,6 +26,7 @@
#include "ui_jsalert.h" #include "ui_jsalert.h"
#include "ui_jsprompt.h" #include "ui_jsprompt.h"
#include "widget.h" #include "widget.h"
#include "globalfunctions.h"
WebPage::WebPage(WebView* parent, QupZilla* mainClass) WebPage::WebPage(WebView* parent, QupZilla* mainClass)
: QWebPage(parent) : QWebPage(parent)
@ -124,13 +125,13 @@ bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &r
return false; return false;
} }
TabWidget::OpenUrlIn openIn= frame ? TabWidget::CurrentTab: TabWidget::NewTab; // TabWidget::OpenUrlIn openIn= frame ? TabWidget::CurrentTab: TabWidget::NewTab;
bool accept = QWebPage::acceptNavigationRequest(frame, request, type); bool accept = QWebPage::acceptNavigationRequest(frame, request, type);
if (accept && openIn == TabWidget::NewTab) { // if (accept && openIn == TabWidget::NewTab) {
// m_isOpeningNextWindowAsNewTab = true; // m_isOpeningNextWindowAsNewTab = true;
// p_QupZilla->tabWidget()->addView(request.url(),tr("New tab"), openIn); // p_QupZilla->tabWidget()->addView(request.url(),tr("New tab"), openIn);
} // }
return accept; return accept;
} }
@ -267,20 +268,14 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
errString.replace("%TITLE%", tr("Failed loading page")); errString.replace("%TITLE%", tr("Failed loading page"));
//QPixmap pixmap = QIcon::fromTheme("dialog-warning").pixmap(45,45); //QPixmap pixmap = QIcon::fromTheme("dialog-warning").pixmap(45,45);
QPixmap pixmap = MainApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45,45); QByteArray image = qz_pixmapToByteArray(MainApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45,45));
QByteArray bytes; if (!image.isEmpty())
QBuffer buffer(&bytes); errString.replace("%IMAGE%", image);
buffer.open(QIODevice::WriteOnly);
if (pixmap.save(&buffer, "PNG"))
errString.replace("%IMAGE%", buffer.buffer().toBase64());
//pixmap = QIcon::fromTheme("dialog-warning").pixmap(16,16); //pixmap = QIcon::fromTheme("dialog-warning").pixmap(16,16);
pixmap = MainApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16,16); image = qz_pixmapToByteArray(MainApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16,16));
bytes.clear(); if (!image.isEmpty())
QBuffer buffer2(&bytes); errString.replace("%FAVICON%", image);
buffer2.open(QIODevice::WriteOnly);
if (pixmap.save(&buffer2, "PNG"))
errString.replace("%FAVICON%", buffer.buffer().toBase64());
errString.replace("%HEADING%", errorString); errString.replace("%HEADING%", errorString);
errString.replace("%HEADING2%", tr("QupZilla can't load page from %1.").arg(QUrl(loadedUrl).host())); errString.replace("%HEADING2%", tr("QupZilla can't load page from %1.").arg(QUrl(loadedUrl).host()));

View File

@ -759,7 +759,7 @@ void WebView::closeTab()
void WebView::load(const QUrl &url) void WebView::load(const QUrl &url)
{ {
if (url.toString().startsWith("javascript:")) { if (url.scheme() == "javascript") {
page()->mainFrame()->evaluateJavaScript(url.toString()); page()->mainFrame()->evaluateJavaScript(url.toString());
return; return;
} }
@ -801,7 +801,7 @@ QString WebView::title() const
void WebView::reload() void WebView::reload()
{ {
if (QWebView::url().isEmpty() && !m_aboutToLoadUrl.isEmpty()) { if (QWebView::url().isEmpty() && !m_aboutToLoadUrl.isEmpty()) {
qDebug() << "loading about to load"; // qDebug() << "loading about to load";
load(m_aboutToLoadUrl); load(m_aboutToLoadUrl);
return; return;
} }
@ -810,6 +810,9 @@ void WebView::reload()
bool WebView::isUrlValid(const QUrl &url) bool WebView::isUrlValid(const QUrl &url)
{ {
if (url.scheme() == "qupzilla")
return true;
if (url.isValid() && !url.host().isEmpty() && !url.scheme().isEmpty()) if (url.isValid() && !url.host().isEmpty() && !url.scheme().isEmpty())
return true; return true;
return false; return false;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff