2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
2011-03-03 18:29:20 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
2011-03-02 16:57:41 +01:00
|
|
|
#include "webtab.h"
|
2014-02-19 22:07:21 +01:00
|
|
|
#include "browserwindow.h"
|
2012-01-21 20:27:45 +01:00
|
|
|
#include "tabbedwebview.h"
|
2014-03-31 17:46:59 +02:00
|
|
|
#include "webinspector.h"
|
2011-07-11 20:30:49 +02:00
|
|
|
#include "webpage.h"
|
2011-03-25 19:16:21 +01:00
|
|
|
#include "tabbar.h"
|
2014-03-18 20:00:34 +01:00
|
|
|
#include "tabicon.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "tabwidget.h"
|
2011-07-11 20:30:49 +02:00
|
|
|
#include "locationbar.h"
|
2013-01-22 19:04:22 +01:00
|
|
|
#include "qztools.h"
|
2012-08-10 21:16:43 +02:00
|
|
|
#include "qzsettings.h"
|
2013-02-11 16:45:10 +01:00
|
|
|
#include "mainapplication.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
#include <QVBoxLayout>
|
2012-03-11 15:17:12 +01:00
|
|
|
#include <QWebHistory>
|
2012-04-08 21:45:40 +02:00
|
|
|
#include <QWebFrame>
|
2012-03-11 15:17:12 +01:00
|
|
|
#include <QLabel>
|
2013-02-11 09:51:22 +01:00
|
|
|
#include <QTimer>
|
2014-03-31 17:46:59 +02:00
|
|
|
#include <QSplitter>
|
2012-03-11 15:17:12 +01:00
|
|
|
|
2013-05-03 00:35:14 +02:00
|
|
|
static const int savedTabVersion = 1;
|
|
|
|
|
2012-03-11 15:17:12 +01:00
|
|
|
WebTab::SavedTab::SavedTab(WebTab* webTab)
|
|
|
|
{
|
2012-03-12 18:22:01 +01:00
|
|
|
title = webTab->title();
|
|
|
|
url = webTab->url();
|
|
|
|
icon = webTab->icon();
|
|
|
|
history = webTab->historyData();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
bool WebTab::SavedTab::isEmpty() const
|
|
|
|
{
|
|
|
|
return url.isEmpty();
|
|
|
|
}
|
|
|
|
|
2012-03-11 15:17:12 +01:00
|
|
|
void WebTab::SavedTab::clear()
|
|
|
|
{
|
|
|
|
title.clear();
|
|
|
|
url.clear();
|
|
|
|
icon = QIcon();
|
|
|
|
history.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
QDataStream &operator <<(QDataStream &stream, const WebTab::SavedTab &tab)
|
|
|
|
{
|
2013-05-03 00:35:14 +02:00
|
|
|
stream << savedTabVersion;
|
2012-03-11 15:17:12 +01:00
|
|
|
stream << tab.title;
|
|
|
|
stream << tab.url;
|
2013-05-03 00:35:14 +02:00
|
|
|
stream << tab.icon.pixmap(16);
|
2012-03-11 15:17:12 +01:00
|
|
|
stream << tab.history;
|
|
|
|
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDataStream &operator >>(QDataStream &stream, WebTab::SavedTab &tab)
|
|
|
|
{
|
2013-05-03 00:35:14 +02:00
|
|
|
int version;
|
|
|
|
stream >> version;
|
|
|
|
|
|
|
|
QPixmap pixmap;
|
2012-03-11 15:17:12 +01:00
|
|
|
stream >> tab.title;
|
|
|
|
stream >> tab.url;
|
2013-05-03 00:35:14 +02:00
|
|
|
stream >> pixmap;
|
2012-03-11 15:17:12 +01:00
|
|
|
stream >> tab.history;
|
|
|
|
|
2013-05-03 00:35:14 +02:00
|
|
|
tab.icon = QIcon(pixmap);
|
|
|
|
|
2012-03-11 15:17:12 +01:00
|
|
|
return stream;
|
|
|
|
}
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
WebTab::WebTab(BrowserWindow* window)
|
2011-10-14 20:14:57 +02:00
|
|
|
: QWidget()
|
2014-02-19 22:07:21 +01:00
|
|
|
, m_window(window)
|
2014-03-31 17:46:59 +02:00
|
|
|
, m_inspector(0)
|
2014-04-01 18:47:19 +02:00
|
|
|
, m_tabBar(0)
|
2014-03-18 20:00:34 +01:00
|
|
|
, m_isPinned(false)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2014-03-31 17:46:59 +02:00
|
|
|
setObjectName(QSL("webtab"));
|
2013-01-31 14:18:28 +01:00
|
|
|
|
|
|
|
// This fixes background of pages with dark themes
|
|
|
|
setStyleSheet("#webtab {background-color:white;}");
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
m_webView = new TabbedWebView(m_window, this);
|
|
|
|
m_webView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
2014-03-31 17:46:59 +02:00
|
|
|
m_webView->setWebPage(new WebPage(m_webView));
|
2014-03-18 20:00:34 +01:00
|
|
|
|
|
|
|
m_locationBar = new LocationBar(m_window);
|
|
|
|
m_locationBar->setWebView(m_webView);
|
|
|
|
|
|
|
|
m_tabIcon = new TabIcon(this);
|
|
|
|
m_tabIcon->setWebTab(this);
|
|
|
|
|
2014-03-31 17:46:59 +02:00
|
|
|
m_splitter = new QSplitter(Qt::Vertical, this);
|
|
|
|
m_splitter->setChildrenCollapsible(false);
|
|
|
|
m_splitter->addWidget(m_webView);
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
m_layout = new QVBoxLayout(this);
|
2011-11-06 17:01:23 +01:00
|
|
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
2011-03-02 16:57:41 +01:00
|
|
|
m_layout->setSpacing(0);
|
2014-03-31 17:46:59 +02:00
|
|
|
m_layout->addWidget(m_splitter);
|
2011-07-19 15:18:49 +02:00
|
|
|
setLayout(m_layout);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
connect(m_webView, SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*)));
|
2014-04-01 18:47:19 +02:00
|
|
|
connect(m_webView, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
|
|
|
|
connect(m_webView, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged(QString)));
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
TabbedWebView* WebTab::webView() const
|
2011-12-18 16:57:14 +01:00
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_webView;
|
2011-12-18 16:57:14 +01:00
|
|
|
}
|
|
|
|
|
2014-03-31 17:46:59 +02:00
|
|
|
void WebTab::showWebInspector()
|
2012-03-11 15:17:12 +01:00
|
|
|
{
|
2014-03-31 17:46:59 +02:00
|
|
|
if (!m_inspector) {
|
|
|
|
m_inspector = new WebInspector(this);
|
|
|
|
m_inspector->setPage(m_webView->page());
|
|
|
|
m_splitter->addWidget(m_inspector);
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
2014-03-31 17:46:59 +02:00
|
|
|
|
|
|
|
m_inspector->show();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QUrl WebTab::url() const
|
|
|
|
{
|
|
|
|
if (isRestored()) {
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_webView->url();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return m_savedTab.url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString WebTab::title() const
|
|
|
|
{
|
|
|
|
if (isRestored()) {
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_webView->title();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return m_savedTab.title;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QIcon WebTab::icon() const
|
|
|
|
{
|
|
|
|
if (isRestored()) {
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_webView->icon();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return m_savedTab.icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QWebHistory* WebTab::history() const
|
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_webView->history();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
|
2014-04-01 18:47:19 +02:00
|
|
|
void WebTab::detach()
|
2013-05-12 22:55:53 +02:00
|
|
|
{
|
2014-04-01 18:47:19 +02:00
|
|
|
// Remove icon from tab
|
2014-03-18 20:00:34 +01:00
|
|
|
m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), 0);
|
|
|
|
|
2014-04-01 18:47:19 +02:00
|
|
|
m_window = 0;
|
|
|
|
m_tabBar = 0;
|
|
|
|
|
|
|
|
setParent(0);
|
|
|
|
m_locationBar->setParent(this);
|
2014-03-18 20:00:34 +01:00
|
|
|
}
|
|
|
|
|
2014-04-01 18:47:19 +02:00
|
|
|
void WebTab::attach(BrowserWindow* window, TabBar* tabBar)
|
2014-03-18 20:00:34 +01:00
|
|
|
{
|
2014-04-01 18:47:19 +02:00
|
|
|
m_window = window;
|
|
|
|
m_tabBar = tabBar;
|
|
|
|
|
|
|
|
m_webView->moveToWindow(m_window);
|
|
|
|
m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), m_tabIcon);
|
|
|
|
m_tabBar->setTabText(tabIndex(), title());
|
2013-05-12 22:55:53 +02:00
|
|
|
}
|
|
|
|
|
2012-03-12 18:22:01 +01:00
|
|
|
void WebTab::setHistoryData(const QByteArray &data)
|
|
|
|
{
|
|
|
|
QDataStream historyStream(data);
|
2014-03-18 20:00:34 +01:00
|
|
|
historyStream >> *m_webView->history();
|
2012-03-12 18:22:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray WebTab::historyData() const
|
|
|
|
{
|
|
|
|
if (isRestored()) {
|
|
|
|
QByteArray historyArray;
|
|
|
|
QDataStream historyStream(&historyArray, QIODevice::WriteOnly);
|
2014-03-18 20:00:34 +01:00
|
|
|
historyStream << *m_webView->history();
|
2012-03-12 18:22:01 +01:00
|
|
|
|
|
|
|
return historyArray;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return m_savedTab.history;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-11 15:17:12 +01:00
|
|
|
void WebTab::reload()
|
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
m_webView->reload();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebTab::stop()
|
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
m_webView->stop();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WebTab::isLoading() const
|
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_webView->isLoading();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WebTab::isPinned() const
|
2011-12-18 16:57:14 +01:00
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_isPinned;
|
2011-12-18 16:57:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebTab::setPinned(bool state)
|
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
m_isPinned = state;
|
2011-12-18 16:57:14 +01:00
|
|
|
}
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
LocationBar* WebTab::locationBar() const
|
2011-12-18 16:57:14 +01:00
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_locationBar;
|
2011-12-18 16:57:14 +01:00
|
|
|
}
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
TabIcon* WebTab::tabIcon() const
|
2011-12-18 16:57:14 +01:00
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
return m_tabIcon;
|
2011-12-18 16:57:14 +01:00
|
|
|
}
|
|
|
|
|
2012-03-11 15:17:12 +01:00
|
|
|
bool WebTab::isRestored() const
|
|
|
|
{
|
|
|
|
return m_savedTab.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebTab::restoreTab(const WebTab::SavedTab &tab)
|
|
|
|
{
|
2014-04-01 18:47:19 +02:00
|
|
|
Q_ASSERT(m_tabBar);
|
|
|
|
|
2012-08-10 21:16:43 +02:00
|
|
|
if (qzSettings->loadTabsOnActivation) {
|
2012-03-11 15:17:12 +01:00
|
|
|
m_savedTab = tab;
|
|
|
|
int index = tabIndex();
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
m_tabBar->setTabText(index, tab.title);
|
|
|
|
m_locationBar->showUrl(tab.url);
|
|
|
|
m_tabIcon->setIcon(tab.icon);
|
2013-06-18 11:03:52 +02:00
|
|
|
|
|
|
|
if (!tab.url.isEmpty()) {
|
2014-03-18 20:00:34 +01:00
|
|
|
QColor col = m_tabBar->palette().text().color();
|
2013-09-17 17:03:50 +02:00
|
|
|
QColor newCol = col.lighter(250);
|
|
|
|
|
|
|
|
// It won't work for black color because (V) = 0
|
|
|
|
// It won't also work for white, as white won't get any lighter
|
|
|
|
if (col == Qt::black || col == Qt::white) {
|
|
|
|
newCol = Qt::gray;
|
2013-09-13 17:29:52 +02:00
|
|
|
}
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
m_tabBar->overrideTabTextColor(index, newCol);
|
2013-06-18 11:03:52 +02:00
|
|
|
}
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
p_restoreTab(tab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebTab::p_restoreTab(const QUrl &url, const QByteArray &history)
|
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
m_webView->load(url);
|
2013-03-13 11:55:22 +01:00
|
|
|
|
2012-03-11 15:17:12 +01:00
|
|
|
QDataStream historyStream(history);
|
2014-03-18 20:00:34 +01:00
|
|
|
historyStream >> *m_webView->history();
|
2012-03-11 15:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebTab::p_restoreTab(const WebTab::SavedTab &tab)
|
|
|
|
{
|
|
|
|
p_restoreTab(tab.url, tab.history);
|
|
|
|
}
|
|
|
|
|
2012-04-08 21:45:40 +02:00
|
|
|
QPixmap WebTab::renderTabPreview()
|
|
|
|
{
|
2014-03-18 20:00:34 +01:00
|
|
|
WebPage* page = m_webView->page();
|
2013-02-07 12:35:54 +01:00
|
|
|
const QSize oldSize = page->viewportSize();
|
2013-02-06 23:45:43 +01:00
|
|
|
const QPoint originalScrollPosition = page->mainFrame()->scrollPosition();
|
|
|
|
|
2013-02-07 11:04:09 +01:00
|
|
|
// Hack to ensure rendering the same preview before and after the page was shown for the first time
|
2013-02-06 23:45:43 +01:00
|
|
|
// This can occur eg. with opening background tabs
|
2014-04-01 18:47:19 +02:00
|
|
|
TabbedWebView* currentWebView = m_window ? m_window->weView() : 0;
|
2013-02-07 12:35:54 +01:00
|
|
|
if (currentWebView) {
|
|
|
|
page->setViewportSize(currentWebView->size());
|
|
|
|
}
|
2012-04-08 21:45:40 +02:00
|
|
|
|
2012-04-12 06:24:51 +02:00
|
|
|
const int previewWidth = 230;
|
|
|
|
const int previewHeight = 150;
|
2012-04-15 22:08:41 +02:00
|
|
|
const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
|
2012-04-12 15:41:28 +02:00
|
|
|
const int pageWidth = qMin(page->mainFrame()->contentsSize().width(), 1280);
|
|
|
|
const int pageHeight = (pageWidth / 23 * 15);
|
|
|
|
const qreal scalingFactor = 2 * static_cast<qreal>(previewWidth) / pageWidth;
|
2012-04-12 15:24:57 +02:00
|
|
|
|
2012-04-12 15:41:28 +02:00
|
|
|
page->setViewportSize(QSize(pageWidth, pageHeight));
|
2012-04-12 06:24:51 +02:00
|
|
|
|
2012-04-15 22:08:41 +02:00
|
|
|
QPixmap pageImage((2 * previewWidth) - scrollBarExtent, (2 * previewHeight) - scrollBarExtent);
|
|
|
|
pageImage.fill(Qt::transparent);
|
2012-04-08 21:45:40 +02:00
|
|
|
|
|
|
|
QPainter p(&pageImage);
|
2012-04-12 06:24:51 +02:00
|
|
|
p.scale(scalingFactor, scalingFactor);
|
2014-03-18 20:00:34 +01:00
|
|
|
m_webView->page()->mainFrame()->render(&p, QWebFrame::ContentsLayer);
|
2012-04-08 21:45:40 +02:00
|
|
|
p.end();
|
|
|
|
|
|
|
|
page->setViewportSize(oldSize);
|
2013-02-06 23:45:43 +01:00
|
|
|
// Restore also scrollbar positions, to prevent messing scrolling to anchor links
|
|
|
|
page->mainFrame()->setScrollBarValue(Qt::Vertical, originalScrollPosition.y());
|
|
|
|
page->mainFrame()->setScrollBarValue(Qt::Horizontal, originalScrollPosition.x());
|
2012-04-08 21:45:40 +02:00
|
|
|
|
2012-04-12 06:24:51 +02:00
|
|
|
return pageImage.scaled(previewWidth, previewHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
2012-04-08 21:45:40 +02:00
|
|
|
}
|
2012-03-11 15:17:12 +01:00
|
|
|
|
2011-03-17 17:03:04 +01:00
|
|
|
void WebTab::showNotification(QWidget* notif)
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
2013-11-26 14:14:36 +01:00
|
|
|
const int notifPos = 0;
|
2013-02-09 13:00:45 +01:00
|
|
|
|
2013-02-17 11:41:42 +01:00
|
|
|
if (m_layout->count() > notifPos + 1) {
|
|
|
|
delete m_layout->itemAt(notifPos)->widget();
|
2011-11-06 17:01:23 +01:00
|
|
|
}
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2013-02-17 11:41:42 +01:00
|
|
|
m_layout->insertWidget(notifPos, notif);
|
2011-03-02 17:54:12 +01:00
|
|
|
notif->show();
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|
|
|
|
|
2014-04-01 18:47:19 +02:00
|
|
|
void WebTab::loadStarted()
|
|
|
|
{
|
|
|
|
if (m_tabBar && m_webView->isTitleEmpty()) {
|
|
|
|
m_tabBar->setTabText(tabIndex(), tr("Loading..."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebTab::titleChanged(const QString &title)
|
|
|
|
{
|
|
|
|
if (!m_tabBar || !m_window || title.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isCurrentTab()) {
|
|
|
|
m_window->setWindowTitle(tr("%1 - QupZilla").arg(title));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_tabBar->setTabText(tabIndex(), title);
|
|
|
|
}
|
|
|
|
|
2013-02-11 09:51:22 +01:00
|
|
|
void WebTab::slotRestore()
|
|
|
|
{
|
2014-04-01 18:47:19 +02:00
|
|
|
Q_ASSERT(m_tabBar);
|
|
|
|
|
2013-02-11 09:51:22 +01:00
|
|
|
p_restoreTab(m_savedTab);
|
|
|
|
m_savedTab.clear();
|
2013-06-18 11:03:52 +02:00
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
m_tabBar->restoreTabTextColor(tabIndex());
|
2013-02-11 09:51:22 +01:00
|
|
|
}
|
|
|
|
|
2014-03-31 17:46:59 +02:00
|
|
|
void WebTab::showEvent(QShowEvent* event)
|
|
|
|
{
|
|
|
|
QWidget::showEvent(event);
|
|
|
|
|
|
|
|
if (!isRestored()) {
|
|
|
|
// When session is being restored, restore the tab immediately
|
|
|
|
if (mApp->isRestoring()) {
|
|
|
|
slotRestore();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
QTimer::singleShot(0, this, SLOT(slotRestore()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
bool WebTab::isCurrentTab() const
|
2014-02-13 16:44:00 +01:00
|
|
|
{
|
2014-04-01 18:47:19 +02:00
|
|
|
return m_tabBar && tabIndex() == m_tabBar->currentIndex();
|
2014-02-13 16:44:00 +01:00
|
|
|
}
|
|
|
|
|
2012-03-11 15:17:12 +01:00
|
|
|
int WebTab::tabIndex() const
|
2011-03-25 19:16:21 +01:00
|
|
|
{
|
2014-04-01 18:47:19 +02:00
|
|
|
Q_ASSERT(m_tabBar);
|
|
|
|
|
|
|
|
return m_tabBar->tabWidget()->indexOf(const_cast<WebTab*>(this));
|
2011-03-25 19:16:21 +01:00
|
|
|
}
|
|
|
|
|
2014-04-01 18:47:19 +02:00
|
|
|
void WebTab::togglePinned()
|
2011-03-25 19:16:21 +01:00
|
|
|
{
|
2014-04-01 18:47:19 +02:00
|
|
|
Q_ASSERT(m_tabBar);
|
|
|
|
Q_ASSERT(m_window);
|
2011-03-25 19:16:21 +01:00
|
|
|
|
2014-04-01 18:47:19 +02:00
|
|
|
m_isPinned = !m_isPinned;
|
|
|
|
m_window->tabWidget()->pinUnPinTab(tabIndex(), title());
|
2011-03-02 16:57:41 +01:00
|
|
|
}
|