mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
Show toolbars menu on right click in menubar and navigation toolbar.
This commit is contained in:
parent
83f3c90752
commit
8a6beac501
|
@ -63,6 +63,7 @@
|
|||
#include "qzsettings.h"
|
||||
#include "webtab.h"
|
||||
#include "speeddial.h"
|
||||
#include "menubar.h"
|
||||
#include "qtwin.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
@ -332,6 +333,8 @@ void QupZilla::setupMenu()
|
|||
else {
|
||||
mApp->macMenuReceiver()->setMenuBar(new QMenuBar(0));
|
||||
}
|
||||
#else
|
||||
setMenuBar(new MenuBar(this));
|
||||
#endif
|
||||
|
||||
// Standard actions - needed on Mac to be placed correctly in "application" menu
|
||||
|
@ -449,18 +452,18 @@ void QupZilla::setupMenu()
|
|||
m_actionCaretBrowsing->setVisible(true);
|
||||
#endif
|
||||
|
||||
QMenu* toolbarsMenu = new QMenu(tr("Toolbars"));
|
||||
m_toolbarsMenu = new QMenu(tr("Toolbars"));
|
||||
#ifndef Q_OS_MAC
|
||||
toolbarsMenu->addAction(m_actionShowMenubar);
|
||||
m_toolbarsMenu->addAction(m_actionShowMenubar);
|
||||
#endif
|
||||
toolbarsMenu->addAction(m_actionShowToolbar);
|
||||
toolbarsMenu->addAction(m_actionShowBookmarksToolbar);
|
||||
toolbarsMenu->addSeparator();
|
||||
toolbarsMenu->addAction(m_actionTabsOnTop);
|
||||
m_toolbarsMenu->addAction(m_actionShowToolbar);
|
||||
m_toolbarsMenu->addAction(m_actionShowBookmarksToolbar);
|
||||
m_toolbarsMenu->addSeparator();
|
||||
m_toolbarsMenu->addAction(m_actionTabsOnTop);
|
||||
QMenu* sidebarsMenu = new QMenu(tr("Sidebars"));
|
||||
m_sideBarManager->setSideBarMenu(sidebarsMenu);
|
||||
|
||||
m_menuView->addMenu(toolbarsMenu);
|
||||
m_menuView->addMenu(m_toolbarsMenu);
|
||||
m_menuView->addMenu(sidebarsMenu);
|
||||
m_menuView->addAction(m_actionShowStatusbar);
|
||||
m_menuView->addSeparator();
|
||||
|
@ -565,8 +568,6 @@ void QupZilla::setupMenu()
|
|||
/************
|
||||
* Menu Bar *
|
||||
************/
|
||||
menuBar()->setObjectName("mainwindow-menubar");
|
||||
menuBar()->setCursor(Qt::ArrowCursor);
|
||||
menuBar()->addMenu(m_menuFile);
|
||||
menuBar()->addMenu(m_menuEdit);
|
||||
menuBar()->addMenu(m_menuView);
|
||||
|
@ -574,7 +575,6 @@ void QupZilla::setupMenu()
|
|||
menuBar()->addMenu(m_menuBookmarks);
|
||||
menuBar()->addMenu(m_menuTools);
|
||||
menuBar()->addMenu(m_menuHelp);
|
||||
menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
/*****************
|
||||
* Other Actions *
|
||||
|
@ -804,7 +804,7 @@ LocationBar* QupZilla::locationBar() const
|
|||
return qobject_cast<LocationBar*>(m_tabWidget->locationBars()->currentWidget());
|
||||
}
|
||||
|
||||
QWidget* QupZilla::navigationContainer()
|
||||
QWidget* QupZilla::navigationContainer() const
|
||||
{
|
||||
if (!qzSettings->tabsOnTop) {
|
||||
return 0;
|
||||
|
@ -813,6 +813,13 @@ QWidget* QupZilla::navigationContainer()
|
|||
return m_navigationContainer;
|
||||
}
|
||||
|
||||
void QupZilla::popupToolbarsMenu(const QPoint &pos)
|
||||
{
|
||||
aboutToShowViewMenu();
|
||||
m_toolbarsMenu->exec(pos);
|
||||
aboutToHideViewMenu();
|
||||
}
|
||||
|
||||
void QupZilla::setWindowTitle(const QString &t)
|
||||
{
|
||||
QString title = t;
|
||||
|
|
|
@ -95,12 +95,13 @@ public:
|
|||
ProgressBar* progressBar() { return m_progressBar; }
|
||||
QLabel* ipLabel() { return m_ipLabel; }
|
||||
AdBlockIcon* adBlockIcon() { return m_adblockIcon; }
|
||||
QMenu* menuHelp() { return m_menuHelp; }
|
||||
QAction* actionRestoreTab() { return m_actionRestoreTab; }
|
||||
QAction* actionReload() { return m_actionReload; }
|
||||
QMenu* menuHelp() { return m_menuHelp; }
|
||||
QMenu* superMenu() { return m_superMenu; }
|
||||
|
||||
QWidget* navigationContainer();
|
||||
QWidget* navigationContainer() const;
|
||||
void popupToolbarsMenu(const QPoint &pos);
|
||||
|
||||
bool isClosing() { return m_isClosing; }
|
||||
QUrl homepageUrl() { return m_homepage; }
|
||||
|
@ -259,6 +260,7 @@ private:
|
|||
QMenu* m_menuTools;
|
||||
QMenu* m_menuHelp;
|
||||
QMenu* m_menuView;
|
||||
QMenu* m_toolbarsMenu;
|
||||
Menu* m_menuBookmarks;
|
||||
Menu* m_menuHistory;
|
||||
QMenu* m_menuClosedTabs;
|
||||
|
|
|
@ -211,7 +211,8 @@ SOURCES += \
|
|||
autofill/autofill.cpp \
|
||||
network/schemehandlers/ftpschemehandler.cpp \
|
||||
autofill/autofillicon.cpp \
|
||||
autofill/autofillwidget.cpp
|
||||
autofill/autofillwidget.cpp \
|
||||
tools/menubar.cpp
|
||||
|
||||
HEADERS += \
|
||||
webview/tabpreview.h \
|
||||
|
@ -377,7 +378,8 @@ HEADERS += \
|
|||
autofill/autofill.h \
|
||||
network/schemehandlers/ftpschemehandler.h \
|
||||
autofill/autofillicon.h \
|
||||
autofill/autofillwidget.h
|
||||
autofill/autofillwidget.h \
|
||||
tools/menubar.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2013 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
|
||||
|
@ -33,6 +33,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QStackedWidget>
|
||||
#include <QWebHistory>
|
||||
#include <QMouseEvent>
|
||||
|
||||
QString NavigationBar::titleForUrl(QString title, const QUrl &url)
|
||||
{
|
||||
|
@ -146,6 +147,9 @@ NavigationBar::NavigationBar(QupZilla* mainClass)
|
|||
#endif
|
||||
m_layout->addWidget(m_exitFullscreen);
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
||||
|
||||
connect(m_menuBack, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryBackMenu()));
|
||||
connect(m_menuForward, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryNextMenu()));
|
||||
connect(m_buttonBack, SIGNAL(clicked()), this, SLOT(goBack()));
|
||||
|
@ -270,6 +274,11 @@ void NavigationBar::clearHistory()
|
|||
refreshHistory();
|
||||
}
|
||||
|
||||
void NavigationBar::contextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
p_QupZilla->popupToolbarsMenu(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void NavigationBar::goAtHistoryIndex()
|
||||
{
|
||||
QWebHistory* history = p_QupZilla->weView()->page()->history();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2013 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
|
||||
|
@ -43,15 +43,15 @@ public:
|
|||
void showReloadButton();
|
||||
void showStopButton();
|
||||
|
||||
inline ToolButton* buttonBack() { return m_buttonBack; }
|
||||
inline ToolButton* buttonNext() { return m_buttonNext; }
|
||||
inline ToolButton* buttonHome() { return m_buttonHome; }
|
||||
inline ToolButton* buttonAddTab() { return m_buttonAddTab; }
|
||||
inline ToolButton* buttonSuperMenu() { return m_supMenu; }
|
||||
inline ToolButton* buttonExitFullscreen() { return m_exitFullscreen; }
|
||||
inline ReloadStopButton* buttonReloadStop() { return m_reloadStop; }
|
||||
inline WebSearchBar* searchLine() { return m_searchLine; }
|
||||
inline QSplitter* splitter() { return m_navigationSplitter; }
|
||||
ToolButton* buttonBack() { return m_buttonBack; }
|
||||
ToolButton* buttonNext() { return m_buttonNext; }
|
||||
ToolButton* buttonHome() { return m_buttonHome; }
|
||||
ToolButton* buttonAddTab() { return m_buttonAddTab; }
|
||||
ToolButton* buttonSuperMenu() { return m_supMenu; }
|
||||
ToolButton* buttonExitFullscreen() { return m_exitFullscreen; }
|
||||
ReloadStopButton* buttonReloadStop() { return m_reloadStop; }
|
||||
WebSearchBar* searchLine() { return m_searchLine; }
|
||||
QSplitter* splitter() { return m_navigationSplitter; }
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -72,6 +72,8 @@ private slots:
|
|||
|
||||
void clearHistory();
|
||||
|
||||
void contextMenuRequested(const QPoint &pos);
|
||||
|
||||
private:
|
||||
QString titleForUrl(QString title, const QUrl &url);
|
||||
QIcon iconForPage(const QUrl &url, const QIcon &sIcon);
|
||||
|
|
38
src/lib/tools/menubar.cpp
Normal file
38
src/lib/tools/menubar.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2013 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 "menubar.h"
|
||||
#include "qupzilla.h"
|
||||
|
||||
MenuBar::MenuBar(QupZilla* parent)
|
||||
: QMenuBar(parent)
|
||||
, p_QupZilla(parent)
|
||||
{
|
||||
setObjectName("mainwindow-menubar");
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)),
|
||||
this, SLOT(contextMenuRequested(QPoint)));
|
||||
}
|
||||
|
||||
void MenuBar::contextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
if (!actionAt(pos)) {
|
||||
p_QupZilla->popupToolbarsMenu(mapToGlobal(pos));
|
||||
}
|
||||
}
|
41
src/lib/tools/menubar.h
Normal file
41
src/lib/tools/menubar.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2013 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 MENUBAR_H
|
||||
#define MENUBAR_H
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
#include <QMenuBar>
|
||||
|
||||
class QupZilla;
|
||||
|
||||
class QT_QUPZILLA_EXPORT MenuBar : public QMenuBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MenuBar(QupZilla* parent);
|
||||
|
||||
private slots:
|
||||
void contextMenuRequested(const QPoint &pos);
|
||||
|
||||
private:
|
||||
QupZilla* p_QupZilla;
|
||||
|
||||
};
|
||||
|
||||
#endif // MENUBAR_H
|
Loading…
Reference in New Issue
Block a user