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
|
|
|
#ifndef TABBAR_H
|
|
|
|
#define TABBAR_H
|
|
|
|
|
2013-11-26 14:14:36 +01:00
|
|
|
#include "combotabbar.h"
|
|
|
|
|
2013-02-09 15:44:17 +01:00
|
|
|
#include <QRect>
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-26 20:03:20 +01:00
|
|
|
#include "qzcommon.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2014-02-19 22:07:21 +01:00
|
|
|
class BrowserWindow;
|
2011-10-14 23:12:10 +02:00
|
|
|
class TabWidget;
|
2012-04-08 21:45:40 +02:00
|
|
|
class TabPreview;
|
2014-03-18 20:00:34 +01:00
|
|
|
class WebTab;
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT TabBar : public ComboTabBar
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-19 22:07:21 +01:00
|
|
|
explicit TabBar(BrowserWindow* window, 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);
|
|
|
|
|
2013-06-18 11:03:52 +02:00
|
|
|
void overrideTabTextColor(int index, QColor color);
|
|
|
|
void restoreTabTextColor(int index);
|
|
|
|
|
2014-03-18 20:00:34 +01:00
|
|
|
void setTabText(int index, const QString &text);
|
2012-09-03 22:40:52 +02:00
|
|
|
void updatePinnedTabCloseButton(int index);
|
|
|
|
|
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);
|
2013-05-13 22:01:36 +02:00
|
|
|
void detachTab(int index);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-10-23 14:44:18 +02:00
|
|
|
void moveAddTabButton(int posX);
|
|
|
|
|
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
|
|
|
|
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 closeTab() { emit closeTab(m_clickedTab); }
|
2011-04-08 17:27:08 +02:00
|
|
|
void duplicateTab() { emit duplicateTab(m_clickedTab); }
|
2013-05-13 22:01:36 +02:00
|
|
|
void detachTab() { emit detachTab(m_clickedTab); }
|
2013-11-21 18:37:59 +01:00
|
|
|
void closeAllButCurrent();
|
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
|
|
|
|
2013-12-24 11:55:40 +01:00
|
|
|
void showTabPreview(bool delayed = true);
|
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(); }
|
|
|
|
|
2013-06-06 13:14:12 +02:00
|
|
|
void tabInserted(int index);
|
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);
|
2013-11-26 14:14:36 +01:00
|
|
|
void resizeEvent(QResizeEvent* e);
|
2012-03-05 13:16:34 +01:00
|
|
|
|
2012-03-05 11:30:18 +01:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event);
|
|
|
|
void dropEvent(QDropEvent* event);
|
|
|
|
|
2013-11-26 14:14:36 +01:00
|
|
|
QSize tabSizeHint(int index, bool fast) const;
|
|
|
|
int comboTabBarPixelMetric(ComboTabBar::SizeType sizeType) const;
|
2014-03-18 20:00:34 +01:00
|
|
|
WebTab* webTab(int index = -1) const;
|
2011-10-23 14:44:18 +02:00
|
|
|
|
2014-02-19 22:07:21 +01:00
|
|
|
BrowserWindow* m_window;
|
2011-10-14 23:12:10 +02:00
|
|
|
TabWidget* m_tabWidget;
|
2012-04-08 21:45:40 +02:00
|
|
|
TabPreview* m_tabPreview;
|
2013-12-24 11:55:40 +01:00
|
|
|
QTimer* m_tabPreviewShowTimer;
|
|
|
|
QTimer* m_tabPreviewHideTimer;
|
2011-10-14 23:12:10 +02:00
|
|
|
|
2012-04-10 18:29:22 +02:00
|
|
|
bool m_showTabPreviews;
|
2013-06-06 13:14:12 +02:00
|
|
|
bool m_hideTabBarWithOneTab;
|
2014-02-23 14:54:22 +01:00
|
|
|
|
2014-02-23 14:49:32 +01:00
|
|
|
int m_showCloseOnInactive;
|
2011-03-02 16:57:41 +01:00
|
|
|
int m_clickedTab;
|
|
|
|
|
2012-04-21 22:19:35 +02:00
|
|
|
mutable int m_normalTabWidth;
|
2012-12-10 00:26:25 +01:00
|
|
|
mutable int m_activeTabWidth;
|
2011-12-29 21:50:03 +01:00
|
|
|
|
2013-06-18 11:03:52 +02:00
|
|
|
QColor m_originalTabTextColor;
|
2011-12-29 21:50:03 +01:00
|
|
|
QPoint m_dragStartPosition;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TABBAR_H
|