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:
parent
8f296c0f51
commit
6652b433c5
17
COPYRIGHT
17
COPYRIGHT
@ -15,14 +15,8 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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
|
||||
and all files in adblock/ folder:
|
||||
AdBlock, LineEdit class and SqueezeLabel class:
|
||||
-----------------------------------------------------------
|
||||
* 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.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
qtlocalpeer.h, qtlocalpeer.cpp, qtsingleapplication.h, qtsingleapplication.cpp,
|
||||
qtlockedfile.h, qtlockedfile_unix.cpp, qtlockedfile_win.cpp:
|
||||
QtSingleApplication class:
|
||||
-----------------------------------------------------------------------------
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
---------------------------------------------------------------------------
|
||||
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
|
||||
* 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/
|
||||
-----------------------------------------------------------------------------
|
||||
In application are used also some icons from Faenza icon set, which are
|
||||
|
Binary file not shown.
@ -131,7 +131,9 @@ SOURCES += main.cpp\
|
||||
tools/toolbutton.cpp \
|
||||
navigation/navigationbar.cpp \
|
||||
navigation/reloadstopbutton.cpp \
|
||||
preferences/thememanager.cpp
|
||||
preferences/thememanager.cpp \
|
||||
network/qupzillaschemehandler.cpp \
|
||||
tools/globalfunctions.cpp
|
||||
|
||||
HEADERS += \
|
||||
3rdparty/qtwin.h \
|
||||
@ -223,7 +225,9 @@ HEADERS += \
|
||||
tools/toolbutton.h \
|
||||
navigation/navigationbar.h \
|
||||
navigation/reloadstopbutton.h \
|
||||
preferences/thememanager.h
|
||||
preferences/thememanager.h \
|
||||
network/qupzillaschemehandler.h \
|
||||
tools/globalfunctions.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
@ -276,3 +280,11 @@ win32:LIBS += User32.lib Ole32.lib Shell32.lib ShlWapi.lib Gdi32.lib ComCtl32.li
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -620,11 +620,13 @@ void QupZilla::aboutToShowClosedTabsMenu()
|
||||
void QupZilla::aboutToShowHelpMenu()
|
||||
{
|
||||
m_menuHelp->clear();
|
||||
m_menuHelp->addAction(tr("Report &Bug"), this, SLOT(reportBug()));
|
||||
m_menuHelp->addSeparator();
|
||||
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/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()
|
||||
|
@ -4,5 +4,8 @@
|
||||
<file>html/info.png</file>
|
||||
<file>html/adblock_big.png</file>
|
||||
<file>html/adblockPage.html</file>
|
||||
<file>html/about.html</file>
|
||||
<file>html/box-border.png</file>
|
||||
<file>html/copyright</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -63,5 +63,6 @@
|
||||
<file>icons/exeicons/qupzilla64.png</file>
|
||||
<file>icons/exeicons/qupzilla128.png</file>
|
||||
<file>icons/exeicons/qupzilla256.png</file>
|
||||
<file>icons/menu/informations.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -40,7 +40,7 @@ int HistoryModel::addHistoryEntry(const QString &url, QString &title)
|
||||
{
|
||||
if (!m_isSaving)
|
||||
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;
|
||||
if (title == "")
|
||||
title=tr("No Named Page");
|
||||
|
@ -25,12 +25,14 @@
|
||||
#include "adblockmanager.h"
|
||||
#include "adblocknetwork.h"
|
||||
#include "networkproxyfactory.h"
|
||||
#include "qupzillaschemehandler.h"
|
||||
|
||||
NetworkManager::NetworkManager(QupZilla* mainClass, QObject* parent) :
|
||||
NetworkManagerProxy(mainClass, parent)
|
||||
,m_adblockNetwork(0)
|
||||
,p_QupZilla(mainClass)
|
||||
,m_ignoreAllWarnings(false)
|
||||
NetworkManager::NetworkManager(QupZilla* mainClass, QObject* parent)
|
||||
: NetworkManagerProxy(mainClass, parent)
|
||||
, m_adblockNetwork(0)
|
||||
, p_QupZilla(mainClass)
|
||||
, m_qupzillaSchemeHandler(new QupZillaSchemeHandler)
|
||||
, m_ignoreAllWarnings(false)
|
||||
{
|
||||
connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authentication(QNetworkReply*, 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;
|
||||
req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
|
||||
if (req.attribute(QNetworkRequest::CacheLoadControlAttribute).toInt() == QNetworkRequest::PreferNetwork)
|
||||
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||
QNetworkReply* reply = 0;
|
||||
|
||||
if (m_doNotTrack)
|
||||
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
|
||||
if (op == QNetworkAccessManager::GetOperation) {
|
||||
if (!m_adblockNetwork)
|
||||
m_adblockNetwork = AdBlockManager::instance()->network();
|
||||
QNetworkReply* reply = m_adblockNetwork->block(req);
|
||||
reply = m_adblockNetwork->block(req);
|
||||
if (reply)
|
||||
return reply;
|
||||
}
|
||||
|
||||
QNetworkReply* reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
|
||||
reply = QNetworkAccessManager::createRequest(op, req, outgoingData);
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
class QupZilla;
|
||||
class AdBlockNetwork;
|
||||
class NetworkProxyFactory;
|
||||
class QupZillaSchemeHandler;
|
||||
class NetworkManager : public NetworkManagerProxy
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -65,6 +66,8 @@ private:
|
||||
QNetworkDiskCache* m_diskCache;
|
||||
NetworkProxyFactory* m_proxyFactory;
|
||||
|
||||
QupZillaSchemeHandler* m_qupzillaSchemeHandler;
|
||||
|
||||
bool m_ignoreAllWarnings;
|
||||
bool m_doNotTrack;
|
||||
};
|
||||
|
119
src/network/qupzillaschemehandler.cpp
Normal file
119
src/network/qupzillaschemehandler.cpp
Normal 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;
|
||||
}
|
49
src/network/qupzillaschemehandler.h
Normal file
49
src/network/qupzillaschemehandler.h
Normal 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
|
@ -1,12 +1,14 @@
|
||||
#include "thememanager.h"
|
||||
#include "ui_thememanager.h"
|
||||
#include "mainapplication.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
ThemeManager::ThemeManager(QWidget* parent)
|
||||
: QWidget()
|
||||
, ui(new Ui::ThemeManager)
|
||||
{
|
||||
ui->setupUi(parent);
|
||||
ui->license->hide();
|
||||
QSettings settings(mApp->getActiveProfilPath()+"settings.ini", QSettings::IniFormat);
|
||||
settings.beginGroup("Themes");
|
||||
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->license, SIGNAL(clicked(QPoint)), this, SLOT(showLicense()));
|
||||
|
||||
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()
|
||||
{
|
||||
QListWidgetItem* currentItem = ui->listWidget->currentItem();
|
||||
@ -46,6 +66,7 @@ void ThemeManager::currentChanged()
|
||||
ui->name->setText(currentTheme.name);
|
||||
ui->author->setText(currentTheme.author);
|
||||
ui->descirption->setText(currentTheme.longDescription);
|
||||
ui->license->setHidden(currentTheme.license.isEmpty());
|
||||
}
|
||||
|
||||
ThemeManager::Theme ThemeManager::parseTheme(const QString &name)
|
||||
@ -64,9 +85,10 @@ ThemeManager::Theme ThemeManager::parseTheme(const QString &name)
|
||||
else
|
||||
info.icon = QIcon(":icons/preferences/style-default.png");
|
||||
|
||||
QFile file(path + "theme.info");
|
||||
file.open(QFile::ReadOnly);
|
||||
QString theme_info = file.readAll();
|
||||
if (QFile(path + "theme.license").exists())
|
||||
info.license = qz_readAllFileContents(path + "theme.license");
|
||||
|
||||
QString theme_info = qz_readAllFileContents(path + "theme.info");
|
||||
|
||||
QRegExp rx("Name:(.*)\\n");
|
||||
rx.setMinimal(true);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QDir>
|
||||
#include <QListWidgetItem>
|
||||
#include <QHash>
|
||||
#include <QTextBrowser>
|
||||
|
||||
namespace Ui {
|
||||
class ThemeManager;
|
||||
@ -23,6 +24,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void currentChanged();
|
||||
void showLicense();
|
||||
|
||||
private:
|
||||
struct Theme {
|
||||
@ -32,6 +34,7 @@ private:
|
||||
QString author;
|
||||
QString shortDescription;
|
||||
QString longDescription;
|
||||
QString license;
|
||||
};
|
||||
|
||||
Theme parseTheme(const QString &name);
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>512</width>
|
||||
<height>367</height>
|
||||
<height>316</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -23,6 +23,9 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
@ -46,26 +49,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><b>Description:</b></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">
|
||||
<widget class="QLabel" name="author">
|
||||
<property name="text">
|
||||
@ -76,6 +59,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><b>Description:</b></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="descirption">
|
||||
<property name="text">
|
||||
@ -86,11 +79,48 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ClickableLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>clickablelabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
22
src/tools/globalfunctions.cpp
Normal file
22
src/tools/globalfunctions.cpp
Normal 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;
|
||||
}
|
12
src/tools/globalfunctions.h
Normal file
12
src/tools/globalfunctions.h
Normal 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
|
@ -27,7 +27,7 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent) :
|
||||
{
|
||||
WebView* view = p_QupZilla->weView();
|
||||
QUrl url = view->url();
|
||||
if (url.isEmpty())
|
||||
if (url.isEmpty() || url.scheme() == "qupzilla")
|
||||
return;
|
||||
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "ui_jsalert.h"
|
||||
#include "ui_jsprompt.h"
|
||||
#include "widget.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
WebPage::WebPage(WebView* parent, QupZilla* mainClass)
|
||||
: QWebPage(parent)
|
||||
@ -124,13 +125,13 @@ bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &r
|
||||
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);
|
||||
if (accept && openIn == TabWidget::NewTab) {
|
||||
// if (accept && openIn == TabWidget::NewTab) {
|
||||
// m_isOpeningNextWindowAsNewTab = true;
|
||||
// p_QupZilla->tabWidget()->addView(request.url(),tr("New tab"), openIn);
|
||||
}
|
||||
// }
|
||||
return accept;
|
||||
}
|
||||
|
||||
@ -267,20 +268,14 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
|
||||
errString.replace("%TITLE%", tr("Failed loading page"));
|
||||
|
||||
//QPixmap pixmap = QIcon::fromTheme("dialog-warning").pixmap(45,45);
|
||||
QPixmap pixmap = MainApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45,45);
|
||||
QByteArray bytes;
|
||||
QBuffer buffer(&bytes);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
if (pixmap.save(&buffer, "PNG"))
|
||||
errString.replace("%IMAGE%", buffer.buffer().toBase64());
|
||||
QByteArray image = qz_pixmapToByteArray(MainApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45,45));
|
||||
if (!image.isEmpty())
|
||||
errString.replace("%IMAGE%", image);
|
||||
|
||||
//pixmap = QIcon::fromTheme("dialog-warning").pixmap(16,16);
|
||||
pixmap = MainApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16,16);
|
||||
bytes.clear();
|
||||
QBuffer buffer2(&bytes);
|
||||
buffer2.open(QIODevice::WriteOnly);
|
||||
if (pixmap.save(&buffer2, "PNG"))
|
||||
errString.replace("%FAVICON%", buffer.buffer().toBase64());
|
||||
image = qz_pixmapToByteArray(MainApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16,16));
|
||||
if (!image.isEmpty())
|
||||
errString.replace("%FAVICON%", image);
|
||||
|
||||
errString.replace("%HEADING%", errorString);
|
||||
errString.replace("%HEADING2%", tr("QupZilla can't load page from %1.").arg(QUrl(loadedUrl).host()));
|
||||
|
@ -759,7 +759,7 @@ void WebView::closeTab()
|
||||
|
||||
void WebView::load(const QUrl &url)
|
||||
{
|
||||
if (url.toString().startsWith("javascript:")) {
|
||||
if (url.scheme() == "javascript") {
|
||||
page()->mainFrame()->evaluateJavaScript(url.toString());
|
||||
return;
|
||||
}
|
||||
@ -801,7 +801,7 @@ QString WebView::title() const
|
||||
void WebView::reload()
|
||||
{
|
||||
if (QWebView::url().isEmpty() && !m_aboutToLoadUrl.isEmpty()) {
|
||||
qDebug() << "loading about to load";
|
||||
// qDebug() << "loading about to load";
|
||||
load(m_aboutToLoadUrl);
|
||||
return;
|
||||
}
|
||||
@ -810,6 +810,9 @@ void WebView::reload()
|
||||
|
||||
bool WebView::isUrlValid(const QUrl &url)
|
||||
{
|
||||
if (url.scheme() == "qupzilla")
|
||||
return true;
|
||||
|
||||
if (url.isValid() && !url.host().isEmpty() && !url.scheme().isEmpty())
|
||||
return true;
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user