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 TABWIDGET_H
|
|
|
|
#define TABWIDGET_H
|
|
|
|
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QTabBar>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QToolButton>
|
2011-03-26 13:34:08 +01:00
|
|
|
#include <QStylePainter>
|
2011-07-11 20:30:49 +02:00
|
|
|
#include <QStackedWidget>
|
2011-11-03 20:12:35 +01:00
|
|
|
#include <QTextDocument>
|
2012-01-21 23:19:38 +01:00
|
|
|
#include <QUrl>
|
2011-11-03 20:12:35 +01:00
|
|
|
|
2012-01-21 23:19:38 +01:00
|
|
|
#include "qz_namespace.h"
|
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;
|
|
|
|
class WebTab;
|
2011-03-26 13:34:08 +01:00
|
|
|
class TabListButton;
|
|
|
|
class NewTabButton;
|
2011-05-07 12:59:53 +02:00
|
|
|
class ClosedTabsManager;
|
2011-09-11 19:15:06 +02:00
|
|
|
class ToolButton;
|
2011-03-02 16:57:41 +01:00
|
|
|
class TabWidget : public QTabWidget
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
|
|
|
|
QByteArray saveState();
|
|
|
|
bool restoreState(const QByteArray &state);
|
2011-03-25 19:16:21 +01:00
|
|
|
void savePinnedTabs();
|
|
|
|
void restorePinnedTabs();
|
|
|
|
|
2011-04-24 09:08:53 +02:00
|
|
|
void setTabText(int index, const QString &text);
|
2011-03-02 16:57:41 +01:00
|
|
|
void loadSettings();
|
|
|
|
|
|
|
|
inline TabBar* getTabBar() { return m_tabBar; }
|
2011-05-07 12:59:53 +02:00
|
|
|
inline ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; }
|
|
|
|
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; }
|
2011-10-23 14:44:18 +02:00
|
|
|
ToolButton* buttonAddTab() { return m_buttonAddTab; }
|
2011-03-02 16:57:41 +01:00
|
|
|
|
2011-11-07 19:56:53 +01:00
|
|
|
void createKeyPressEvent(QKeyEvent* event);
|
2012-01-04 16:00:59 +01:00
|
|
|
void showTabBar();
|
2011-11-07 19:56:53 +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);
|
|
|
|
int addView(QUrl url = QUrl(), 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);
|
|
|
|
|
|
|
|
void closeTab(int index = -1);
|
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);
|
|
|
|
void backTab(int index);
|
|
|
|
void forwardTab(int index);
|
2011-03-02 16:57:41 +01:00
|
|
|
void closeAllButCurrent(int index);
|
|
|
|
void restoreClosedTab();
|
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:
|
2011-11-06 17:01:23 +01:00
|
|
|
void resizeEvent(QResizeEvent* e);
|
2012-01-21 23:19:38 +01:00
|
|
|
inline TabbedWebView* weView();
|
|
|
|
inline TabbedWebView* weView(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;
|
2011-03-02 16:57:41 +01:00
|
|
|
QUrl m_urlOnNewTab;
|
|
|
|
QupZilla* p_QupZilla;
|
|
|
|
|
|
|
|
int m_lastTabIndex;
|
2011-05-21 11:19:19 +02:00
|
|
|
bool m_isClosingToLastTabIndex;
|
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;
|
2011-10-23 14:44:18 +02:00
|
|
|
ToolButton* 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
|