2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2012-01-01 15:29:55 +01:00
|
|
|
* Copyright (C) 2010-2012 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
|
|
|
#ifndef TABBAR_H
|
|
|
|
#define TABBAR_H
|
|
|
|
|
|
|
|
#include <QTabBar>
|
2012-09-03 22:40:52 +02:00
|
|
|
#include <QAbstractButton>
|
2012-02-29 18:33:50 +01:00
|
|
|
|
|
|
|
#include "qz_namespace.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
class QupZilla;
|
2011-10-14 23:12:10 +02:00
|
|
|
class TabWidget;
|
2012-04-08 21:45:40 +02:00
|
|
|
class TabPreview;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
|
|
|
class QT_QUPZILLA_EXPORT TabBar : public QTabBar
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2011-10-18 21:07:58 +02:00
|
|
|
explicit TabBar(QupZilla* mainClass, TabWidget* tabWidget);
|
2011-03-25 19:16:21 +01:00
|
|
|
|
|
|
|
void loadSettings();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-10-24 17:46:45 +02:00
|
|
|
void setVisible(bool visible);
|
|
|
|
void updateVisibilityWithFullscreen(bool visible);
|
|
|
|
|
2011-11-05 15:04:29 +01:00
|
|
|
int pinnedTabsCount();
|
|
|
|
int normalTabsCount();
|
|
|
|
|
2012-09-03 22:40:52 +02:00
|
|
|
void updatePinnedTabCloseButton(int index);
|
|
|
|
|
2012-01-14 11:46:06 +01:00
|
|
|
void disconnectObjects();
|
|
|
|
|
2012-05-27 12:44:56 +02:00
|
|
|
void wheelEvent(QWheelEvent* event);
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
signals:
|
|
|
|
void reloadTab(int index);
|
|
|
|
void stopTab(int index);
|
|
|
|
void closeAllButCurrent(int index);
|
|
|
|
void closeTab(int index);
|
2011-04-08 17:27:08 +02:00
|
|
|
void duplicateTab(int index);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-10-23 14:44:18 +02:00
|
|
|
void moveAddTabButton(int posX);
|
|
|
|
|
2011-10-24 17:46:45 +02:00
|
|
|
void showButtons();
|
|
|
|
void hideButtons();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private slots:
|
2012-04-09 14:09:40 +02:00
|
|
|
void currentTabChanged(int index);
|
2011-10-14 23:12:10 +02:00
|
|
|
void pinnedTabAdded();
|
|
|
|
void pinnedTabClosed();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void contextMenuRequested(const QPoint &position);
|
|
|
|
void reloadTab() { emit reloadTab(m_clickedTab); }
|
|
|
|
void stopTab() { emit stopTab(m_clickedTab); }
|
|
|
|
void closeAllButCurrent() { emit closeAllButCurrent(m_clickedTab); }
|
|
|
|
void closeTab() { emit closeTab(m_clickedTab); }
|
2011-04-08 17:27:08 +02:00
|
|
|
void duplicateTab() { emit duplicateTab(m_clickedTab); }
|
2011-03-02 16:57:41 +01:00
|
|
|
void bookmarkTab();
|
2011-03-25 19:16:21 +01:00
|
|
|
void pinTab();
|
2012-09-03 22:40:52 +02:00
|
|
|
|
2011-03-25 19:16:21 +01:00
|
|
|
void closeCurrentTab();
|
2012-09-03 22:40:52 +02:00
|
|
|
void closeTabFromButton();
|
2011-03-25 19:16:21 +01:00
|
|
|
|
2012-04-08 21:45:40 +02:00
|
|
|
void showTabPreview();
|
2012-04-09 14:09:40 +02:00
|
|
|
void hideTabPreview(bool delayed = true);
|
2012-04-08 21:45:40 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private:
|
2012-09-03 22:40:52 +02:00
|
|
|
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
|
|
|
|
|
2012-09-05 19:57:36 +02:00
|
|
|
void tabRemoved(int index);
|
|
|
|
|
2012-09-03 22:40:52 +02:00
|
|
|
void hideCloseButton(int index);
|
|
|
|
void showCloseButton(int index);
|
|
|
|
|
2012-03-05 13:16:34 +01:00
|
|
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
2012-01-02 17:23:31 +01:00
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
2011-12-12 21:14:43 +01:00
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
2012-04-10 18:29:22 +02:00
|
|
|
bool event(QEvent* event);
|
2012-03-05 13:16:34 +01:00
|
|
|
|
2012-03-05 11:30:18 +01:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event);
|
|
|
|
void dropEvent(QDropEvent* event);
|
|
|
|
|
2011-03-25 19:16:21 +01:00
|
|
|
QSize tabSizeHint(int index) const;
|
2011-10-23 14:44:18 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QupZilla* p_QupZilla;
|
2011-10-14 23:12:10 +02:00
|
|
|
TabWidget* m_tabWidget;
|
2012-04-08 21:45:40 +02:00
|
|
|
TabPreview* m_tabPreview;
|
2012-04-09 14:09:40 +02:00
|
|
|
QTimer* m_tabPreviewTimer;
|
2011-10-14 23:12:10 +02:00
|
|
|
|
2012-04-10 18:29:22 +02:00
|
|
|
bool m_showTabPreviews;
|
2011-10-14 23:12:10 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
int m_clickedTab;
|
2011-10-14 23:12:10 +02:00
|
|
|
int m_pinnedTabsCount;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-04-21 22:19:35 +02:00
|
|
|
mutable int m_normalTabWidth;
|
|
|
|
mutable int m_lastTabWidth;
|
2011-12-29 21:50:03 +01:00
|
|
|
|
|
|
|
QPoint m_dragStartPosition;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
2012-09-03 22:40:52 +02:00
|
|
|
// Class for close button on tabs
|
|
|
|
// * taken from qtabbar.cpp
|
|
|
|
class CloseButton : public QAbstractButton
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
CloseButton(QWidget* parent = 0);
|
|
|
|
|
|
|
|
QSize sizeHint() const;
|
|
|
|
inline QSize minimumSizeHint() const { return sizeHint(); }
|
|
|
|
|
|
|
|
void enterEvent(QEvent* event);
|
|
|
|
void leaveEvent(QEvent* event);
|
|
|
|
void paintEvent(QPaintEvent* event);
|
|
|
|
};
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
#endif // TABBAR_H
|