mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-19 18:26:34 +01:00
[SuperMenu] Improved menu in button used instead of menubar.
The menu is now displayed inside window, even when window is not in fullscreen. It now also contains the most important actions in addition to copy of top level menus.
This commit is contained in:
parent
8820703a2e
commit
b12c324f87
@ -7,6 +7,7 @@ Version 1.4.0
|
||||
* added support for saving passwords of multiple users per site
|
||||
* added support for showing tabs on top
|
||||
* added bash autocompletion file
|
||||
* added more actions to super menu, also show menu inside window
|
||||
* possibility to select text on page with Shift+Arrow keys
|
||||
* asking user whether to allow site to use notifications/geolocation
|
||||
* option to set JavaScript privacy permissions
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#navigation-button-back::menu-indicator
|
||||
{
|
||||
background: url(images/transp.png);
|
||||
image: none;
|
||||
}
|
||||
|
||||
#navigation-button-next
|
||||
@ -39,7 +39,7 @@
|
||||
|
||||
#navigation-button-next::menu-indicator
|
||||
{
|
||||
background: url(images/transp.png);
|
||||
image: none;
|
||||
}
|
||||
|
||||
#navigation-button-stop
|
||||
@ -77,6 +77,11 @@
|
||||
qproperty-iconSize: 24px 24px;
|
||||
}
|
||||
|
||||
#navigation-button-supermenu::menu-indicator
|
||||
{
|
||||
image: none;
|
||||
}
|
||||
|
||||
/*TabWidget*/
|
||||
#tabbar::tab
|
||||
{
|
||||
@ -103,7 +108,7 @@
|
||||
|
||||
#tabwidget-button-opentabs::menu-indicator
|
||||
{
|
||||
background: url(images/transp.png);
|
||||
image: none;
|
||||
}
|
||||
|
||||
/*IconProvider*/
|
||||
@ -182,7 +187,7 @@ IconProvider
|
||||
|
||||
#bookmarksbar QToolButton::menu-indicator
|
||||
{
|
||||
background: url(images/transp.png);
|
||||
image: none;
|
||||
}
|
||||
|
||||
/*SideBar*/
|
||||
@ -219,7 +224,7 @@ IconProvider
|
||||
|
||||
#websearchbar-searchprovider-comobobox::menu-indicator
|
||||
{
|
||||
background: url(images/transp.png);
|
||||
image: none;
|
||||
}
|
||||
|
||||
/*SourceViewer*/
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "webinspectordockwidget.h"
|
||||
#include "bookmarksimportdialog.h"
|
||||
#include "qztools.h"
|
||||
#include "actioncopy.h"
|
||||
#include "reloadstopbutton.h"
|
||||
#include "enhancedmenu.h"
|
||||
#include "navigationcontainer.h"
|
||||
@ -341,7 +342,7 @@ void QupZilla::setupMenu()
|
||||
#endif
|
||||
|
||||
// Standard actions - needed on Mac to be placed correctly in "application" menu
|
||||
m_actionAbout = new QAction(QIcon(":/icons/qupzilla.png"), tr("&About QupZilla"), 0);
|
||||
m_actionAbout = new QAction(QIcon::fromTheme("help-about"), tr("&About QupZilla"), 0);
|
||||
m_actionAbout->setMenuRole(QAction::AboutRole);
|
||||
connect(m_actionAbout, SIGNAL(triggered()), MENU_RECEIVER, SLOT(aboutQupZilla()));
|
||||
|
||||
@ -366,8 +367,8 @@ void QupZilla::setupMenu()
|
||||
* File Menu *
|
||||
*************/
|
||||
m_menuFile = new QMenu(tr("&File"));
|
||||
m_menuFile->addAction(QIcon::fromTheme("window-new"), tr("&New Window"), MENU_RECEIVER, SLOT(newWindow()))->setShortcut(QKeySequence("Ctrl+N"));
|
||||
m_menuFile->addAction(QIcon(":/icons/menu/new-tab.png"), tr("New Tab"), MENU_RECEIVER, SLOT(addTab()))->setShortcut(QKeySequence("Ctrl+T"));
|
||||
m_menuFile->addAction(QIcon::fromTheme("window-new"), tr("&New Window"), MENU_RECEIVER, SLOT(newWindow()))->setShortcut(QKeySequence("Ctrl+N"));
|
||||
m_menuFile->addAction(QIcon::fromTheme("document-open-remote"), tr("Open Location"), MENU_RECEIVER, SLOT(openLocation()))->setShortcut(QKeySequence("Ctrl+L"));
|
||||
m_menuFile->addAction(QIcon::fromTheme("document-open"), tr("Open &File"), MENU_RECEIVER, SLOT(openFile()))->setShortcut(QKeySequence("Ctrl+O"));
|
||||
m_menuFile->addAction(tr("Close Tab"), MENU_RECEIVER, SLOT(closeTab()))->setShortcut(QKeySequence("Ctrl+W"));
|
||||
@ -564,7 +565,7 @@ void QupZilla::setupMenu()
|
||||
m_menuHelp->addAction(m_actionAbout);
|
||||
m_menuHelp->addSeparator();
|
||||
#endif
|
||||
QAction* infoAction = new QAction(tr("Information about application"), m_menuHelp);
|
||||
QAction* infoAction = new QAction(QIcon::fromTheme("help-contents"), tr("Information about application"), m_menuHelp);
|
||||
infoAction->setData(QUrl("qupzilla:about"));
|
||||
infoAction->setShortcut(QKeySequence(QKeySequence::HelpContents));
|
||||
connect(infoAction, SIGNAL(triggered()), MENU_RECEIVER, SLOT(loadActionUrlInNewTab()));
|
||||
@ -589,13 +590,35 @@ void QupZilla::setupMenu()
|
||||
setupOtherActions();
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
m_superMenu->addMenu(m_menuFile);
|
||||
m_superMenu->addMenu(m_menuEdit);
|
||||
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(0), this));
|
||||
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(1), this));
|
||||
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(3), this));
|
||||
|
||||
m_superMenu->addSeparator();
|
||||
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(7), this));
|
||||
m_superMenu->addAction(new ActionCopy(m_menuFile->actions().at(10), this));
|
||||
|
||||
m_superMenu->addSeparator();
|
||||
m_superMenu->addAction(new ActionCopy(m_menuEdit->actions().at(7), this));
|
||||
m_superMenu->addAction(new ActionCopy(m_menuEdit->actions().at(8), this));
|
||||
|
||||
m_superMenu->addSeparator();
|
||||
m_superMenu->addAction(new ActionCopy(m_actionPreferences, this));
|
||||
|
||||
m_superMenu->addSeparator();
|
||||
m_superMenu->addMenu(m_menuView);
|
||||
m_superMenu->addMenu(m_menuHistory);
|
||||
m_superMenu->addMenu(m_menuBookmarks);
|
||||
m_superMenu->addMenu(m_menuTools);
|
||||
m_superMenu->addMenu(m_menuHelp);
|
||||
|
||||
m_superMenu->addSeparator();
|
||||
m_superMenu->addAction(new ActionCopy(m_actionAbout, this));
|
||||
m_superMenu->addAction(new ActionCopy(m_menuHelp->actions().at(3), this));
|
||||
m_superMenu->addAction(new ActionCopy(m_menuHelp->actions().at(4), this));
|
||||
m_superMenu->addAction(new ActionCopy(m_menuHelp->actions().at(5), this));
|
||||
|
||||
m_superMenu->addSeparator();
|
||||
m_superMenu->addAction(new ActionCopy(m_actionQuit, this));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -726,7 +749,7 @@ void QupZilla::loadSettings()
|
||||
menuBar()->setVisible(showMenuBar);
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
m_navigationBar->buttonSuperMenu()->setVisible(!showMenuBar);
|
||||
m_navigationBar->setSuperMenuVisible(!showMenuBar);
|
||||
#endif
|
||||
m_navigationBar->buttonReloadStop()->setVisible(showReloadButton);
|
||||
m_navigationBar->buttonHome()->setVisible(showHomeButton);
|
||||
@ -1535,7 +1558,7 @@ void QupZilla::showMenubar()
|
||||
}
|
||||
|
||||
menuBar()->setVisible(!menuBar()->isVisible());
|
||||
m_navigationBar->buttonSuperMenu()->setVisible(!menuBar()->isVisible());
|
||||
m_navigationBar->setSuperMenuVisible(!menuBar()->isVisible());
|
||||
|
||||
Settings settings;
|
||||
settings.setValue("Browser-View-Settings/showMenubar", menuBar()->isVisible());
|
||||
@ -1766,7 +1789,7 @@ bool QupZilla::event(QEvent* event)
|
||||
m_navigationContainer->hide();
|
||||
m_tabWidget->getTabBar()->hide();
|
||||
#ifndef Q_OS_MAC
|
||||
m_navigationBar->buttonSuperMenu()->hide();
|
||||
m_navigationBar->setSuperMenuVisible(false);
|
||||
#endif
|
||||
m_hideNavigationTimer->stop();
|
||||
m_actionShowFullScreen->setChecked(true);
|
||||
@ -1789,7 +1812,7 @@ bool QupZilla::event(QEvent* event)
|
||||
m_tabWidget->showTabBar();
|
||||
m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(true);
|
||||
#ifndef Q_OS_MAC
|
||||
m_navigationBar->buttonSuperMenu()->setVisible(!m_menuBarVisible);
|
||||
m_navigationBar->setSuperMenuVisible(!m_menuBarVisible);
|
||||
#endif
|
||||
m_hideNavigationTimer->stop();
|
||||
m_actionShowFullScreen->setChecked(false);
|
||||
|
@ -212,6 +212,7 @@ SOURCES += \
|
||||
navigation/navigationcontainer.cpp \
|
||||
tools/horizontallistwidget.cpp \
|
||||
tools/mactoolbutton.cpp \
|
||||
tools/actioncopy.cpp
|
||||
|
||||
HEADERS += \
|
||||
webview/tabpreview.h \
|
||||
@ -382,7 +383,8 @@ HEADERS += \
|
||||
navigation/navigationcontainer.h \
|
||||
tools/horizontallistwidget.h \
|
||||
tools/mactoolbutton.h \
|
||||
tools/qzregexp.h
|
||||
tools/qzregexp.h \
|
||||
tools/actioncopy.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
|
@ -120,6 +120,7 @@ NavigationBar::NavigationBar(QupZilla* mainClass)
|
||||
m_supMenu->setAutoRaise(true);
|
||||
m_supMenu->setFocusPolicy(Qt::NoFocus);
|
||||
m_supMenu->setMenu(p_QupZilla->superMenu());
|
||||
m_supMenu->setShowMenuInside(true);
|
||||
#endif
|
||||
|
||||
m_searchLine = new WebSearchBar(p_QupZilla);
|
||||
@ -193,6 +194,11 @@ void NavigationBar::showStopButton()
|
||||
m_reloadStop->showStopButton();
|
||||
}
|
||||
|
||||
void NavigationBar::setSuperMenuVisible(bool visible)
|
||||
{
|
||||
m_supMenu->setVisible(visible);
|
||||
}
|
||||
|
||||
void NavigationBar::aboutToShowHistoryBackMenu()
|
||||
{
|
||||
if (!m_menuBack || !p_QupZilla->weView()) {
|
||||
|
@ -47,12 +47,13 @@ public:
|
||||
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; }
|
||||
|
||||
void setSuperMenuVisible(bool visible);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
49
src/lib/tools/actioncopy.cpp
Normal file
49
src/lib/tools/actioncopy.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
/* ============================================================
|
||||
* 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 "actioncopy.h"
|
||||
|
||||
ActionCopy::ActionCopy(QAction* original, QObject* parent)
|
||||
: QAction(parent)
|
||||
, m_action(original)
|
||||
{
|
||||
updateAction();
|
||||
|
||||
connect(m_action, SIGNAL(changed()), this, SLOT(updateAction()));
|
||||
connect(this, SIGNAL(toggled(bool)), this, SLOT(actionToggled()));
|
||||
connect(this, SIGNAL(triggered()), this, SLOT(actionTriggered()));
|
||||
}
|
||||
|
||||
void ActionCopy::updateAction()
|
||||
{
|
||||
const QString &shortcutString = m_action->shortcut().toString(QKeySequence::NativeText);
|
||||
const QString &actionText = QString("%1\t%2").arg(m_action->text(), shortcutString);
|
||||
|
||||
setText(actionText);
|
||||
setIcon(m_action->icon());
|
||||
|
||||
}
|
||||
|
||||
void ActionCopy::actionToggled()
|
||||
{
|
||||
m_action->toggle();
|
||||
}
|
||||
|
||||
void ActionCopy::actionTriggered()
|
||||
{
|
||||
m_action->trigger();
|
||||
}
|
42
src/lib/tools/actioncopy.h
Normal file
42
src/lib/tools/actioncopy.h
Normal file
@ -0,0 +1,42 @@
|
||||
/* ============================================================
|
||||
* 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 ACTIONCOPY_H
|
||||
#define ACTIONCOPY_H
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QT_QUPZILLA_EXPORT ActionCopy : public QAction
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActionCopy(QAction* original, QObject* parent = 0);
|
||||
|
||||
private slots:
|
||||
void updateAction();
|
||||
|
||||
void actionToggled();
|
||||
void actionTriggered();
|
||||
|
||||
private:
|
||||
QAction* m_action;
|
||||
|
||||
};
|
||||
|
||||
#endif // ACTIONCOPY_H
|
@ -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
|
||||
@ -18,12 +18,14 @@
|
||||
#include "toolbutton.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionToolButton>
|
||||
|
||||
ToolButton::ToolButton(QWidget* parent)
|
||||
: QToolButton(parent)
|
||||
, m_usingMultiIcon(false)
|
||||
, m_showMenuInside(false)
|
||||
{
|
||||
setMinimumWidth(16);
|
||||
}
|
||||
@ -53,6 +55,16 @@ void ToolButton::setIcon(const QIcon &image)
|
||||
QToolButton::setIcon(image);
|
||||
}
|
||||
|
||||
void ToolButton::setShowMenuInside(bool inside)
|
||||
{
|
||||
m_showMenuInside = inside;
|
||||
}
|
||||
|
||||
bool ToolButton::showMenuInside() const
|
||||
{
|
||||
return m_showMenuInside;
|
||||
}
|
||||
|
||||
void ToolButton::setData(const QVariant &data)
|
||||
{
|
||||
m_data = data;
|
||||
@ -80,7 +92,7 @@ void ToolButton::setMultiIcon(const QPixmap &image)
|
||||
|
||||
void ToolButton::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() == Qt::RightButton && menu()) {
|
||||
if (e->button() != Qt::MiddleButton && menu()) {
|
||||
setDown(true);
|
||||
showMenu();
|
||||
return;
|
||||
@ -111,6 +123,27 @@ void ToolButton::mouseReleaseEvent(QMouseEvent* e)
|
||||
setDown(false);
|
||||
}
|
||||
|
||||
void ToolButton::showMenu()
|
||||
{
|
||||
if (!m_showMenuInside) {
|
||||
QToolButton::showMenu();
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu* m = menu();
|
||||
|
||||
if (!m) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPoint pos = mapToGlobal(rect().bottomRight());
|
||||
pos.setX(pos.x() - m->sizeHint().width());
|
||||
|
||||
setDown(true);
|
||||
m->exec(pos);
|
||||
setDown(false);
|
||||
}
|
||||
|
||||
void ToolButton::paintEvent(QPaintEvent* e)
|
||||
{
|
||||
if (!m_usingMultiIcon) {
|
||||
|
@ -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
|
||||
@ -50,11 +50,16 @@ public:
|
||||
void setFallbackIcon(const QIcon &image);
|
||||
void setIcon(const QIcon &image);
|
||||
|
||||
void setShowMenuInside(bool inside);
|
||||
bool showMenuInside() const;
|
||||
|
||||
|
||||
signals:
|
||||
void middleMouseClicked();
|
||||
void controlClicked();
|
||||
|
||||
public slots:
|
||||
void showMenu();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* e);
|
||||
@ -64,6 +69,7 @@ private:
|
||||
void paintEvent(QPaintEvent* e);
|
||||
|
||||
bool m_usingMultiIcon;
|
||||
bool m_showMenuInside;
|
||||
|
||||
QPixmap m_normalIcon;
|
||||
QPixmap m_hoverIcon;
|
||||
|
@ -331,7 +331,7 @@ void TreeWidget::filterString(const QString &string)
|
||||
QList<QTreeWidgetItem*> _allItems = allItems();
|
||||
QList<QTreeWidgetItem*> parents;
|
||||
bool stringIsEmpty = string.isEmpty();
|
||||
foreach(QTreeWidgetItem * item, _allItems) {
|
||||
foreach (QTreeWidgetItem* item, _allItems) {
|
||||
bool containsString = stringIsEmpty || item->text(0).contains(string, Qt::CaseInsensitive);
|
||||
if (containsString) {
|
||||
item->setHidden(false);
|
||||
@ -349,7 +349,7 @@ void TreeWidget::filterString(const QString &string)
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < parents.size(); ++i) {
|
||||
for (int i = 0; i < parents.size(); ++i) {
|
||||
QTreeWidgetItem* parentItem = parents.at(i);
|
||||
parentItem->setHidden(false);
|
||||
if (stringIsEmpty) {
|
||||
|
Loading…
Reference in New Issue
Block a user