mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
TabWidget: Add moveTab() method that supports moving tabs between both tabbars
This commit is contained in:
parent
802e447c0c
commit
eb90925a32
@ -186,21 +186,8 @@ bool TabModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
||||
WebTab *tab = mimeData->tab();
|
||||
|
||||
if (tab->browserWindow() == m_window) {
|
||||
if (tab->isPinned()) {
|
||||
if (row < 0) {
|
||||
row = m_window->tabWidget()->pinnedTabsCount();
|
||||
}
|
||||
if (row > m_window->tabWidget()->pinnedTabsCount()) {
|
||||
tab->togglePinned();
|
||||
}
|
||||
} else {
|
||||
if (row < 0) {
|
||||
row = m_window->tabWidget()->count();
|
||||
}
|
||||
if (row < m_window->tabWidget()->pinnedTabsCount()) {
|
||||
tab->togglePinned();
|
||||
row++;
|
||||
}
|
||||
if (row < 0) {
|
||||
row = tab->isPinned() ? m_window->tabWidget()->pinnedTabsCount() : m_window->tabWidget()->count();
|
||||
}
|
||||
tab->moveTab(row > mimeData->tab()->tabIndex() ? row - 1 : row);
|
||||
} else {
|
||||
|
@ -649,6 +649,19 @@ void TabWidget::closeToLeft(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void TabWidget::moveTab(int from, int to)
|
||||
{
|
||||
WebTab *tab = webTab(from);
|
||||
if (!tab) {
|
||||
return;
|
||||
}
|
||||
// (Un)pin tab when needed
|
||||
if ((tab->isPinned() && to >= pinnedTabsCount()) || (!tab->isPinned() && to < pinnedTabsCount())) {
|
||||
tab->togglePinned();
|
||||
}
|
||||
TabStackedWidget::moveTab(tab->tabIndex(), to);
|
||||
}
|
||||
|
||||
int TabWidget::pinUnPinTab(int index, const QString &title)
|
||||
{
|
||||
const int newIndex = TabStackedWidget::pinUnPinTab(index, title);
|
||||
|
@ -96,6 +96,7 @@ public:
|
||||
ToolButton* buttonClosedTabs() const;
|
||||
AddTabButton* buttonAddTab() const;
|
||||
|
||||
void moveTab(int from, int to);
|
||||
int pinUnPinTab(int index, const QString &title = QString());
|
||||
|
||||
void detachTab(WebTab* tab);
|
||||
|
Loading…
Reference in New Issue
Block a user