36 setObjectName(QStringLiteral(
"tabcontextmenu"));
41 connect(
this, SIGNAL(
stopTab(
int)), tabWidget, SLOT(
stopTab(
int)));
47 connect(
this, SIGNAL(
loadTab(
int)), tabWidget, SLOT(
loadTab(
int)));
53static bool canCloseTabs(
const QString &settingsKey,
const QString &title,
const QString &description)
56 bool ask = settings.
value(
QSL(
"Browser-Tabs-Settings/") + settingsKey,
true).toBool();
60 dialog.setDefaultButton(QMessageBox::No);
61 dialog.setWindowTitle(title);
62 dialog.setText(description);
63 dialog.setCheckBoxText(TabBar::tr(
"Don't ask again"));
64 dialog.setIcon(QMessageBox::Question);
66 if (dialog.exec() != QMessageBox::Yes) {
70 if (dialog.isChecked()) {
71 settings.
setValue(
QSL(
"Browser-Tabs-Settings/") + settingsKey,
false);
80 if (canCloseTabs(QLatin1String(
"AskOnClosingAllButCurrent"), tr(
"Close Tabs"), tr(
"Do you really want to close other tabs?"))) {
88 ? tr(
"Do you really want to close all tabs to the right?")
89 : tr(
"Do you really want to close all tabs to the bottom?");
91 if (canCloseTabs(QLatin1String(
"AskOnClosingToRight"), tr(
"Close Tabs"), label)) {
99 ? tr(
"Do you really want to close all tabs to the left?")
100 : tr(
"Do you really want to close all tabs to the top?");
102 if (canCloseTabs(QLatin1String(
"AskOnClosingToLeft"), tr(
"Close Tabs"), label)) {
107void TabContextMenu::init()
110 if (m_clickedTab != -1) {
117 addAction(QIcon::fromTheme(
QSL(
"process-stop")), tr(
"&Stop Tab"),
this, SLOT(
stopTab()));
120 addAction(QIcon::fromTheme(
QSL(
"view-refresh")), tr(
"&Reload Tab"),
this, SLOT(
reloadTab()));
123 addAction(QIcon::fromTheme(
QSL(
"tab-duplicate")), tr(
"&Duplicate Tab"),
this, SLOT(
duplicateTab()));
126 addAction(QIcon::fromTheme(
QSL(
"tab-detach")), tr(
"D&etach Tab"),
this, SLOT(
detachTab()));
129 addAction(webTab->
isPinned() ? tr(
"Un&pin Tab") : tr(
"&Pin Tab"),
this, &TabContextMenu::pinTab);
130 addAction(webTab->
isMuted() ? tr(
"Un&mute Tab") : tr(
"&Mute Tab"),
this, &TabContextMenu::muteTab);
133 addAction(tr(
"Load Tab"),
this, SLOT(
loadTab()));
135 addAction(tr(
"Unload Tab"),
this, SLOT(
unloadTab()));
145 addAction(m_options &
HorizontalTabs ? tr(
"Close Tabs To The Right") : tr(
"Close Tabs To The Bottom"),
this, SLOT(
closeToRight()));
146 addAction(m_options &
HorizontalTabs ? tr(
"Close Tabs To The Left") : tr(
"Close Tabs To The Top"),
this, SLOT(
closeToLeft()));
150 addAction(m_window->
action(
QSL(
"Other/RestoreClosedTab")));
151 addAction(QIcon::fromTheme(
QSL(
"window-close")), tr(
"Cl&ose Tab"),
this, &TabContextMenu::closeTab);
158 addAction(m_window->
action(
QSL(
"Other/RestoreClosedTab")));
162 connect(
this, &QMenu::aboutToHide,
this, [
this]() {
163 m_window->
action(
QSL(
"Other/RestoreClosedTab"))->setEnabled(
true);
167void TabContextMenu::pinTab()
175void TabContextMenu::muteTab()
QAction * action(const QString &name) const
TabWidget * tabWidget() const
TabbedWebView * weView() const
void tabCloseRequested(int index)
static QIcon newTabIcon()
QVariant value(const QString &key, const QVariant &defaultValue=QVariant())
void setValue(const QString &key, const QVariant &defaultValue=QVariant())