mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 18:26:34 +01:00
Improved source viewer, it now shows lines and fixed go to line.
- plugins can now register scheme handlers - tweaked javascript alert window - initial support for Geolocation & Notifications API * question to ask user for permission needs not implemented yet
This commit is contained in:
parent
fb42b91107
commit
60c5b81f88
43
COPYRIGHT
43
COPYRIGHT
@ -91,6 +91,49 @@
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
-----------------------------------------------------------------------------
|
||||
HtmlHighlighter and PlainTextEditorWithLines classes:
|
||||
-----------------------------------------------------------------------------
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
Click2Flash plugin:
|
||||
---------------------------------------------------------------------------
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "aboutdialog.h"
|
||||
#include "pluginproxy.h"
|
||||
#include "qtwin.h"
|
||||
#include "ui_closedialog.h"
|
||||
#include "checkboxdialog.h"
|
||||
#include "adblockmanager.h"
|
||||
#include "clickablelabel.h"
|
||||
#include "docktitlebarwidget.h"
|
||||
@ -1809,15 +1809,15 @@ bool QupZilla::quitApp()
|
||||
settings.endGroup();
|
||||
|
||||
if (askOnClose && afterLaunch != 3 && m_tabWidget->count() > 1) {
|
||||
QDialog dialog(this);
|
||||
Ui_CloseDialog* ui = new Ui_CloseDialog();
|
||||
ui->setupUi(&dialog);
|
||||
ui->textLabel->setText(tr("There are still %1 open tabs and your session won't be stored. Are you sure to quit QupZilla?").arg(m_tabWidget->count()));
|
||||
ui->iconLabel->setPixmap(style()->standardPixmap(QStyle::SP_MessageBoxWarning));
|
||||
CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, this);
|
||||
dialog.setText(tr("There are still %1 open tabs and your session won't be stored. \nAre you sure to quit QupZilla?").arg(m_tabWidget->count()));
|
||||
dialog.setCheckBoxText(tr("Don't ask again"));
|
||||
dialog.setWindowTitle(tr("There are still open tabs"));
|
||||
dialog.setPixmap(style()->standardPixmap(QStyle::SP_MessageBoxWarning));
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return false;
|
||||
}
|
||||
if (ui->dontAskAgain->isChecked()) {
|
||||
if (dialog.isChecked()) {
|
||||
settings.setValue("Browser-Tabs-Settings/AskOnClosing", false);
|
||||
}
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ void BookmarksManager::removeBookmark(const BookmarksModel::Bookmark &bookmark)
|
||||
QTreeWidgetItem* item = list.at(0);
|
||||
int id = item->data(0, Qt::UserRole + 10).toInt();
|
||||
|
||||
if (item && id == bookmark.id) {
|
||||
if (id == bookmark.id) {
|
||||
ui->bookmarksTree->deleteItem(item);
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,49 @@
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact Nokia at qt-info@nokia.com.
|
||||
**
|
||||
-----------------------------------------------------------------------------
|
||||
HtmlHighlighter and PlainTextEditorWithLines classes:
|
||||
-----------------------------------------------------------------------------
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
Click2Flash plugin:
|
||||
---------------------------------------------------------------------------
|
||||
|
@ -165,7 +165,10 @@ SOURCES += \
|
||||
preferences/pluginlistdelegate.cpp \
|
||||
popupwindow/popupstatusbarmessage.cpp \
|
||||
other/licenseviewer.cpp \
|
||||
bookmarksimport/bookmarksimporticonfetcher.cpp
|
||||
bookmarksimport/bookmarksimporticonfetcher.cpp \
|
||||
other/checkboxdialog.cpp \
|
||||
network/schemehandler.cpp \
|
||||
tools/plaineditwithlines.cpp
|
||||
|
||||
HEADERS += \
|
||||
3rdparty/qtwin.h \
|
||||
@ -302,7 +305,10 @@ HEADERS += \
|
||||
preferences/pluginlistdelegate.h \
|
||||
popupwindow/popupstatusbarmessage.h \
|
||||
other/licenseviewer.h \
|
||||
bookmarksimport/bookmarksimporticonfetcher.h
|
||||
bookmarksimport/bookmarksimporticonfetcher.h \
|
||||
other/checkboxdialog.h \
|
||||
network/schemehandler.h \
|
||||
tools/plaineditwithlines.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
@ -325,7 +331,6 @@ FORMS += \
|
||||
preferences/sslmanager.ui \
|
||||
other/clearprivatedata.ui \
|
||||
other/sourceviewersearch.ui \
|
||||
other/closedialog.ui \
|
||||
adblock/adblockdialog.ui \
|
||||
tools/docktitlebarwidget.ui \
|
||||
sidebar/bookmarkssidebar.ui \
|
||||
@ -343,7 +348,8 @@ FORMS += \
|
||||
preferences/addacceptlanguage.ui \
|
||||
opensearch/searchenginesdialog.ui \
|
||||
opensearch/editsearchengine.ui \
|
||||
bookmarksimport/bookmarksimportdialog.ui
|
||||
bookmarksimport/bookmarksimportdialog.ui \
|
||||
other/checkboxdialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
data/icons.qrc \
|
||||
|
@ -61,7 +61,6 @@ NetworkManager::NetworkManager(QupZilla* mainClass, QObject* parent)
|
||||
: NetworkManagerProxy(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*)));
|
||||
@ -69,6 +68,8 @@ NetworkManager::NetworkManager(QupZilla* mainClass, QObject* parent)
|
||||
connect(this, SIGNAL(sslErrors(QNetworkReply*, QList<QSslError>)), this, SLOT(sslError(QNetworkReply*, QList<QSslError>)));
|
||||
connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(setSSLConfiguration(QNetworkReply*)));
|
||||
|
||||
m_schemeHandlers["qupzilla"] = new QupZillaSchemeHandler;
|
||||
|
||||
m_proxyFactory = new NetworkProxyFactory();
|
||||
setProxyFactory(m_proxyFactory);
|
||||
loadSettings();
|
||||
@ -322,6 +323,14 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
|
||||
QNetworkRequest req = request;
|
||||
QNetworkReply* reply = 0;
|
||||
|
||||
//SchemeHandlers
|
||||
if (m_schemeHandlers.contains(req.url().scheme())) {
|
||||
reply = m_schemeHandlers[req.url().scheme()]->createRequest(op, req, outgoingData);
|
||||
if (reply) {
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_doNotTrack) {
|
||||
req.setRawHeader("DNT", QByteArray("1"));
|
||||
}
|
||||
@ -332,14 +341,6 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
|
||||
|
||||
req.setRawHeader("Accept-Language", m_acceptLanguage);
|
||||
|
||||
//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);
|
||||
@ -418,6 +419,16 @@ void NetworkManager::addLocalCertificate(const QSslCertificate &cert)
|
||||
}
|
||||
}
|
||||
|
||||
bool NetworkManager::registerSchemeHandler(const QString &scheme, SchemeHandler* handler)
|
||||
{
|
||||
if (m_schemeHandlers.contains(scheme)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_schemeHandlers[scheme] = handler;
|
||||
return true;
|
||||
}
|
||||
|
||||
void NetworkManager::saveCertificates()
|
||||
{
|
||||
Settings settings;
|
||||
|
@ -30,6 +30,7 @@ class QupZilla;
|
||||
class AdBlockNetwork;
|
||||
class NetworkProxyFactory;
|
||||
class QupZillaSchemeHandler;
|
||||
class SchemeHandler;
|
||||
|
||||
class QT_QUPZILLA_EXPORT NetworkManager : public NetworkManagerProxy
|
||||
{
|
||||
@ -54,6 +55,8 @@ public:
|
||||
void setIgnoreAllWarnings(bool state) { m_ignoreAllWarnings = state; }
|
||||
bool isIgnoringAllWarnings() { return m_ignoreAllWarnings; }
|
||||
|
||||
bool registerSchemeHandler(const QString &scheme, SchemeHandler* handler);
|
||||
|
||||
void disconnectObjects();
|
||||
|
||||
signals:
|
||||
@ -71,14 +74,13 @@ private:
|
||||
QupZilla* p_QupZilla;
|
||||
QNetworkDiskCache* m_diskCache;
|
||||
NetworkProxyFactory* m_proxyFactory;
|
||||
QupZillaSchemeHandler* m_qupzillaSchemeHandler;
|
||||
|
||||
QStringList m_certPaths;
|
||||
QList<QSslCertificate> m_caCerts;
|
||||
QList<QSslCertificate> m_localCerts;
|
||||
|
||||
QList<QSslCertificate> m_ignoredCerts;
|
||||
|
||||
QHash<QString, SchemeHandler*> m_schemeHandlers;
|
||||
QByteArray m_acceptLanguage;
|
||||
|
||||
bool m_ignoreAllWarnings;
|
||||
|
@ -60,7 +60,8 @@ QupZillaSchemeReply::QupZillaSchemeReply(const QNetworkRequest &req, QObject* pa
|
||||
setUrl(req.url());
|
||||
|
||||
m_pageName = req.url().path();
|
||||
if (m_pageName == "about" || m_pageName == "reportbug" || m_pageName == "start" || m_pageName == "speeddial" || m_pageName == "config") {
|
||||
if (m_pageName == "about" || m_pageName == "reportbug" || m_pageName == "start" ||
|
||||
m_pageName == "speeddial" || m_pageName == "config") {
|
||||
m_buffer.open(QIODevice::ReadWrite);
|
||||
setError(QNetworkReply::NoError, tr("No Error"));
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
#ifndef QUPZILLASCHEMEHANDLER_H
|
||||
#define QUPZILLASCHEMEHANDLER_H
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "schemehandler.h"
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QupZillaSchemeHandler
|
||||
class QT_QUPZILLA_EXPORT QupZillaSchemeHandler : public SchemeHandler
|
||||
{
|
||||
public:
|
||||
explicit QupZillaSchemeHandler();
|
||||
|
22
src/lib/network/schemehandler.cpp
Normal file
22
src/lib/network/schemehandler.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
* ============================================================ */
|
||||
#include "schemehandler.h"
|
||||
|
||||
SchemeHandler::SchemeHandler()
|
||||
{
|
||||
}
|
33
src/lib/network/schemehandler.h
Normal file
33
src/lib/network/schemehandler.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
* ============================================================ */
|
||||
#ifndef SCHEMEHANDLER_H
|
||||
#define SCHEMEHANDLER_H
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QT_QUPZILLA_EXPORT SchemeHandler
|
||||
{
|
||||
public:
|
||||
SchemeHandler();
|
||||
|
||||
virtual QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData) = 0;
|
||||
};
|
||||
|
||||
#endif // SCHEMEHANDLER_H
|
@ -62,7 +62,7 @@ void AboutDialog::showAbout()
|
||||
#endif
|
||||
));
|
||||
m_aboutHtml.append(tr("<b>WebKit version %1</b></p>").arg(QupZilla::WEBKITVERSION));
|
||||
m_aboutHtml.append(tr("<p>© %1 %2<br/>All rights reserved.<br/>").arg(QupZilla::COPYRIGHT, QupZilla::AUTHOR));
|
||||
m_aboutHtml.append(tr("<p>© %1 %2<br/>").arg(QupZilla::COPYRIGHT, QupZilla::AUTHOR));
|
||||
m_aboutHtml.append(tr("<small>Build time: %1 </small></p>").arg(QupZilla::BUILDTIME));
|
||||
m_aboutHtml.append(QString("<p><a href=%1>%1</a></p>").arg(QupZilla::WWWADDRESS));
|
||||
m_aboutHtml.append("<p>" + mApp->getWindow()->weView()->webPage()->userAgentForUrl(QUrl()) + "</p>");
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>381</width>
|
||||
<height>440</height>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
57
src/lib/other/checkboxdialog.cpp
Normal file
57
src/lib/other/checkboxdialog.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
* ============================================================ */
|
||||
#include "checkboxdialog.h"
|
||||
#include "ui_checkboxdialog.h"
|
||||
|
||||
CheckBoxDialog::CheckBoxDialog(const QDialogButtonBox::StandardButtons &buttons, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::CheckBoxDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->buttonBox->setStandardButtons(buttons);
|
||||
}
|
||||
|
||||
void CheckBoxDialog::setPixmap(const QPixmap &pixmap)
|
||||
{
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->iconLabel->setFixedWidth(pixmap.width());
|
||||
}
|
||||
|
||||
void CheckBoxDialog::setText(const QString &text)
|
||||
{
|
||||
ui->textLabel->setText(text);
|
||||
}
|
||||
|
||||
void CheckBoxDialog::setCheckBoxText(const QString &text)
|
||||
{
|
||||
ui->checkBox->setText(text);
|
||||
}
|
||||
|
||||
bool CheckBoxDialog::isChecked() const
|
||||
{
|
||||
return ui->checkBox->isChecked();
|
||||
}
|
||||
|
||||
int CheckBoxDialog::exec()
|
||||
{
|
||||
ui->buttonBox->setFocus();
|
||||
setMaximumSize(size());
|
||||
|
||||
return QDialog::exec();
|
||||
}
|
51
src/lib/other/checkboxdialog.h
Normal file
51
src/lib/other/checkboxdialog.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
* ============================================================ */
|
||||
#ifndef CHECKBOXDIALOG_H
|
||||
#define CHECKBOXDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CheckBoxDialog;
|
||||
}
|
||||
|
||||
class QT_QUPZILLA_EXPORT CheckBoxDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CheckBoxDialog(const QDialogButtonBox::StandardButtons &buttons, QWidget* parent = 0);
|
||||
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
void setText(const QString &text);
|
||||
void setCheckBoxText(const QString &text);
|
||||
|
||||
bool isChecked() const;
|
||||
|
||||
public slots:
|
||||
int exec();
|
||||
|
||||
private:
|
||||
Ui::CheckBoxDialog* ui;
|
||||
|
||||
};
|
||||
|
||||
#endif // CHECKBOXDIALOG_H
|
98
src/lib/other/checkboxdialog.ui
Normal file
98
src/lib/other/checkboxdialog.ui
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CheckBoxDialog</class>
|
||||
<widget class="QDialog" name="CheckBoxDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>409</width>
|
||||
<height>94</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="iconLabel"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CheckBoxDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CheckBoxDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,88 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CloseDialog</class>
|
||||
<widget class="QDialog" name="CloseDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>208</width>
|
||||
<height>98</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>There are still open tabs</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="textLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="3">
|
||||
<widget class="QLabel" name="iconLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="dontAskAgain">
|
||||
<property name="text">
|
||||
<string>Don't ask again</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CloseDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CloseDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
DatabaseWriter::DatabaseWriter(QObject *parent)
|
||||
DatabaseWriter::DatabaseWriter(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
@ -22,10 +22,10 @@
|
||||
#include "globalfunctions.h"
|
||||
#include "iconprovider.h"
|
||||
#include "enhancedmenu.h"
|
||||
#include "plaineditwithlines.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QMenuBar>
|
||||
#include <QTextEdit>
|
||||
#include <QStatusBar>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
@ -39,7 +39,7 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowTitle(tr("Source of ") + frame->url().toString());
|
||||
m_layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
|
||||
m_sourceEdit = new QTextEdit(this);
|
||||
m_sourceEdit = new PlainEditWithLines(this);
|
||||
m_sourceEdit->setObjectName("sourceviewer-textedit");
|
||||
|
||||
m_statusBar = new QStatusBar(this);
|
||||
@ -175,10 +175,5 @@ void SourceViewer::goToLine()
|
||||
return;
|
||||
}
|
||||
|
||||
m_sourceEdit->setUpdatesEnabled(false);
|
||||
m_sourceEdit->moveCursor(QTextCursor::Start);
|
||||
for (int i = 0; i < line; i++) {
|
||||
m_sourceEdit->moveCursor(QTextCursor::Down);
|
||||
}
|
||||
m_sourceEdit->setUpdatesEnabled(true);
|
||||
m_sourceEdit->goToLine(line);
|
||||
}
|
||||
|
@ -23,7 +23,8 @@
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QTextEdit;
|
||||
class PlainEditWithLines;
|
||||
|
||||
class QBoxLayout;
|
||||
class QStatusBar;
|
||||
class QWebFrame;
|
||||
@ -33,7 +34,7 @@ class QT_QUPZILLA_EXPORT SourceViewer : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SourceViewer(QWebFrame* frame, const QString &selectedHtml);
|
||||
QTextEdit* sourceEdit() { return m_sourceEdit; }
|
||||
PlainEditWithLines* sourceEdit() { return m_sourceEdit; }
|
||||
|
||||
signals:
|
||||
|
||||
@ -49,7 +50,7 @@ private slots:
|
||||
|
||||
private:
|
||||
QBoxLayout* m_layout;
|
||||
QTextEdit* m_sourceEdit;
|
||||
PlainEditWithLines* m_sourceEdit;
|
||||
QWeakPointer<QWebFrame> m_frame;
|
||||
QStatusBar* m_statusBar;
|
||||
};
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include "ui_sourceviewersearch.h"
|
||||
#include "sourceviewer.h"
|
||||
#include "iconprovider.h"
|
||||
#include "plaineditwithlines.h"
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QShortcut>
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define PLUGINPROXY_H
|
||||
|
||||
#include "mainapplication.h"
|
||||
#include "networkmanager.h"
|
||||
#include "plugins.h"
|
||||
#include "qz_namespace.h"
|
||||
|
||||
@ -74,5 +75,6 @@ private:
|
||||
};
|
||||
|
||||
#define QZ_REGISTER_EVENT_HANDLER(Type) mApp->plugins()->registerAppEventHandler(Type, this);
|
||||
#define QZ_REGISTER_SCHEME_HANDLER(Scheme, Object) mApp->networkManager()->registerSchemeHandler(Scheme, Object);
|
||||
|
||||
#endif // PLUGINPROXY_H
|
||||
|
@ -152,9 +152,9 @@ void Plugins::loadAvailablePlugins()
|
||||
|
||||
QStringList dirs;
|
||||
dirs << mApp->DATADIR + "plugins/"
|
||||
#ifdef Q_WS_X11
|
||||
#ifdef Q_WS_X11
|
||||
<< "/usr/lib/qupzilla/"
|
||||
#endif
|
||||
#endif
|
||||
<< mApp->PROFILEDIR + "plugins/";
|
||||
|
||||
foreach(const QString & dir, dirs) {
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
explicit ClosedTabsManager();
|
||||
|
||||
void saveView(WebTab *tab, int position);
|
||||
void saveView(WebTab* tab, int position);
|
||||
ClosedTabsManager::Tab getFirstClosedTab();
|
||||
ClosedTabsManager::Tab getTabAt(int index);
|
||||
|
||||
|
@ -173,6 +173,8 @@ QString qz_urlEncodeQueryString(const QUrl &url)
|
||||
returnString.append(url.encodedFragment());
|
||||
}
|
||||
|
||||
returnString.replace(" ", "%20");
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
||||
|
199
src/lib/tools/plaineditwithlines.cpp
Normal file
199
src/lib/tools/plaineditwithlines.cpp
Normal file
@ -0,0 +1,199 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
* ============================================================ */
|
||||
#include "plaineditwithlines.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QTextBlock>
|
||||
|
||||
PlainEditWithLines::PlainEditWithLines(QWidget* parent)
|
||||
: QPlainTextEdit(parent)
|
||||
, m_lineNumberArea(new LineNumberArea(this))
|
||||
, m_countCache(-1, -1)
|
||||
{
|
||||
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
|
||||
connect(this, SIGNAL(updateRequest(QRect, int)), this, SLOT(updateLineNumberArea(QRect, int)));
|
||||
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
|
||||
|
||||
updateLineNumberAreaWidth(0);
|
||||
highlightCurrentLine();
|
||||
}
|
||||
|
||||
int PlainEditWithLines::lineNumberAreaWidth()
|
||||
{
|
||||
int digits = 1;
|
||||
int max = qMax(1, blockCount());
|
||||
while (max >= 10) {
|
||||
max /= 10;
|
||||
++digits;
|
||||
}
|
||||
|
||||
int space = 5 + fontMetrics().width(QLatin1Char('9')) * digits;
|
||||
|
||||
return space;
|
||||
}
|
||||
|
||||
void PlainEditWithLines::setReadOnly(bool ro)
|
||||
{
|
||||
QPlainTextEdit::setReadOnly(ro);
|
||||
|
||||
highlightCurrentLine();
|
||||
}
|
||||
|
||||
void PlainEditWithLines::goToLine(int line)
|
||||
{
|
||||
setUpdatesEnabled(false);
|
||||
|
||||
moveCursor(QTextCursor::Start);
|
||||
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, line - 1);
|
||||
|
||||
setTextCursor(cursor);
|
||||
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void PlainEditWithLines::updateLineNumberAreaWidth(int /* newBlockCount */)
|
||||
{
|
||||
setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
|
||||
}
|
||||
|
||||
void PlainEditWithLines::updateLineNumberArea(const QRect &rect, int dy)
|
||||
{
|
||||
if (dy) {
|
||||
m_lineNumberArea->scroll(0, dy);
|
||||
}
|
||||
else if (m_countCache.first != blockCount() || m_countCache.second != textCursor().block().lineCount()) {
|
||||
m_lineNumberArea->update(0, rect.y(), m_lineNumberArea->width(), rect.height());
|
||||
m_countCache.first = blockCount();
|
||||
m_countCache.second = textCursor().block().lineCount();
|
||||
}
|
||||
|
||||
if (rect.contains(viewport()->rect())) {
|
||||
updateLineNumberAreaWidth(0);
|
||||
}
|
||||
}
|
||||
|
||||
void PlainEditWithLines::resizeEvent(QResizeEvent* e)
|
||||
{
|
||||
QPlainTextEdit::resizeEvent(e);
|
||||
|
||||
QRect cr = contentsRect();
|
||||
m_lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
|
||||
}
|
||||
|
||||
void PlainEditWithLines::highlightCurrentLine()
|
||||
{
|
||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||
QTextEdit::ExtraSelection selection;
|
||||
QColor lineColor = palette().color(QPalette::Highlight).lighter();
|
||||
|
||||
selection.format.setBackground(lineColor);
|
||||
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||
selection.cursor = textCursor();
|
||||
selection.cursor.clearSelection();
|
||||
extraSelections.append(selection);
|
||||
|
||||
setExtraSelections(extraSelections);
|
||||
}
|
||||
|
||||
void PlainEditWithLines::lineNumberAreaPaintEvent(QPaintEvent* event)
|
||||
{
|
||||
const QRect &eventRect = event->rect();
|
||||
|
||||
QPainter painter(m_lineNumberArea);
|
||||
painter.fillRect(eventRect, QColor(235, 235, 235));
|
||||
painter.fillRect(QRect(eventRect.width() - 1, 0, 1, viewport()->height()), QColor(175, 175, 175));
|
||||
|
||||
QTextBlock block = firstVisibleBlock();
|
||||
int blockNumber = block.blockNumber();
|
||||
int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top();
|
||||
int bottom = top + (int) blockBoundingRect(block).height();
|
||||
|
||||
QColor textColor(175, 175, 175);
|
||||
|
||||
while (block.isValid() && top <= eventRect.bottom()) {
|
||||
if (block.isVisible() && bottom >= eventRect.top()) {
|
||||
QString number = QString::number(blockNumber + 1);
|
||||
painter.setPen(textColor);
|
||||
|
||||
painter.drawText(0, top, m_lineNumberArea->width() - 3, fontMetrics().height(),
|
||||
Qt::AlignRight, number);
|
||||
}
|
||||
|
||||
block = block.next();
|
||||
top = bottom;
|
||||
bottom = top + (int) blockBoundingRect(block).height();
|
||||
++blockNumber;
|
||||
}
|
||||
}
|
||||
|
||||
LineNumberArea::LineNumberArea(PlainEditWithLines* editor)
|
||||
: QWidget(editor)
|
||||
, m_codeEditor(editor)
|
||||
{
|
||||
}
|
||||
|
||||
QSize LineNumberArea::sizeHint() const
|
||||
{
|
||||
return QSize(m_codeEditor->lineNumberAreaWidth(), 0);
|
||||
}
|
||||
|
||||
void LineNumberArea::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
m_codeEditor->lineNumberAreaPaintEvent(event);
|
||||
}
|
116
src/lib/tools/plaineditwithlines.h
Normal file
116
src/lib/tools/plaineditwithlines.h
Normal file
@ -0,0 +1,116 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the examples of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:BSD$
|
||||
** You may use this file under the terms of the BSD license as follows:
|
||||
**
|
||||
** "Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
||||
** the names of its contributors may be used to endorse or promote
|
||||
** products derived from this software without specific prior written
|
||||
** permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
* ============================================================ */
|
||||
#ifndef PLAINEDITWITHLINES_H
|
||||
#define PLAINEDITWITHLINES_H
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QPaintEvent;
|
||||
class QResizeEvent;
|
||||
class QSize;
|
||||
class QWidget;
|
||||
|
||||
class LineNumberArea;
|
||||
|
||||
|
||||
class QT_QUPZILLA_EXPORT PlainEditWithLines : public QPlainTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlainEditWithLines(QWidget* parent = 0);
|
||||
|
||||
void lineNumberAreaPaintEvent(QPaintEvent* event);
|
||||
int lineNumberAreaWidth();
|
||||
|
||||
void setReadOnly(bool ro);
|
||||
|
||||
public slots:
|
||||
void goToLine(int line);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
|
||||
private slots:
|
||||
void updateLineNumberAreaWidth(int newBlockCount);
|
||||
void highlightCurrentLine();
|
||||
void updateLineNumberArea(const QRect &, int);
|
||||
|
||||
private:
|
||||
QWidget* m_lineNumberArea;
|
||||
|
||||
QPair<int, int> m_countCache;
|
||||
};
|
||||
|
||||
|
||||
class QT_QUPZILLA_EXPORT LineNumberArea : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit LineNumberArea(PlainEditWithLines* editor);
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event);
|
||||
|
||||
private:
|
||||
PlainEditWithLines* m_codeEditor;
|
||||
};
|
||||
|
||||
#endif // PLAINEDITWITHLINES_H
|
@ -411,7 +411,7 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event)
|
||||
QTabBar::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void TabBar::wheelEvent(QWheelEvent *event)
|
||||
void TabBar::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
if (mApp->plugins()->processWheelEvent(Qz::ON_TabBar, this, event)) {
|
||||
return;
|
||||
|
@ -79,7 +79,7 @@ private:
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "ui_jsalert.h"
|
||||
#include "ui_jsprompt.h"
|
||||
#endif
|
||||
#include "ui_closedialog.h"
|
||||
#include "checkboxdialog.h"
|
||||
#include "widget.h"
|
||||
#include "globalfunctions.h"
|
||||
#include "pluginproxy.h"
|
||||
@ -43,6 +43,7 @@
|
||||
#include <QTimer>
|
||||
#include <QNetworkReply>
|
||||
#include <QDebug>
|
||||
#include <QStyle>
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
@ -80,6 +81,10 @@ WebPage::WebPage(QupZilla* mainClass)
|
||||
connect(this, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
|
||||
|
||||
connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject()));
|
||||
|
||||
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0))
|
||||
connect(this, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this, SLOT(featurePermissionRequested(QWebFrame*, QWebPage::Feature)));
|
||||
#endif
|
||||
}
|
||||
|
||||
QUrl WebPage::url() const
|
||||
@ -281,6 +286,13 @@ void WebPage::windowCloseRequested()
|
||||
webView->closeView();
|
||||
}
|
||||
|
||||
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0))
|
||||
void WebPage::featurePermissionRequested(QWebFrame* frame, const QWebPage::Feature &feature)
|
||||
{
|
||||
// We should probably ask user here ... -,-
|
||||
setFeaturePermission(frame, feature, PermissionGrantedByUser);
|
||||
}
|
||||
#endif
|
||||
|
||||
void WebPage::setSSLCertificate(const QSslCertificate &cert)
|
||||
{
|
||||
@ -645,22 +657,20 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
|
||||
}
|
||||
|
||||
#ifndef NONBLOCK_JS_DIALOGS
|
||||
QDialog* dialog = new QDialog(view());
|
||||
Ui_CloseDialog* ui = new Ui_CloseDialog();
|
||||
ui->setupUi(dialog);
|
||||
ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok);
|
||||
ui->dontAskAgain->setText(tr("Prevent this page from creating additional dialogs"));
|
||||
ui->textLabel->setText(msg);
|
||||
ui->iconLabel->setPixmap(mApp->style()->standardPixmap(QStyle::SP_MessageBoxInformation));
|
||||
ui->buttonBox->setFocus();
|
||||
dialog->setWindowTitle(tr("JavaScript alert - %1").arg(url().host()));
|
||||
dialog->exec();
|
||||
|
||||
if (ui->dontAskAgain->isChecked()) {
|
||||
m_blockAlerts = true;
|
||||
QString title = tr("JavaScript alert");
|
||||
if (!url().host().isEmpty()) {
|
||||
title.append(QString(" - %1").arg(url().host()));
|
||||
}
|
||||
|
||||
delete dialog;
|
||||
CheckBoxDialog dialog(QDialogButtonBox::Ok, view());
|
||||
dialog.setWindowTitle(title);
|
||||
dialog.setText(msg);
|
||||
dialog.setCheckBoxText(tr("Prevent this page from creating additional dialogs"));
|
||||
dialog.setPixmap(mApp->style()->standardPixmap(QStyle::SP_MessageBoxInformation));
|
||||
dialog.exec();
|
||||
|
||||
m_blockAlerts = dialog.isChecked();
|
||||
|
||||
#else
|
||||
WebView* webView = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
ResizableFrame* widget = new ResizableFrame(webView->overlayForJsAlert());
|
||||
|
@ -91,6 +91,10 @@ private slots:
|
||||
void downloadRequested(const QNetworkRequest &request);
|
||||
void windowCloseRequested();
|
||||
|
||||
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0))
|
||||
void featurePermissionRequested(QWebFrame* frame, const QWebPage::Feature &feature);
|
||||
#endif
|
||||
|
||||
private:
|
||||
virtual bool supportsExtension(Extension extension) const;
|
||||
virtual bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0);
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
QUrl url() const;
|
||||
QString title() const;
|
||||
QIcon icon() const;
|
||||
QWebHistory *history() const;
|
||||
QWebHistory* history() const;
|
||||
|
||||
void setHistoryData(const QByteArray &data);
|
||||
QByteArray historyData() const;
|
||||
|
Loading…
Reference in New Issue
Block a user