2013-11-26 14:14:36 +01:00
|
|
|
/* ============================================================
|
2017-08-25 17:11:29 +02:00
|
|
|
* Falkon - Qt web browser
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2013-2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
|
2013-11-26 14:14:36 +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/>.
|
|
|
|
* ============================================================ */
|
|
|
|
#ifndef TABSTACKEDWIDGET_H
|
|
|
|
#define TABSTACKEDWIDGET_H
|
|
|
|
|
2014-02-26 20:03:20 +01:00
|
|
|
#include "qzcommon.h"
|
2013-11-26 14:14:36 +01:00
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class ComboTabBar;
|
|
|
|
|
|
|
|
class QStackedWidget;
|
|
|
|
class QVBoxLayout;
|
|
|
|
|
|
|
|
|
2017-08-25 17:11:29 +02:00
|
|
|
class FALKON_EXPORT TabStackedWidget : public QWidget
|
2013-11-26 14:14:36 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit TabStackedWidget(QWidget* parent = 0);
|
|
|
|
~TabStackedWidget();
|
|
|
|
|
|
|
|
ComboTabBar* tabBar();
|
|
|
|
void setTabBar(ComboTabBar* tb);
|
|
|
|
|
|
|
|
bool documentMode() const;
|
|
|
|
void setDocumentMode(bool enabled);
|
|
|
|
|
|
|
|
int addTab(QWidget* widget, const QString &label, bool pinned = false);
|
|
|
|
int insertTab(int index, QWidget* widget, const QString &label, bool pinned = false);
|
|
|
|
|
|
|
|
QString tabText(int index) const;
|
|
|
|
void setTabText(int index, const QString &label);
|
|
|
|
|
|
|
|
QString tabToolTip(int index) const;
|
|
|
|
void setTabToolTip(int index, const QString &tip);
|
|
|
|
|
|
|
|
int pinUnPinTab(int index, const QString &title = QString());
|
|
|
|
|
|
|
|
void removeTab(int index);
|
|
|
|
|
|
|
|
int currentIndex() const;
|
|
|
|
QWidget* currentWidget() const;
|
|
|
|
QWidget* widget(int index) const;
|
|
|
|
int indexOf(QWidget* widget) const;
|
|
|
|
int count() const;
|
|
|
|
|
2014-01-29 21:15:04 +01:00
|
|
|
signals:
|
|
|
|
void currentChanged(int index);
|
|
|
|
void tabCloseRequested(int index);
|
2014-12-02 07:34:03 +01:00
|
|
|
void pinStateChanged(int index, bool pinned);
|
2014-01-29 21:15:04 +01:00
|
|
|
|
2013-11-26 14:14:36 +01:00
|
|
|
public slots:
|
|
|
|
void setCurrentIndex(int index);
|
|
|
|
void setCurrentWidget(QWidget* widget);
|
2014-03-10 09:36:37 +01:00
|
|
|
void setUpLayout();
|
2013-11-26 14:14:36 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void showTab(int index);
|
|
|
|
void tabWasMoved(int from, int to);
|
2014-04-01 18:47:19 +02:00
|
|
|
void tabWasRemoved(int index);
|
2013-11-26 14:14:36 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject* obj, QEvent* event);
|
|
|
|
void keyPressEvent(QKeyEvent* event);
|
|
|
|
|
2014-01-29 21:15:04 +01:00
|
|
|
private:
|
|
|
|
bool validIndex(int index) const;
|
2015-10-14 21:58:03 +02:00
|
|
|
void selectTabOnRemove();
|
2014-01-29 21:15:04 +01:00
|
|
|
|
|
|
|
QStackedWidget* m_stack;
|
|
|
|
ComboTabBar* m_tabBar;
|
|
|
|
QVBoxLayout* m_mainLayout;
|
|
|
|
bool m_dirtyTabBar;
|
2015-10-14 21:58:03 +02:00
|
|
|
|
|
|
|
int m_currentIndex;
|
|
|
|
int m_previousIndex;
|
2013-11-26 14:14:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TABSTACKEDWIDGET_H
|