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:
parent
2c04ebba63
commit
0b0041af41
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user