mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[TabListButton] Show popup menu inside window for tab-list button in tabbar
This commit is contained in:
parent
851e19ce01
commit
3ec9e0b893
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user