Falkon Develop
Cross-platform Qt-based web browser
tabbar.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "tabbar.h"
19#include "tabwidget.h"
20#include "browserwindow.h"
21#include "webtab.h"
22#include "toolbutton.h"
23#include "settings.h"
24#include "mainapplication.h"
25#include "pluginproxy.h"
26#include "iconprovider.h"
27#include "tabcontextmenu.h"
29#include "tabmrumodel.h"
30
31#include <QMimeData>
32#include <QMouseEvent>
33#include <QStyleOption>
34#include <QApplication>
35#include <QTimer>
36#include <QRect>
37#include <QLabel>
38#include <QScrollArea>
39#include <QHBoxLayout>
40#include <QDrag>
41
42#define MIMETYPE QSL("application/falkon.tabbar.tab")
43
44class TabBarTabMetrics : public QWidget
45{
46 Q_OBJECT
47 Q_PROPERTY(int normalMaxWidth READ normalMaxWidth WRITE setNormalMaxWidth)
48 Q_PROPERTY(int normalMinWidth READ normalMinWidth WRITE setNormalMinWidth)
49 Q_PROPERTY(int activeMinWidth READ activeMinWidth WRITE setActiveMinWidth)
50 Q_PROPERTY(int overflowedWidth READ overflowedWidth WRITE setOverflowedWidth)
51 Q_PROPERTY(int pinnedWidth READ pinnedWidth WRITE setPinnedWidth)
52
53public:
54 void init()
55 {
56 if (!m_metrics.isEmpty()) {
57 return;
58 }
59 m_metrics[0] = 250;
60 m_metrics[1] = 100;
61 m_metrics[2] = 100;
62 m_metrics[3] = 100;
63 m_metrics[4] = -1; // Will be initialized from TabBar
64 }
65
66 int normalMaxWidth() const { return m_metrics.value(0); }
67 void setNormalMaxWidth(int value) { m_metrics[0] = value; }
68
69 int normalMinWidth() const { return m_metrics.value(1); }
70 void setNormalMinWidth(int value) { m_metrics[1] = value; }
71
72 int activeMinWidth() const { return m_metrics.value(2); }
73 void setActiveMinWidth(int value) { m_metrics[2] = value; }
74
75 int overflowedWidth() const { return m_metrics.value(3); }
76 void setOverflowedWidth(int value) { m_metrics[3] = value; }
77
78 int pinnedWidth() const { return m_metrics.value(4); }
79 void setPinnedWidth(int value) { m_metrics[4] = value; }
80
81private:
82 QHash<int, int> m_metrics;
83};
84
85Q_GLOBAL_STATIC(TabBarTabMetrics, tabMetrics)
86
87TabBar::TabBar(BrowserWindow* window, TabWidget* tabWidget)
88 : ComboTabBar()
89 , m_window(window)
90 , m_tabWidget(tabWidget)
91 , m_hideTabBarWithOneTab(false)
92 , m_showCloseOnInactive(0)
93 , m_normalTabWidth(0)
94 , m_activeTabWidth(0)
95 , m_forceHidden(false)
96{
97 setObjectName(QSL("tabbar"));
98 setElideMode(Qt::ElideRight);
99 setFocusPolicy(Qt::NoFocus);
100 setTabsClosable(false);
101 setMouseTracking(true);
102 setDocumentMode(true);
103 setAcceptDrops(true);
104 setDrawBase(false);
105 setMovable(true);
106
107 connect(this, &ComboTabBar::currentChanged, this, &TabBar::currentTabChanged);
108
109 // ComboTabBar features
110 setUsesScrollButtons(true);
111 setCloseButtonsToolTip(BrowserWindow::tr("Close Tab"));
112 connect(this, &ComboTabBar::overFlowChanged, this, &TabBar::overflowChanged);
113
114 tabMetrics()->init();
115
116 if (mApp->isPrivate()) {
117 auto* privateBrowsing = new QLabel(this);
118 privateBrowsing->setObjectName(QSL("private-browsing-icon"));
119 privateBrowsing->setPixmap(IconProvider::privateBrowsingIcon().pixmap(16));
120 privateBrowsing->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
121 privateBrowsing->setFixedWidth(30);
122 addCornerWidget(privateBrowsing, Qt::TopLeftCorner);
123 }
124}
125
127{
128 Settings settings;
129 settings.beginGroup(QSL("Browser-Tabs-Settings"));
130 m_hideTabBarWithOneTab = settings.value(QSL("hideTabsWithOneTab"), false).toBool();
131 bool activateLastTab = settings.value(QSL("ActivateLastTabWhenClosingActual"), false).toBool();
132 m_showCloseOnInactive = settings.value(QSL("showCloseOnInactiveTabs"), 0).toInt(nullptr);
133 settings.endGroup();
134
135 setSelectionBehaviorOnRemove(activateLastTab ? QTabBar::SelectPreviousTab : QTabBar::SelectRightTab);
136 setVisible(!(count() <= 1 && m_hideTabBarWithOneTab));
137
138 setUpLayout();
139}
140
142{
143 return m_tabWidget;
144}
145
146void TabBar::setVisible(bool visible)
147{
148 if (m_forceHidden) {
149 ComboTabBar::setVisible(false);
150 return;
151 }
152
153 // Make sure to honor user preference
154 if (visible) {
155 visible = !(count() <= 1 && m_hideTabBarWithOneTab);
156 }
157
158 ComboTabBar::setVisible(visible);
159}
160
161void TabBar::setForceHidden(bool hidden)
162{
163 m_forceHidden = hidden;
164 setVisible(!m_forceHidden);
165}
166
167void TabBar::overflowChanged(bool overflowed)
168{
169 // Make sure close buttons on inactive tabs are hidden
170 // This is needed for when leaving fullscreen from non-overflowed to overflowed state
171 if (overflowed && m_showCloseOnInactive != 1) {
172 setTabsClosable(false);
173 showCloseButton(currentIndex());
174 }
175}
176
177QSize TabBar::tabSizeHint(int index, bool fast) const
178{
179 if (!m_window->isVisible()) {
180 // Don't calculate it when window is not visible
181 // It produces invalid size anyway
182 return QSize(-1, -1);
183 }
184
185 const int pinnedTabWidth = comboTabBarPixelMetric(ComboTabBar::PinnedTabWidth);
186 const int minTabWidth = comboTabBarPixelMetric(ComboTabBar::NormalTabMinimumWidth);
187
188 QSize size = ComboTabBar::tabSizeHint(index);
189
190 // The overflowed tabs have same size and we can use this fast method
191 if (fast) {
192 size.setWidth(index >= pinnedTabsCount() ? minTabWidth : pinnedTabWidth);
193 return size;
194 }
195
196 auto* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
197 auto* tabBar = const_cast <TabBar*>(this);
198
199 if (webTab && webTab->isPinned()) {
200 size.setWidth(pinnedTabWidth);
201 }
202 else {
203 int availableWidth = mainTabBarWidth() - comboTabBarPixelMetric(ExtraReservedWidth);
204
205 if (availableWidth < 0) {
206 return QSize(-1, -1);
207 }
208
210 const int maxTabWidth = comboTabBarPixelMetric(ComboTabBar::NormalTabMaximumWidth);
211
212 if (availableWidth >= maxTabWidth * normalTabsCount) {
213 m_normalTabWidth = maxTabWidth;
214 size.setWidth(m_normalTabWidth);
215 }
216 else if (normalTabsCount > 0) {
217 const int minActiveTabWidth = comboTabBarPixelMetric(ComboTabBar::ActiveTabMinimumWidth);
218
219 int maxWidthForTab = availableWidth / normalTabsCount;
220 int realTabWidth = maxWidthForTab;
221 bool adjustingActiveTab = false;
222
223 if (realTabWidth < minActiveTabWidth) {
224 maxWidthForTab = normalTabsCount > 1 ? (availableWidth - minActiveTabWidth) / (normalTabsCount - 1) : 0;
225 realTabWidth = minActiveTabWidth;
226 adjustingActiveTab = true;
227 }
228
229 bool tryAdjusting = availableWidth >= minTabWidth * normalTabsCount;
230
231 if (m_showCloseOnInactive != 1 && tabsClosable() && availableWidth < (minTabWidth + 25) * normalTabsCount) {
232 // Hiding close buttons to save some space
233 tabBar->setTabsClosable(false);
234 tabBar->showCloseButton(currentIndex());
235 }
236 if (m_showCloseOnInactive == 1) {
237 // Always showing close buttons
238 tabBar->setTabsClosable(true);
239 tabBar->showCloseButton(currentIndex());
240 }
241
242 if (tryAdjusting) {
243 m_normalTabWidth = maxWidthForTab;
244
245 // Fill any empty space (we've got from rounding) with active tab
246 if (index == mainTabBarCurrentIndex()) {
247 if (adjustingActiveTab) {
248 m_activeTabWidth = (availableWidth - minActiveTabWidth
249 - maxWidthForTab * (normalTabsCount - 1)) + realTabWidth;
250 }
251 else {
252 m_activeTabWidth = (availableWidth - maxWidthForTab * normalTabsCount) + maxWidthForTab;
253 }
254 size.setWidth(m_activeTabWidth);
255 }
256 else {
257 size.setWidth(m_normalTabWidth);
258 }
259 }
260 }
261
262 // Restore close buttons according to preferences
263 if (m_showCloseOnInactive != 2 && !tabsClosable() && availableWidth >= (minTabWidth + 25) * normalTabsCount) {
264 tabBar->setTabsClosable(true);
265
266 // Hide close buttons on pinned tabs
267 for (int i = 0; i < count(); ++i) {
268 tabBar->updatePinnedTabCloseButton(i);
269 }
270 }
271 }
272
273 if (index == count() - 1) {
274 auto* lastMainActiveTab = qobject_cast<WebTab*>(m_tabWidget->widget(mainTabBarCurrentIndex()));
275 int xForAddTabButton = cornerWidth(Qt::TopLeftCorner) + pinTabBarWidth() + normalTabsCount() * m_normalTabWidth;
276
277 if (lastMainActiveTab && m_activeTabWidth > m_normalTabWidth) {
278 xForAddTabButton += m_activeTabWidth - m_normalTabWidth;
279 }
280
281 if (QApplication::layoutDirection() == Qt::RightToLeft) {
282 xForAddTabButton = width() - xForAddTabButton;
283 }
284
285 Q_EMIT tabBar->moveAddTabButton(xForAddTabButton);
286 }
287
288 return size;
289}
290
291int TabBar::comboTabBarPixelMetric(ComboTabBar::SizeType sizeType) const
292{
293 switch (sizeType) {
295 return tabMetrics()->pinnedWidth() > 0 ? tabMetrics()->pinnedWidth() : 32;
296
298 return tabMetrics()->activeMinWidth();
299
301 return tabMetrics()->normalMinWidth();
302
304 return tabMetrics()->overflowedWidth();
305
307 return tabMetrics()->normalMaxWidth();
308
310 return m_tabWidget->extraReservedWidth();
311
312 default:
313 break;
314 }
315
316 return -1;
317}
318
319WebTab* TabBar::webTab(int index) const
320{
321 if (index == -1) {
322 return qobject_cast<WebTab*>(m_tabWidget->widget(currentIndex()));
323 }
324 return qobject_cast<WebTab*>(m_tabWidget->widget(index));
325}
326
327void TabBar::showCloseButton(int index)
328{
329 if (!validIndex(index)) {
330 return;
331 }
332
333 auto* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
334 auto* button = qobject_cast<QAbstractButton*>(tabButton(index, closeButtonPosition()));
335
336 if (button || (webTab && webTab->isPinned())) {
337 return;
338 }
339
340 insertCloseButton(index);
341}
342
343void TabBar::contextMenuEvent(QContextMenuEvent* event)
344{
345 if (isDragInProgress()) {
346 return;
347 }
348
349 int index = tabAt(event->pos());
350
351 TabContextMenu menu(index, m_window);
352
353 // Prevent choosing first option with double rightclick
354 const QPoint pos = event->globalPos();
355 QPoint p(pos.x(), pos.y() + 1);
356 menu.exec(p);
357}
358
359void TabBar::hideCloseButton(int index)
360{
361 if (!validIndex(index) || tabsClosable()) {
362 return;
363 }
364
365 auto* button = qobject_cast<CloseButton*>(tabButton(index, closeButtonPosition()));
366 if (!button) {
367 return;
368 }
369
370 setTabButton(index, closeButtonPosition(), nullptr);
371 button->deleteLater();
372}
373
374void TabBar::updatePinnedTabCloseButton(int index)
375{
376 if (!validIndex(index)) {
377 return;
378 }
379
380 auto* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
381 auto* button = qobject_cast<QAbstractButton*>(tabButton(index, closeButtonPosition()));
382
383 bool pinned = webTab && webTab->isPinned();
384
385 if (pinned) {
386 if (button) {
387 button->hide();
388 }
389 }
390 else {
391 if (button) {
392 button->show();
393 }
394 else {
395 showCloseButton(index);
396 }
397 }
398}
399
400void TabBar::closeTabFromButton()
401{
402 QWidget* button = qobject_cast<QWidget*>(sender());
403
404 int tabToClose = -1;
405
406 for (int i = 0; i < count(); ++i) {
407 if (tabButton(i, closeButtonPosition()) == button) {
408 tabToClose = i;
409 break;
410 }
411 }
412
413 if (tabToClose != -1) {
414 m_tabWidget->requestCloseTab(tabToClose);
415 }
416}
417
418void TabBar::currentTabChanged(int index)
419{
420 if (!validIndex(index)) {
421 return;
422 }
423
424 // Don't hide close buttons when dragging tabs
425 if (m_dragStartPosition.isNull() && !m_isRestoring) {
426 showCloseButton(index);
427 if (m_lastTab) {
428 hideCloseButton(m_lastTab->tabIndex());
429 }
430 QTimer::singleShot(100, this, [this]() { ensureVisible(); });
431 }
432
433 m_lastTab = webTab(index);
434 m_tabWidget->currentTabChanged(index);
435}
436
437void TabBar::setTabText(int index, const QString &text)
438{
439 if (m_isRestoring) {
440 return;
441 }
442
443 QString tabText = text;
444
445 // Avoid Alt+letter shortcuts
446 tabText.replace(QLatin1Char('&'), QLatin1String("&&"));
447
448 if (WebTab* tab = webTab(index)) {
449 if (tab->isPinned()) {
450 tabText.clear();
451 }
452 }
453
454 setTabToolTip(index, text);
456}
457
458void TabBar::tabInserted(int index)
459{
460 Q_UNUSED(index)
461
462 // Initialize pinned tab metrics
463 if (tabMetrics()->pinnedWidth() == -1) {
464 QTimer::singleShot(0, this, [this]() {
465 if (tabMetrics()->pinnedWidth() != -1) {
466 return;
467 }
468 QWidget *w = tabButton(0, iconButtonPosition());
469 if (w && w->parentWidget()) {
470 const QRect wg = w->parentWidget()->geometry();
471 const QRect wr = QStyle::visualRect(layoutDirection(), wg, w->geometry());
472 tabMetrics()->setPinnedWidth(iconButtonSize().width() + wr.x() * 2);
473 setUpLayout();
474 }
475 });
476 }
477
478 setVisible(!(count() <= 1 && m_hideTabBarWithOneTab));
479}
480
481void TabBar::tabRemoved(int index)
482{
483 Q_UNUSED(index)
484
485 showCloseButton(currentIndex());
486 setVisible(!(count() <= 1 && m_hideTabBarWithOneTab));
487
488 // Make sure to move add tab button to correct position when there are no normal tabs
489 if (normalTabsCount() == 0) {
490 int xForAddTabButton = cornerWidth(Qt::TopLeftCorner) + pinTabBarWidth();
491 if (QApplication::layoutDirection() == Qt::RightToLeft)
492 xForAddTabButton = width() - xForAddTabButton;
493 Q_EMIT moveAddTabButton(xForAddTabButton);
494 }
495}
496
497void TabBar::mouseDoubleClickEvent(QMouseEvent* event)
498{
499 if (mApp->plugins()->processMouseDoubleClick(Qz::ON_TabBar, this, event)) {
500 return;
501 }
502
503 if (event->buttons() == Qt::LeftButton && emptyArea(event->position().toPoint())) {
504 m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true);
505 return;
506 }
507
508 ComboTabBar::mouseDoubleClickEvent(event);
509}
510
511void TabBar::mousePressEvent(QMouseEvent* event)
512{
513 ComboTabBar::mousePressEvent(event);
514
515 if (mApp->plugins()->processMousePress(Qz::ON_TabBar, this, event)) {
516 return;
517 }
518
519 if (event->buttons() == Qt::LeftButton && !emptyArea(event->position().toPoint())) {
520 m_dragStartPosition = event->position().toPoint();
521 } else {
522 m_dragStartPosition = QPoint();
523 }
524}
525
526void TabBar::mouseMoveEvent(QMouseEvent* event)
527{
528 ComboTabBar::mouseMoveEvent(event);
529
530 if (mApp->plugins()->processMouseMove(Qz::ON_TabBar, this, event)) {
531 return;
532 }
533
534 if (count() == 1 && mApp->windowCount() == 1) {
535 return;
536 }
537
538 if (!m_dragStartPosition.isNull()) {
539 int offset = 0;
540 const int eventY = event->position().toPoint().y();
541 if (eventY < 0) {
542 offset = qAbs(eventY);
543 } else if (eventY > height()) {
544 offset = eventY - height();
545 }
546 if (offset > QApplication::startDragDistance() * 3) {
547 const QPoint global = mapToGlobal(m_dragStartPosition);
548 QWidget *w = QApplication::widgetAt(global);
549 if (w) {
550 QMouseEvent mouse(QEvent::MouseButtonRelease, event->position(), w->mapFromGlobal(global), Qt::LeftButton, Qt::LeftButton, event->modifiers());
551 QApplication::sendEvent(w, &mouse);
552 }
553 auto *drag = new QDrag(this);
554 auto *mime = new QMimeData;
555 mime->setData(MIMETYPE, QByteArray());
556 drag->setMimeData(mime);
557 drag->setPixmap(tabPixmap(currentIndex()));
558 if (drag->exec() == Qt::IgnoreAction) {
559 m_tabWidget->detachTab(currentIndex());
560 }
561 return;
562 }
563 }
564}
565
566void TabBar::mouseReleaseEvent(QMouseEvent* event)
567{
568 ComboTabBar::mouseReleaseEvent(event);
569
570 m_dragStartPosition = QPoint();
571
572 if (mApp->plugins()->processMouseRelease(Qz::ON_TabBar, this, event)) {
573 return;
574 }
575
576 if (!rect().contains(event->position().toPoint())) {
577 ComboTabBar::mouseReleaseEvent(event);
578 return;
579 }
580
581 if (event->button() == Qt::MiddleButton) {
582 if (emptyArea(event->position().toPoint())) {
583 m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true);
584 return;
585 }
586
587 int id = tabAt(event->position().toPoint());
588 if (id != -1) {
589 m_tabWidget->requestCloseTab(id);
590 return;
591 }
592 }
593}
594
595void TabBar::wheelEvent(QWheelEvent* event)
596{
597 if (mApp->plugins()->processWheelEvent(Qz::ON_TabBar, this, event)) {
598 return;
599 }
600
602}
603
610
611static TabDropAction tabDropAction(const QPoint &pos, const QRect &tabRect, bool allowSelect)
612{
613 if (!tabRect.contains(pos)) {
614 return NoAction;
615 }
616
617 const QPoint c = tabRect.center();
618 const QSize csize = QSize(tabRect.width() * 0.7, tabRect.height() * 0.7);
619 const QRect center(c.x() - csize.width() / 2, c.y() - csize.height() / 2, csize.width(), csize.height());
620
621 if (allowSelect && center.contains(pos)) {
622 return SelectTab;
623 } else if (pos.x() < c.x()) {
624 return PrependTab;
625 } else {
626 return AppendTab;
627 }
628}
629
630void TabBar::dragEnterEvent(QDragEnterEvent* event)
631{
632 const QMimeData* mime = event->mimeData();
633
634 if (mime->hasText() || mime->hasUrls() || (mime->hasFormat(MIMETYPE) && event->source())) {
635 event->acceptProposedAction();
636 return;
637 }
638
639 ComboTabBar::dragEnterEvent(event);
640}
641
642void TabBar::dragMoveEvent(QDragMoveEvent *event)
643{
644 const int index = tabAt(event->position().toPoint());
645 const QMimeData* mime = event->mimeData();
646
647 if (index == -1) {
648 ComboTabBar::dragMoveEvent(event);
649 return;
650 }
651
652 switch (tabDropAction(event->position().toPoint(), tabRect(index), !mime->hasFormat(MIMETYPE))) {
653 case PrependTab:
655 break;
656 case AppendTab:
658 break;
659 default:
661 break;
662 }
663}
664
665void TabBar::dragLeaveEvent(QDragLeaveEvent *event)
666{
668
669 ComboTabBar::dragLeaveEvent(event);
670}
671
672void TabBar::dropEvent(QDropEvent* event)
673{
675
676 const QMimeData* mime = event->mimeData();
677
678 if (!mime->hasText() && !mime->hasUrls() && !mime->hasFormat(MIMETYPE)) {
679 ComboTabBar::dropEvent(event);
680 return;
681 }
682
683 event->acceptProposedAction();
684
685 auto *sourceTabBar = qobject_cast<TabBar*>(event->source());
686
687 int index = tabAt(event->position().toPoint());
688 if (index == -1) {
689 if (mime->hasUrls()) {
690 const auto urls = mime->urls();
691 for (const QUrl &url : urls) {
692 m_tabWidget->addView(url, Qz::NT_SelectedTabAtTheEnd);
693 }
694 } else if (mime->hasText()) {
695 m_tabWidget->addView(mApp->searchEnginesManager()->searchResult(mime->text()), Qz::NT_SelectedNewEmptyTab);
696 } else if (mime->hasFormat(MIMETYPE) && sourceTabBar) {
697 WebTab *tab = sourceTabBar->webTab();
698 if (tab) {
699 sourceTabBar->m_tabWidget->detachTab(tab);
700 tab->setPinned(false);
701 m_tabWidget->addView(tab, Qz::NT_SelectedTab);
702 }
703 }
704 } else {
705 LoadRequest req;
706 WebTab* tab = m_tabWidget->webTab(index);
707 TabDropAction action = tabDropAction(event->position().toPoint(), tabRect(index), !mime->hasFormat(MIMETYPE));
708 if (mime->hasUrls()) {
709 req = mime->urls().at(0);
710 } else if (mime->hasText()) {
711 req = mApp->searchEnginesManager()->searchResult(mime->text());
712 }
713 if (action == SelectTab) {
714 if (req.isValid()) {
715 tab->load(req);
716 }
717 } else if (action == PrependTab || action == AppendTab) {
718 const int newIndex = action == PrependTab ? index : index + 1;
719 if (req.isValid()) {
720 m_tabWidget->addView(req, QString(), Qz::NT_SelectedNewEmptyTab, false, newIndex, index < pinnedTabsCount());
721 } else if (mime->hasFormat(MIMETYPE) && sourceTabBar) {
722 WebTab *tab = sourceTabBar->webTab();
723 if (tab) {
724 if (sourceTabBar == this) {
725 tab->moveTab(newIndex > tab->tabIndex() ? newIndex - 1 : newIndex);
726 } else {
727 sourceTabBar->m_tabWidget->detachTab(tab);
728 tab->setPinned(index < pinnedTabsCount());
729 m_tabWidget->insertView(newIndex, tab, Qz::NT_SelectedTab);
730 }
731 }
732 }
733 }
734 }
735}
736
737void TabBar::setIsRestoring(bool restoring)
738{
739 m_isRestoring = restoring;
740}
741
743{
744 return m_isRestoring;
745}
746
747#include "tabbar.moc"
int tabAt(const QPoint &pos) const
QTabBar::ButtonPosition iconButtonPosition() const
bool isDragInProgress() const
@ OverflowedTabWidth
Definition: combotabbar.h:51
@ ActiveTabMinimumWidth
Definition: combotabbar.h:48
@ NormalTabMaximumWidth
Definition: combotabbar.h:50
@ ExtraReservedWidth
Definition: combotabbar.h:52
@ NormalTabMinimumWidth
Definition: combotabbar.h:49
int normalTabsCount() const
QString tabText(int index) const
void clearDropIndicator()
int mainTabBarCurrentIndex() const
void showDropIndicator(int index, DropIndicatorPosition position)
QPixmap tabPixmap(int index) const
QWidget * tabButton(int index, QTabBar::ButtonPosition position) const
QRect tabRect(int index) const
QSize iconButtonSize() const
void ensureVisible(int index=-1, int xmargin=-1)
QTabBar::ButtonPosition closeButtonPosition() const
int currentIndex
Definition: combotabbar.h:42
int pinnedTabsCount() const
void setTabButton(int index, QTabBar::ButtonPosition position, QWidget *widget)
void currentChanged(int index)
void setSelectionBehaviorOnRemove(QTabBar::SelectionBehavior behavior)
int pinTabBarWidth() const
int cornerWidth(Qt::Corner corner) const
void overFlowChanged(bool overFlow)
void setTabToolTip(int index, const QString &tip)
void setUpLayout()
virtual QSize tabSizeHint(int index, bool fast=false) const
bool event(QEvent *event) override
void setTabText(int index, const QString &text)
void wheelEvent(QWheelEvent *event) override
int mainTabBarWidth() const
void setTabsClosable(bool closable)
bool emptyArea(const QPoint &pos) const
bool tabsClosable() const
void insertCloseButton(int index)
static QIcon privateBrowsingIcon()
bool isValid() const
Definition: loadrequest.cpp:39
void beginGroup(const QString &prefix)
Definition: settings.cpp:79
void endGroup()
Definition: settings.cpp:84
QVariant value(const QString &key, const QVariant &defaultValue=QVariant())
Definition: settings.cpp:74
Definition: tabbar.h:31
bool isRestoring()
Definition: tabbar.cpp:742
void wheelEvent(QWheelEvent *event) override
Definition: tabbar.cpp:595
void setTabText(int index, const QString &text)
Definition: tabbar.cpp:437
void setVisible(bool visible) override
Definition: tabbar.cpp:146
void setForceHidden(bool hidden)
Definition: tabbar.cpp:161
void loadSettings()
Definition: tabbar.cpp:126
void moveAddTabButton(int posX)
void setIsRestoring(bool restoring)
Definition: tabbar.cpp:737
TabWidget * tabWidget() const
Definition: tabbar.cpp:141
void setNormalMinWidth(int value)
Definition: tabbar.cpp:70
void setActiveMinWidth(int value)
Definition: tabbar.cpp:73
void setNormalMaxWidth(int value)
Definition: tabbar.cpp:67
void setOverflowedWidth(int value)
Definition: tabbar.cpp:76
int normalMaxWidth
Definition: tabbar.cpp:47
int activeMinWidth
Definition: tabbar.cpp:49
int activeMinWidth() const
Definition: tabbar.cpp:72
void setPinnedWidth(int value)
Definition: tabbar.cpp:79
int overflowedWidth() const
Definition: tabbar.cpp:75
int normalMaxWidth() const
Definition: tabbar.cpp:66
int pinnedWidth() const
Definition: tabbar.cpp:78
int normalMinWidth
Definition: tabbar.cpp:48
int overflowedWidth
Definition: tabbar.cpp:50
int normalMinWidth() const
Definition: tabbar.cpp:69
QWidget * widget(int index) const
void requestCloseTab(int index=-1)
Definition: tabwidget.cpp:471
WebTab * webTab(int index=-1) const
Definition: tabwidget.cpp:570
int insertView(int index, WebTab *tab, const Qz::NewTabPositionFlags &openFlags)
Definition: tabwidget.cpp:400
void currentTabChanged(int index)
Definition: tabwidget.cpp:502
int addView(const LoadRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine=false, bool pinned=false)
Definition: tabwidget.cpp:314
void detachTab(WebTab *tab)
Definition: tabwidget.cpp:685
int extraReservedWidth() const
Definition: tabwidget.cpp:575
Definition: webtab.h:40
void setPinned(bool state)
Definition: webtab.cpp:419
int tabIndex() const
Definition: webtab.cpp:710
void load(const LoadRequest &request)
Definition: webtab.cpp:391
bool isPinned() const
Definition: webtab.cpp:414
void moveTab(int to)
Definition: webtab.cpp:703
#define mApp
int value(const QColor &c)
Definition: colors.cpp:238
@ ON_TabBar
Definition: qzcommon.h:91
@ NT_SelectedTabAtTheEnd
Definition: qzcommon.h:104
@ NT_SelectedTab
Definition: qzcommon.h:97
@ NT_SelectedNewEmptyTab
Definition: qzcommon.h:103
i
Definition: i18n.py:23
#define QSL(x)
Definition: qzcommon.h:40
#define MIMETYPE
Definition: tabbar.cpp:42
TabDropAction
Definition: tabbar.cpp:604
@ SelectTab
Definition: tabbar.cpp:606
@ AppendTab
Definition: tabbar.cpp:608
@ NoAction
Definition: tabbar.cpp:605
@ PrependTab
Definition: tabbar.cpp:607