mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
TabContextMenu: Require only WebTab in constructor
This commit is contained in:
parent
29735b24c8
commit
0c7245fa9f
|
@ -346,14 +346,14 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = tabAt(event->pos());
|
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(tabAt(event->pos())));
|
||||||
|
if (webTab) {
|
||||||
TabContextMenu menu(index, Qt::Horizontal, m_window, m_tabWidget);
|
TabContextMenu menu(webTab, Qt::Horizontal);
|
||||||
|
|
||||||
// Prevent choosing first option with double rightclick
|
// Prevent choosing first option with double rightclick
|
||||||
const QPoint pos = event->globalPos();
|
const QPoint pos = event->globalPos();
|
||||||
QPoint p(pos.x(), pos.y() + 1);
|
QPoint p(pos.x(), pos.y() + 1);
|
||||||
menu.exec(p);
|
menu.exec(p);
|
||||||
|
}
|
||||||
|
|
||||||
m_window->action(QSL("Other/RestoreClosedTab"))->setEnabled(true);
|
m_window->action(QSL("Other/RestoreClosedTab"))->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,12 @@
|
||||||
#include "checkboxdialog.h"
|
#include "checkboxdialog.h"
|
||||||
|
|
||||||
|
|
||||||
TabContextMenu::TabContextMenu(int index, Qt::Orientation orientation, BrowserWindow* window, TabWidget* tabWidget, bool showCloseOtherTabs)
|
TabContextMenu::TabContextMenu(WebTab *tab, Qt::Orientation orientation, bool showCloseOtherTabs)
|
||||||
: QMenu()
|
: QMenu()
|
||||||
, m_clickedTab(index)
|
, m_clickedTab(tab->tabIndex())
|
||||||
, m_tabsOrientation(orientation)
|
, m_tabsOrientation(orientation)
|
||||||
, m_window(window)
|
, m_window(tab->webView()->browserWindow())
|
||||||
, m_tabWidget(tabWidget)
|
, m_tabWidget(m_window->tabWidget())
|
||||||
, m_showCloseOtherTabs(showCloseOtherTabs)
|
, m_showCloseOtherTabs(showCloseOtherTabs)
|
||||||
{
|
{
|
||||||
setObjectName("tabcontextmenu");
|
setObjectName("tabcontextmenu");
|
||||||
|
|
|
@ -22,14 +22,15 @@
|
||||||
|
|
||||||
#include "qzcommon.h"
|
#include "qzcommon.h"
|
||||||
|
|
||||||
class BrowserWindow;
|
class WebTab;
|
||||||
class TabWidget;
|
class TabWidget;
|
||||||
|
class BrowserWindow;
|
||||||
|
|
||||||
class FALKON_EXPORT TabContextMenu : public QMenu
|
class FALKON_EXPORT TabContextMenu : public QMenu
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit TabContextMenu(int index, Qt::Orientation orientation, BrowserWindow* window, TabWidget* tabWidget, bool showCloseOtherTabs = true);
|
explicit TabContextMenu(WebTab *tab, Qt::Orientation orientation, bool showCloseOtherTabs = true);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void reloadTab(int index);
|
void reloadTab(int index);
|
||||||
|
|
|
@ -279,16 +279,12 @@ void TabManagerWidget::customContextMenuRequested(const QPoint &pos)
|
||||||
TabItem* item = static_cast<TabItem*>(ui->treeWidget->itemAt(pos));
|
TabItem* item = static_cast<TabItem*>(ui->treeWidget->itemAt(pos));
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
BrowserWindow* mainWindow = item->window();
|
WebTab *tab = item->webTab();
|
||||||
QWidget* tabWidget = item->webTab();
|
if (tab) {
|
||||||
|
|
||||||
if (mainWindow && tabWidget) {
|
|
||||||
int index = mainWindow->tabWidget()->indexOf(tabWidget);
|
|
||||||
|
|
||||||
// if items are not grouped by Window then actions "Close Other Tabs",
|
// if items are not grouped by Window then actions "Close Other Tabs",
|
||||||
// "Close Tabs To The Bottom" and "Close Tabs To The Top"
|
// "Close Tabs To The Bottom" and "Close Tabs To The Top"
|
||||||
// are ambiguous and should be hidden.
|
// are ambiguous and should be hidden.
|
||||||
menu = new TabContextMenu(index, Qt::Vertical, mainWindow, mainWindow->tabWidget(), m_groupType == GroupByWindow);
|
menu = new TabContextMenu(tab, Qt::Vertical, m_groupType == GroupByWindow);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user