1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Issue #2049 close tabs to right & close tabs to left (#2062)

* add close to right menu 
Closes #2049
This commit is contained in:
std46 2016-08-28 09:24:09 -05:00 committed by David Rosca
parent 3da4150fcb
commit e906f6ae20
4 changed files with 62 additions and 0 deletions

View File

@ -127,6 +127,7 @@ void TabBar::overflowChanged(bool overflowed)
}
}
//TODO: replace these 3 w/ preferencable mbox
void TabBar::closeAllButCurrent()
{
QMessageBox::StandardButton button = QMessageBox::question(this, tr("Close Tabs"), tr("Do you really want to close other tabs?"),
@ -137,6 +138,26 @@ void TabBar::closeAllButCurrent()
}
}
void TabBar::closeToRight()
{
QMessageBox::StandardButton button = QMessageBox::question(this, tr("Close Tabs"), tr("Do you really want to close all tabs to the right?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (button == QMessageBox::Yes) {
emit closeToRight(m_clickedTab);
}
}
void TabBar::closeToLeft()
{
QMessageBox::StandardButton button = QMessageBox::question(this, tr("Close Tabs"), tr("Do you really want to close all tabs to the left?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (button == QMessageBox::Yes) {
emit closeToLeft(m_clickedTab);
}
}
QSize TabBar::tabSizeHint(int index, bool fast) const
{
if (!m_window->isVisible()) {
@ -341,6 +362,8 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
menu.addAction(m_window->action(QSL("Other/RestoreClosedTab")));
menu.addSeparator();
menu.addAction(tr("Close Ot&her Tabs"), this, SLOT(closeAllButCurrent()));
menu.addAction(tr("Close Tabs To The Right"), this, SLOT(closeToRight()));
menu.addAction(tr("Close Tabs To The Left"), this, SLOT(closeToLeft()));
menu.addAction(QIcon::fromTheme("window-close"), tr("Cl&ose"), this, SLOT(closeTab()));
menu.addSeparator();
}

View File

@ -52,6 +52,8 @@ signals:
void reloadTab(int index);
void stopTab(int index);
void closeAllButCurrent(int index);
void closeToRight(int index);
void closeToLeft(int index);
void duplicateTab(int index);
void detachTab(int index);
@ -73,6 +75,8 @@ private slots:
void closeCurrentTab();
void closeAllButCurrent();
void closeToRight();
void closeToLeft();
void closeTabFromButton();
private:

View File

@ -128,6 +128,8 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int)));
connect(m_tabBar, SIGNAL(stopTab(int)), this, SLOT(stopTab(int)));
connect(m_tabBar, SIGNAL(closeAllButCurrent(int)), this, SLOT(closeAllButCurrent(int)));
connect(m_tabBar, SIGNAL(closeToRight(int)), this, SLOT(closeToRight(int)));
connect(m_tabBar, SIGNAL(closeToLeft(int)), this, SLOT(closeToLeft(int)));
connect(m_tabBar, SIGNAL(duplicateTab(int)), this, SLOT(duplicateTab(int)));
connect(m_tabBar, SIGNAL(detachTab(int)), this, SLOT(detachTab(int)));
connect(m_tabBar, SIGNAL(tabMoved(int,int)), this, SLOT(tabMoved(int,int)));
@ -618,6 +620,37 @@ void TabWidget::closeAllButCurrent(int index)
}
}
void TabWidget::closeToRight(int index)
{
if (!validIndex(index)) {
return;
}
foreach (WebTab* tab, allTabs(false)) {
int tabIndex = tab->tabIndex();
if (index >= tabIndex) {
continue;
}
requestCloseTab(tabIndex);
}
}
void TabWidget::closeToLeft(int index)
{
if (!validIndex(index)) {
return;
}
foreach (WebTab* tab, allTabs(false)) {
int tabIndex = tab->tabIndex();
if (index <= tabIndex) {
continue;
}
requestCloseTab(tabIndex);
}
}
void TabWidget::detachTab(int index)
{
WebTab* tab = weTab(index);

View File

@ -117,6 +117,8 @@ public slots:
void reloadAllTabs();
void stopTab(int index);
void closeAllButCurrent(int index);
void closeToRight(int index);
void closeToLeft(int index);
void detachTab(int index);
void restoreClosedTab(QObject* obj = 0);
void restoreAllClosedTabs();