diff --git a/src/lib/tools/toolbutton.cpp b/src/lib/tools/toolbutton.cpp index 074f64eca..63b69ea30 100644 --- a/src/lib/tools/toolbutton.cpp +++ b/src/lib/tools/toolbutton.cpp @@ -58,6 +58,18 @@ void ToolButton::setIcon(const QIcon &image) QToolButton::setIcon(image); } +void ToolButton::setMenu(QMenu* m) +{ + if (m) { + connect(m, SIGNAL(aboutToHide()), this, SLOT(menuAboutToHide())); + } + else if (menu()) { + disconnect(menu(), SIGNAL(aboutToHide()), this, SLOT(menuAboutToHide())); + } + + QToolButton::setMenu(m); +} + void ToolButton::setShowMenuInside(bool inside) { m_showMenuInside = inside; @@ -173,6 +185,8 @@ void ToolButton::showMenu() return; } + m->popup(QPoint(0, 0)); + QPoint pos = mapToGlobal(rect().bottomRight()); if (QApplication::layoutDirection() == Qt::RightToLeft) { pos.setX(pos.x() - rect().width()); @@ -181,8 +195,11 @@ void ToolButton::showMenu() pos.setX(pos.x() - m->sizeHint().width()); } - setDown(true); - m->exec(pos); + m->move(pos); +} + +void ToolButton::menuAboutToHide() +{ setDown(false); } diff --git a/src/lib/tools/toolbutton.h b/src/lib/tools/toolbutton.h index c53b181f0..984c0d49d 100644 --- a/src/lib/tools/toolbutton.h +++ b/src/lib/tools/toolbutton.h @@ -50,6 +50,8 @@ public: void setFallbackIcon(const QIcon &image); void setIcon(const QIcon &image); + void setMenu(QMenu* m); + void setShowMenuInside(bool inside); bool showMenuInside() const; @@ -65,6 +67,9 @@ signals: public slots: void showMenu(); +private slots: + void menuAboutToHide(); + protected: void mousePressEvent(QMouseEvent* e); void mouseReleaseEvent(QMouseEvent* e); diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index 98dff72ae..b692a6291 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -149,6 +149,7 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) m_buttonListTabs->setToolTip(tr("List of tabs")); m_buttonListTabs->setAutoRaise(true); m_buttonListTabs->setFocusPolicy(Qt::NoFocus); + m_buttonListTabs->setShowMenuInside(true); m_buttonAddTab = new AddTabButton(this, m_tabBar); @@ -164,6 +165,7 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) m_buttonListTabs2->setToolTip(tr("List of tabs")); m_buttonListTabs2->setAutoRaise(true); m_buttonListTabs2->setFocusPolicy(Qt::NoFocus); + m_buttonListTabs2->setShowMenuInside(true); m_buttonAddTab2 = new AddTabButton(this, m_tabBar); m_buttonAddTab2->setProperty("outside-tabbar", true);