diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index 2fc4eaa61..395cb4283 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -48,6 +48,14 @@ QString titleForUrl(QString title, const QUrl &url) return title; } +QIcon iconForPage(const QUrl &url, const QIcon &sIcon) +{ + QIcon icon; + icon.addPixmap(url.scheme() == "qupzilla" ? QIcon(":icons/qupzilla.png").pixmap(16, 16) :_iconForUrl(url).pixmap(16, 16)); + icon.addPixmap(sIcon.pixmap(16, 16), QIcon::Active); + return icon; +} + NavigationBar::NavigationBar(QupZilla* mainClass, QWidget* parent) : QWidget(parent) , p_QupZilla(mainClass) @@ -196,7 +204,8 @@ void NavigationBar::aboutToShowHistoryBackMenu() if (item.isValid() && lastUrl != item.url()) { QString title = titleForUrl(item.title(), item.url()); - Action* act = new Action(_iconForUrl(item.url()), title); + const QIcon &icon = iconForPage(item.url(), IconProvider::fromTheme("go-previous")); + Action* act = new Action(icon, title); act->setData(i); connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex())); connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab())); @@ -232,7 +241,8 @@ void NavigationBar::aboutToShowHistoryNextMenu() if (item.isValid() && lastUrl != item.url()) { QString title = titleForUrl(item.title(), item.url()); - Action* act = new Action(_iconForUrl(item.url()), title); + const QIcon &icon = iconForPage(item.url(), IconProvider::fromTheme("go-next")); + Action* act = new Action(icon, title); act->setData(i); connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex())); connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab())); diff --git a/src/lib/plugins/pluginproxy.cpp b/src/lib/plugins/pluginproxy.cpp index 6e910bed6..28f08b1bf 100644 --- a/src/lib/plugins/pluginproxy.cpp +++ b/src/lib/plugins/pluginproxy.cpp @@ -192,14 +192,14 @@ bool PluginProxy::processKeyRelease(const Qz::ObjectName &type, QObject* obj, QK return accepted; } -void PluginProxy::emitWebViewCreated(WebView* view) +void PluginProxy::emitWebPageCreated(WebPage* page) { - emit webViewCreated(view); + emit webPageCreated(page); } -void PluginProxy::emitWebViewDeleted(WebView* view) +void PluginProxy::emitWebPageDeleted(WebPage* page) { - emit webViewDeleted(view); + emit webPageDeleted(page); } void PluginProxy::emitMainWindowCreated(QupZilla* window) diff --git a/src/lib/plugins/pluginproxy.h b/src/lib/plugins/pluginproxy.h index a9ac146f5..5a9cc0eef 100644 --- a/src/lib/plugins/pluginproxy.h +++ b/src/lib/plugins/pluginproxy.h @@ -22,6 +22,7 @@ #include "qz_namespace.h" class QupZilla; +class WebPage; class QT_QUPZILLA_EXPORT PluginProxy : public Plugins { @@ -49,15 +50,15 @@ public: bool processKeyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event); bool processKeyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event); - void emitWebViewCreated(WebView* view); - void emitWebViewDeleted(WebView* view); + void emitWebPageCreated(WebPage* page); + void emitWebPageDeleted(WebPage* page); void emitMainWindowCreated(QupZilla* window); void emitMainWindowDeleted(QupZilla* window); signals: - void webViewCreated(WebView* view); - void webViewDeleted(WebView* view); + void webPageCreated(WebPage* page); + void webPageDeleted(WebPage* page); void mainWindowCreated(QupZilla* window); void mainWindowDeleted(QupZilla* window); diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 4aa48e58b..d1ece6a7f 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -767,6 +767,8 @@ void WebPage::disconnectObjects() disconnect(this); m_networkProxy->disconnectObjects(); + + mApp->plugins()->emitWebPageDeleted(this); } WebPage::~WebPage() diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index 34bbb21db..725fa9537 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -49,7 +49,9 @@ WebView::WebView(QWidget* parent) , m_isLoading(false) , m_progress(0) , m_clickedFrame(0) - , m_actionsHaveImages(false) + , m_actionReload(0) + , m_actionStop(0) + , m_actionsInitialized(false) { connect(this, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted())); connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); @@ -60,8 +62,6 @@ WebView::WebView(QWidget* parent) m_zoomLevels << 30 << 50 << 67 << 80 << 90 << 100 << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; installEventFilter(this); - - mApp->plugins()->emitWebViewCreated(this); } QIcon WebView::icon() const @@ -112,8 +112,9 @@ void WebView::setPage(QWebPage* page) QWebView::setPage(page); setZoom(WebViewSettings::defaultZoom); - connect(page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), this, SLOT(frameStateChanged())); + + mApp->plugins()->emitWebPageCreated(qobject_cast(page)); } void WebView::load(const QUrl &url) @@ -291,6 +292,11 @@ void WebView::slotLoadStarted() { m_isLoading = true; m_progress = 0; + + if (m_actionsInitialized) { + m_actionStop->setEnabled(true); + m_actionReload->setEnabled(false); + } } void WebView::slotLoadProgress(int progress) @@ -303,6 +309,11 @@ void WebView::slotLoadFinished() m_isLoading = false; m_progress = 100; + if (m_actionsInitialized) { + m_actionStop->setEnabled(false); + m_actionReload->setEnabled(true); + } + if (m_lastUrl != url()) { mApp->history()->addHistoryEntry(this); } @@ -578,13 +589,22 @@ void WebView::createSearchEngine() void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, const QPoint &pos) { - if (!m_actionsHaveImages) { - m_actionsHaveImages = true; + if (!m_actionsInitialized) { + m_actionsInitialized = true; pageAction(QWebPage::Cut)->setIcon(QIcon::fromTheme("edit-cut")); pageAction(QWebPage::Copy)->setIcon(QIcon::fromTheme("edit-copy")); pageAction(QWebPage::Paste)->setIcon(QIcon::fromTheme("edit-paste")); pageAction(QWebPage::SelectAll)->setIcon(QIcon::fromTheme("edit-select-all")); + + m_actionReload = new QAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this); + m_actionStop = new QAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("S&top"), this); + + connect(m_actionReload, SIGNAL(triggered()), this, SLOT(reload())); + connect(m_actionStop, SIGNAL(triggered()), this, SLOT(stop())); + + m_actionReload->setEnabled(!isLoading()); + m_actionStop->setEnabled(isLoading()); } if (!hitTest.linkUrl().isEmpty() && hitTest.linkUrl().scheme() != "javascript") { @@ -669,9 +689,8 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos) action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward)); action->setEnabled(WebHistoryWrapper::canGoForward(history())); - menu->addAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reload())); - action = menu->addAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("S&top"), this, SLOT(stop())); - action->setEnabled(isLoading()); + menu->addAction(m_actionReload); + menu->addAction(m_actionStop); menu->addSeparator(); if (frameAtPos && page()->mainFrame() != frameAtPos) { @@ -1098,6 +1117,4 @@ bool WebView::eventFilter(QObject* obj, QEvent* event) void WebView::disconnectObjects() { disconnect(this); - - mApp->plugins()->emitWebViewDeleted(this); } diff --git a/src/lib/webview/webview.h b/src/lib/webview/webview.h index 3d517b51d..e6fc09e2f 100644 --- a/src/lib/webview/webview.h +++ b/src/lib/webview/webview.h @@ -97,7 +97,6 @@ protected slots: void createSearchEngine(); - // Clicked frame actions void loadClickedFrame(); void loadClickedFrameInNewTab(); @@ -152,7 +151,10 @@ private: QWebElement m_clickedElement; QWebFrame* m_clickedFrame; QUrl m_clickedUrl; - bool m_actionsHaveImages; + + QAction* m_actionReload; + QAction* m_actionStop; + bool m_actionsInitialized; QList m_touchPoints; };