mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
ToolButton: Disable showing button menu on right click by default
This commit is contained in:
parent
23279f6e10
commit
c5b59d1011
@ -74,6 +74,7 @@ NavigationBar::NavigationBar(BrowserWindow* window)
|
||||
m_buttonBack->setToolTip(tr("Back"));
|
||||
m_buttonBack->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
m_buttonBack->setToolbarButtonLook(true);
|
||||
m_buttonBack->setShowMenuOnRightClick(true);
|
||||
m_buttonBack->setAutoRaise(true);
|
||||
m_buttonBack->setEnabled(false);
|
||||
m_buttonBack->setFocusPolicy(Qt::NoFocus);
|
||||
@ -83,6 +84,7 @@ NavigationBar::NavigationBar(BrowserWindow* window)
|
||||
m_buttonForward->setToolTip(tr("Forward"));
|
||||
m_buttonForward->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
m_buttonForward->setToolbarButtonLook(true);
|
||||
m_buttonForward->setShowMenuOnRightClick(true);
|
||||
m_buttonForward->setAutoRaise(true);
|
||||
m_buttonForward->setEnabled(false);
|
||||
m_buttonForward->setFocusPolicy(Qt::NoFocus);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2018 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
|
||||
@ -117,6 +117,16 @@ void ToolButton::setShowMenuInside(bool enable)
|
||||
m_options &= ~ShowMenuInsideOption;
|
||||
}
|
||||
|
||||
bool ToolButton::showMenuOnRightClick() const
|
||||
{
|
||||
return m_options & ShowMenuOnRightClick;
|
||||
}
|
||||
|
||||
void ToolButton::setShowMenuOnRightClick(bool enable)
|
||||
{
|
||||
m_options.setFlag(ShowMenuOnRightClick, enable);
|
||||
}
|
||||
|
||||
bool ToolButton::toolbarButtonLook() const
|
||||
{
|
||||
return m_options & ToolBarLookOption;
|
||||
@ -172,14 +182,14 @@ void ToolButton::showMenu()
|
||||
|
||||
void ToolButton::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (popupMode() == QToolButton::DelayedPopup)
|
||||
if (e->buttons() == Qt::LeftButton && popupMode() == QToolButton::DelayedPopup)
|
||||
m_pressTimer.start();
|
||||
|
||||
if (e->buttons() == Qt::LeftButton && menu() && popupMode() == QToolButton::InstantPopup) {
|
||||
setDown(true);
|
||||
showMenu();
|
||||
}
|
||||
else if (e->buttons() == Qt::RightButton && menu()) {
|
||||
else if (e->buttons() == Qt::RightButton && menu() && m_options & ShowMenuOnRightClick) {
|
||||
setDown(true);
|
||||
showMenu();
|
||||
} else {
|
||||
@ -217,7 +227,7 @@ void ToolButton::mouseDoubleClickEvent(QMouseEvent* e)
|
||||
void ToolButton::contextMenuEvent(QContextMenuEvent *e)
|
||||
{
|
||||
// Block to prevent showing both context menu and button menu
|
||||
if (menu())
|
||||
if (menu() && m_options & ShowMenuOnRightClick)
|
||||
return;
|
||||
|
||||
QToolButton::contextMenuEvent(e);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2018 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
|
||||
@ -64,6 +64,10 @@ public:
|
||||
bool showMenuInside() const;
|
||||
void setShowMenuInside(bool enable);
|
||||
|
||||
// Show button menu on right click
|
||||
bool showMenuOnRightClick() const;
|
||||
void setShowMenuOnRightClick(bool enable);
|
||||
|
||||
// Set the button to look as it was in toolbar
|
||||
// (it now only sets the correct icon size)
|
||||
bool toolbarButtonLook() const;
|
||||
@ -98,7 +102,8 @@ private:
|
||||
enum Options {
|
||||
MultiIconOption = 1,
|
||||
ShowMenuInsideOption = 2,
|
||||
ToolBarLookOption = 4
|
||||
ToolBarLookOption = 4,
|
||||
ShowMenuOnRightClick = 8
|
||||
};
|
||||
Q_DECLARE_FLAGS(OptionsFlags, Options)
|
||||
OptionsFlags m_options;
|
||||
|
Loading…
Reference in New Issue
Block a user