QupZilla / qupzilla

Cross-platform Qt web browser
http://www.qupzilla.com
GNU General Public License v3.0
1.12k stars 347 forks source link

Tabs drag/drop into the same window #2602

Closed tarptaeya closed 6 years ago

tarptaeya commented 6 years ago

Currently drag/drop in current window just returns, instead It can function like what is done in firefox or chrome that tabs scroll (or placed) within the same window at a new index.

nowrep commented 6 years ago

This will detach -> attach the tab instead of just moving it inside the tabbar which will result in changing of current tab and will eg. load unloaded tab. It should use the same logic as TabModel.

tarptaeya commented 6 years ago

hmm., I will improve this

tarptaeya commented 6 years ago

What about this ... ?

nowrep commented 6 years ago

Still wrong:

If you really want to implement it, it should use the same logic as moving tabs in TabModel (see TabModel::dropMimeData). Although, that being said, moving pinned tabs requires special handling, so in order to not duplicate code, maybe TabWidget::moveTab should handle the pinned tab case instead of manually doing it in both TabModel and TabBar.

Pinned tab case: In order to move pinned tab to normal tabs / move normal tab to pinned tabs you first need to pin/unpin them and only after this move them to target index.

tarptaeya commented 6 years ago

I think this will work now.

nowrep commented 6 years ago

Have you seen the logic in TabModel?

        if (tab->isPinned()) {
            if (row > m_window->tabWidget()->pinnedTabsCount()) {
                tab->togglePinned();
            }
        } else {
            if (row < m_window->tabWidget()->pinnedTabsCount()) {
                tab->togglePinned();
                row++;
            }
        }
        tab->moveTab(row > mimeData->tab()->tabIndex() ? row - 1 : row);

It's this simple and easy to understand, you don't need anything more complex.

Also this code is in wrong place and thus duplicating a lot of code that is done down in the function. Case of moving tab should be handled in:

} else if (mime->hasFormat(MIMETYPE) && sourceTabBar) {
    // here
    WebTab *tab = sourceTabBar->webTab();
    if (tab) {
        sourceTabBar->m_tabWidget->detachTab(tab);
nowrep commented 6 years ago

See e0cbec5a5f6eb5de8edde631528dcc3848048622