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

Qt5: Main code has been edited to support both Qt4 and Qt5

It doesn't include plugins yet.
Even thought the app can be built with Qt5 now, it won't run.
I am still working on a fix.
This commit is contained in:
nowrep 2012-12-20 14:45:35 +01:00
parent 14874913b4
commit 89e091f09c
74 changed files with 312 additions and 114 deletions

View File

@ -14,5 +14,10 @@ lessThan(QT_VERSION, 4.7) {
mac|unix: system(test -d bin/plugins || mkdir bin/plugins) mac|unix: system(test -d bin/plugins || mkdir bin/plugins)
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS = src/lib src/main src/plugins SUBDIRS = src/lib src/main
CONFIG += ordered CONFIG += ordered
# TODO: Fix plugins for Qt5
!isEqual(QT_MAJOR_VERSION, 5) {
SUBDIRS += src/plugins
}

View File

@ -45,7 +45,7 @@
#include <QToolButton> #include <QToolButton>
#include <QToolTip> #include <QToolTip>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWindowsStyle> //#include <QWindowsStyle>
using namespace Core; using namespace Core;
using namespace Internal; using namespace Internal;
@ -250,7 +250,7 @@ FancyTabBar::FancyTabBar(QWidget* parent)
: QWidget(parent) : QWidget(parent)
{ {
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
setStyle(new QWindowsStyle); //setStyle(new QWindowsStyle);
setMinimumWidth(qMax(2 * m_rounding, 40)); setMinimumWidth(qMax(2 * m_rounding, 40));
setAttribute(Qt::WA_Hover, true); setAttribute(Qt::WA_Hover, true);
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);

View File

@ -86,7 +86,8 @@ void LineEdit::init()
mainLayout->addWidget(m_leftWidget, 0, Qt::AlignVCenter | Qt::AlignLeft); mainLayout->addWidget(m_leftWidget, 0, Qt::AlignVCenter | Qt::AlignLeft);
mainLayout->addItem(horizontalSpacer); mainLayout->addItem(horizontalSpacer);
mainLayout->addWidget(m_rightWidget, 0, Qt::AlignVCenter | Qt::AlignRight); mainLayout->addWidget(m_rightWidget, 0, Qt::AlignVCenter | Qt::AlignRight);
//by this we undo reversing of layout when direction is RTL. //TODO: don't do this and show reversed icon when needed // by this we undo reversing of layout when direction is RTL.
// TODO: don't do this and show reversed icon when needed
mainLayout->setDirection(isRightToLeft() ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight); mainLayout->setDirection(isRightToLeft() ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight);
setWidgetSpacing(3); setWidgetSpacing(3);

View File

@ -47,7 +47,7 @@
#include "qtsingleapplication.h" #include "qtsingleapplication.h"
#include "qtlocalpeer.h" #include "qtlocalpeer.h"
#include <QtGui/QWidget> #include <QWidget>
/*! /*!
@ -179,20 +179,6 @@ QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char**
sysInit(appId); sysInit(appId);
} }
/*!
Creates a QtSingleApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc, \a
argv, and \a type are passed on to the QAppliation constructor.
*/
QtSingleApplication::QtSingleApplication(int &argc, char** argv, Type type)
: QApplication(argc, argv, type)
, peer(0)
, actWin(0)
{
}
#if defined(Q_WS_X11) #if defined(Q_WS_X11)
/*! /*!
Special constructor for X11, ref. the documentation of Special constructor for X11, ref. the documentation of

View File

@ -45,7 +45,7 @@
****************************************************************************/ ****************************************************************************/
#include <QtGui/QApplication> #include <QApplication>
class QtLocalPeer; class QtLocalPeer;
@ -72,7 +72,6 @@ class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
public: public:
QtSingleApplication(int &argc, char** argv, bool GUIenabled = true); QtSingleApplication(int &argc, char** argv, bool GUIenabled = true);
QtSingleApplication(const QString &id, int &argc, char** argv); QtSingleApplication(const QString &id, int &argc, char** argv);
QtSingleApplication(int &argc, char** argv, Type type);
#if defined(Q_WS_X11) #if defined(Q_WS_X11)
QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
QtSingleApplication(Display* dpy, int &argc, char** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); QtSingleApplication(Display* dpy, int &argc, char** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0);

View File

@ -20,6 +20,8 @@
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMimeData>
#include <QDrag>
#include <QMenu> #include <QMenu>
SqueezeLabelV2::SqueezeLabelV2(QWidget* parent) SqueezeLabelV2::SqueezeLabelV2(QWidget* parent)

View File

@ -29,13 +29,13 @@
#include "stylehelper.h" #include "stylehelper.h"
#include <QtGui/QPixmapCache> #include <QPixmapCache>
#include <QtGui/QWidget> #include <QWidget>
#include <QtCore/QRect> #include <QtCore/QRect>
#include <QtGui/QPainter> #include <QPainter>
#include <QtGui/QApplication> #include <QApplication>
#include <QtGui/QPalette> #include <QPalette>
#include <QtGui/QStyleOption> #include <QStyleOption>
#include <QtCore/QObject> #include <QtCore/QObject>
// Clamps float color values within (0, 255) // Clamps float color values within (0, 255)

View File

@ -32,8 +32,8 @@
#include "qz_namespace.h" #include "qz_namespace.h"
#include <QtGui/QColor> #include <QColor>
#include <QtGui/QStyle> #include <QStyle>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QPalette; class QPalette;

View File

@ -131,7 +131,7 @@ AdBlockSubscription* AdBlockManager::addSubscription(const QString &title, const
QString fileName = qz_filterCharsFromFilename(title.toLower()) + ".txt"; QString fileName = qz_filterCharsFromFilename(title.toLower()) + ".txt";
QString filePath = qz_ensureUniqueFilename(mApp->currentProfilePath() + "adblock/" + fileName); QString filePath = qz_ensureUniqueFilename(mApp->currentProfilePath() + "adblock/" + fileName);
QByteArray data = QString("Title: %1\nUrl: %2\n[Adblock Plus 1.1.1]").arg(title, url).toAscii(); QByteArray data = QString("Title: %1\nUrl: %2\n[Adblock Plus 1.1.1]").arg(title, url).toLatin1();
QFile file(filePath); QFile file(filePath);
if (!file.open(QFile::WriteOnly | QFile::Truncate)) { if (!file.open(QFile::WriteOnly | QFile::Truncate)) {

View File

@ -20,7 +20,7 @@
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <QWeakPointer> #include <QPointer>
#include "qz_namespace.h" #include "qz_namespace.h"
@ -81,7 +81,7 @@ private:
QList<AdBlockSubscription*> m_subscriptions; QList<AdBlockSubscription*> m_subscriptions;
QStringList m_disabledRules; QStringList m_disabledRules;
QWeakPointer<AdBlockDialog> m_adBlockDialog; QPointer<AdBlockDialog> m_adBlockDialog;
}; };
#endif // ADBLOCKMANAGER_H #endif // ADBLOCKMANAGER_H

View File

@ -19,6 +19,8 @@
#define COMMANDLINEOPTIONS_H #define COMMANDLINEOPTIONS_H
#include <QPair> #include <QPair>
#include <QString>
#include <QList>
#include <iostream> #include <iostream>
#include "qz_namespace.h" #include "qz_namespace.h"

View File

@ -866,7 +866,7 @@ QUrl MainApplication::userStyleSheet(const QString &filePath) const
file.close(); file.close();
} }
const QString &encodedStyle = userStyle.toAscii().toBase64(); const QString &encodedStyle = userStyle.toLatin1().toBase64();
const QString &dataString = QString("data:text/css;charset=utf-8;base64,%1").arg(encodedStyle); const QString &dataString = QString("data:text/css;charset=utf-8;base64,%1").arg(encodedStyle);
return QUrl(dataString); return QUrl(dataString);

View File

@ -22,7 +22,7 @@
#include <QList> #include <QList>
#include <QUrl> #include <QUrl>
#include <QWeakPointer> #include <QPointer>
#include "restoremanager.h" #include "restoremanager.h"
#include "qtsingleapplication.h" #include "qtsingleapplication.h"
@ -164,7 +164,7 @@ private:
DatabaseWriter* m_dbWriter; DatabaseWriter* m_dbWriter;
UserAgentManager* m_uaManager; UserAgentManager* m_uaManager;
QList<QWeakPointer<QupZilla> > m_mainWindows; QList<QPointer<QupZilla> > m_mainWindows;
QString m_activeProfil; QString m_activeProfil;
QString m_activeLanguage; QString m_activeLanguage;

View File

@ -87,6 +87,10 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#endif #endif
#if QT_VERSION < 0x050000
#include "qwebkitversion.h"
#endif
const QString QupZilla::VERSION = "1.3.5"; const QString QupZilla::VERSION = "1.3.5";
const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; const QString QupZilla::BUILDTIME = __DATE__" "__TIME__;
const QString QupZilla::AUTHOR = "David Rosca"; const QString QupZilla::AUTHOR = "David Rosca";
@ -1842,7 +1846,7 @@ void QupZilla::disconnectObjects()
tab->view()->page()->disconnectObjects(); tab->view()->page()->disconnectObjects();
} }
foreach(const QWeakPointer<QWidget> &pointer, m_deleteOnCloseWidgets) { foreach(const QPointer<QWidget> &pointer, m_deleteOnCloseWidgets) {
if (pointer) { if (pointer) {
pointer.data()->deleteLater(); pointer.data()->deleteLater();
} }

View File

@ -20,7 +20,6 @@
#include <QMainWindow> #include <QMainWindow>
#include <QUrl> #include <QUrl>
#include "qwebkitversion.h"
#include "restoremanager.h" #include "restoremanager.h"
#include "qz_namespace.h" #include "qz_namespace.h"
@ -265,11 +264,11 @@ private:
QLabel* m_privateBrowsing; QLabel* m_privateBrowsing;
AdBlockIcon* m_adblockIcon; AdBlockIcon* m_adblockIcon;
QWeakPointer<WebInspectorDockWidget> m_webInspectorDock; QPointer<WebInspectorDockWidget> m_webInspectorDock;
BookmarksToolbar* m_bookmarksToolbar; BookmarksToolbar* m_bookmarksToolbar;
TabWidget* m_tabWidget; TabWidget* m_tabWidget;
QWeakPointer<SideBar> m_sideBar; QPointer<SideBar> m_sideBar;
SideBarManager* m_sideBarManager; SideBarManager* m_sideBarManager;
StatusBarMessage* m_statusBarMessage; StatusBarMessage* m_statusBarMessage;
NavigationBar* m_navigationBar; NavigationBar* m_navigationBar;
@ -294,7 +293,7 @@ private:
bool m_navigationVisible; bool m_navigationVisible;
bool m_bookmarksToolBarVisible; bool m_bookmarksToolBarVisible;
QList<QWeakPointer<QWidget> > m_deleteOnCloseWidgets; QList<QPointer<QWidget> > m_deleteOnCloseWidgets;
}; };
#endif // QUPZILLA_H #endif // QUPZILLA_H

View File

@ -30,6 +30,10 @@
#include <QWebFrame> #include <QWebFrame>
#include <QNetworkRequest> #include <QNetworkRequest>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
AutoFillModel::AutoFillModel(QupZilla* mainClass, QObject* parent) AutoFillModel::AutoFillModel(QupZilla* mainClass, QObject* parent)
: QObject(parent) : QObject(parent)
, p_QupZilla(mainClass) , p_QupZilla(mainClass)
@ -224,8 +228,11 @@ void AutoFillModel::completePage(WebPage* page)
// Why not to use encodedQueryItems = QByteArrays ? // Why not to use encodedQueryItems = QByteArrays ?
// Because we need to filter "+" characters that must be spaces // Because we need to filter "+" characters that must be spaces
// (not real "+" characters "%2B") // (not real "+" characters "%2B")
#if QT_VERSION >= 0x050000
QueryItems arguments = QUrlQuery(QUrl::fromEncoded("http://bla.com/?" + data)).queryItems();
#else
QueryItems arguments = QUrl::fromEncoded("http://bla.com/?" + data).queryItems(); QueryItems arguments = QUrl::fromEncoded("http://bla.com/?" + data).queryItems();
#endif
for (int i = 0; i < arguments.count(); i++) { for (int i = 0; i < arguments.count(); i++) {
QString key = arguments.at(i).first; QString key = arguments.at(i).first;
QString value = arguments.at(i).second; QString value = arguments.at(i).second;
@ -345,7 +352,11 @@ QString AutoFillModel::getValueFromData(const QByteArray &data, QWebElement elem
QString value = element.evaluateJavaScript("this.value").toString(); QString value = element.evaluateJavaScript("this.value").toString();
if (value.isEmpty()) { if (value.isEmpty()) {
#if QT_VERSION >= 0x050000
QueryItems queryItems = QUrlQuery(QUrl::fromEncoded("http://a.b/?" + data)).queryItems();
#else
QueryItems queryItems = QUrl::fromEncoded("http://a.b/?" + data).queryItems(); QueryItems queryItems = QUrl::fromEncoded("http://a.b/?" + data).queryItems();
#endif
for (int i = 0; i < queryItems.count(); i++) { for (int i = 0; i < queryItems.count(); i++) {
QueryItem item = queryItems.at(i); QueryItem item = queryItems.at(i);
@ -404,7 +415,11 @@ QByteArray AutoFillModel::convertWebKitFormBoundaryIfNecessary(const QByteArray
bool AutoFillModel::dataContains(const QByteArray &data, const QString &attributeName) bool AutoFillModel::dataContains(const QByteArray &data, const QString &attributeName)
{ {
#if QT_VERSION >= 0x050000
QueryItems queryItems = QUrlQuery(QUrl::fromEncoded("http://a.b/?" + data)).queryItems();
#else
QueryItems queryItems = QUrl::fromEncoded("http://a.b/?" + data).queryItems(); QueryItems queryItems = QUrl::fromEncoded("http://a.b/?" + data).queryItems();
#endif
for (int i = 0; i < queryItems.count(); i++) { for (int i = 0; i < queryItems.count(); i++) {
QueryItem item = queryItems.at(i); QueryItem item = queryItems.at(i);

View File

@ -18,6 +18,7 @@
#ifndef AUTOFILLMODEL_H #ifndef AUTOFILLMODEL_H
#define AUTOFILLMODEL_H #define AUTOFILLMODEL_H
#include <QObject>
#include <QPair> #include <QPair>
#include "qz_namespace.h" #include "qz_namespace.h"

View File

@ -169,7 +169,7 @@ void BookmarksManager::changeIcon()
QIcon icon; QIcon icon;
IconChooser chooser(this); IconChooser chooser(this);
icon = chooser.exec(); icon = chooser.getIcon();
if (!icon.isNull()) { if (!icon.isNull()) {
m_bookmarksModel->changeIcon(id, icon); m_bookmarksModel->changeIcon(id, icon);

View File

@ -19,7 +19,7 @@
#define BOOKMARKSMANAGER_H #define BOOKMARKSMANAGER_H
#include <QWidget> #include <QWidget>
#include <QWeakPointer> #include <QPointer>
#include "bookmarksmodel.h" #include "bookmarksmodel.h"
#include "qz_namespace.h" #include "qz_namespace.h"
@ -84,7 +84,7 @@ private:
bool m_isRefreshing; bool m_isRefreshing;
Ui::BookmarksManager* ui; Ui::BookmarksManager* ui;
QWeakPointer<QupZilla> p_QupZilla; QPointer<QupZilla> p_QupZilla;
BookmarksModel* m_bookmarksModel; BookmarksModel* m_bookmarksModel;
}; };

View File

@ -20,6 +20,7 @@
#include "mainapplication.h" #include "mainapplication.h"
#include "settings.h" #include "settings.h"
#include <QNetworkCookie>
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>

View File

@ -23,6 +23,7 @@
#include "globalfunctions.h" #include "globalfunctions.h"
#include "settings.h" #include "settings.h"
#include <QNetworkCookie>
#include <QMessageBox> #include <QMessageBox>
#include <QDateTime> #include <QDateTime>
#include <QShortcut> #include <QShortcut>
@ -153,7 +154,7 @@ void CookieManager::slotRefreshTable()
ui->cookieTree->clear(); ui->cookieTree->clear();
int counter = 0; int counter = 0;
QWeakPointer<CookieManager> guard = this; QPointer<CookieManager> guard = this;
QHash<QString, QTreeWidgetItem*> hash; QHash<QString, QTreeWidgetItem*> hash;
for (int i = 0; i < allCookies.count(); ++i) { for (int i = 0; i < allCookies.count(); ++i) {
const QNetworkCookie &cookie = allCookies.at(i); const QNetworkCookie &cookie = allCookies.at(i);

View File

@ -22,7 +22,7 @@
#include <QObject> #include <QObject>
#include <QPoint> #include <QPoint>
#include <QWeakPointer> #include <QPointer>
class QPixmap; class QPixmap;
@ -48,7 +48,7 @@ private:
Type m_notifType; Type m_notifType;
QPoint m_position; QPoint m_position;
QWeakPointer<DesktopNotification> m_desktopNotif; QPointer<DesktopNotification> m_desktopNotif;
quint32 m_uint; quint32 m_uint;
}; };

View File

@ -32,7 +32,12 @@
#include <QWebHistory> #include <QWebHistory>
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#if QT_VERSION >= 0x050000
#include <QStandardPaths>
#else
#include <QDesktopServices> #include <QDesktopServices>
#endif
DownloadFileHelper::DownloadFileHelper(const QString &lastDownloadPath, const QString &downloadPath, bool useNativeDialog) DownloadFileHelper::DownloadFileHelper(const QString &lastDownloadPath, const QString &downloadPath, bool useNativeDialog)
: QObject() : QObject()
@ -165,12 +170,22 @@ void DownloadFileHelper::optionsDialogAccepted(int finish)
dialog->selectFile(m_h_fileName); dialog->selectFile(m_h_fileName);
QList<QUrl> urls; QList<QUrl> urls;
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)) urls <<
#if QT_VERSION >= 0x050000
QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation))
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
#else
QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)) << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)) << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)) << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation)) << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation))
<< QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation)); << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
#endif
dialog->setSidebarUrls(urls); dialog->setSidebarUrls(urls);
dialog->show(); dialog->show();

View File

@ -19,7 +19,7 @@
#define HISTORYMANAGER_H #define HISTORYMANAGER_H
#include <QWidget> #include <QWidget>
#include <QWeakPointer> #include <QPointer>
#include "qz_namespace.h" #include "qz_namespace.h"
#include "historyview.h" #include "historyview.h"
@ -58,7 +58,7 @@ private:
QupZilla* getQupZilla(); QupZilla* getQupZilla();
Ui::HistoryManager* ui; Ui::HistoryManager* ui;
QWeakPointer<QupZilla> p_QupZilla; QPointer<QupZilla> p_QupZilla;
}; };
#endif // HISTORYMANAGER_H #endif // HISTORYMANAGER_H

View File

@ -1,4 +1,9 @@
QT += core gui webkit sql network script isEqual(QT_MAJOR_VERSION, 5) {
QT += webkitwidgets network widgets printsupport sql script
} else {
QT += core gui webkit sql network script
}
TARGET = QupZilla TARGET = QupZilla
TEMPLATE = lib TEMPLATE = lib

View File

@ -40,6 +40,7 @@
#include "qzsettings.h" #include "qzsettings.h"
#include "colors.h" #include "colors.h"
#include <QMimeData>
#include <QClipboard> #include <QClipboard>
#include <QTimer> #include <QTimer>
#include <QContextMenuEvent> #include <QContextMenuEvent>

View File

@ -20,6 +20,8 @@
#include "tabbedwebview.h" #include "tabbedwebview.h"
#include "globalfunctions.h" #include "globalfunctions.h"
#include <QDrag>
#include <QMimeData>
#include <QApplication> #include <QApplication>
#include <QContextMenuEvent> #include <QContextMenuEvent>

View File

@ -29,6 +29,8 @@
#include "searchenginesdialog.h" #include "searchenginesdialog.h"
#include "networkmanager.h" #include "networkmanager.h"
#include <QMimeData>
#include <QAbstractItemView>
#include <QCompleter> #include <QCompleter>
#include <QStringListModel> #include <QStringListModel>
#include <QMenu> #include <QMenu>

View File

@ -18,7 +18,7 @@
#ifndef WEBSEARCHBAR_H #ifndef WEBSEARCHBAR_H
#define WEBSEARCHBAR_H #define WEBSEARCHBAR_H
#include <QWeakPointer> #include <QPointer>
#include "qz_namespace.h" #include "qz_namespace.h"
#include "lineedit.h" #include "lineedit.h"
@ -91,7 +91,7 @@ private:
WebSearchBar_Button* m_buttonSearch; WebSearchBar_Button* m_buttonSearch;
ButtonWithMenu* m_boxSearchType; ButtonWithMenu* m_boxSearchType;
SearchEnginesManager* m_searchManager; SearchEnginesManager* m_searchManager;
QWeakPointer<SearchEnginesDialog> m_searchDialog; QPointer<SearchEnginesDialog> m_searchDialog;
QAction* m_pasteAndGoAction; QAction* m_pasteAndGoAction;
QAction* m_clearAction; QAction* m_clearAction;

View File

@ -38,7 +38,6 @@
#include <QLineEdit> #include <QLineEdit>
#include <QCheckBox> #include <QCheckBox>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QTextDocument>
#include <QNetworkDiskCache> #include <QNetworkDiskCache>
#include <QDir> #include <QDir>
#include <QSslSocket> #include <QSslSocket>
@ -130,7 +129,7 @@ void NetworkManager::setSSLConfiguration(QNetworkReply* reply)
{ {
if (!reply->sslConfiguration().isNull()) { if (!reply->sslConfiguration().isNull()) {
QSslCertificate cert = reply->sslConfiguration().peerCertificate(); QSslCertificate cert = reply->sslConfiguration().peerCertificate();
if (!cert.isValid() || reply->property("downReply").toBool()) { if (!qz_isCertificateValid(cert) || reply->property("downReply").toBool()) {
return; return;
} }
@ -269,7 +268,7 @@ void NetworkManager::authentication(QNetworkReply* reply, QAuthenticator* auth)
connect(box, SIGNAL(accepted()), dialog, SLOT(accept())); connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));
label->setText(tr("A username and password are being requested by %1. " label->setText(tr("A username and password are being requested by %1. "
"The site says: \"%2\"").arg(reply->url().toEncoded(), Qt::escape(auth->realm()))); "The site says: \"%2\"").arg(reply->url().toEncoded(), qz_escape(auth->realm())));
formLa->addRow(label); formLa->addRow(label);
formLa->addRow(userLab, user); formLa->addRow(userLab, user);

View File

@ -22,6 +22,10 @@
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QMessageBox> #include <QMessageBox>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
AdBlockSchemeHandler::AdBlockSchemeHandler() AdBlockSchemeHandler::AdBlockSchemeHandler()
: SchemeHandler() : SchemeHandler()
{ {
@ -36,7 +40,12 @@ QNetworkReply* AdBlockSchemeHandler::createRequest(QNetworkAccessManager::Operat
} }
const QUrl &url = request.url(); const QUrl &url = request.url();
const QList<QPair<QString, QString> > queryItems = url.queryItems(); const QList<QPair<QString, QString> > queryItems =
#if QT_VERSION >= 0x050000
QUrlQuery(url).queryItems();
#else
url.queryItems();
#endif
QString subscriptionTitle; QString subscriptionTitle;
QString subscriptionUrl; QString subscriptionUrl;

View File

@ -27,7 +27,6 @@
#include "settings.h" #include "settings.h"
#include "iconprovider.h" #include "iconprovider.h"
#include <QTextDocument>
#include <QTextStream> #include <QTextStream>
#include <QTimer> #include <QTimer>
#include <QSettings> #include <QSettings>
@ -191,7 +190,7 @@ QString QupZillaSchemeReply::aboutPage()
aPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png")); aPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png"));
aPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); aPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png"));
aPage.replace(QLatin1String("%ABOUT-IMG%"), QLatin1String("qrc:icons/other/about.png")); aPage.replace(QLatin1String("%ABOUT-IMG%"), QLatin1String("qrc:icons/other/about.png"));
aPage.replace(QLatin1String("%COPYRIGHT-INCLUDE%"), Qt::escape(qz_readAllFileContents(":html/copyright"))); aPage.replace(QLatin1String("%COPYRIGHT-INCLUDE%"), qz_escape(qz_readAllFileContents(":html/copyright")));
aPage.replace(QLatin1String("%TITLE%"), tr("About QupZilla")); aPage.replace(QLatin1String("%TITLE%"), tr("About QupZilla"));
aPage.replace(QLatin1String("%ABOUT-QUPZILLA%"), tr("About QupZilla")); aPage.replace(QLatin1String("%ABOUT-QUPZILLA%"), tr("About QupZilla"));
@ -420,7 +419,7 @@ QString QupZillaSchemeReply::configPage()
foreach(const Plugins::Plugin & plugin, availablePlugins) { foreach(const Plugins::Plugin & plugin, availablePlugins) {
PluginSpec spec = plugin.pluginSpec; PluginSpec spec = plugin.pluginSpec;
pluginsString.append(QString("<tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td></tr>").arg( pluginsString.append(QString("<tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td></tr>").arg(
spec.name, spec.version, Qt::escape(spec.author), spec.description)); spec.name, spec.version, qz_escape(spec.author), spec.description));
} }
if (pluginsString.isEmpty()) { if (pluginsString.isEmpty()) {
@ -462,7 +461,7 @@ QString QupZillaSchemeReply::configPage()
keyString = QLatin1String("\"empty\""); keyString = QLatin1String("\"empty\"");
} }
groupString.append(QString("<tr><td>%1</td><td>%2</td></tr>").arg(key, Qt::escape(keyString))); groupString.append(QString("<tr><td>%1</td><td>%2</td></tr>").arg(key, qz_escape(keyString)));
} }
settings->endGroup(); settings->endGroup();

View File

@ -89,7 +89,7 @@ void EditSearchEngine::hideIconLabels()
void EditSearchEngine::chooseIcon() void EditSearchEngine::chooseIcon()
{ {
IconChooser chooser(this); IconChooser chooser(this);
QIcon icon = chooser.exec(); QIcon icon = chooser.getIcon();
if (!icon.isNull()) { if (!icon.isNull()) {
setIcon(icon); setIcon(icon);

View File

@ -48,6 +48,11 @@
#include <qscriptvalue.h> #include <qscriptvalue.h>
#include <qstringlist.h> #include <qstringlist.h>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
/*! /*!
\class OpenSearchEngine \class OpenSearchEngine
\brief A class representing a single search engine described in OpenSearch format \brief A class representing a single search engine described in OpenSearch format
@ -226,12 +231,22 @@ QUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const
QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8()); QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8());
#if QT_VERSION >= 0x050000
QUrlQuery query(retVal);
#endif
if (m_searchMethod != QLatin1String("post")) { if (m_searchMethod != QLatin1String("post")) {
Parameters::const_iterator end = m_searchParameters.constEnd(); Parameters::const_iterator end = m_searchParameters.constEnd();
Parameters::const_iterator i = m_searchParameters.constBegin(); Parameters::const_iterator i = m_searchParameters.constBegin();
for (; i != end; ++i) { for (; i != end; ++i) {
#if QT_VERSION >= 0x050000
query.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#else
retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#endif
} }
#if QT_VERSION >= 0x050000
retVal.setQuery(query);
#endif
} }
return retVal; return retVal;
@ -286,12 +301,22 @@ QUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const
QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8()); QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8());
#if QT_VERSION >= 0x050000
QUrlQuery query(retVal);
#endif
if (m_suggestionsMethod != QLatin1String("post")) { if (m_suggestionsMethod != QLatin1String("post")) {
Parameters::const_iterator end = m_suggestionsParameters.constEnd(); Parameters::const_iterator end = m_suggestionsParameters.constEnd();
Parameters::const_iterator i = m_suggestionsParameters.constBegin(); Parameters::const_iterator i = m_suggestionsParameters.constBegin();
for (; i != end; ++i) { for (; i != end; ++i) {
#if QT_VERSION >= 0x050000
query.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#else
retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second)); retVal.addQueryItem(i->first, parseTemplate(searchTerm, i->second));
#endif
} }
#if QT_VERSION >= 0x050000
retVal.setQuery(query);
#endif
} }
return retVal; return retVal;

View File

@ -32,6 +32,10 @@
#include <QMessageBox> #include <QMessageBox>
#include <QWebElement> #include <QWebElement>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
#define ENSURE_LOADED if (!m_settingsLoaded) loadSettings(); #define ENSURE_LOADED if (!m_settingsLoaded) loadSettings();
QIcon SearchEnginesManager::iconForSearchEngine(const QUrl &url) QIcon SearchEnginesManager::iconForSearchEngine(const QUrl &url)
@ -224,7 +228,21 @@ void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView
if (actionUrl.isRelative()) { if (actionUrl.isRelative()) {
actionUrl = view->url().resolved(actionUrl); actionUrl = view->url().resolved(actionUrl);
} }
#if QT_VERSION >= 0x050000
QUrlQuery query(actionUrl);
query.addQueryItem(element.attribute("name"), "%s");
QWebElementCollection allInputs = formElement.findAll("input");
foreach(QWebElement e, allInputs) {
if (element == e || !e.hasAttribute("name")) {
continue;
}
query.addQueryItem(e.attribute("name"), e.evaluateJavaScript("this.value").toString());
}
actionUrl.setQuery(query);
#else
actionUrl.addQueryItem(element.attribute("name"), "%s"); actionUrl.addQueryItem(element.attribute("name"), "%s");
QList<QPair<QByteArray, QByteArray> > queryItems; QList<QPair<QByteArray, QByteArray> > queryItems;
@ -242,6 +260,7 @@ void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView
} }
actionUrl.setEncodedQueryItems(queryItems + actionUrl.encodedQueryItems()); actionUrl.setEncodedQueryItems(queryItems + actionUrl.encodedQueryItems());
#endif
SearchEngine engine; SearchEngine engine;
engine.name = view->title(); engine.name = view->title();

View File

@ -28,6 +28,7 @@
#include "iconprovider.h" #include "iconprovider.h"
#include "globalfunctions.h" #include "globalfunctions.h"
#include <QNetworkCookie>
#include <QWebDatabase> #include <QWebDatabase>
#include <QWebSettings> #include <QWebSettings>
#include <QNetworkDiskCache> #include <QNetworkDiskCache>

View File

@ -75,7 +75,7 @@ void IconChooser::searchIcon(const QString &string)
} }
} }
QIcon IconChooser::exec() QIcon IconChooser::getIcon()
{ {
QIcon icon; QIcon icon;
int status = QDialog::exec(); int status = QDialog::exec();

View File

@ -38,7 +38,7 @@ public:
explicit IconChooser(QWidget* parent = 0); explicit IconChooser(QWidget* parent = 0);
~IconChooser(); ~IconChooser();
QIcon exec(); QIcon getIcon();
private slots: private slots:
void chooseFile(); void chooseFile();

View File

@ -25,9 +25,15 @@
#include <QWebFrame> #include <QWebFrame>
#include <QTimer> #include <QTimer>
#include <QMovie> #include <QMovie>
#include <QtConcurrentRun>
#include <QPushButton> #include <QPushButton>
#if QT_VERSION >= 0x050000
#include <QtConcurrent/QtConcurrentRun>
#else
#include <QtConcurrentRun>
#endif
PageScreen::PageScreen(WebView* view, QWidget* parent) PageScreen::PageScreen(WebView* view, QWidget* parent)
: QDialog(parent) : QDialog(parent)
, ui(new Ui::PageScreen) , ui(new Ui::PageScreen)

View File

@ -19,6 +19,7 @@
#ifndef REGISTERQAPPASSOCIATION_H #ifndef REGISTERQAPPASSOCIATION_H
#define REGISTERQAPPASSOCIATION_H #define REGISTERQAPPASSOCIATION_H
#include <QObject>
#include <QHash> #include <QHash>
#include <QPair> #include <QPair>

View File

@ -19,7 +19,7 @@
#define SOURCEVIEWER_H #define SOURCEVIEWER_H
#include <QWidget> #include <QWidget>
#include <QWeakPointer> #include <QPointer>
#include "qz_namespace.h" #include "qz_namespace.h"
@ -53,7 +53,7 @@ private slots:
private: private:
QBoxLayout* m_layout; QBoxLayout* m_layout;
PlainEditWithLines* m_sourceEdit; PlainEditWithLines* m_sourceEdit;
QWeakPointer<QWebFrame> m_frame; QPointer<QWebFrame> m_frame;
QStatusBar* m_statusBar; QStatusBar* m_statusBar;
QString m_selectedHtml; QString m_selectedHtml;

View File

@ -19,6 +19,7 @@
#define USERAGENTMANAGER_H #define USERAGENTMANAGER_H
#include <QHash> #include <QHash>
#include <QString>
#include "qz_namespace.h" #include "qz_namespace.h"

View File

@ -20,7 +20,7 @@
#include <QObject> #include <QObject>
#include <QVariant> #include <QVariant>
#include <QWeakPointer> #include <QPointer>
#include "qz_namespace.h" #include "qz_namespace.h"
#include "plugininterface.h" #include "plugininterface.h"

View File

@ -19,7 +19,7 @@
#define SPEEDDIAL_H #define SPEEDDIAL_H
#include <QObject> #include <QObject>
#include <QWeakPointer> #include <QPointer>
#include "qz_namespace.h" #include "qz_namespace.h"
@ -97,7 +97,7 @@ private:
int m_sizeOfSpeedDials; int m_sizeOfSpeedDials;
int m_sdcentered; int m_sdcentered;
QList<QWeakPointer<QWebFrame> > m_webFrames; QList<QPointer<QWebFrame> > m_webFrames;
QList<Page> m_webPages; QList<Page> m_webPages;
bool m_loaded; bool m_loaded;

View File

@ -21,10 +21,10 @@
#include "mainapplication.h" #include "mainapplication.h"
#include "plugininterface.h" #include "plugininterface.h"
#include "pluginlistdelegate.h" #include "pluginlistdelegate.h"
#include "globalfunctions.h"
#include "settings.h" #include "settings.h"
#include <QInputDialog> #include <QInputDialog>
#include <QTextDocument>
#include <QMessageBox> #include <QMessageBox>
#include <QTimer> #include <QTimer>
@ -177,7 +177,7 @@ void PluginsManager::refresh()
} }
item->setIcon(icon); item->setIcon(icon);
QString pluginInfo = QString("<b>%1</b> %2<br/><i>%3</i><br/>%4").arg(spec.name, spec.version, Qt::escape(spec.author), spec.info); QString pluginInfo = QString("<b>%1</b> %2<br/><i>%3</i><br/>%4").arg(spec.name, spec.version, qz_escape(spec.author), spec.info);
item->setToolTip(pluginInfo); item->setToolTip(pluginInfo);
item->setText(spec.name); item->setText(spec.name);

View File

@ -19,7 +19,7 @@
#define PREFERENCES_H #define PREFERENCES_H
#include <QDialog> #include <QDialog>
#include <QWeakPointer> #include <QPointer>
#include "qz_namespace.h" #include "qz_namespace.h"
@ -98,7 +98,7 @@ private:
AutoFillManager* m_autoFillManager; AutoFillManager* m_autoFillManager;
PluginsManager* m_pluginsList; PluginsManager* m_pluginsList;
ThemeManager* m_themesManager; ThemeManager* m_themesManager;
QWeakPointer<DesktopNotification> m_notification; QPointer<DesktopNotification> m_notification;
QString m_homepage; QString m_homepage;
QString m_newTabUrl; QString m_newTabUrl;

View File

@ -25,7 +25,7 @@
#include <QUrl> #include <QUrl>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QFormLayout> #include <QFormLayout>
#include <QWeakPointer> #include <QPointer>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QToolButton> #include <QToolButton>
#include <QInputDialog> #include <QInputDialog>
@ -72,7 +72,7 @@ private:
Ui::RSSManager* ui; Ui::RSSManager* ui;
QToolButton* m_reloadButton; QToolButton* m_reloadButton;
QWeakPointer<QupZilla> p_QupZilla; QPointer<QupZilla> p_QupZilla;
}; };
#endif // RSSMANAGER_H #endif // RSSMANAGER_H

View File

@ -103,7 +103,7 @@ void RSSNotification::addRss()
switch (ui->comboBox->itemData(index).toInt()) { switch (ui->comboBox->itemData(index).toInt()) {
case WebApplication: { case WebApplication: {
const RssApp &app = m_rssApps.at(index); const RssApp &app = m_rssApps.at(index);
const QUrl &url = QUrl::fromEncoded(QString(app.address + QUrl::toPercentEncoding(m_url.toString())).toAscii()); const QUrl &url = QUrl::fromEncoded(QString(app.address + QUrl::toPercentEncoding(m_url.toString())).toLatin1());
m_view->openUrlInNewTab(url, Qz::NT_SelectedTab); m_view->openUrlInNewTab(url, Qz::NT_SelectedTab);
success = true; success = true;

View File

@ -26,7 +26,7 @@
#include <QMenu> #include <QMenu>
QHash<QString, QWeakPointer<SideBarInterface> > SideBarManager::s_sidebars; QHash<QString, QPointer<SideBarInterface> > SideBarManager::s_sidebars;
SideBar::SideBar(SideBarManager* manager, QupZilla* mainClass) SideBar::SideBar(SideBarManager* manager, QupZilla* mainClass)
: QWidget(mainClass) : QWidget(mainClass)
@ -134,7 +134,7 @@ void SideBarManager::refreshMenu()
act->setShortcut(QKeySequence("Ctrl+H")); act->setShortcut(QKeySequence("Ctrl+H"));
act->setData("History"); act->setData("History");
foreach(const QWeakPointer<SideBarInterface> &sidebar, s_sidebars) { foreach(const QPointer<SideBarInterface> &sidebar, s_sidebars) {
if (!sidebar) { if (!sidebar) {
continue; continue;
} }

View File

@ -20,7 +20,7 @@
#include <QWidget> #include <QWidget>
#include <QHash> #include <QHash>
#include <QWeakPointer> #include <QPointer>
#include "qz_namespace.h" #include "qz_namespace.h"
@ -67,7 +67,7 @@ public:
void sideBarRemoved(const QString &id); void sideBarRemoved(const QString &id);
void closeSideBar(); void closeSideBar();
static QHash<QString, QWeakPointer<SideBarInterface> > s_sidebars; static QHash<QString, QPointer<SideBarInterface> > s_sidebars;
static void addSidebar(const QString &id, SideBarInterface* interface); static void addSidebar(const QString &id, SideBarInterface* interface);
static void removeSidebar(const QString &id); static void removeSidebar(const QString &id);
@ -78,7 +78,7 @@ private:
void updateActions(); void updateActions();
QupZilla* p_QupZilla; QupZilla* p_QupZilla;
QWeakPointer<SideBar> m_sideBar; QPointer<SideBar> m_sideBar;
QMenu* m_menu; QMenu* m_menu;
QString m_activeBar; QString m_activeBar;

View File

@ -18,15 +18,20 @@
#include "certificateinfowidget.h" #include "certificateinfowidget.h"
#include "ui_certificateinfowidget.h" #include "ui_certificateinfowidget.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "globalfunctions.h"
#include <QSslCertificate> #include <QSslCertificate>
#include <QTextDocument>
#include <QDateTime> #include <QDateTime>
QString CertificateInfoWidget::certificateItemText(const QSslCertificate &cert) QString CertificateInfoWidget::certificateItemText(const QSslCertificate &cert)
{ {
#if QT_VERSION >= 0x050000
QString commonName = cert.subjectInfo(QSslCertificate::CommonName).isEmpty() ? QString() : cert.subjectInfo(QSslCertificate::CommonName).at(0);
QString organization = cert.subjectInfo(QSslCertificate::Organization).isEmpty() ? QString() : cert.subjectInfo(QSslCertificate::Organization).at(0);
#else
QString commonName = cert.subjectInfo(QSslCertificate::CommonName); QString commonName = cert.subjectInfo(QSslCertificate::CommonName);
QString organization = cert.subjectInfo(QSslCertificate::Organization); QString organization = cert.subjectInfo(QSslCertificate::Organization);
#endif
if (commonName.isEmpty()) { if (commonName.isEmpty()) {
return clearCertSpecialSymbols(organization); return clearCertSpecialSymbols(organization);
@ -37,7 +42,7 @@ QString CertificateInfoWidget::certificateItemText(const QSslCertificate &cert)
QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string) QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string)
{ {
QString n = Qt::escape(string); QString n = qz_escape(string);
if (!n.contains(QLatin1String("\\"))) { if (!n.contains(QLatin1String("\\"))) {
return n; return n;
@ -285,6 +290,15 @@ QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string)
return n; return n;
} }
QString CertificateInfoWidget::clearCertSpecialSymbols(const QStringList &stringList)
{
if (stringList.isEmpty()) {
return QString();
}
return clearCertSpecialSymbols(stringList.at(0));
}
QString CertificateInfoWidget::showCertInfo(const QString &string) QString CertificateInfoWidget::showCertInfo(const QString &string)
{ {
if (string.isEmpty()) { if (string.isEmpty()) {
@ -295,6 +309,15 @@ QString CertificateInfoWidget::showCertInfo(const QString &string)
} }
} }
QString CertificateInfoWidget::showCertInfo(const QStringList &stringList)
{
if (stringList.isEmpty()) {
return QString();
}
return showCertInfo(stringList.at(0));
}
CertificateInfoWidget::CertificateInfoWidget(const QSslCertificate &cert, QWidget* parent) CertificateInfoWidget::CertificateInfoWidget(const QSslCertificate &cert, QWidget* parent)
: QWidget(parent) : QWidget(parent)
, ui(new Ui::CertificateInfoWidget) , ui(new Ui::CertificateInfoWidget)

View File

@ -35,8 +35,16 @@ public:
explicit CertificateInfoWidget(const QSslCertificate &cert, QWidget* parent = 0); explicit CertificateInfoWidget(const QSslCertificate &cert, QWidget* parent = 0);
~CertificateInfoWidget(); ~CertificateInfoWidget();
// Qt5 compatibility
// QSslCertificate::subjectInfo returns:
// QString in Qt 4
// QStringList in Qt 5
//
static QString showCertInfo(const QString &string); static QString showCertInfo(const QString &string);
static QString showCertInfo(const QStringList &stringList);
static QString clearCertSpecialSymbols(const QString &string); static QString clearCertSpecialSymbols(const QString &string);
static QString clearCertSpecialSymbols(const QStringList &stringList);
static QString certificateItemText(const QSslCertificate &cert); static QString certificateItemText(const QSslCertificate &cert);
private: private:

View File

@ -17,6 +17,8 @@
* ============================================================ */ * ============================================================ */
#include "globalfunctions.h" #include "globalfunctions.h"
#include <QTextDocument>
#include <QDateTime>
#include <QByteArray> #include <QByteArray>
#include <QPixmap> #include <QPixmap>
#include <QPainter> #include <QPainter>
@ -25,10 +27,15 @@
#include <QDir> #include <QDir>
#include <QWidget> #include <QWidget>
#include <QApplication> #include <QApplication>
#include <QSslCertificate>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QUrl> #include <QUrl>
#include <QIcon> #include <QIcon>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
QByteArray qz_pixmapToByteArray(const QPixmap &pix) QByteArray qz_pixmapToByteArray(const QPixmap &pix)
{ {
QByteArray bytes; QByteArray bytes;
@ -166,11 +173,19 @@ QString qz_urlEncodeQueryString(const QUrl &url)
QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment); QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment);
if (url.hasQuery()) { if (url.hasQuery()) {
#if QT_VERSION >= 0x050000
returnString += QLatin1Char('?') + url.query(QUrl::FullyEncoded);
#else
returnString += QLatin1Char('?') + url.encodedQuery(); returnString += QLatin1Char('?') + url.encodedQuery();
#endif
} }
if (url.hasFragment()) { if (url.hasFragment()) {
#if QT_VERSION >= 0x050000
returnString += QLatin1Char('#') + url.fragment(QUrl::FullyEncoded);
#else
returnString += QLatin1Char('#') + url.encodedFragment(); returnString += QLatin1Char('#') + url.encodedFragment();
#endif
} }
returnString.replace(QLatin1Char(' '), QLatin1String("%20")); returnString.replace(QLatin1Char(' '), QLatin1String("%20"));
@ -342,6 +357,28 @@ QString QT_QUPZILLA_EXPORT qz_applyDirectionToPage(QString &pageContents)
return pageContents; return pageContents;
} }
// Qt5 migration help functions
bool QT_QUPZILLA_EXPORT qz_isCertificateValid(const QSslCertificate &cert)
{
#if QT_VERSION >= 0x050000
const QDateTime currentTime = QDateTime::currentDateTime();
return currentTime >= cert.effectiveDate() &&
currentTime <= cert.expiryDate() &&
!cert.isBlacklisted();
#else
return cert.isValid();
#endif
}
QString QT_QUPZILLA_EXPORT qz_escape(const QString &string)
{
#if QT_VERSION >= 0x050000
return string.toHtmlEscaped();
#else
return qz_escape(string);
#endif
}
QString qz_buildSystem() QString qz_buildSystem()
{ {
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX

View File

@ -23,6 +23,7 @@
#include "qz_namespace.h" #include "qz_namespace.h"
class QSslCertificate;
class QFontMetrics; class QFontMetrics;
class QPixmap; class QPixmap;
class QIcon; class QIcon;
@ -56,6 +57,10 @@ QString QT_QUPZILLA_EXPORT qz_applyDirectionToPage(QString &pageContents);
QString QT_QUPZILLA_EXPORT qz_buildSystem(); QString QT_QUPZILLA_EXPORT qz_buildSystem();
// Qt5 migration help functions
bool QT_QUPZILLA_EXPORT qz_isCertificateValid(const QSslCertificate &cert);
QString QT_QUPZILLA_EXPORT qz_escape(const QString &string);
template <typename T> template <typename T>
bool qz_listContainsIndex(const QList<T> &list, int index) bool qz_listContainsIndex(const QList<T> &list, int index)
{ {

View File

@ -25,7 +25,11 @@ HeaderView::HeaderView(QAbstractItemView* parent)
, m_parent(parent) , m_parent(parent)
, m_menu(0) , m_menu(0)
{ {
#if QT_VERSION >= 0x050000
setSectionsMovable(true);
#else
setMovable(true); setMovable(true);
#endif
setStretchLastSection(true); setStretchLastSection(true);
setDefaultAlignment(Qt::AlignLeft); setDefaultAlignment(Qt::AlignLeft);
setMinimumSectionSize(60); setMinimumSectionSize(60);

View File

@ -18,6 +18,7 @@
#include "treewidget.h" #include "treewidget.h"
#include "bookmarksmodel.h" #include "bookmarksmodel.h"
#include <QMimeData>
#include <QMouseEvent> #include <QMouseEvent>
#include <QSqlDatabase> #include <QSqlDatabase>
#include <QApplication> #include <QApplication>
@ -455,7 +456,10 @@ void TreeWidget::setDragDropReceiver(bool enable, QObject* receiver)
viewport()->setAcceptDrops(enable); viewport()->setAcceptDrops(enable);
setDropIndicatorShown(enable); setDropIndicatorShown(enable);
if (enable) { if (enable) {
// TODO: It won't probably work in Qt5
#if QT_VERSION < 0x050000
model()->setSupportedDragActions(Qt::CopyAction); model()->setSupportedDragActions(Qt::CopyAction);
#endif
connect(this, SIGNAL(folderParentChanged(QString, bool, bool*)), receiver, SLOT(changeFolderParent(QString, bool, bool*))); connect(this, SIGNAL(folderParentChanged(QString, bool, bool*)), receiver, SLOT(changeFolderParent(QString, bool, bool*)));
connect(this, SIGNAL(bookmarkParentChanged(int, QString, QString, bool*)), receiver, SLOT(changeBookmarkParent(int, QString, QString, bool*))); connect(this, SIGNAL(bookmarkParentChanged(int, QString, QString, bool*)), receiver, SLOT(changeBookmarkParent(int, QString, QString, bool*)));
connect(this, SIGNAL(linkWasDroped(QUrl, QString, QVariant, QString, bool*)), receiver, SLOT(bookmarkDropedLink(QUrl, QString, QVariant, QString, bool*))); connect(this, SIGNAL(linkWasDroped(QUrl, QString, QVariant, QString, bool*)), receiver, SLOT(bookmarkDropedLink(QUrl, QString, QVariant, QString, bool*)));

View File

@ -146,12 +146,11 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent)
} }
//SECURITY //SECURITY
if (cert.isValid()) { if (qz_isCertificateValid(cert)) {
ui->securityLabel->setText(tr("<b>Connection is Encrypted.</b>")); ui->securityLabel->setText(tr("<b>Connection is Encrypted.</b>"));
ui->certLabel->setText(tr("<b>Your connection to this page is secured with this certificate: </b>")); ui->certLabel->setText(tr("<b>Your connection to this page is secured with this certificate: </b>"));
m_certWidget = new CertificateInfoWidget(cert); m_certWidget = new CertificateInfoWidget(cert);
ui->certFrame->addWidget(m_certWidget); ui->certFrame->addWidget(m_certWidget);
} }
else { else {
ui->securityLabel->setText(tr("<b>Connection Not Encrypted.</b>")); ui->securityLabel->setText(tr("<b>Connection Not Encrypted.</b>"));

View File

@ -15,6 +15,7 @@
* 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/>.
* ============================================================ */ * ============================================================ */
#include "globalfunctions.h"
#include "siteinfowidget.h" #include "siteinfowidget.h"
#include "ui_siteinfowidget.h" #include "ui_siteinfowidget.h"
#include "qupzilla.h" #include "qupzilla.h"
@ -39,7 +40,7 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent)
WebPage* webPage = view->page(); WebPage* webPage = view->page();
QUrl url = view->url(); QUrl url = view->url();
if (webPage->sslCertificate().isValid()) { if (qz_isCertificateValid(webPage->sslCertificate())) {
ui->secureLabel->setText(tr("Your connection to this site is <b>secured</b>.")); ui->secureLabel->setText(tr("Your connection to this site is <b>secured</b>."));
ui->secureIcon->setPixmap(QPixmap(":/icons/locationbar/accept.png")); ui->secureIcon->setPixmap(QPixmap(":/icons/locationbar/accept.png"));
} }

View File

@ -28,6 +28,7 @@
#include "pluginproxy.h" #include "pluginproxy.h"
#include <QMenu> #include <QMenu>
#include <QMimeData>
#include <QMouseEvent> #include <QMouseEvent>
#include <QStyleOption> #include <QStyleOption>
#include <QApplication> #include <QApplication>
@ -213,7 +214,6 @@ QSize TabBar::tabSizeHint(int index) const
if (maxWidthForTab < PINNED_TAB_WIDTH) { if (maxWidthForTab < PINNED_TAB_WIDTH) {
// FIXME: It overflows now // FIXME: It overflows now
m_normalTabWidth = PINNED_TAB_WIDTH; m_normalTabWidth = PINNED_TAB_WIDTH;
if (index == currentIndex()) { if (index == currentIndex()) {
size.setWidth(m_activeTabWidth); size.setWidth(m_activeTabWidth);

View File

@ -33,6 +33,7 @@
#include <QMovie> #include <QMovie>
#include <QMenu> #include <QMenu>
#include <QMimeData>
#include <QStackedWidget> #include <QStackedWidget>
#include <QMouseEvent> #include <QMouseEvent>
#include <QWebHistory> #include <QWebHistory>

View File

@ -55,7 +55,7 @@ void WebInspectorDockWidget::close()
void WebInspectorDockWidget::show() void WebInspectorDockWidget::show()
{ {
QWebPage* page = p_QupZilla->weView()->page(); QWebPage* page = p_QupZilla->weView()->page();
QWeakPointer<WebInspector> inspector = m_inspectors[page]; QPointer<WebInspector> inspector = m_inspectors[page];
if (!inspector) { if (!inspector) {
inspector = new WebInspector(this); inspector = new WebInspector(this);

View File

@ -20,7 +20,7 @@
#include <QWebInspector> #include <QWebInspector>
#include <QDockWidget> #include <QDockWidget>
#include <QWeakPointer> #include <QPointer>
#include <QHash> #include <QHash>
#include "qz_namespace.h" #include "qz_namespace.h"
@ -56,9 +56,9 @@ public slots:
private: private:
QupZilla* p_QupZilla; QupZilla* p_QupZilla;
QHash<QWebPage*, QWeakPointer<WebInspector> > m_inspectors; QHash<QWebPage*, QPointer<WebInspector> > m_inspectors;
QWeakPointer<WebInspector> m_currentInspector; QPointer<WebInspector> m_currentInspector;
}; };
#endif // WEBINSPECTORDOCKWIDGET_H #endif // WEBINSPECTORDOCKWIDGET_H

View File

@ -196,11 +196,11 @@ void WebPage::progress(int prog)
{ {
m_loadProgress = prog; m_loadProgress = prog;
bool secStatus = sslCertificate().isValid(); bool secStatus = qz_isCertificateValid(sslCertificate());
if (secStatus != m_secureStatus) { if (secStatus != m_secureStatus) {
m_secureStatus = secStatus; m_secureStatus = secStatus;
emit privacyChanged(sslCertificate().isValid()); emit privacyChanged(qz_isCertificateValid(sslCertificate()));
} }
} }
@ -451,7 +451,7 @@ void WebPage::setSSLCertificate(const QSslCertificate &cert)
QSslCertificate WebPage::sslCertificate() QSslCertificate WebPage::sslCertificate()
{ {
if (url().scheme() == QLatin1String("https") && m_sslCert.isValid()) { if (url().scheme() == QLatin1String("https") && qz_isCertificateValid(m_sslCert)) {
return m_sslCert; return m_sslCert;
} }

View File

@ -19,7 +19,7 @@
#define WEBTAB_H #define WEBTAB_H
#include <QWidget> #include <QWidget>
#include <QWeakPointer> #include <QPointer>
#include <QIcon> #include <QIcon>
#include <QUrl> #include <QUrl>
@ -102,7 +102,7 @@ private:
QupZilla* p_QupZilla; QupZilla* p_QupZilla;
TabbedWebView* m_view; TabbedWebView* m_view;
QVBoxLayout* m_layout; QVBoxLayout* m_layout;
QWeakPointer<LocationBar> m_locationBar; QPointer<LocationBar> m_locationBar;
SavedTab m_savedTab; SavedTab m_savedTab;

View File

@ -504,7 +504,7 @@ void WebView::searchSelectedText()
SearchEngine engine = mApp->searchEnginesManager()->activeEngine(); SearchEngine engine = mApp->searchEnginesManager()->activeEngine();
if (QAction* act = qobject_cast<QAction*>(sender())) { if (QAction* act = qobject_cast<QAction*>(sender())) {
if (act->data().isValid()) { if (act->data().isValid()) {
engine = qVariantValue<SearchEngine>(act->data()); engine = act->data().value<SearchEngine>();
} }
} }
@ -517,7 +517,7 @@ void WebView::searchSelectedTextInBackgroundTab()
SearchEngine engine = mApp->searchEnginesManager()->activeEngine(); SearchEngine engine = mApp->searchEnginesManager()->activeEngine();
if (QAction* act = qobject_cast<QAction*>(sender())) { if (QAction* act = qobject_cast<QAction*>(sender())) {
if (act->data().isValid()) { if (act->data().isValid()) {
engine = qVariantValue<SearchEngine>(act->data()); engine = act->data().value<SearchEngine>();
} }
} }

View File

@ -31,6 +31,12 @@
#include <QDateTime> #include <QDateTime>
#include <QTextStream> #include <QTextStream>
#if QT_VERSION >= 0x050000
#include <QWebPage>
#else
#include "qwebkitversion.h"
#endif
void qupzilla_signal_handler(int s) void qupzilla_signal_handler(int s)
{ {
switch (s) { switch (s) {

View File

@ -1,4 +1,8 @@
QT += core gui webkit sql network script isEqual(QT_MAJOR_VERSION, 5) {
QT += webkitwidgets network widgets printsupport sql script
} else {
QT += core gui webkit sql network script
}
TARGET = qupzilla TARGET = qupzilla
mac: TARGET = QupZilla mac: TARGET = QupZilla

View File

@ -27,9 +27,14 @@ INCLUDEPATH += $$PWD/lib/3rdparty\
TEMPLATE = lib TEMPLATE = lib
CONFIG += plugin CONFIG += plugin
QT *= webkit network
DESTDIR = $$PWD/../bin/plugins/ DESTDIR = $$PWD/../bin/plugins/
isEqual(QT_MAJOR_VERSION, 5) {
QT *= webkitwidgets network
} else {
QT *= webkit network
}
OBJECTS_DIR = build OBJECTS_DIR = build
MOC_DIR = build MOC_DIR = build
RCC_DIR = build RCC_DIR = build

View File

@ -22,7 +22,7 @@
#include <QTime> #include <QTime>
#include <QHash> #include <QHash>
#include <QWebElement> #include <QWebElement>
#include <QWeakPointer> #include <QPointer>
class QKeyEvent; class QKeyEvent;
class QWebElement; class QWebElement;
@ -57,7 +57,7 @@ private:
void makeAccessKeyLabel(const QChar &accessKey, const QWebElement &element); void makeAccessKeyLabel(const QChar &accessKey, const QWebElement &element);
void handleAccessKey(QKeyEvent* event); void handleAccessKey(QKeyEvent* event);
QWeakPointer<WebView> m_view; QPointer<WebView> m_view;
QList<QLabel*> m_accessKeyLabels; QList<QLabel*> m_accessKeyLabels;
QHash<QChar, QWebElement> m_accessKeyNodes; QHash<QChar, QWebElement> m_accessKeyNodes;

View File

@ -18,7 +18,7 @@
#ifndef AKN_PLUGIN_H #ifndef AKN_PLUGIN_H
#define AKN_PLUGIN_H #define AKN_PLUGIN_H
#include <QWeakPointer> #include <QPointer>
#include "plugininterface.h" #include "plugininterface.h"
@ -44,7 +44,7 @@ public:
bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event); bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
private: private:
QWeakPointer<AKN_Settings> m_settings; QPointer<AKN_Settings> m_settings;
AKN_Handler* m_handler; AKN_Handler* m_handler;
}; };

View File

@ -20,7 +20,7 @@
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <QWeakPointer> #include <QPointer>
class QUrl; class QUrl;
class QNetworkRequest; class QNetworkRequest;
@ -68,7 +68,7 @@ private slots:
private: private:
QString m_settingsPath; QString m_settingsPath;
QString m_bootstrap; QString m_bootstrap;
QWeakPointer<GM_Settings> m_settings; QPointer<GM_Settings> m_settings;
QStringList m_disabledScripts; QStringList m_disabledScripts;
QList<GM_Script*> m_endScripts; QList<GM_Script*> m_endScripts;

View File

@ -19,7 +19,7 @@
#define MOUSEGESTURES_H #define MOUSEGESTURES_H
#include <QObject> #include <QObject>
#include <QWeakPointer> #include <QPointer>
class QMouseEvent; class QMouseEvent;
@ -56,8 +56,8 @@ private slots:
private: private:
QjtMouseGestureFilter* m_filter; QjtMouseGestureFilter* m_filter;
QWeakPointer<MouseGesturesSettingsDialog> m_settings; QPointer<MouseGesturesSettingsDialog> m_settings;
QWeakPointer<WebView> m_view; QPointer<WebView> m_view;
}; };
#endif // MOUSEGESTURES_H #endif // MOUSEGESTURES_H

View File

@ -24,7 +24,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QWebHitTestResult> #include <QWebHitTestResult>
#include <QMenu> #include <QMenu>
#include <QWeakPointer> #include <QPointer>
#include <QHash> #include <QHash>
class WebView; class WebView;
@ -81,8 +81,8 @@ private:
QHash<PI_Type, QStringList> m_infoMatches; QHash<PI_Type, QStringList> m_infoMatches;
QHash<PI_Type, QString> m_translations; QHash<PI_Type, QString> m_translations;
QWeakPointer<PIM_Settings> m_settings; QPointer<PIM_Settings> m_settings;
QWeakPointer<WebView> m_view; QPointer<WebView> m_view;
QWebElement m_element; QWebElement m_element;
QString m_settingsFile; QString m_settingsFile;