1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

WebSearchBar: Show the search engine menu relative to lineedit

This commit is contained in:
David Rosca 2016-01-25 14:42:57 +01:00
parent 2c04ebba63
commit 0b0041af41
2 changed files with 14 additions and 3 deletions

View File

@ -24,10 +24,8 @@ ButtonWithMenu::ButtonWithMenu(QWidget* parent)
: ToolButton(parent)
, m_menu(new QMenu(this))
{
setPopupMode(QToolButton::InstantPopup);
setCursor(Qt::ArrowCursor);
setFocusPolicy(Qt::ClickFocus);
setMenu(m_menu);
connect(this, SIGNAL(aboutToShowMenu()), this, SLOT(generateMenu()));
}
@ -155,6 +153,17 @@ void ButtonWithMenu::generateMenu()
}
}
void ButtonWithMenu::mousePressEvent(QMouseEvent *event)
{
if (parentWidget() && parentWidget()->parentWidget()) {
emit aboutToShowMenu();
QWidget *w = parentWidget()->parentWidget();
m_menu->popup(w->mapToGlobal(w->rect().bottomLeft()));
}
ToolButton::mousePressEvent(event);
}
ButtonWithMenu::~ButtonWithMenu()
{
}

View File

@ -23,7 +23,8 @@
#include "toolbutton.h"
#include "qzcommon.h"
class QUPZILLA_EXPORT ButtonWithMenu : public ToolButton
// Only to be used in WebSearchBar
class ButtonWithMenu : public ToolButton
{
Q_OBJECT
public:
@ -81,6 +82,7 @@ private slots:
void generateMenu();
private:
void mousePressEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent* event);
QMenu* m_menu;