Falkon Develop
Cross-platform Qt-based web browser
tabstackedwidget.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2013-2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
4* Copyright (C) 2018 David Rosca <nowrep@gmail.com>
5*
6* This program is free software: you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation, either version 3 of the License, or
9* (at your option) any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program. If not, see <http://www.gnu.org/licenses/>.
18* ============================================================ */
19#ifndef TABSTACKEDWIDGET_H
20#define TABSTACKEDWIDGET_H
21
22#include "qzcommon.h"
23
24#include <QWidget>
25
26class ComboTabBar;
27
28class QStackedWidget;
29class QVBoxLayout;
30
31
32class FALKON_EXPORT TabStackedWidget : public QWidget
33{
34 Q_OBJECT
35public:
36 explicit TabStackedWidget(QWidget* parent = nullptr);
38
39 ComboTabBar* tabBar();
40 void setTabBar(ComboTabBar* tb);
41
42 bool documentMode() const;
43 void setDocumentMode(bool enabled);
44
45 int addTab(QWidget* widget, const QString &label, bool pinned = false);
46 int insertTab(int index, QWidget* widget, const QString &label, bool pinned = false);
47
48 QString tabText(int index) const;
49 void setTabText(int index, const QString &label);
50
51 QString tabToolTip(int index) const;
52 void setTabToolTip(int index, const QString &tip);
53
54 int pinUnPinTab(int index, const QString &title = QString());
55
56 void removeTab(int index);
57 void moveTab(int from, int to);
58
59 int currentIndex() const;
60 QWidget* currentWidget() const;
61 QWidget* widget(int index) const;
62 int indexOf(QWidget* widget) const;
63 int count() const;
64
65Q_SIGNALS:
66 void currentChanged(int index);
67 void tabCloseRequested(int index);
68 void pinStateChanged(int index, bool pinned);
69
70public Q_SLOTS:
71 void setCurrentIndex(int index);
72 void setCurrentWidget(QWidget* widget);
73 void setUpLayout();
74
75private Q_SLOTS:
76 void showTab(int index);
77 void tabWasMoved(int from, int to);
78 void tabWasRemoved(int index);
79
80protected:
81 bool eventFilter(QObject* obj, QEvent* event) override;
82 void keyPressEvent(QKeyEvent* event) override;
83
84private:
85 bool validIndex(int index) const;
86 void selectTabOnRemove();
87
88 QStackedWidget* m_stack;
89 ComboTabBar* m_tabBar;
90 QVBoxLayout* m_mainLayout;
91 bool m_dirtyTabBar;
92
93 int m_currentIndex;
94 int m_previousIndex;
95};
96
97#endif // TABSTACKEDWIDGET_H
~TabStackedWidget() override
void pinStateChanged(int index, bool pinned)
void currentChanged(int index)
void tabCloseRequested(int index)
#define FALKON_EXPORT
Definition: qzcommon.h:28