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 TABWIDGET_H
|
|
|
|
#define TABWIDGET_H
|
|
|
|
|
|
|
|
#include <QTabWidget>
|
2013-06-14 12:28:38 +02:00
|
|
|
#include <QMenu>
|
2011-11-03 20:12:35 +01:00
|
|
|
|
2013-11-26 14:14:36 +01:00
|
|
|
#include "tabstackedwidget.h"
|
2012-03-05 11:30:18 +01:00
|
|
|
#include "toolbutton.h"
|
2014-03-19 21:27:43 +01:00
|
|
|
#include "loadrequest.h"
|
2012-08-21 20:28:38 +02:00
|
|
|
#include "webtab.h"
|
2014-03-17 15:01:28 +01:00
|
|
|
#include "qzcommon.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
class QMenu;
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
class TabBar;
|
2014-03-17 10:43:18 +01:00
|
|
|
class TabIcon;
|
2012-03-05 11:30:18 +01:00
|
|
|
class TabWidget;
|
2014-03-17 15:01:28 +01:00
|
|
|
class BrowserWindow;
|
|
|
|
class TabbedWebView;
|
2011-05-07 12:59:53 +02:00
|
|
|
class ClosedTabsManager;
|
2012-03-05 11:30:18 +01:00
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT AddTabButton : public ToolButton
|
2012-03-05 11:30:18 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AddTabButton(TabWidget* tabWidget, TabBar* tabBar);
|
|
|
|
|
|
|
|
private:
|
2012-05-27 12:44:56 +02:00
|
|
|
void wheelEvent(QWheelEvent* event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
2012-03-05 11:30:18 +01:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event);
|
|
|
|
void dropEvent(QDropEvent* event);
|
|
|
|
|
|
|
|
TabBar* m_tabBar;
|
|
|
|
TabWidget* m_tabWidget;
|
|
|
|
};
|
2012-02-29 18:33:50 +01:00
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT MenuTabs : public QMenu
|
2013-06-14 12:28:38 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-06-18 11:03:52 +02:00
|
|
|
explicit MenuTabs(QWidget* parent = 0) : QMenu(parent) {}
|
2013-06-14 12:28:38 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void closeTab(int);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
|
|
|
};
|
|
|
|
|
2014-02-19 22:12:32 +01:00
|
|
|
class QUPZILLA_EXPORT TabWidget : public TabStackedWidget
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-19 22:07:21 +01:00
|
|
|
explicit TabWidget(BrowserWindow* mainclass, QWidget* parent = 0);
|
2011-03-02 16:57:41 +01:00
|
|
|
~TabWidget();
|
|
|
|
|
|
|
|
QByteArray saveState();
|
2013-02-26 12:56:11 +01:00
|
|
|
bool restoreState(const QVector<WebTab::SavedTab> &tabs, int currentTab);
|
2012-08-24 19:24:48 +02:00
|
|
|
void closeRecoveryTab();
|
2012-03-13 17:51:06 +01:00
|
|
|
|
2011-03-25 19:16:21 +01:00
|
|
|
void savePinnedTabs();
|
|
|
|
void restorePinnedTabs();
|
|
|
|
|
2012-09-03 22:40:52 +02:00
|
|
|
void setCurrentIndex(int index);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-03-22 17:19:10 +01:00
|
|
|
void nextTab();
|
|
|
|
void previousTab();
|
2013-02-09 13:00:45 +01:00
|
|
|
void currentTabChanged(int index);
|
2012-03-22 17:19:10 +01:00
|
|
|
|
2012-08-24 19:24:48 +02:00
|
|
|
int normalTabsCount() const;
|
|
|
|
int pinnedTabsCount() const;
|
2012-09-03 22:40:52 +02:00
|
|
|
int lastTabIndex() const;
|
2014-03-18 17:35:44 +01:00
|
|
|
int extraReservedWidth() const;
|
2012-03-22 17:19:10 +01:00
|
|
|
|
2014-04-04 17:14:31 +02:00
|
|
|
TabBar* tabBar() const;
|
2013-02-09 13:00:45 +01:00
|
|
|
ClosedTabsManager* closedTabsManager() const;
|
2011-04-18 21:35:57 +02:00
|
|
|
QList<WebTab*> allTabs(bool withPinned = true);
|
2013-02-09 13:00:45 +01:00
|
|
|
bool canRestoreTab() const;
|
|
|
|
|
|
|
|
QStackedWidget* locationBars() const;
|
2014-03-17 15:01:28 +01:00
|
|
|
ToolButton* buttonClosedTabs() const;
|
2013-02-09 13:00:45 +01:00
|
|
|
AddTabButton* buttonAddTab() const;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
public slots:
|
2014-03-19 21:27:43 +01:00
|
|
|
int addView(const LoadRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false, bool pinned = false);
|
|
|
|
int addView(const LoadRequest &req, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1, bool pinned = false);
|
2013-05-13 22:01:36 +02:00
|
|
|
int addView(WebTab* tab);
|
2012-03-10 13:57:50 +01:00
|
|
|
|
2013-06-02 16:46:26 +02:00
|
|
|
void addTabFromClipboard();
|
2011-12-29 15:45:29 +01:00
|
|
|
int duplicateTab(int index);
|
|
|
|
|
2012-08-21 20:28:38 +02:00
|
|
|
void closeTab(int index = -1, bool force = false);
|
2012-01-21 23:19:38 +01:00
|
|
|
void reloadTab(int index);
|
2011-03-02 16:57:41 +01:00
|
|
|
void reloadAllTabs();
|
2012-01-21 23:19:38 +01:00
|
|
|
void stopTab(int index);
|
2011-03-02 16:57:41 +01:00
|
|
|
void closeAllButCurrent(int index);
|
2013-05-13 22:01:36 +02:00
|
|
|
void detachTab(int index);
|
2013-02-07 15:01:25 +01:00
|
|
|
void restoreClosedTab(QObject* obj = 0);
|
2011-05-16 21:36:39 +02:00
|
|
|
void restoreAllClosedTabs();
|
2011-07-28 21:59:56 +02:00
|
|
|
void clearClosedTabsList();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-10-23 14:44:18 +02:00
|
|
|
void moveAddTabButton(int posX);
|
|
|
|
|
2014-03-18 17:35:44 +01:00
|
|
|
void tabBarOverFlowChanged(bool overflowed);
|
2013-11-26 14:14:36 +01:00
|
|
|
|
2014-03-06 16:12:36 +01:00
|
|
|
signals:
|
|
|
|
void changed();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private slots:
|
2014-03-09 12:49:45 +01:00
|
|
|
void loadSettings();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void aboutToShowTabsMenu();
|
2014-03-17 15:01:28 +01:00
|
|
|
void aboutToShowClosedTabsMenu();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
void actionChangeIndex();
|
2011-05-21 11:19:19 +02:00
|
|
|
void tabMoved(int before, int after);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
private:
|
2013-05-26 18:15:24 +02:00
|
|
|
WebTab* weTab();
|
|
|
|
WebTab* weTab(int index);
|
2014-03-17 10:43:18 +01:00
|
|
|
TabIcon* tabIcon(int index);
|
|
|
|
|
2014-03-17 15:01:28 +01:00
|
|
|
bool validIndex(int index) const;
|
|
|
|
void updateClosedTabsButton();
|
2013-02-09 13:00:45 +01:00
|
|
|
|
2014-02-19 22:07:21 +01:00
|
|
|
BrowserWindow* m_window;
|
2011-03-02 16:57:41 +01:00
|
|
|
TabBar* m_tabBar;
|
2014-03-17 15:01:28 +01:00
|
|
|
QStackedWidget* m_locationBars;
|
|
|
|
ClosedTabsManager* m_closedTabsManager;
|
|
|
|
|
2013-06-14 12:28:38 +02:00
|
|
|
MenuTabs* m_menuTabs;
|
2011-09-11 19:15:06 +02:00
|
|
|
ToolButton* m_buttonListTabs;
|
2014-03-17 15:01:28 +01:00
|
|
|
QMenu* m_menuClosedTabs;
|
|
|
|
ToolButton* m_buttonClosedTabs;
|
2012-03-05 11:30:18 +01:00
|
|
|
AddTabButton* m_buttonAddTab;
|
2013-11-26 14:14:36 +01:00
|
|
|
AddTabButton* m_buttonAddTab2;
|
2011-07-11 20:30:49 +02:00
|
|
|
|
2014-03-17 15:01:28 +01:00
|
|
|
int m_lastTabIndex;
|
|
|
|
int m_lastBackgroundTabIndex;
|
|
|
|
|
|
|
|
bool m_dontCloseWithOneTab;
|
|
|
|
bool m_showClosedTabsButton;
|
|
|
|
bool m_newTabAfterActive;
|
|
|
|
bool m_newEmptyTabAfterActive;
|
|
|
|
QUrl m_urlOnNewTab;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TABWIDGET_H
|