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

TabWidget: Add insertView method for WebTab

This commit is contained in:
David Rosca 2018-01-01 11:57:31 +01:00
parent 0e25eb2e92
commit f5ad4424aa
4 changed files with 28 additions and 9 deletions

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* Falkon - Qt web browser * Falkon - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -205,7 +205,7 @@ void BrowserWindow::postLaunch()
if (m_startTab) { if (m_startTab) {
addTab = false; addTab = false;
m_tabWidget->addView(m_startTab); m_tabWidget->addView(m_startTab, Qz::NT_SelectedTab);
} }
if (m_startPage) { if (m_startPage) {

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* Falkon - Qt web browser * Falkon - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -378,17 +378,34 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N
return index; return index;
} }
int TabWidget::addView(WebTab* tab) int TabWidget::addView(WebTab *tab, const Qz::NewTabPositionFlags &openFlags)
{
return insertView(count() + 1, tab, openFlags);
}
int TabWidget::insertView(int index, WebTab *tab, const Qz::NewTabPositionFlags &openFlags)
{ {
m_locationBars->addWidget(tab->locationBar()); m_locationBars->addWidget(tab->locationBar());
int index = addTab(tab, QString()); int newIndex = insertTab(index, tab, QString());
tab->attach(m_window); tab->attach(m_window);
if (openFlags.testFlag(Qz::NT_SelectedTab)) {
setCurrentIndex(newIndex);
} else {
m_lastBackgroundTabIndex = index;
}
connect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); connect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int)));
connect(tab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); connect(tab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed()));
connect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString))); connect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString)));
return index; // Make sure user notice opening new background tabs
if (!(openFlags & Qz::NT_SelectedTab)) {
m_tabBar->ensureVisible(index);
}
emit changed();
return newIndex;
} }
void TabWidget::addTabFromClipboard() void TabWidget::addTabFromClipboard()

View File

@ -1,6 +1,6 @@
/* ============================================================ /* ============================================================
* Falkon - Qt web browser * Falkon - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com> * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -100,7 +100,8 @@ public:
public slots: public slots:
int addView(const LoadRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false, bool pinned = false); int addView(const LoadRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false, bool pinned = false);
int addView(const LoadRequest &req, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1, bool pinned = false); int addView(const LoadRequest &req, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1, bool pinned = false);
int addView(WebTab* tab); int addView(WebTab *tab, const Qz::NewTabPositionFlags &openFlags);
int insertView(int index, WebTab *tab, const Qz::NewTabPositionFlags &openFlags);
void addTabFromClipboard(); void addTabFromClipboard();
int duplicateTab(int index); int duplicateTab(int index);

View File

@ -1,6 +1,7 @@
/* ============================================================ /* ============================================================
* TabManager plugin for Falkon * TabManager plugin for Falkon
* Copyright (C) 2013-2017 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com> * Copyright (C) 2013-2017 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
* Copyright (C) 2018 David Rosca <nowrep@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -546,7 +547,7 @@ static void detachTabsTo(BrowserWindow* targetWindow, const QHash<BrowserWindow*
mainWindow = 0; mainWindow = 0;
} }
targetWindow->tabWidget()->addView(webTab); targetWindow->tabWidget()->addView(webTab, Qz::NT_NotSelectedTab);
} }
} }
} }