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

Refactoring whole code to support popup windows.

- it is needed to provide support for casting WebView
  into TabbedWebView and PopupWebView
This commit is contained in:
nowrep 2012-01-21 20:27:45 +01:00
parent a9f9876a25
commit 977f9db6f6
95 changed files with 1103 additions and 377 deletions

View File

@ -52,8 +52,6 @@ class QNetworkRequest;
class QNetworkReply;
class AdBlockNetwork : public QObject
{
Q_OBJECT
public:
AdBlockNetwork(QObject* parent = 0);
QNetworkReply* block(const QNetworkRequest &request);

View File

@ -35,8 +35,6 @@ class AdBlockRule;
class QWebPage;
class AdBlockPage : public QObject
{
Q_OBJECT
public:
AdBlockPage(QObject* parent = 0);

View File

@ -19,8 +19,7 @@
#include "qupzilla.h"
CommandLineOptions::CommandLineOptions(int &argc, char** argv)
: QObject(0)
, m_argc(argc)
: m_argc(argc)
, m_argv(argv)
{
parseActions();

View File

@ -18,13 +18,11 @@
#ifndef COMMANDLINEOPTIONS_H
#define COMMANDLINEOPTIONS_H
#include <QObject>
#include <QPair>
#include <iostream>
class CommandLineOptions : public QObject
class CommandLineOptions
{
Q_OBJECT
public:
enum Action { NoAction, OpenUrl, StartWithProfile, StartWithoutAddons,
NewTab, NewWindow, ShowDownloadManager, StartPrivateBrowsing,

View File

@ -433,7 +433,7 @@ void MainApplication::receiveAppMessage(QString message)
QWidget* actWin = getWindow();
if (message.startsWith("URL:")) {
QString url(message.remove("URL:"));
addNewTab(WebView::guessUrlFromString(url));
addNewTab(QUrl::fromUserInput(url));
actWin = getWindow();
}
else if (message.startsWith("ACTION:")) {

View File

@ -21,8 +21,7 @@
#include "mainapplication.h"
ProfileUpdater::ProfileUpdater(const QString &profilePath)
: QObject()
, m_profilePath(profilePath)
: m_profilePath(profilePath)
{
}

View File

@ -18,21 +18,15 @@
#ifndef PROFILEUPDATER_H
#define PROFILEUPDATER_H
#include <QObject>
#include <QDir>
#include <iostream>
class ProfileUpdater : public QObject
class ProfileUpdater
{
Q_OBJECT
public:
explicit ProfileUpdater(const QString &profilePath);
void checkProfile();
signals:
public slots:
private:
void updateProfile(const QString &current, const QString &profile);
void copyDataToProfile();

View File

@ -5,17 +5,11 @@
class ProxyStyle : public QProxyStyle
{
Q_OBJECT
public:
explicit ProxyStyle();
int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
// int pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const;
signals:
public slots:
};
#endif // PROXYSTYLE_H

View File

@ -19,7 +19,7 @@
#include "tabwidget.h"
#include "tabbar.h"
#include "webpage.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "lineedit.h"
#include "historymodel.h"
#include "locationbar.h"
@ -176,7 +176,7 @@ void QupZilla::postLaunch()
}
if (!m_startingUrl.isEmpty()) {
startUrl = WebView::guessUrlFromString(m_startingUrl.toString());
startUrl = QUrl::fromUserInput(m_startingUrl.toString());
addTab = true;
}
@ -1021,15 +1021,6 @@ void QupZilla::loadAddress(const QUrl &url)
locationBar()->setText(url.toEncoded());
}
void QupZilla::urlEnter()
{
if (locationBar()->text().isEmpty()) {
return;
}
loadAddress(QUrl(WebView::guessUrlFromString(locationBar()->text())));
weView()->setFocus();
}
void QupZilla::showCookieManager()
{
CookieManager* m = mApp->cookieManager();
@ -1082,7 +1073,7 @@ void QupZilla::showSource(QWebFrame* frame, const QString &selectedHtml)
void QupZilla::showPageInfo()
{
SiteInfo* info = new SiteInfo(this, this);
SiteInfo* info = new SiteInfo(weView(), this);
info->setAttribute(Qt::WA_DeleteOnClose);
info->show();
}
@ -1208,12 +1199,12 @@ void QupZilla::refreshHistory()
void QupZilla::currentTabChanged()
{
WebView* view = weView();
TabbedWebView* view = weView();
if (!view) {
return;
}
setWindowTitle(view->title() + tr(" - QupZilla"));
setWindowTitle(tr("%1 - QupZilla").arg(view->title()));
m_ipLabel->setText(view->getIp());
view->setFocus();
@ -1226,7 +1217,7 @@ void QupZilla::currentTabChanged()
void QupZilla::updateLoadingActions()
{
WebView* view = weView();
TabbedWebView* view = weView();
if (!view) {
return;
}
@ -1239,7 +1230,7 @@ void QupZilla::updateLoadingActions()
m_actionReload->setEnabled(!isLoading);
if (isLoading) {
m_progressBar->setValue(view->getLoading());
m_progressBar->setValue(view->loadProgress());
m_navigationBar->showStopButton();
}
else {
@ -1247,6 +1238,13 @@ void QupZilla::updateLoadingActions()
}
}
void QupZilla::addDeleteOnCloseWidget(QWidget* widget)
{
if (!m_deleteOnCloseWidgets.contains(widget)) {
m_deleteOnCloseWidgets.append(widget);
}
}
void QupZilla::aboutQupZilla()
{
AboutDialog about(this);
@ -1489,22 +1487,6 @@ void QupZilla::keyPressEvent(QKeyEvent* event)
}
}
void QupZilla::mousePressEvent(QMouseEvent* event)
{
switch (event->button()) {
case Qt::XButton1:
weView()->back();
break;
case Qt::XButton2:
weView()->forward();
break;
default:
QMainWindow::mousePressEvent(event);
break;
}
}
void QupZilla::closeEvent(QCloseEvent* event)
{
if (mApp->isClosing()) {
@ -1577,12 +1559,12 @@ bool QupZilla::quitApp()
settings.endGroup();
if (askOnClose && afterLaunch != 3 && m_tabWidget->count() > 1) {
QDialog* dialog = new QDialog(this);
QDialog dialog(this);
Ui_CloseDialog* ui = new Ui_CloseDialog();
ui->setupUi(dialog);
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));
if (dialog->exec() != QDialog::Accepted) {
if (dialog.exec() != QDialog::Accepted) {
return false;
}
if (ui->dontAskAgain->isChecked()) {
@ -1596,4 +1578,9 @@ bool QupZilla::quitApp()
QupZilla::~QupZilla()
{
foreach(const QWeakPointer<QWidget> &pointer, m_deleteOnCloseWidgets) {
if (pointer) {
pointer.data()->deleteLater();
}
}
}

View File

@ -44,13 +44,13 @@
#include "qwebkitversion.h"
#include "webtab.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "tabwidget.h"
#include "mainapplication.h"
#include "locationbar.h"
class TabWidget;
class WebView;
class TabbedWebView;
class LineEdit;
class SearchToolBar;
class BookmarksToolbar;
@ -94,10 +94,12 @@ public:
void currentTabChanged();
void updateLoadingActions();
void addDeleteOnCloseWidget(QWidget* widget);
virtual QMenuBar* menuBar() const;
inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); }
inline WebView* weView(int index) const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); }
inline TabbedWebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); }
inline TabbedWebView* weView(int index) const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); }
inline LocationBar* locationBar() { return qobject_cast<LocationBar*>(m_tabWidget->locationBars()->currentWidget()); }
inline TabWidget* tabWidget() { return m_tabWidget; }
inline BookmarksToolbar* bookmarksToolbar() { return m_bookmarksToolbar; }
@ -149,7 +151,6 @@ private slots:
void stop() { weView()->stop(); }
void reload() { weView()->reload(); }
void reloadByPassCache() { weView()->page()->triggerAction(QWebPage::ReloadAndBypassCache); }
void urlEnter();
void aboutQupZilla();
void addTab() { m_tabWidget->addView(QUrl(), TabWidget::NewTab, true); }
void savePageScreen();
@ -208,7 +209,6 @@ private slots:
private:
void resizeEvent(QResizeEvent* event);
void keyPressEvent(QKeyEvent* event);
void mousePressEvent(QMouseEvent* event);
void closeEvent(QCloseEvent* event);
void setupUi();
@ -287,6 +287,8 @@ private:
bool m_statusBarVisible;
bool m_navigationVisible;
bool m_bookmarksToolBarVisible;
QList<QWeakPointer<QWidget> > m_deleteOnCloseWidgets;
};
#endif // QUPZILLA_H

View File

@ -2,8 +2,7 @@
QSettings* Settings::m_settings = 0;
Settings::Settings(QObject* parent)
: QObject(parent)
Settings::Settings()
{
}

View File

@ -4,11 +4,10 @@
#include <QObject>
#include <QSettings>
class Settings : public QObject
class Settings
{
Q_OBJECT
public:
explicit Settings(QObject* parent = 0);
explicit Settings();
~Settings();
static void createSettings(const QString &fileName);

View File

@ -17,7 +17,9 @@
* ============================================================ */
#include "autofillmodel.h"
#include "qupzilla.h"
#include "webview.h"
#include "webpage.h"
#include "tabbedwebview.h"
#include "popupwebview.h"
#include "mainapplication.h"
#include "autofillnotification.h"
#include "databasewriter.h"
@ -28,7 +30,7 @@ AutoFillModel::AutoFillModel(QupZilla* mainClass, QObject* parent)
, p_QupZilla(mainClass)
, m_isStoring(false)
{
QTimer::singleShot(0, this, SLOT(loadSettings()));
loadSettings();
}
void AutoFillModel::loadSettings()
@ -46,6 +48,10 @@ bool AutoFillModel::isStored(const QUrl &url)
}
QString server = url.host();
if (server.isEmpty()) {
server = url.toString();
}
QSqlQuery query;
query.exec("SELECT count(id) FROM autofill WHERE server='" + server + "'");
query.next();
@ -62,6 +68,10 @@ bool AutoFillModel::isStoringEnabled(const QUrl &url)
}
QString server = url.host();
if (server.isEmpty()) {
server = url.toString();
}
QSqlQuery query;
query.exec("SELECT count(id) FROM autofill_exceptions WHERE server='" + server + "'");
query.next();
@ -74,6 +84,10 @@ bool AutoFillModel::isStoringEnabled(const QUrl &url)
void AutoFillModel::blockStoringfor(const QUrl &url)
{
QString server = url.host();
if (server.isEmpty()) {
server = url.toString();
}
QSqlQuery query;
query.prepare("INSERT INTO autofill_exceptions (server) VALUES (?)");
query.addBindValue(server);
@ -83,6 +97,10 @@ void AutoFillModel::blockStoringfor(const QUrl &url)
QString AutoFillModel::getUsername(const QUrl &url)
{
QString server = url.host();
if (server.isEmpty()) {
server = url.toString();
}
QSqlQuery query;
query.exec("SELECT username FROM autofill WHERE server='" + server + "'");
query.next();
@ -92,6 +110,10 @@ QString AutoFillModel::getUsername(const QUrl &url)
QString AutoFillModel::getPassword(const QUrl &url)
{
QString server = url.host();
if (server.isEmpty()) {
server = url.toString();
}
QSqlQuery query;
query.exec("SELECT password FROM autofill WHERE server='" + server + "'");
query.next();
@ -106,8 +128,14 @@ void AutoFillModel::addEntry(const QUrl &url, const QString &name, const QString
if (query.next()) {
return;
}
QString server = url.host();
if (server.isEmpty()) {
server = url.toString();
}
query.prepare("INSERT INTO autofill (server, username, password) VALUES (?,?,?)");
query.bindValue(0, url.host());
query.bindValue(0, server);
query.bindValue(1, name);
query.bindValue(2, pass);
mApp->dbWriter()->executeQuery(query);
@ -122,31 +150,48 @@ void AutoFillModel::addEntry(const QUrl &url, const QByteArray &data, const QStr
return;
}
QString server = url.host();
if (server.isEmpty()) {
server = url.toString();
}
query.prepare("INSERT INTO autofill (server, data, username, password) VALUES (?,?,?,?)");
query.bindValue(0, url.host());
query.bindValue(0, server);
query.bindValue(1, data);
query.bindValue(2, user);
query.bindValue(3, pass);
mApp->dbWriter()->executeQuery(query);
}
void AutoFillModel::completePage(WebView* view)
void AutoFillModel::completePage(WebPage* page)
{
if (!isStored(view->url())) {
if (!page) {
return;
}
QUrl pageUrl = page->url();
if (!isStored(pageUrl)) {
return;
}
QWebElementCollection inputs;
QList<QWebFrame*> frames;
frames.append(view->page()->mainFrame());
frames.append(page->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
inputs.append(frame->findAllElements("input"));
frames += frame->childFrames();
}
QString server = pageUrl.host();
if (server.isEmpty()) {
server = pageUrl.toString();
}
QSqlQuery query;
query.exec("SELECT data FROM autofill WHERE server='" + view->url().host() + "'");
query.prepare("SELECT data FROM autofill WHERE server=?");
query.addBindValue(server);
query.exec();
query.next();
QByteArray data = query.value(0).toByteArray();
if (data.isEmpty()) {
@ -183,10 +228,12 @@ void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgo
m_lastOutgoingData = outgoingData;
QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100));
QWebPage* webPage = static_cast<QWebPage*>(v.value<void*>());
v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 102));
WebView* webView = static_cast<WebView*>(v.value<void*>());
if (!webPage || !webView) {
WebPage* webPage = static_cast<WebPage*>(v.value<void*>());
if (!webPage) {
return;
}
WebView* webView = qobject_cast<WebView*>(webPage->view());
if (!webView) {
return;
}
@ -201,7 +248,7 @@ void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgo
QString usernameValue;
QString passwordName;
QString passwordValue;
QUrl siteUrl = webView->url();
QUrl siteUrl = webPage->url();
if (!isStoringEnabled(siteUrl)) {
return;

View File

@ -24,16 +24,16 @@
#include <QWebElement>
class QupZilla;
class WebView;
class WebPage;
class AutoFillModel : public QObject
{
Q_OBJECT
public:
typedef QList<QPair<QString, QString> > QueryItems;
typedef QPair<QString, QString> QueryItem;
explicit AutoFillModel(QupZilla* mainClass, QObject* parent = 0);
void completePage(WebView* view);
void loadSettings();
bool isStored(const QUrl &url);
bool isStoringEnabled(const QUrl &url);
@ -45,11 +45,7 @@ public:
void addEntry(const QUrl &url, const QByteArray &data, const QString &user, const QString &pass);
void post(const QNetworkRequest &request, const QByteArray &outgoingData);
signals:
public slots:
void loadSettings();
void completePage(WebPage* frame);
private:
bool dataContains(const QByteArray &data, const QString &attributeName);

View File

@ -22,6 +22,7 @@
#include "clickablelabel.h"
#include "bookmarksmodel.h"
class QupZilla;
class BookmarksModel;
class BookmarkIcon : public ClickableLabel
@ -31,10 +32,6 @@ public:
explicit BookmarkIcon(QupZilla* mainClass, QWidget* parent = 0);
void checkBookmark(const QUrl &url);
signals:
public slots:
private slots:
void iconClicked();
void bookmarkAdded(const BookmarksModel::Bookmark &bookmark);

View File

@ -19,7 +19,7 @@
#include "bookmarksmanager.h"
#include "ui_bookmarksmanager.h"
#include "qupzilla.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "bookmarkstoolbar.h"
#include "tabwidget.h"
#include "bookmarksmodel.h"
@ -191,7 +191,7 @@ void BookmarksManager::deleteItem()
void BookmarksManager::addBookmark(WebView* view)
{
insertBookmark(view->url(), view->title(), view->siteIcon());
insertBookmark(view->url(), view->title(), view->icon());
}
void BookmarksManager::moveBookmark()
@ -617,12 +617,12 @@ void BookmarksManager::insertAllTabs()
}
foreach(WebTab * tab, getQupZilla()->tabWidget()->allTabs(false)) {
WebView* view = tab->view();
TabbedWebView* view = tab->view();
if (view->url().isEmpty()) {
continue;
}
m_bookmarksModel->saveBookmark(view->url(), view->title(), view->siteIcon(), BookmarksModel::fromTranslatedFolder(combo->currentText()));
m_bookmarksModel->saveBookmark(view->url(), view->title(), view->icon(), BookmarksModel::fromTranslatedFolder(combo->currentText()));
}
delete dialog;

View File

@ -18,7 +18,7 @@
#include "bookmarksmodel.h"
#include "settings.h"
#include "mainapplication.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "iconprovider.h"
#include "databasewriter.h"
@ -156,7 +156,7 @@ bool BookmarksModel::saveBookmark(const QUrl &url, const QString &title, const Q
bool BookmarksModel::saveBookmark(WebView* view, const QString &folder)
{
return saveBookmark(view->url(), view->title(), view->siteIcon(), folder);
return saveBookmark(view->url(), view->title(), view->icon(), folder);
}
bool BookmarksModel::removeBookmark(int id)

View File

@ -203,6 +203,8 @@ void BookmarksToolbar::editBookmark()
editUrl->setText(b.url.toString());
editTitle->setText(b.title);
editUrl->setCursorPosition(0);
editTitle->setCursorPosition(0);
dialog->setWindowTitle(tr("Edit Bookmark"));
dialog->setMinimumSize(400, 100);

View File

@ -17,11 +17,12 @@
* ============================================================ */
#include "chromeimporter.h"
#include "globalfunctions.h"
#include "bookmarksimportdialog.h"
ChromeImporter::ChromeImporter(QObject* parent)
: QObject(parent)
, m_error(false)
, m_errorString(tr("No Error"))
, m_errorString(BookmarksImportDialog::tr("No Error"))
{
}
@ -36,7 +37,7 @@ bool ChromeImporter::openFile()
if (!m_file.open(QFile::ReadOnly)) {
m_error = true;
m_errorString = tr("Unable to open file.");
m_errorString = BookmarksImportDialog::tr("Unable to open file.");
return false;
}
@ -81,7 +82,7 @@ QList<BookmarksModel::Bookmark> ChromeImporter::exportBookmarks()
}
else {
m_error = true;
m_errorString = tr("Cannot evaluate JSON code.");
m_errorString = BookmarksImportDialog::tr("Cannot evaluate JSON code.");
}
}

View File

@ -29,7 +29,6 @@
class ChromeImporter : public QObject
{
Q_OBJECT
public:
explicit ChromeImporter(QObject* parent = 0);
@ -41,10 +40,6 @@ public:
bool error() { return m_error; }
QString errorString() { return m_errorString; }
signals:
public slots:
private:
QString m_path;
QFile m_file;

View File

@ -16,11 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "firefoximporter.h"
#include "bookmarksimportdialog.h"
FirefoxImporter::FirefoxImporter(QObject* parent)
: QObject(parent)
, m_error(false)
, m_errorString(tr("No Error"))
, m_errorString(BookmarksImportDialog::tr("No Error"))
{
}
@ -35,7 +36,7 @@ bool FirefoxImporter::openDatabase()
if (!QFile::exists(m_path)) {
m_error = true;
m_errorString = tr("File does not exists.");
m_errorString = BookmarksImportDialog::tr("File does not exists.");
return false;
}
db.setDatabaseName(m_path);
@ -43,7 +44,7 @@ bool FirefoxImporter::openDatabase()
if (!open) {
m_error = true;
m_errorString = tr("Unable to open database. Is Firefox running?");
m_errorString = BookmarksImportDialog::tr("Unable to open database. Is Firefox running?");
return false;
}

View File

@ -28,7 +28,6 @@
class FirefoxImporter : public QObject
{
Q_OBJECT
public:
explicit FirefoxImporter(QObject* parent = 0);
@ -40,10 +39,6 @@ public:
bool error() { return m_error; }
QString errorString() { return m_errorString; }
signals:
public slots:
private:
QString m_path;
QSqlDatabase db;

View File

@ -1,9 +1,10 @@
#include "htmlimporter.h"
#include "bookmarksimportdialog.h"
HtmlImporter::HtmlImporter(QObject* parent)
: QObject(parent)
, m_error(false)
, m_errorString(tr("No Error"))
, m_errorString(BookmarksImportDialog::tr("No Error"))
{
}
@ -18,7 +19,7 @@ bool HtmlImporter::openFile()
if (!m_file.open(QFile::ReadOnly)) {
m_error = true;
m_errorString = tr("Unable to open file.");
m_errorString = BookmarksImportDialog::tr("Unable to open file.");
return false;
}

View File

@ -9,7 +9,6 @@
class HtmlImporter : public QObject
{
Q_OBJECT
public:
explicit HtmlImporter(QObject* parent = 0);
@ -21,10 +20,6 @@ public:
bool error() { return m_error; }
QString errorString() { return m_errorString; }
signals:
public slots:
private:
QString m_path;
QFile m_file;

View File

@ -16,11 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "operaimporter.h"
#include "bookmarksimportdialog.h"
OperaImporter::OperaImporter(QObject* parent)
: QObject(parent)
, m_error(false)
, m_errorString(tr("No Error"))
, m_errorString(BookmarksImportDialog::tr("No Error"))
{
}
@ -35,7 +36,7 @@ bool OperaImporter::openFile()
if (!m_file.open(QFile::ReadOnly)) {
m_error = true;
m_errorString = tr("Unable to open file.");
m_errorString = BookmarksImportDialog::tr("Unable to open file.");
return false;
}

View File

@ -25,7 +25,6 @@
class OperaImporter : public QObject
{
Q_OBJECT
public:
explicit OperaImporter(QObject* parent = 0);
@ -37,10 +36,6 @@ public:
bool error() { return m_error; }
QString errorString() { return m_errorString; }
signals:
public slots:
private:
QString m_path;
QFile m_file;

View File

@ -25,7 +25,6 @@
class QupZilla;
class CookieJar : public QNetworkCookieJar
{
Q_OBJECT
public:
explicit CookieJar(QupZilla* mainClass, QObject* parent = 0);
@ -41,10 +40,6 @@ public:
void setAllowCookies(bool allow);
void turnPrivateJar(bool state);
signals:
public slots:
private:
QupZilla* p_QupZilla;
bool m_allowCookies;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 574 B

View File

@ -30,8 +30,6 @@ class DesktopNotification;
class DesktopNotification : public QWidget
{
Q_OBJECT
public:
explicit DesktopNotification(bool setPosition = false);
void setPixmap(const QPixmap &icon) { m_icon = icon; }

View File

@ -98,7 +98,7 @@ void DesktopNotificationsFactory::nativeNotificationPreview()
args.append("qupzilla");
args.append(m_uint);
args.append(tmp.fileName());
args.append(tr("Native System Notification"));
args.append(QObject::tr("Native System Notification"));
args.append("");
args.append(QStringList());
args.append(QVariantMap());

View File

@ -32,20 +32,16 @@
class DesktopNotification;
class DesktopNotificationsFactory : public QObject
{
Q_OBJECT
public:
enum Type { DesktopNative, PopupWidget };
explicit DesktopNotificationsFactory(QObject* parent = 0);
void loadSettings();
void showNotifications(const QPixmap &icon, const QString &heading, const QString &text);
void nativeNotificationPreview();
signals:
public slots:
void loadSettings();
private:
bool m_enabled;
int m_timeout;

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "downloadfilehelper.h"
#include "webpage.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "downloadoptionsdialog.h"
#include "mainapplication.h"
#include "qupzilla.h"
@ -65,14 +65,15 @@ void DownloadFileHelper::handleUnsupportedContent(QNetworkReply* reply, bool ask
// Close Empty Tab
if (m_webPage) {
if (!m_webPage->mainFrame()->url().isEmpty() && m_webPage->mainFrame()->url().toString() != "about:blank") {
m_downloadPage = m_webPage->mainFrame()->url();
WebView* view = qobject_cast<WebView*>(m_webPage->view());
if (!m_webPage->url().isEmpty() && m_webPage->url().toString() != "about:blank") {
m_downloadPage = m_webPage->url();
}
else if (m_webPage->history()->canGoBack()) {
m_downloadPage = m_webPage->history()->backItem().url();
}
else if (m_webPage->history()->count() == 0) {
m_webPage->getView()->closeTab();
else if (view && m_webPage->history()->count() == 0) {
view->closeView();
}
}

View File

@ -169,11 +169,14 @@ void DownloadManager::clearList()
void DownloadManager::download(const QNetworkRequest &request, WebPage* page, bool askWhatToDo)
{
if (!page) {
return;
}
// Clearing web page info from request
QNetworkRequest req = request;
req.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100), 0);
req.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 101), 0);
req.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 102), 0);
handleUnsupportedContent(m_networkManager->get(req), page, askWhatToDo);
}

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "historymodel.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "qupzilla.h"
#include "iconprovider.h"
#include "databasewriter.h"

View File

@ -23,17 +23,12 @@
class WebHistoryInterface : public QWebHistoryInterface
{
Q_OBJECT
public:
explicit WebHistoryInterface(QObject* parent = 0);
void addHistoryEntry(const QString &url);
bool historyContains(const QString &url) const;
signals:
public slots:
private:
QStringList m_clickedLinks;

View File

@ -30,8 +30,6 @@ int main(int argc, char* argv[])
Q_INIT_RESOURCE(icons);
Q_INIT_RESOURCE(html);
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#ifdef Q_WS_X11
QApplication::setGraphicsSystem("raster"); // Better overall performance on X11
#endif

View File

@ -5,7 +5,6 @@
class DownIcon : public ClickableLabel
{
Q_OBJECT
public:
explicit DownIcon(QWidget* parent = 0);

View File

@ -5,14 +5,9 @@
class GoIcon : public ClickableLabel
{
Q_OBJECT
public:
explicit GoIcon(QWidget* parent = 0);
signals:
public slots:
private:
void mousePressEvent(QMouseEvent* ev);

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "locationbar.h"
#include "qupzilla.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "rssmanager.h"
#include "mainapplication.h"
#include "locationcompleter.h"
@ -70,7 +70,7 @@ LocationBar::LocationBar(QupZilla* mainClass)
connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit()));
connect(this, SIGNAL(textEdited(QString)), m_locationCompleter, SLOT(refreshCompleter(QString)));
connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), p_QupZilla, SLOT(urlEnter()));
connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), this, SLOT(urlEnter()));
connect(m_siteIcon, SIGNAL(clicked()), this, SLOT(showSiteInfo()));
connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter()));
connect(m_rssIcon, SIGNAL(clicked(QPoint)), this, SLOT(rssIconClicked()));
@ -191,9 +191,9 @@ void LocationBar::showRSSIcon(bool state)
m_rssIcon->setVisible(state);
}
void LocationBar::showUrl(const QUrl &url, bool empty)
void LocationBar::showUrl(const QUrl &url)
{
if (hasFocus() || (url.isEmpty() && empty)) {
if (hasFocus() || url.isEmpty()) {
return;
}
@ -206,16 +206,15 @@ void LocationBar::showUrl(const QUrl &url, bool empty)
if (url.toEncoded() != text()) {
setText(encodedUrl);
}
p_QupZilla->statusBarMessage()->clearMessage();
hideGoButton();
m_bookmarkIcon->checkBookmark(url);
}
void LocationBar::siteIconChanged()
{
QIcon icon_ = m_webView->siteIcon();
QIcon icon_ = m_webView->icon();
if (icon_.isNull()) {
clearIcon();
@ -375,7 +374,8 @@ void LocationBar::keyPressEvent(QKeyEvent* event)
{
switch (event->key()) {
case Qt::Key_Escape:
setText(m_webView->url().toEncoded());
m_webView->setFocus();
showUrl(m_webView->url());
event->accept();
break;

View File

@ -38,7 +38,7 @@ class LineEdit;
class LocationCompleter;
class ClickableLabel;
class BookmarkIcon;
class WebView;
class TabbedWebView;
class LocationBarSettings;
class SiteIcon;
class GoIcon;
@ -54,14 +54,14 @@ public:
explicit LocationBar(QupZilla* mainClass);
~LocationBar();
void setWebView(WebView* view) { m_webView = view; }
WebView* webView() { return m_webView; }
void setWebView(TabbedWebView* view) { m_webView = view; }
TabbedWebView* webView() { return m_webView; }
signals:
void loadUrl(const QUrl &url);
public slots:
void showUrl(const QUrl &url, bool empty = true);
void showUrl(const QUrl &url);
virtual void setText(const QString &text);
private slots:
@ -98,7 +98,7 @@ private:
SiteIcon* m_siteIcon;
QupZilla* p_QupZilla;
WebView* m_webView;
TabbedWebView* m_webView;
LocationCompleter* m_locationCompleter;
LocationBarSettings* m_locationBarSettings;

View File

@ -25,7 +25,7 @@ ReloadStopButton::ReloadStopButton(QWidget* parent)
m_buttonStop = new ToolButton(this);
m_buttonStop->setObjectName("navigation-button-stop");
m_buttonStop->setToolTip(tr("Stop"));
m_buttonStop->setToolTip(ToolButton::tr("Stop"));
m_buttonStop->setToolButtonStyle(Qt::ToolButtonIconOnly);
m_buttonStop->setVisible(false);
m_buttonStop->setAutoRaise(true);
@ -33,7 +33,7 @@ ReloadStopButton::ReloadStopButton(QWidget* parent)
m_buttonReload = new ToolButton(this);
m_buttonReload->setObjectName("navigation-button-reload");
m_buttonReload->setToolTip(tr("Reload"));
m_buttonReload->setToolTip(ToolButton::tr("Reload"));
m_buttonReload->setToolButtonStyle(Qt::ToolButtonIconOnly);
m_buttonReload->setAutoRaise(true);
m_buttonReload->setFocusPolicy(Qt::NoFocus);

View File

@ -24,7 +24,6 @@
class ReloadStopButton : public QWidget
{
Q_OBJECT
public:
explicit ReloadStopButton(QWidget* parent = 0);
~ReloadStopButton();
@ -35,10 +34,6 @@ public:
ToolButton* buttonStop() { return m_buttonStop; }
ToolButton* buttonReload() { return m_buttonReload; }
signals:
public slots:
private:
ToolButton* m_buttonStop;
ToolButton* m_buttonReload;

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "siteicon.h"
#include "locationbar.h"
#include "webview.h"
#include "tabbedwebview.h"
SiteIcon::SiteIcon(LocationBar* parent)
: ToolButton(parent)
@ -26,7 +26,7 @@ SiteIcon::SiteIcon(LocationBar* parent)
setObjectName("locationbar-siteicon");
setToolButtonStyle(Qt::ToolButtonIconOnly);
setCursor(Qt::ArrowCursor);
setToolTip(tr("Show information about this page"));
setToolTip(LocationBar::tr("Show information about this page"));
setFocusPolicy(Qt::ClickFocus);
}
@ -44,6 +44,10 @@ void SiteIcon::mousePressEvent(QMouseEvent* e)
void SiteIcon::mouseMoveEvent(QMouseEvent* e)
{
if (!m_locationBar) {
return;
}
int manhattanLength = (e->pos() - m_dragStartPosition).manhattanLength();
if (manhattanLength <= QApplication::startDragDistance()) {
ToolButton::mouseMoveEvent(e);

View File

@ -25,14 +25,9 @@
class LocationBar;
class SiteIcon : public ToolButton
{
Q_OBJECT
public:
explicit SiteIcon(LocationBar* parent);
signals:
public slots:
private:
void mousePressEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent* e);

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "websearchbar.h"
#include "qupzilla.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "webpage.h"
#include "clickablelabel.h"
#include "buttonwithmenu.h"
@ -151,7 +151,7 @@ void WebSearchBar::searchInNewTab()
void WebSearchBar::completeMenuWithAvailableEngines(QMenu* menu)
{
WebView* view = p_QupZilla->weView();
QWebFrame* frame = view->webPage()->mainFrame();
QWebFrame* frame = view->page()->mainFrame();
QWebElementCollection elements = frame->documentElement().findAll(QLatin1String("link[rel=search]"));
foreach(QWebElement element, elements) {

View File

@ -116,13 +116,11 @@ void NetworkManager::setSSLConfiguration(QNetworkReply* reply)
QNetworkRequest request = reply->request();
QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100));
WebPage* webPage = static_cast<WebPage*>(v.value<void*>());
v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 102));
WebView* webView = static_cast<WebView*>(v.value<void*>());
if (!webPage || !webView) {
if (!webPage) {
return;
}
if (webView->url().host() == reply->url().host()) {
if (webPage->url().host() == reply->url().host()) {
webPage->setSSLCertificate(cert);
}
}
@ -186,7 +184,8 @@ void NetworkManager::sslError(QNetworkReply* reply, QList<QSslError> errors)
QString message = QString("<b>%1</b><p>%2</p>%3<p>%4</p>").arg(title, text1, certs, text2);
if (!certs.isEmpty()) {
if (!webPage->javaScriptConfirm(webPage->mainFrame(), message)) {
if (QMessageBox::critical(webPage->view(), tr("SSL Certificate Error!"), message,
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
return;
}

View File

@ -64,7 +64,6 @@ public:
void disconnectObjects();
signals:
void finishLoading(bool state);
void wantsFocus(const QUrl &url);
void sslDialogClosed();

View File

@ -23,29 +23,21 @@
NetworkManagerProxy::NetworkManagerProxy(QObject* parent)
: QNetworkAccessManager(parent)
, m_view(0)
, m_page(0)
, m_manager(0)
{
setCookieJar(mApp->cookieJar());
}
void NetworkManagerProxy::populateNetworkRequest(QNetworkRequest &request)
{
qDebug() << __FUNCTION__ << "called";
QVariant variant = qVariantFromValue((void*) m_page);
request.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100), variant);
}
void NetworkManagerProxy::setPrimaryNetworkAccessManager(NetworkManager* manager)
{
Q_ASSERT(manager);
m_manager = manager;
connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), manager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)));
connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)), manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)));
connect(this, SIGNAL(finished(QNetworkReply*)), manager, SIGNAL(finished(QNetworkReply*)));
connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), manager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)));
connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), m_manager, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)));
connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)), m_manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)));
connect(this, SIGNAL(finished(QNetworkReply*)), m_manager, SIGNAL(finished(QNetworkReply*)));
connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), m_manager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)));
}
QNetworkReply* NetworkManagerProxy::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData)
@ -60,6 +52,11 @@ QNetworkReply* NetworkManagerProxy::createRequest(QNetworkAccessManager::Operati
return QNetworkAccessManager::createRequest(op, request, outgoingData);
}
void NetworkManagerProxy::disconnectObjects()
{
disconnect(m_manager);
}
NetworkManagerProxy::~NetworkManagerProxy()
{
// Prevent deleting of cookie jar

View File

@ -22,28 +22,23 @@
#include <QNetworkRequest>
#include <QNetworkAccessManager>
class WebView;
class WebPage;
class NetworkManager;
class NetworkManagerProxy : public QNetworkAccessManager
{
Q_OBJECT
public:
explicit NetworkManagerProxy(QObject* parent = 0);
~NetworkManagerProxy();
void setView(WebView* view) { m_view = view; }
void setPage(WebPage* page) { m_page = page; }
void setPrimaryNetworkAccessManager(NetworkManager* manager);
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData);
protected:
virtual void populateNetworkRequest(QNetworkRequest &request);
void disconnectObjects();
private:
WebView* m_view;
WebPage* m_page;
NetworkManager* m_manager;
};

View File

@ -28,8 +28,12 @@ QString authorString(const QString &name, const QString &mail)
return QString("%1 &lt;<a href=\"mailto:%2\">%2</a>&gt;").arg(name, mail);
}
QupZillaSchemeHandler::QupZillaSchemeHandler(QObject* parent)
: QObject(parent)
QString authorString(const char* name, const QString &mail)
{
return authorString(QString::fromUtf8(name), mail);
}
QupZillaSchemeHandler::QupZillaSchemeHandler()
{
}

View File

@ -25,18 +25,12 @@
#include <QTimer>
#include <QTextStream>
class QupZillaSchemeHandler : public QObject
class QupZillaSchemeHandler
{
Q_OBJECT
public:
explicit QupZillaSchemeHandler(QObject* parent = 0);
explicit QupZillaSchemeHandler();
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData);
signals:
public slots:
};
class QupZillaSchemeReply : public QNetworkReply

View File

@ -18,7 +18,7 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include "qupzilla.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "webpage.h"
#include "qtwin.h"
@ -77,30 +77,30 @@ void AboutDialog::showAuthors()
m_authorsHtml.append("<div style='margin:10px;'>");
m_authorsHtml.append(tr("<p><b>Main developer:</b><br/>%1 &lt;%2&gt;</p>").arg(QupZilla::AUTHOR, "<a href=mailto:nowrep@gmail.com>nowrep@gmail.com</a>"));
m_authorsHtml.append(tr("<p><b>Contributors:</b><br/>%1</p>").arg(
"Mladen Pejaković<br/>"
"Bryan M Dunsmore<br/>"
"Mariusz Fik<br/>"
"Jan Rajnoha<br/>"
"Daniele Cocca"
QString::fromUtf8("Mladen Pejaković<br/>"
"Bryan M Dunsmore<br/>"
"Mariusz Fik<br/>"
"Jan Rajnoha<br/>"
"Daniele Cocca")
));
m_authorsHtml.append(tr("<p><b>Translators:</b><br/>%1</p>").arg(
"Heimen Stoffels (Dutch)<br/>"
"Peter Vacula (Slovakia)<br/>"
"Ján Ďanovský (Slovakia)<br/>"
"Jonathan Hooverman (German)<br/>"
"Unink-Lio (Chinese)<br/>"
"Federico Fabiani (Italy)<br/>"
"Francesco Marinucci (Italy)<br/>"
"Jorge Sevilla (Spanish)<br/>"
"Michał Szymanowski (Polish)<br/>"
"Mariusz Fik (Polish)<br/>"
"Jérôme Giry (French)<br/>"
"Nicolas Ourceau (French)<br/>"
"Vasilis Tsivikis (Greek)<br/>"
"Alexander Maslov (Russian)<br/>"
"Oleg Brezhnev (Russian)<br/>"
"Sérgio Marques (Portuguese)<br/>"
"Mladen Pejaković (Serbian)"
QString::fromUtf8("Heimen Stoffels (Dutch)<br/>"
"Peter Vacula (Slovakia)<br/>"
"Ján Ďanovský (Slovakia)<br/>"
"Jonathan Hooverman (German)<br/>"
"Unink-Lio (Chinese)<br/>"
"Federico Fabiani (Italy)<br/>"
"Francesco Marinucci (Italy)<br/>"
"Jorge Sevilla (Spanish)<br/>"
"Michał Szymanowski (Polish)<br/>"
"Mariusz Fik (Polish)<br/>"
"Jérôme Giry (French)<br/>"
"Nicolas Ourceau (French)<br/>"
"Vasilis Tsivikis (Greek)<br/>"
"Alexander Maslov (Russian)<br/>"
"Oleg Brezhnev (Russian)<br/>"
"Sérgio Marques (Portuguese)<br/>"
"Mladen Pejaković (Serbian)")
));
m_authorsHtml.append("</div>");
}

View File

@ -36,6 +36,7 @@ BrowsingLibrary::BrowsingLibrary(QupZilla* mainClass, QWidget* parent)
, m_rssLoaded(false)
{
ui->setupUi(this);
Settings settings;
settings.beginGroup("BrowsingLibrary");
resize(settings.value("size", QSize(760, 470)).toSize());

View File

@ -36,10 +36,6 @@ class ClearPrivateData : public QDialog
public:
explicit ClearPrivateData(QupZilla* mainClass, QWidget* parent = 0);
signals:
public slots:
private slots:
void historyClicked(bool state);
void dialogAccepted();

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "pagescreen.h"
#include "ui_pagescreen.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "globalfunctions.h"
PageScreen::PageScreen(WebView* view, QWidget* parent)

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "sourceviewer.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "htmlhighlighter.h"
#include "sourceviewersearch.h"
#include "globalfunctions.h"
@ -134,10 +134,15 @@ void SourceViewer::findText()
void SourceViewer::reload()
{
m_sourceEdit->clear();
m_sourceEdit->insertPlainText(m_frame->toHtml());
if (m_frame) {
m_sourceEdit->clear();
m_sourceEdit->insertPlainText(m_frame.data()->toHtml());
m_statusBar->showMessage(tr("Source reloaded"));
m_statusBar->showMessage(tr("Source reloaded"));
}
else {
m_statusBar->showMessage(tr("Cannot reload source. Page has been closed."));
}
}
void SourceViewer::setTextEditable()

View File

@ -54,7 +54,7 @@ private slots:
private:
QBoxLayout* m_layout;
QTextEdit* m_sourceEdit;
QWebFrame* m_frame;
QWeakPointer<QWebFrame> m_frame;
QStatusBar* m_statusBar;
};

View File

@ -28,8 +28,6 @@ class TipLabel;
class TipLabel : public SqueezeLabelV1
{
Q_OBJECT
public:
TipLabel(QupZilla* parent);
@ -45,17 +43,12 @@ private:
class StatusBarMessage : public QObject
{
Q_OBJECT
public:
explicit StatusBarMessage(QupZilla* mainClass);
void showMessage(const QString &message);
void clearMessage();
signals:
public slots:
private:
QupZilla* p_QupZilla;
TipLabel* m_statusBarText;

View File

@ -286,7 +286,7 @@ void ClickToFlash::showInfo()
}
widg->setMaximumHeight(500);
qz_centerWidgetToParent(widg, m_page->qupzilla());
qz_centerWidgetToParent(widg, m_page->view());
widg->show();
}

View File

@ -22,6 +22,8 @@
SpeedDial::SpeedDial(QObject* parent)
: QObject(parent)
, m_maxPagesInRow(4)
, m_sizeOfSpeedDials(231)
, m_loaded(false)
, m_regenerateScript(true)
{

View File

@ -35,7 +35,7 @@ QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, cons
}
if (mime != "application/x-shockwave-flash") {
if (mime != "application/futuresplash") {
if (mime != "application/futuresplash" && mime != "application/x-java-applet") {
qDebug() << "WebPluginFactory::create missing mimeType handler for: " << mime;
}
return 0;

View File

@ -24,8 +24,6 @@
class WebPage;
class WebPluginFactory : public QWebPluginFactory
{
Q_OBJECT
public:
WebPluginFactory(QObject* parent);
virtual QObject* create(const QString &mimeType, const QUrl &url, const QStringList &argumentNames, const QStringList &argumentValues) const;

View File

@ -33,6 +33,7 @@ ThemeManager::ThemeManager(QWidget* parent)
{
ui->setupUi(parent);
ui->license->hide();
Settings settings;
settings.beginGroup("Themes");
m_activeTheme = settings.value("activeTheme", DEFAULT_THEME_NAME).toString();

View File

@ -1,3 +1,20 @@
/* ============================================================
* 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 "rssicon.h"
RssIcon::RssIcon(QWidget* parent)

View File

@ -1,3 +1,20 @@
/* ============================================================
* 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 RSSICON_H
#define RSSICON_H
@ -9,10 +26,6 @@ class RssIcon : public ClickableLabel
public:
explicit RssIcon(QWidget* parent = 0);
signals:
public slots:
private:
void mousePressEvent(QMouseEvent* ev);
};

View File

@ -28,7 +28,7 @@ RSSNotification::RSSNotification(QString host, QWidget* parent)
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(widget());
ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton));
ui->label->setText(tr("You have successfully added RSS feed \"%1\".").arg(host));
ui->label->setText(QupZilla::tr("You have successfully added RSS feed \"%1\".").arg(host));
connect(ui->pushButton, SIGNAL(clicked()), mApp->getWindow(), SLOT(showRSSManager()));
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hide()));

View File

@ -30,8 +30,6 @@ class RSSNotification;
class AnimatedWidget;
class RSSNotification : public AnimatedWidget
{
Q_OBJECT
public:
explicit RSSNotification(QString host, QWidget* parent = 0);
~RSSNotification();

View File

@ -18,7 +18,7 @@
#include "rsswidget.h"
#include "ui_rsswidget.h"
#include "mainapplication.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "rssmanager.h"
#include "rssnotification.h"
@ -107,7 +107,7 @@ void RSSWidget::addRss()
title = button->toolTip();
}
if (mApp->rssManager()->addRssFeed(urlString, title, m_view->siteIcon())) {
if (mApp->rssManager()->addRssFeed(urlString, title, m_view->icon())) {
RSSNotification* notif = new RSSNotification(title, m_view);
m_view->addNotification(notif);
close();

View File

@ -20,7 +20,7 @@
#include "ui_bookmarkssidebar.h"
#include "qupzilla.h"
#include "iconprovider.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "bookmarkstoolbar.h"
#include "tabwidget.h"
#include "bookmarksmodel.h"

View File

@ -29,7 +29,6 @@ namespace Ui
class BookmarksSideBar;
}
class WebView;
class QupZilla;
class BookmarksModel;
class BookmarksSideBar : public QWidget

View File

@ -38,6 +38,7 @@ TRANSLATIONS +=../translations/cs_CZ.ts\
../translations/pt_PT.ts\
../translations/sr_BA.ts\
../translations/sr_RS.ts\
../translations/sv_SE.ts\
../translations/empty.ts\
INCLUDEPATH += 3rdparty\
@ -62,6 +63,7 @@ INCLUDEPATH += 3rdparty\
desktopnotifications\
opensearch\
bookmarksimport\
popupwindow\
SOURCES += main.cpp\
3rdparty/qtwin.cpp \
@ -88,7 +90,6 @@ SOURCES += main.cpp\
preferences/preferences.cpp \
rss/rssmanager.cpp \
other/clearprivatedata.cpp \
webview/webview.cpp \
webview/webpage.cpp \
webview/tabwidget.cpp \
webview/tabbar.cpp \
@ -185,7 +186,13 @@ SOURCES += main.cpp\
navigation/downicon.cpp \
network/cabundleupdater.cpp \
app/settings.cpp \
app/proxystyle.cpp
app/proxystyle.cpp \
popupwindow/popupwebpage.cpp \
webview/popupwebview.cpp \
popupwindow/popupwindow.cpp \
popupwindow/popuplocationbar.cpp \
webview/tabbedwebview.cpp \
webview/webview.cpp
HEADERS += \
3rdparty/qtwin.h \
@ -212,7 +219,6 @@ HEADERS += \
preferences/preferences.h \
rss/rssmanager.h \
other/clearprivatedata.h \
webview/webview.h \
webview/webpage.h \
webview/tabwidget.h \
webview/tabbar.h \
@ -311,7 +317,13 @@ HEADERS += \
navigation/downicon.h \
network/cabundleupdater.h \
app/settings.h \
app/proxystyle.h
app/proxystyle.h \
popupwindow/popupwebpage.h \
webview/popupwebview.h \
popupwindow/popupwindow.h \
popupwindow/popuplocationbar.h \
webview/tabbedwebview.h \
webview/webview.h
FORMS += \
preferences/autofillmanager.ui \

View File

@ -283,7 +283,7 @@ QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string)
QString CertificateInfoWidget::showCertInfo(const QString &string)
{
if (string.isEmpty()) {
return tr("<not set in certificate>");
return QObject::tr("<not set in certificate>");
}
else {
return clearCertSpecialSymbols(string);

View File

@ -30,8 +30,6 @@ class CertificateInfoWidget;
class CertificateInfoWidget : public QWidget
{
Q_OBJECT
public:
explicit CertificateInfoWidget(const QSslCertificate &cert, QWidget* parent = 0);
~CertificateInfoWidget();

View File

@ -24,7 +24,6 @@
class WebView;
class ClosedTabsManager : public QObject
{
Q_OBJECT
public:
explicit ClosedTabsManager(QObject* parent = 0);
struct Tab {
@ -49,10 +48,6 @@ public:
QList<ClosedTabsManager::Tab> allClosedTabs() { return m_closedTabs; }
signals:
public slots:
private:
QList<ClosedTabsManager::Tab> m_closedTabs;

View File

@ -24,8 +24,6 @@
class DockTitleBarWidget : public QWidget, public Ui_DockTitleBarWidget
{
Q_OBJECT
public:
explicit DockTitleBarWidget(const QString &title, QWidget* parent = 0);
~DockTitleBarWidget();

View File

@ -23,14 +23,9 @@
class Frame : public QFrame
{
Q_OBJECT
public:
explicit Frame(QWidget* parent = 0);
signals:
public slots:
private:
void mousePressEvent(QMouseEvent* event);

View File

@ -66,8 +66,6 @@ class QTextDocument;
class HtmlHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
HtmlHighlighter(QTextDocument* parent = 0);

View File

@ -36,7 +36,7 @@ void IconProvider::saveIcon(WebView* view)
item.image = view->icon().pixmap(16, 16).toImage();
item.url = view->url();
if (item.image.isNull()) {
if (item.image == QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic).toImage()) {
return;
}

View File

@ -22,8 +22,8 @@ ProgressBar::ProgressBar(QWidget* parent)
, m_value(0)
, m_lastPaintedValue(-1)
{
setMinimumSize(QSize(130, 16));
setMaximumSize(QSize(150, 16));
setMinimumSize(130, 16);
setMaximumSize(150, 16);
}
void ProgressBar::setValue(int value)
@ -51,8 +51,11 @@ void ProgressBar::initStyleOption(QStyleOptionProgressBar* option)
void ProgressBar::paintEvent(QPaintEvent*)
{
QStylePainter paint(this);
QStyleOptionProgressBarV2 opt;
initStyleOption(&opt);
paint.drawControl(QStyle::CE_ProgressBar, opt);
m_lastPaintedValue = m_value;
}

View File

@ -40,7 +40,6 @@ protected:
private:
int m_value;
int m_lastPaintedValue;
};
#endif // PROGRESSBAR_H

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "searchtoolbar.h"
#include "qupzilla.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "lineedit.h"
#include "ui_searchtoolbar.h"
#include "iconprovider.h"

View File

@ -17,9 +17,9 @@
* ============================================================ */
#include "siteinfo.h"
#include "ui_siteinfo.h"
#include "qupzilla.h"
#include "webview.h"
#include "webpage.h"
#include "mainapplication.h"
#include "downloaditem.h"
#include "certificateinfowidget.h"
#include "globalfunctions.h"
@ -35,12 +35,12 @@ QString SiteInfo::showCertInfo(const QString &string)
}
}
SiteInfo::SiteInfo(QupZilla* mainClass, QWidget* parent)
SiteInfo::SiteInfo(WebView* view, QWidget* parent)
: QDialog(parent)
, ui(new Ui::SiteInfo)
, p_QupZilla(mainClass)
, m_certWidget(0)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
ui->listWidget->item(0)->setIcon(QIcon::fromTheme("document-properties", QIcon(":/icons/preferences/document-properties.png")));
@ -48,16 +48,16 @@ SiteInfo::SiteInfo(QupZilla* mainClass, QWidget* parent)
ui->listWidget->item(2)->setIcon(QIcon::fromTheme("dialog-password", QIcon(":/icons/preferences/dialog-password.png")));
ui->listWidget->item(0)->setSelected(true);
WebView* view = p_QupZilla->weView();
WebPage* webPage = qobject_cast<WebPage*>(view->page());
QWebFrame* frame = view->page()->mainFrame();
QString title = view->title();
QSslCertificate cert = view->webPage()->sslCertificate();
QSslCertificate cert = webPage->sslCertificate();
m_baseUrl = view->url();
//GENERAL
ui->heading->setText(QString("<b>%1</b>:").arg(title));
ui->siteAddress->setText(frame->baseUrl().toString());
ui->sizeLabel->setText(DownloadItem::fileSizeToString(view->webPage()->totalBytes()));
ui->sizeLabel->setText(DownloadItem::fileSizeToString(webPage->totalBytes()));
QString encoding;
//Meta

View File

@ -29,14 +29,14 @@ namespace Ui
class SiteInfo;
}
class QupZilla;
class WebView;
class CertificateInfoWidget;
class SiteInfo : public QDialog
{
Q_OBJECT
public:
explicit SiteInfo(QupZilla* mainClass, QWidget* parent = 0);
explicit SiteInfo(WebView* view, QWidget* parent = 0);
~SiteInfo();
static QString showCertInfo(const QString &string);
@ -52,7 +52,6 @@ private slots:
private:
Ui::SiteInfo* ui;
QupZilla* p_QupZilla;
CertificateInfoWidget* m_certWidget;
QPixmap m_activePixmap;

View File

@ -29,9 +29,10 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent)
ui->setupUi(this);
WebView* view = p_QupZilla->weView();
WebPage* webPage = qobject_cast<WebPage*>(view->page());
QUrl url = view->url();
if (view->webPage()->sslCertificate().isValid()) {
if (webPage->sslCertificate().isValid()) {
ui->secureLabel->setText(tr("Your connection to this site is <b>secured</b>."));
ui->secureIcon->setPixmap(QPixmap(":/icons/locationbar/accept.png"));
}

View File

@ -31,7 +31,6 @@ class QupZilla;
class SiteInfoWidget : public QMenu
{
Q_OBJECT
public:
explicit SiteInfoWidget(QupZilla* mainClass, QWidget* parent = 0);
~SiteInfoWidget();

View File

@ -271,7 +271,7 @@ void TabBar::closeCurrentTab()
void TabBar::bookmarkTab()
{
p_QupZilla->addBookmark(p_QupZilla->weView(m_clickedTab)->url(), p_QupZilla->weView(m_clickedTab)->title(), p_QupZilla->weView(m_clickedTab)->siteIcon());
p_QupZilla->addBookmark(p_QupZilla->weView(m_clickedTab)->url(), p_QupZilla->weView(m_clickedTab)->title(), p_QupZilla->weView(m_clickedTab)->icon());
}
void TabBar::pinTab()

View File

@ -0,0 +1,629 @@
/* ============================================================
* 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 "tabbedwebview.h"
#include "qupzilla.h"
#include "webpage.h"
#include "tabwidget.h"
#include "networkmanager.h"
#include "mainapplication.h"
#include "tabbar.h"
#include "pluginproxy.h"
#include "webtab.h"
#include "statusbarmessage.h"
#include "progressbar.h"
#include "navigationbar.h"
#include "iconprovider.h"
#include "searchenginesmanager.h"
TabbedWebView::TabbedWebView(QupZilla* mainClass, WebTab* webTab)
: WebView(webTab)
, p_QupZilla(mainClass)
, m_tabWidget(p_QupZilla->tabWidget())
, m_page(0)
, m_webTab(webTab)
, m_menu(new QMenu(this))
, m_clickedFrame(0)
, m_mouseTrack(false)
, m_navigationVisible(false)
, m_hasRss(false)
, m_rssChecked(false)
{
connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(loadingProgress(int)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished()));
connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
connect(this, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged()));
connect(this, SIGNAL(iconChanged()), this, SLOT(slotIconChanged()));
connect(this, SIGNAL(statusBarMessage(QString)), p_QupZilla->statusBar(), SLOT(showMessage(QString)));
connect(mApp->networkManager(), SIGNAL(wantsFocus(QUrl)), this, SLOT(getFocus(QUrl)));
connect(p_QupZilla, SIGNAL(setWebViewMouseTracking(bool)), this, SLOT(trackMouse(bool)));
// Tracking mouse also on tabs created in fullscreen
trackMouse(p_QupZilla->isFullScreen());
}
void TabbedWebView::setWebPage(WebPage* page)
{
if (m_page == page) {
return;
}
if (m_page) {
delete m_page;
m_page = 0;
}
m_page = page;
m_page->setWebView(this);
m_page->setParent(this);
setPage(m_page);
connect(m_page, SIGNAL(linkHovered(QString, QString, QString)), this, SLOT(linkHovered(QString, QString, QString)));
connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(closeView()));
// Set default zoom
setZoom(mApp->defaultZoom());
}
void TabbedWebView::slotIconChanged()
{
if (url().scheme() == "file" || url().scheme() == "qupzilla" || title().contains(tr("Failed loading page"))) {
return;
}
mApp->iconProvider()->saveIcon(this);
showIcon();
}
WebPage* TabbedWebView::webPage() const
{
return m_page;
}
WebTab* TabbedWebView::webTab() const
{
return m_webTab;
}
QString TabbedWebView::getIp() const
{
return m_currentIp;
}
bool TabbedWebView::isCurrent()
{
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex()));
if (!webTab) {
return false;
}
return (webTab->view() == this);
}
void TabbedWebView::urlChanged(const QUrl &url)
{
if (isCurrent()) {
p_QupZilla->navigationBar()->refreshHistory();
}
if (lastUrl() != url) {
emit changed();
}
}
void TabbedWebView::loadingProgress(int prog)
{
if (prog > 60) {
checkRss();
}
if (isCurrent()) {
p_QupZilla->updateLoadingActions();
}
}
void TabbedWebView::slotLoadStarted()
{
m_rssChecked = false;
emit rssChanged(false);
animationLoading(tabIndex(), true);
if (title().isNull()) {
m_tabWidget->setTabText(tabIndex(), tr("Loading..."));
}
m_currentIp.clear();
}
void TabbedWebView::slotLoadFinished()
{
QMovie* mov = animationLoading(tabIndex(), false)->movie();
if (mov) {
mov->stop();
}
showIcon();
QHostInfo::lookupHost(url().host(), this, SLOT(setIp(QHostInfo)));
if (isCurrent()) {
p_QupZilla->updateLoadingActions();
}
}
QLabel* TabbedWebView::animationLoading(int index, bool addMovie)
{
if (index == -1) {
return 0;
}
QLabel* loadingAnimation = qobject_cast<QLabel*>(m_tabWidget->getTabBar()->tabButton(index, QTabBar::LeftSide));
if (!loadingAnimation) {
loadingAnimation = new QLabel();
}
if (addMovie && !loadingAnimation->movie()) {
QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), loadingAnimation);
movie->setSpeed(70);
loadingAnimation->setMovie(movie);
movie->start();
}
else if (loadingAnimation->movie()) {
loadingAnimation->movie()->stop();
}
m_tabWidget->getTabBar()->setTabButton(index, QTabBar::LeftSide, 0);
m_tabWidget->getTabBar()->setTabButton(index, QTabBar::LeftSide, loadingAnimation);
return loadingAnimation;
}
void TabbedWebView::stopAnimation()
{
QMovie* mov = animationLoading(tabIndex(), false)->movie();
if (mov) {
mov->stop();
}
showIcon();
}
void TabbedWebView::setIp(const QHostInfo &info)
{
if (info.addresses().isEmpty()) {
return;
}
m_currentIp = info.hostName() + " (" + info.addresses().at(0).toString() + ")";
if (isCurrent()) {
emit ipChanged(m_currentIp);
}
}
void TabbedWebView::titleChanged()
{
QString t = title();
m_tabWidget->setTabToolTip(tabIndex(), t);
if (isCurrent()) {
p_QupZilla->setWindowTitle(tr("%1 - QupZilla").arg(t));
}
m_tabWidget->setTabText(tabIndex(), t);
}
void TabbedWebView::showIcon()
{
if (isLoading()) {
return;
}
QIcon icon_ = icon();
if (!icon_.isNull()) {
animationLoading(tabIndex(), false)->setPixmap(icon_.pixmap(16, 16));
}
else {
animationLoading(tabIndex(), false)->setPixmap(IconProvider::fromTheme("text-plain").pixmap(16, 16));
}
}
void TabbedWebView::linkHovered(const QString &link, const QString &title, const QString &content)
{
Q_UNUSED(title)
Q_UNUSED(content)
if (isCurrent()) {
if (link != "") {
p_QupZilla->statusBarMessage()->showMessage(link);
}
else {
p_QupZilla->statusBarMessage()->clearMessage();
}
}
m_hoveredLink = link;
}
// FIXME: Don't do this magic to get index of tab.
// Implement setTabIndex() and call it from TabWidget (when creating and also from
// tabMoved slot)
int TabbedWebView::tabIndex() const
{
int i = 0;
while (WebTab* wTab = qobject_cast<WebTab*>(m_tabWidget->widget(i))) {
if (wTab && wTab->view() == this) {
break;
}
i++;
}
return i;
}
QWidget* TabbedWebView::overlayForJsAlert()
{
return m_webTab;
}
void TabbedWebView::closeView()
{
emit wantsCloseTab(tabIndex());
}
void TabbedWebView::checkRss()
{
if (m_rssChecked) {
return;
}
m_rssChecked = true;
QWebFrame* frame = page()->mainFrame();
QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]");
m_hasRss = links.count() != 0;
emit rssChanged(m_hasRss);
}
void TabbedWebView::contextMenuEvent(QContextMenuEvent* event)
{
m_menu->clear();
m_clickedFrame = 0;
QWebFrame* frameAtPos = page()->frameAt(event->pos());
QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
if (!r.linkUrl().isEmpty() && r.linkUrl().scheme() != "javascript") {
if (page()->selectedText() == r.linkText()) {
findText("");
}
m_menu->addAction(QIcon(":/icons/menu/popup.png"), tr("Open link in new &tab"), this, SLOT(openUrlInNewTab()))->setData(r.linkUrl());
m_menu->addAction(tr("Open link in new &window"), this, SLOT(openUrlInNewWindow()))->setData(r.linkUrl());
m_menu->addSeparator();
m_menu->addAction(IconProvider::fromTheme("user-bookmarks"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(r.linkUrl());
m_menu->addAction(QIcon::fromTheme("document-save"), tr("&Save link as..."), this, SLOT(downloadLinkToDisk()))->setData(r.linkUrl());
m_menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send link..."), this, SLOT(sendLinkByMail()))->setData(r.linkUrl());
m_menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy link address"), this, SLOT(copyLinkToClipboard()))->setData(r.linkUrl());
m_menu->addSeparator();
if (!selectedText().isEmpty()) {
m_menu->addAction(pageAction(QWebPage::Copy));
}
}
if (!r.imageUrl().isEmpty()) {
if (!m_menu->isEmpty()) {
m_menu->addSeparator();
}
m_menu->addAction(tr("Show i&mage"), this, SLOT(openActionUrl()))->setData(r.imageUrl());
m_menu->addAction(tr("Copy im&age"), this, SLOT(copyImageToClipboard()))->setData(r.imageUrl());
m_menu->addAction(QIcon::fromTheme("edit-copy"), tr("Copy image ad&dress"), this, SLOT(copyLinkToClipboard()))->setData(r.imageUrl());
m_menu->addSeparator();
m_menu->addAction(QIcon::fromTheme("document-save"), tr("&Save image as..."), this, SLOT(downloadLinkToDisk()))->setData(r.imageUrl());
m_menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send image..."), this, SLOT(sendLinkByMail()))->setData(r.imageUrl());
m_menu->addSeparator();
//menu->addAction(tr("Block image"), this, SLOT(blockImage()))->setData(r.imageUrl().toString());
if (!selectedText().isEmpty()) {
m_menu->addAction(pageAction(QWebPage::Copy));
}
}
QWebElement element = r.element();
if (!element.isNull() && (element.tagName().toLower() == "input" || element.tagName().toLower() == "textarea" ||
element.tagName().toLower() == "video" || element.tagName().toLower() == "audio")) {
if (m_menu->isEmpty()) {
page()->createStandardContextMenu()->popup(QCursor::pos());
return;
}
}
if (m_menu->isEmpty() && selectedText().isEmpty()) {
QAction* action = m_menu->addAction(tr("&Back"), this, SLOT(back()));
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowBack));
action->setEnabled(history()->canGoBack());
action = m_menu->addAction(tr("&Forward"), this, SLOT(forward()));
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward));
action->setEnabled(history()->canGoForward());
m_menu->addAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reload()));
action = m_menu->addAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("S&top"), this, SLOT(stop()));
action->setEnabled(isLoading());
m_menu->addSeparator();
if (frameAtPos && page()->mainFrame() != frameAtPos) {
m_clickedFrame = frameAtPos;
QMenu* menu = new QMenu(tr("This frame"));
menu->addAction(tr("Show &only this frame"), this, SLOT(loadClickedFrame()));
menu->addAction(QIcon(":/icons/menu/popup.png"), tr("Show this frame in new &tab"), this, SLOT(loadClickedFrameInNewTab()));
menu->addSeparator();
menu->addAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reloadClickedFrame()));
menu->addAction(QIcon::fromTheme("document-print"), tr("Print frame"), this, SLOT(printClickedFrame()));
menu->addSeparator();
menu->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &in"), this, SLOT(clickedFrameZoomIn()));
menu->addAction(QIcon::fromTheme("zoom-out"), tr("&Zoom out"), this, SLOT(clickedFrameZoomOut()));
menu->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), this, SLOT(clickedFrameZoomReset()));
menu->addSeparator();
menu->addAction(QIcon::fromTheme("text-html"), tr("Show so&urce of frame"), this, SLOT(showClickedFrameSource()));
m_menu->addMenu(menu);
}
m_menu->addSeparator();
m_menu->addAction(IconProvider::fromTheme("user-bookmarks"), tr("Book&mark page"), this, SLOT(bookmarkLink()));
m_menu->addAction(QIcon::fromTheme("document-save"), tr("&Save page as..."), this, SLOT(downloadLinkToDisk()))->setData(url());
m_menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy page link"), this, SLOT(copyLinkToClipboard()))->setData(url());
m_menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send page link..."), this, SLOT(sendLinkByMail()))->setData(url());
m_menu->addAction(QIcon::fromTheme("document-print"), tr("&Print page"), this, SLOT(printPage()));
m_menu->addSeparator();
m_menu->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &all"), this, SLOT(selectAll()));
m_menu->addSeparator();
if (url().scheme() == "http" || url().scheme() == "https") {
// bool result = validateConfirm(tr("Do you want to upload this page to an online source code validator?"));
// if (result)
m_menu->addAction(tr("Validate page"), this, SLOT(openUrlInNewTab()))->setData("http://validator.w3.org/check?uri=" + url().toString());
}
m_menu->addAction(QIcon::fromTheme("text-html"), tr("Show so&urce code"), this, SLOT(showSource()));
m_menu->addAction(tr("Show Web &Inspector"), this, SLOT(showInspector()));
m_menu->addSeparator();
m_menu->addAction(QIcon::fromTheme("dialog-information"), tr("Show info ab&out site"), this, SLOT(showSiteInfo()));
}
mApp->plugins()->populateWebViewMenu(m_menu, this, r);
if (!selectedText().isEmpty()) {
QString selectedText = page()->selectedText();
m_menu->addAction(pageAction(QWebPage::Copy));
m_menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send text..."), this, SLOT(sendLinkByMail()))->setData(selectedText);
m_menu->addSeparator();
QString langCode = mApp->getActiveLanguage().left(2);
QUrl googleTranslateUrl = QUrl(QString("http://translate.google.com/#auto|%1|%2").arg(langCode, selectedText));
m_menu->addAction(QIcon(":icons/menu/translate.png"), tr("Google Translate"), this, SLOT(openUrlInNewTab()))->setData(googleTranslateUrl);
m_menu->addAction(tr("Dictionary"), this, SLOT(openUrlInNewTab()))->setData("http://" + (langCode != "" ? langCode + "." : langCode) + "wiktionary.org/wiki/Special:Search?search=" + selectedText);
m_menu->addSeparator();
QString selectedString = selectedText.trimmed();
if (!selectedString.contains(".")) {
// Try to add .com
selectedString.append(".com");
}
QUrl guessedUrl = QUrl::fromUserInput(selectedString);
if (isUrlValid(guessedUrl)) {
m_menu->addAction(QIcon(":/icons/menu/popup.png"), tr("Go to &web address"), this, SLOT(openUrlInNewTab()))->setData(guessedUrl);
}
selectedText.truncate(20);
SearchEngine engine = mApp->searchEnginesManager()->activeEngine();
m_menu->addAction(engine.icon, tr("Search \"%1 ..\" with %2").arg(selectedText, engine.name), this, SLOT(searchSelectedText()));
}
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0))
// still bugged? in 4.8 RC (it shows selection of webkit's internal source, not html from page)
// it may or may not be bug, but this implementation is useless for us
//
// if (!selectedHtml().isEmpty())
// menu->addAction(tr("Show source of selection"), this, SLOT(showSourceOfSelection()));
#endif
if (!m_menu->isEmpty()) {
//Prevent choosing first option with double rightclick
QPoint pos = QCursor::pos();
QPoint p(pos.x(), pos.y() + 1);
m_menu->popup(p);
return;
}
WebView::contextMenuEvent(event);
}
void TabbedWebView::stop()
{
m_page->triggerAction(QWebPage::Stop);
slotLoadFinished();
}
void TabbedWebView::openUrlInNewTab()
{
if (QAction* action = qobject_cast<QAction*>(sender())) {
m_tabWidget->addView(action->data().toUrl(), TabWidget::NewBackgroundTab);
}
}
void TabbedWebView::searchSelectedText()
{
SearchEngine engine = mApp->searchEnginesManager()->activeEngine();
m_tabWidget->addView(engine.url.replace("%s", selectedText()), TabWidget::NewBackgroundTab);
}
void TabbedWebView::bookmarkLink()
{
if (QAction* action = qobject_cast<QAction*>(sender())) {
if (action->data().isNull()) {
p_QupZilla->bookmarkPage();
}
else {
p_QupZilla->addBookmark(action->data().toUrl(), title(), icon());
}
}
}
void TabbedWebView::showSourceOfSelection()
{
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0))
showSource(m_page->mainFrame(), selectedHtml());
#endif
}
void TabbedWebView::showInspector()
{
p_QupZilla->showWebInspector();
}
void TabbedWebView::getFocus(const QUrl &urla)
{
if (urla == url()) {
m_tabWidget->setCurrentWidget(m_webTab);
}
}
// ClickedFrame slots
void TabbedWebView::loadClickedFrame()
{
QUrl frameUrl = m_clickedFrame->url();
if (frameUrl.isEmpty()) {
frameUrl = m_clickedFrame->requestedUrl();
}
load(frameUrl);
}
void TabbedWebView::loadClickedFrameInNewTab()
{
QUrl frameUrl = m_clickedFrame->url();
if (frameUrl.isEmpty()) {
frameUrl = m_clickedFrame->requestedUrl();
}
m_tabWidget->addView(frameUrl);
}
void TabbedWebView::reloadClickedFrame()
{
QUrl frameUrl = m_clickedFrame->url();
if (frameUrl.isEmpty()) {
frameUrl = m_clickedFrame->requestedUrl();
}
m_clickedFrame->load(frameUrl);
}
void TabbedWebView::printClickedFrame()
{
printPage(m_clickedFrame);
}
void TabbedWebView::clickedFrameZoomIn()
{
qreal zFactor = m_clickedFrame->zoomFactor() + 0.1;
if (zFactor > 2.5) {
zFactor = 2.5;
}
m_clickedFrame->setZoomFactor(zFactor);
}
void TabbedWebView::clickedFrameZoomOut()
{
qreal zFactor = m_clickedFrame->zoomFactor() - 0.1;
if (zFactor < 0.5) {
zFactor = 0.5;
}
m_clickedFrame->setZoomFactor(zFactor);
}
void TabbedWebView::clickedFrameZoomReset()
{
m_clickedFrame->setZoomFactor(zoomFactor());
}
void TabbedWebView::showClickedFrameSource()
{
showSource(m_clickedFrame);
}
void TabbedWebView::mousePressEvent(QMouseEvent* event)
{
switch (event->button()) {
case Qt::MiddleButton:
if (isUrlValid(QUrl(m_hoveredLink))) {
m_tabWidget->addView(QUrl::fromEncoded(m_hoveredLink.toUtf8()), TabWidget::NewBackgroundTab);
event->accept();
return;
}
#ifdef Q_WS_WIN
else {
WebView::mouseDoubleClickEvent(event);
return;
}
#endif
break;
case Qt::LeftButton:
if (event->modifiers() == Qt::ControlModifier && isUrlValid(QUrl(m_hoveredLink))) {
m_tabWidget->addView(QUrl::fromEncoded(m_hoveredLink.toUtf8()), TabWidget::NewBackgroundTab);
event->accept();
return;
}
default:
break;
}
WebView::mousePressEvent(event);
}
void TabbedWebView::mouseMoveEvent(QMouseEvent* event)
{
if (m_mouseTrack) {
if (m_navigationVisible) {
m_navigationVisible = false;
p_QupZilla->showNavigationWithFullscreen();
}
else if (event->y() < 5) {
m_navigationVisible = true;
p_QupZilla->showNavigationWithFullscreen();
}
}
WebView::mouseMoveEvent(event);
}
void TabbedWebView::disconnectObjects()
{
disconnect(this);
disconnect(p_QupZilla->statusBar());
}
TabbedWebView::~TabbedWebView()
{
}

124
src/webview/tabbedwebview.h Normal file
View File

@ -0,0 +1,124 @@
/* ============================================================
* 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 TABBEDWEBVIEW_H
#define TABBEDWEBVIEW_H
#include <QDebug>
#include <QTabWidget>
#include <QContextMenuEvent>
#include <QLabel>
#include <QHostInfo>
#include "webview.h"
class QupZilla;
class TabWidget;
class WebPage;
class WebTab;
class TabbedWebView : public WebView
{
Q_OBJECT
public:
explicit TabbedWebView(QupZilla* mainClass, WebTab* webTab);
~TabbedWebView();
void setWebPage(WebPage* page);
WebPage* webPage() const;
WebTab* webTab() const;
QString getIp() const;
QLabel* animationLoading(int index, bool addMovie);
int tabIndex() const;
bool hasRss() { return m_hasRss; }
QWidget* overlayForJsAlert();
void disconnectObjects();
signals:
void wantsCloseTab(int);
void ipChanged(QString);
void rssChanged(bool);
void changed();
public slots:
void titleChanged();
void stop();
void showIcon();
void slotLoadStarted();
void loadingProgress(int prog);
void closeView();
private slots:
void trackMouse(bool state) { m_mouseTrack = state; }
void searchSelectedText();
void slotLoadFinished();
void urlChanged(const QUrl &url);
void linkHovered(const QString &link, const QString &title, const QString &content);
void openUrlInNewTab();
void bookmarkLink();
void showSourceOfSelection();
void getFocus(const QUrl &urla);
void showInspector();
void stopAnimation();
void setIp(const QHostInfo &info);
void checkRss();
void slotIconChanged();
// ClickedFrame
void loadClickedFrame();
void loadClickedFrameInNewTab();
void reloadClickedFrame();
void printClickedFrame();
void clickedFrameZoomIn();
void clickedFrameZoomOut();
void clickedFrameZoomReset();
void showClickedFrameSource();
private:
void mousePressEvent(QMouseEvent* event);
void contextMenuEvent(QContextMenuEvent* event);
void mouseMoveEvent(QMouseEvent* event);
bool isCurrent();
QupZilla* p_QupZilla;
TabWidget* m_tabWidget;
QString m_hoveredLink;
QString m_currentIp;
WebPage* m_page;
WebTab* m_webTab;
QMenu* m_menu;
QWebFrame* m_clickedFrame;
bool m_mouseTrack;
bool m_navigationVisible;
bool m_hasRss;
bool m_rssChecked;
};
#endif // TABBEDWEBVIEW_H

View File

@ -15,7 +15,7 @@
* 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 "webview.h"
#include "tabbedwebview.h"
#include "webpage.h"
#include "qupzilla.h"
#include "tabwidget.h"
@ -197,12 +197,12 @@ void TabWidget::moveAddTabButton(int posX)
void TabWidget::aboutToShowTabsMenu()
{
m_menuTabs->clear();
WebView* actView = weView();
TabbedWebView* actView = weView();
if (!actView) {
return;
}
for (int i = 0; i < count(); i++) {
WebView* view = weView(i);
TabbedWebView* view = weView(i);
if (!view) {
continue;
}
@ -211,7 +211,7 @@ void TabWidget::aboutToShowTabsMenu()
action->setIcon(QIcon(":/icons/menu/dot.png"));
}
else {
action->setIcon(view->siteIcon());
action->setIcon(view->icon());
}
if (view->title().isEmpty()) {
if (view->isLoading()) {
@ -276,7 +276,7 @@ int TabWidget::addView(QUrl url, const QString &title, OpenUrlIn openIn, bool se
index = insertTab(position, new WebTab(p_QupZilla, locBar), "");
}
WebView* webView = weView(index);
TabbedWebView* webView = weView(index);
locBar->setWebView(webView);
setTabText(index, title);
@ -334,25 +334,26 @@ void TabWidget::closeTab(int index)
index = currentIndex();
}
if (count() == 1) {
if (m_dontQuitWithOneTab) {
weView(index)->load(m_urlOnNewTab);
weView(index)->page()->history()->clear();
return;
}
else {
p_QupZilla->close();
return;
}
}
WebView* webView = weView(index);
TabbedWebView* webView = weView(index);
WebPage* webPage = webView->webPage();
WebTab* webTab = webView->webTab();
if (!webView || !webPage || !webTab) {
return;
}
if (count() == 1) {
if (m_dontQuitWithOneTab) {
webView->load(m_urlOnNewTab);
webPage->history()->clear();
return;
}
else {
p_QupZilla->close();
return;
}
}
if (webTab->isPinned()) {
emit pinnedTabClosed();
}
@ -403,7 +404,7 @@ void TabWidget::currentTabChanged(int index)
}
m_isClosingToLastTabIndex = false;
WebView* webView = weView();
TabbedWebView* webView = weView();
LocationBar* locBar = webView->webTab()->locationBar();
if (m_locationBars->indexOf(locBar) != -1) {
@ -518,7 +519,7 @@ void TabWidget::savePinnedTabs()
QStringList tabs;
QList<QByteArray> tabsHistory;
for (int i = 0; i < count(); ++i) {
if (WebView* tab = weView(i)) {
if (TabbedWebView* tab = weView(i)) {
WebTab* webTab = qobject_cast<WebTab*>(widget(i));
if (!webTab || !webTab->isPinned()) {
continue;
@ -598,7 +599,7 @@ QByteArray TabWidget::saveState()
QStringList tabs;
QList<QByteArray> tabsHistory;
for (int i = 0; i < count(); ++i) {
if (WebView* tab = weView(i)) {
if (TabbedWebView* tab = weView(i)) {
WebTab* webTab = qobject_cast<WebTab*>(widget(i));
if (webTab && webTab->isPinned()) {
continue;

View File

@ -26,11 +26,11 @@
#include <QStackedWidget>
#include <QTextDocument>
#include "webview.h"
#include "tabbedwebview.h"
#include "webtab.h"
class QupZilla;
class WebView;
class TabbedWebView;
class TabBar;
class WebTab;
class TabListButton;
@ -98,8 +98,8 @@ private slots:
private:
void resizeEvent(QResizeEvent* e);
inline WebView* weView() { WebTab* webTab = qobject_cast<WebTab*>(widget(currentIndex())); if (!webTab) return 0; return webTab->view(); }
inline WebView* weView(int index) { WebTab* webTab = qobject_cast<WebTab*>(widget(index)); if (!webTab) return 0; return webTab->view(); }
inline TabbedWebView* weView() { WebTab* webTab = qobject_cast<WebTab*>(widget(currentIndex())); if (!webTab) return 0; return webTab->view(); }
inline TabbedWebView* weView(int index) { WebTab* webTab = qobject_cast<WebTab*>(widget(index)); if (!webTab) return 0; return webTab->view(); }
bool m_hideTabBarWithOneTab;
bool m_dontQuitWithOneTab;

View File

@ -17,8 +17,7 @@
* ============================================================ */
#include "webhistorywrapper.h"
WebHistoryWrapper::WebHistoryWrapper(QObject* parent)
: QObject(parent)
WebHistoryWrapper::WebHistoryWrapper()
{
}

View File

@ -21,11 +21,10 @@
#include <QObject>
#include <QWebHistory>
class WebHistoryWrapper : public QObject
class WebHistoryWrapper
{
Q_OBJECT
public:
explicit WebHistoryWrapper(QObject* parent = 0);
explicit WebHistoryWrapper();
static QList<QWebHistoryItem> forwardItems(int maxItems, QWebHistory* history);
static QList<QWebHistoryItem> backItems(int maxItems, QWebHistory* history);

View File

@ -18,7 +18,7 @@
#include "webinspectordockwidget.h"
#include "docktitlebarwidget.h"
#include "webpage.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "webtab.h"
#include "qupzilla.h"

View File

@ -17,7 +17,7 @@
* ============================================================ */
#include "webtab.h"
#include "qupzilla.h"
#include "webview.h"
#include "tabbedwebview.h"
#include "webpage.h"
#include "tabbar.h"
#include "locationbar.h"
@ -33,26 +33,27 @@ WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar)
m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->setSpacing(0);
m_view = new WebView(p_QupZilla, this);
m_view.data()->setLocationBar(locationBar);
m_layout->addWidget(m_view.data());
m_view = new TabbedWebView(p_QupZilla, this);
WebPage* page = new WebPage(p_QupZilla);
m_view->setWebPage(page);
m_layout->addWidget(m_view);
setLayout(m_layout);
setAutoFillBackground(true); // We don't want this transparent
connect(m_view.data(), SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
connect(m_view.data(), SIGNAL(iconChanged()), m_locationBar.data(), SLOT(siteIconChanged()));
connect(m_view.data(), SIGNAL(loadStarted()), m_locationBar.data(), SLOT(clearIcon()));
connect(m_view.data(), SIGNAL(loadFinished(bool)), m_locationBar.data(), SLOT(siteIconChanged()));
connect(m_view.data(), SIGNAL(showUrl(QUrl)), m_locationBar.data(), SLOT(showUrl(QUrl)));
connect(m_view.data(), SIGNAL(rssChanged(bool)), m_locationBar.data(), SLOT(showRSSIcon(bool)));
connect(m_view.data()->webPage(), SIGNAL(privacyChanged(bool)), m_locationBar.data(), SLOT(setPrivacy(bool)));
connect(m_locationBar.data(), SIGNAL(loadUrl(QUrl)), m_view.data(), SLOT(load(QUrl)));
connect(m_view, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
connect(m_view, SIGNAL(iconChanged()), m_locationBar.data(), SLOT(siteIconChanged()));
connect(m_view, SIGNAL(loadStarted()), m_locationBar.data(), SLOT(clearIcon()));
connect(m_view, SIGNAL(loadFinished(bool)), m_locationBar.data(), SLOT(siteIconChanged()));
connect(m_view, SIGNAL(urlChanged(QUrl)), m_locationBar.data(), SLOT(showUrl(QUrl)));
connect(m_view, SIGNAL(rssChanged(bool)), m_locationBar.data(), SLOT(showRSSIcon(bool)));
connect(m_view->webPage(), SIGNAL(privacyChanged(bool)), m_locationBar.data(), SLOT(setPrivacy(bool)));
connect(m_locationBar.data(), SIGNAL(loadUrl(QUrl)), m_view, SLOT(load(QUrl)));
}
WebView* WebTab::view()
TabbedWebView* WebTab::view()
{
return m_view.data();
return m_view;
}
bool WebTab::isPinned()
@ -97,7 +98,7 @@ void WebTab::showNotification(QWidget* notif)
int WebTab::tabIndex()
{
return m_view.data()->tabIndex();
return m_view->tabIndex();
}
void WebTab::pinTab(int index)
@ -109,7 +110,7 @@ void WebTab::pinTab(int index)
if (m_pinned) { //Unpin tab
m_pinned = false;
tabWidget->setTabText(index, m_view.data()->title());
tabWidget->setTabText(index, m_view->title());
tabWidget->getTabBar()->updateCloseButton(index);
}
else { // Pin tab
@ -126,14 +127,12 @@ void WebTab::disconnectObjects()
{
disconnect(this);
disconnect(m_locationBar.data());
disconnect(m_view.data());
disconnect(m_view);
}
WebTab::~WebTab()
{
if (m_locationBar.data()) {
if (m_locationBar) {
delete m_locationBar.data();
}
m_view.data()->deleteLater();
}

View File

@ -21,7 +21,7 @@
#include <QWidget>
#include <QLayout>
#include <QWeakPointer>
#include "webview.h"
#include "tabbedwebview.h"
#include "locationbar.h"
class QupZilla;
@ -32,7 +32,7 @@ class WebTab : public QWidget
public:
explicit WebTab(QupZilla* mainClass, LocationBar* locationBar);
~WebTab();
WebView* view();
TabbedWebView* view();
bool isPinned();
void pinTab(int index);
void setPinned(bool state);
@ -52,7 +52,7 @@ private:
int tabIndex();
QupZilla* p_QupZilla;
QWeakPointer<WebView> m_view;
TabbedWebView* m_view;
QVBoxLayout* m_layout;
QWeakPointer<LocationBar> m_locationBar;