mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Little improvements in context menu on page and in history.
- in history menus, it shows arrow when you hover at current history item
This commit is contained in:
parent
ec4b52eda8
commit
841c05f8f7
@ -48,6 +48,14 @@ QString titleForUrl(QString title, const QUrl &url)
|
|||||||
return title;
|
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)
|
NavigationBar::NavigationBar(QupZilla* mainClass, QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, p_QupZilla(mainClass)
|
, p_QupZilla(mainClass)
|
||||||
@ -196,7 +204,8 @@ void NavigationBar::aboutToShowHistoryBackMenu()
|
|||||||
if (item.isValid() && lastUrl != item.url()) {
|
if (item.isValid() && lastUrl != item.url()) {
|
||||||
QString title = titleForUrl(item.title(), 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);
|
act->setData(i);
|
||||||
connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex()));
|
connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex()));
|
||||||
connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab()));
|
connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab()));
|
||||||
@ -232,7 +241,8 @@ void NavigationBar::aboutToShowHistoryNextMenu()
|
|||||||
if (item.isValid() && lastUrl != item.url()) {
|
if (item.isValid() && lastUrl != item.url()) {
|
||||||
QString title = titleForUrl(item.title(), 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);
|
act->setData(i);
|
||||||
connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex()));
|
connect(act, SIGNAL(triggered()), this, SLOT(goAtHistoryIndex()));
|
||||||
connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab()));
|
connect(act, SIGNAL(middleClicked()), this, SLOT(goAtHistoryIndexInNewTab()));
|
||||||
|
@ -192,14 +192,14 @@ bool PluginProxy::processKeyRelease(const Qz::ObjectName &type, QObject* obj, QK
|
|||||||
return accepted;
|
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)
|
void PluginProxy::emitMainWindowCreated(QupZilla* window)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
|
|
||||||
class QupZilla;
|
class QupZilla;
|
||||||
|
class WebPage;
|
||||||
|
|
||||||
class QT_QUPZILLA_EXPORT PluginProxy : public Plugins
|
class QT_QUPZILLA_EXPORT PluginProxy : public Plugins
|
||||||
{
|
{
|
||||||
@ -49,15 +50,15 @@ public:
|
|||||||
bool processKeyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
bool processKeyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
||||||
bool processKeyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
bool processKeyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
||||||
|
|
||||||
void emitWebViewCreated(WebView* view);
|
void emitWebPageCreated(WebPage* page);
|
||||||
void emitWebViewDeleted(WebView* view);
|
void emitWebPageDeleted(WebPage* page);
|
||||||
|
|
||||||
void emitMainWindowCreated(QupZilla* window);
|
void emitMainWindowCreated(QupZilla* window);
|
||||||
void emitMainWindowDeleted(QupZilla* window);
|
void emitMainWindowDeleted(QupZilla* window);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void webViewCreated(WebView* view);
|
void webPageCreated(WebPage* page);
|
||||||
void webViewDeleted(WebView* view);
|
void webPageDeleted(WebPage* page);
|
||||||
|
|
||||||
void mainWindowCreated(QupZilla* window);
|
void mainWindowCreated(QupZilla* window);
|
||||||
void mainWindowDeleted(QupZilla* window);
|
void mainWindowDeleted(QupZilla* window);
|
||||||
|
@ -767,6 +767,8 @@ void WebPage::disconnectObjects()
|
|||||||
|
|
||||||
disconnect(this);
|
disconnect(this);
|
||||||
m_networkProxy->disconnectObjects();
|
m_networkProxy->disconnectObjects();
|
||||||
|
|
||||||
|
mApp->plugins()->emitWebPageDeleted(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebPage::~WebPage()
|
WebPage::~WebPage()
|
||||||
|
@ -49,7 +49,9 @@ WebView::WebView(QWidget* parent)
|
|||||||
, m_isLoading(false)
|
, m_isLoading(false)
|
||||||
, m_progress(0)
|
, m_progress(0)
|
||||||
, m_clickedFrame(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(loadStarted()), this, SLOT(slotLoadStarted()));
|
||||||
connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
|
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;
|
m_zoomLevels << 30 << 50 << 67 << 80 << 90 << 100 << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300;
|
||||||
|
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
|
||||||
mApp->plugins()->emitWebViewCreated(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon WebView::icon() const
|
QIcon WebView::icon() const
|
||||||
@ -112,8 +112,9 @@ void WebView::setPage(QWebPage* page)
|
|||||||
QWebView::setPage(page);
|
QWebView::setPage(page);
|
||||||
|
|
||||||
setZoom(WebViewSettings::defaultZoom);
|
setZoom(WebViewSettings::defaultZoom);
|
||||||
|
|
||||||
connect(page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), this, SLOT(frameStateChanged()));
|
connect(page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), this, SLOT(frameStateChanged()));
|
||||||
|
|
||||||
|
mApp->plugins()->emitWebPageCreated(qobject_cast<WebPage*>(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::load(const QUrl &url)
|
void WebView::load(const QUrl &url)
|
||||||
@ -291,6 +292,11 @@ void WebView::slotLoadStarted()
|
|||||||
{
|
{
|
||||||
m_isLoading = true;
|
m_isLoading = true;
|
||||||
m_progress = 0;
|
m_progress = 0;
|
||||||
|
|
||||||
|
if (m_actionsInitialized) {
|
||||||
|
m_actionStop->setEnabled(true);
|
||||||
|
m_actionReload->setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::slotLoadProgress(int progress)
|
void WebView::slotLoadProgress(int progress)
|
||||||
@ -303,6 +309,11 @@ void WebView::slotLoadFinished()
|
|||||||
m_isLoading = false;
|
m_isLoading = false;
|
||||||
m_progress = 100;
|
m_progress = 100;
|
||||||
|
|
||||||
|
if (m_actionsInitialized) {
|
||||||
|
m_actionStop->setEnabled(false);
|
||||||
|
m_actionReload->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_lastUrl != url()) {
|
if (m_lastUrl != url()) {
|
||||||
mApp->history()->addHistoryEntry(this);
|
mApp->history()->addHistoryEntry(this);
|
||||||
}
|
}
|
||||||
@ -578,13 +589,22 @@ void WebView::createSearchEngine()
|
|||||||
|
|
||||||
void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, const QPoint &pos)
|
void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, const QPoint &pos)
|
||||||
{
|
{
|
||||||
if (!m_actionsHaveImages) {
|
if (!m_actionsInitialized) {
|
||||||
m_actionsHaveImages = true;
|
m_actionsInitialized = true;
|
||||||
|
|
||||||
pageAction(QWebPage::Cut)->setIcon(QIcon::fromTheme("edit-cut"));
|
pageAction(QWebPage::Cut)->setIcon(QIcon::fromTheme("edit-cut"));
|
||||||
pageAction(QWebPage::Copy)->setIcon(QIcon::fromTheme("edit-copy"));
|
pageAction(QWebPage::Copy)->setIcon(QIcon::fromTheme("edit-copy"));
|
||||||
pageAction(QWebPage::Paste)->setIcon(QIcon::fromTheme("edit-paste"));
|
pageAction(QWebPage::Paste)->setIcon(QIcon::fromTheme("edit-paste"));
|
||||||
pageAction(QWebPage::SelectAll)->setIcon(QIcon::fromTheme("edit-select-all"));
|
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") {
|
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->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward));
|
||||||
action->setEnabled(WebHistoryWrapper::canGoForward(history()));
|
action->setEnabled(WebHistoryWrapper::canGoForward(history()));
|
||||||
|
|
||||||
menu->addAction(IconProvider::standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reload()));
|
menu->addAction(m_actionReload);
|
||||||
action = menu->addAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("S&top"), this, SLOT(stop()));
|
menu->addAction(m_actionStop);
|
||||||
action->setEnabled(isLoading());
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
if (frameAtPos && page()->mainFrame() != frameAtPos) {
|
if (frameAtPos && page()->mainFrame() != frameAtPos) {
|
||||||
@ -1098,6 +1117,4 @@ bool WebView::eventFilter(QObject* obj, QEvent* event)
|
|||||||
void WebView::disconnectObjects()
|
void WebView::disconnectObjects()
|
||||||
{
|
{
|
||||||
disconnect(this);
|
disconnect(this);
|
||||||
|
|
||||||
mApp->plugins()->emitWebViewDeleted(this);
|
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,6 @@ protected slots:
|
|||||||
|
|
||||||
void createSearchEngine();
|
void createSearchEngine();
|
||||||
|
|
||||||
|
|
||||||
// Clicked frame actions
|
// Clicked frame actions
|
||||||
void loadClickedFrame();
|
void loadClickedFrame();
|
||||||
void loadClickedFrameInNewTab();
|
void loadClickedFrameInNewTab();
|
||||||
@ -152,7 +151,10 @@ private:
|
|||||||
QWebElement m_clickedElement;
|
QWebElement m_clickedElement;
|
||||||
QWebFrame* m_clickedFrame;
|
QWebFrame* m_clickedFrame;
|
||||||
QUrl m_clickedUrl;
|
QUrl m_clickedUrl;
|
||||||
bool m_actionsHaveImages;
|
|
||||||
|
QAction* m_actionReload;
|
||||||
|
QAction* m_actionStop;
|
||||||
|
bool m_actionsInitialized;
|
||||||
|
|
||||||
QList<QTouchEvent::TouchPoint> m_touchPoints;
|
QList<QTouchEvent::TouchPoint> m_touchPoints;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user