2011-03-03 18:29:20 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2013-01-25 23:49:46 +01:00
|
|
|
* Copyright (C) 2010-2013 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>
|
2012-01-21 23:19:38 +01:00
|
|
|
#include <QUrl>
|
2012-03-10 13:57:50 +01:00
|
|
|
#include <QNetworkRequest>
|
2011-11-03 20:12:35 +01:00
|
|
|
|
2012-03-05 11:30:18 +01:00
|
|
|
#include "toolbutton.h"
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "qz_namespace.h"
|
2012-08-21 20:28:38 +02:00
|
|
|
#include "webtab.h"
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-02-29 18:33:50 +01:00
|
|
|
class QStackedWidget;
|
|
|
|
class QMenu;
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
class QupZilla;
|
2012-01-21 20:27:45 +01:00
|
|
|
class TabbedWebView;
|
2011-03-02 16:57:41 +01:00
|
|
|
class TabBar;
|
2012-03-05 11:30:18 +01:00
|
|
|
class TabWidget;
|
2011-05-07 12:59:53 +02:00
|
|
|
class ClosedTabsManager;
|
2012-03-05 11:30:18 +01:00
|
|
|
|
|
|
|
class QT_QUPZILLA_EXPORT AddTabButton : public ToolButton
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
class QT_QUPZILLA_EXPORT TabWidget : public QTabWidget
|
2011-03-02 16:57:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2011-03-17 17:03:04 +01:00
|
|
|
explicit TabWidget(QupZilla* mainclass, QWidget* parent = 0);
|
2011-03-02 16:57:41 +01:00
|
|
|
~TabWidget();
|
|
|
|
|
2012-03-13 17:51:06 +01:00
|
|
|
void loadSettings();
|
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
QByteArray saveState();
|
2012-08-21 20:28:38 +02:00
|
|
|
bool restoreState(const QList<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-03-13 17:51:06 +01:00
|
|
|
void startTabAnimation(int index);
|
|
|
|
void stopTabAnimation(int index);
|
|
|
|
|
2012-09-03 22:40:52 +02:00
|
|
|
void setCurrentIndex(int index);
|
2012-03-13 17:51:06 +01:00
|
|
|
void setTabIcon(int index, const QIcon &icon);
|
2011-04-24 09:08:53 +02:00
|
|
|
void setTabText(int index, const QString &text);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-03-22 17:19:10 +01:00
|
|
|
void nextTab();
|
|
|
|
void previousTab();
|
|
|
|
|
2012-08-24 19:24:48 +02:00
|
|
|
int normalTabsCount() const;
|
|
|
|
int pinnedTabsCount() const;
|
|
|
|
|
2012-03-22 17:19:10 +01:00
|
|
|
void showTabBar();
|
2012-09-03 22:40:52 +02:00
|
|
|
int lastTabIndex() const;
|
2012-03-22 17:19:10 +01:00
|
|
|
|
|
|
|
TabBar* getTabBar() { return m_tabBar; }
|
|
|
|
ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; }
|
2011-05-07 12:59:53 +02:00
|
|
|
bool canRestoreTab();
|
2011-04-18 21:35:57 +02:00
|
|
|
QList<WebTab*> allTabs(bool withPinned = true);
|
2011-07-11 20:30:49 +02:00
|
|
|
QStackedWidget* locationBars() { return m_locationBars; }
|
2011-09-19 21:47:15 +02:00
|
|
|
ToolButton* buttonListTabs() { return m_buttonListTabs; }
|
2012-03-05 11:30:18 +01:00
|
|
|
AddTabButton* buttonAddTab() { return m_buttonAddTab; }
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2012-01-14 11:46:06 +01:00
|
|
|
void disconnectObjects();
|
|
|
|
|
2011-10-14 23:12:10 +02:00
|
|
|
signals:
|
|
|
|
void pinnedTabClosed();
|
|
|
|
void pinnedTabAdded();
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
public slots:
|
2012-01-21 23:19:38 +01:00
|
|
|
int addView(const QUrl &url, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false);
|
2012-03-10 13:57:50 +01:00
|
|
|
int addView(const QNetworkRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false);
|
|
|
|
|
|
|
|
int addView(const QUrl &url, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1);
|
|
|
|
int addView(QNetworkRequest req, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1);
|
|
|
|
|
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-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();
|
2012-01-23 00:23:45 +01:00
|
|
|
void aboutToShowClosedTabsMenu();
|
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-10-23 14:44:18 +02:00
|
|
|
|
2011-03-02 16:57:41 +01:00
|
|
|
private slots:
|
|
|
|
void aboutToShowTabsMenu();
|
|
|
|
void actionChangeIndex();
|
2011-07-11 20:30:49 +02:00
|
|
|
void currentTabChanged(int index);
|
2011-05-21 11:19:19 +02:00
|
|
|
void tabMoved(int before, int after);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
private:
|
2012-08-24 19:24:48 +02:00
|
|
|
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
|
|
|
|
|
2012-04-25 11:35:13 +02:00
|
|
|
void tabInserted(int index);
|
|
|
|
void tabRemoved(int index);
|
|
|
|
|
2011-11-06 17:01:23 +01:00
|
|
|
void resizeEvent(QResizeEvent* e);
|
2012-03-11 15:17:12 +01:00
|
|
|
|
|
|
|
WebTab* weTab();
|
|
|
|
WebTab* weTab(int index);
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
bool m_hideTabBarWithOneTab;
|
2012-01-20 14:12:26 +01:00
|
|
|
bool m_dontQuitWithOneTab;
|
2012-01-23 00:23:45 +01:00
|
|
|
bool m_closedInsteadOpened;
|
2012-01-26 17:21:11 +01:00
|
|
|
bool m_newTabAfterActive;
|
2013-01-25 23:49:46 +01:00
|
|
|
bool m_newEmptyTabAfterActive;
|
2011-03-02 16:57:41 +01:00
|
|
|
QUrl m_urlOnNewTab;
|
|
|
|
QupZilla* p_QupZilla;
|
|
|
|
|
|
|
|
int m_lastTabIndex;
|
2012-02-27 17:51:57 +01:00
|
|
|
int m_lastBackgroundTabIndex;
|
2011-05-21 11:19:19 +02:00
|
|
|
bool m_isClosingToLastTabIndex;
|
2012-03-16 23:28:23 +01:00
|
|
|
bool m_isRestoringState;
|
2011-03-02 16:57:41 +01:00
|
|
|
|
|
|
|
TabBar* m_tabBar;
|
|
|
|
QMenu* m_menuTabs;
|
2011-09-11 19:15:06 +02:00
|
|
|
ToolButton* m_buttonListTabs;
|
2012-03-05 11:30:18 +01:00
|
|
|
AddTabButton* m_buttonAddTab;
|
2011-05-07 12:59:53 +02:00
|
|
|
ClosedTabsManager* m_closedTabsManager;
|
2011-07-11 20:30:49 +02:00
|
|
|
|
|
|
|
QStackedWidget* m_locationBars;
|
2011-03-02 16:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TABWIDGET_H
|