1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 12:46:35 +01:00

[ClosedTabsButton] New button in the right corner of tabbar

Added icon for Linux theme.
But it needs a new icon for other themes...
This commit is contained in:
nowrep 2014-03-17 15:01:28 +01:00
parent 9cdad1b45d
commit 96b6743ac6
19 changed files with 209 additions and 155 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -130,6 +130,12 @@
qproperty-multiIcon: url(images/tabs-list-button.png);
}
#tabwidget-button-closedtabs
{
qproperty-icon: url(images/user-trash-full.png);
qproperty-fixedsize: 22px 25px;
}
#tabwidget-button-addtab
{
qproperty-multiIcon: url(images/tabbar-addtab.png);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -145,6 +145,12 @@
background: url(images/transp.png);
}
#tabwidget-button-closedtabs
{
qproperty-icon: url(images/user-trash-full.png);
qproperty-fixedsize: 22px 25px;
}
/*IconProvider*/
IconProvider
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -107,6 +107,13 @@
qproperty-fixedsize: 20px 25px;
}
#tabwidget-button-closedtabs
{
qproperty-themeIcon: "user-trash-full";
qproperty-fallbackIcon: url(images/user-trash-full.png);
qproperty-fixedsize: 22px 25px;
}
#tabwidget-button-addtab
{
qproperty-themeIcon: "list-add";

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -125,6 +125,12 @@
qproperty-multiIcon: url(images/tabs-list-button.png);
}
#tabwidget-button-closedtabs
{
qproperty-icon: url(images/user-trash-full.png);
qproperty-fixedsize: 22px 25px;
}
#tabwidget-button-addtab
{
qproperty-multiIcon: url(images/tabbar-addtab.png);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -136,6 +136,12 @@
qproperty-fixedsize: 18px 28px;
}
#tabwidget-button-closedtabs
{
qproperty-icon: url(images/user-trash-full.png);
qproperty-fixedsize: 22px 28px;
}
#tabwidget-button-opentabs::menu-indicator
{
background: url(images/transp.png);

View File

@ -344,6 +344,9 @@ void BrowserWindow::setupUi()
col.setAlpha(0);
pal.setColor(QPalette::Window, col);
QToolTip::setPalette(pal);
// Set some sane minimum width
setMinimumWidth(300);
}
void BrowserWindow::setupMenu()

View File

@ -22,6 +22,7 @@
#include "mainapplication.h"
#include "closedtabsmanager.h"
#include "tabwidget.h"
#include "qztools.h"
#include "history.h"
#include "qzsettings.h"
@ -38,15 +39,6 @@ static QKeySequence actionShortcut(QKeySequence shortcut, QKeySequence fallback,
return (shortcut.isEmpty() ? fallback : shortcut);
}
static QString truncatedTitle(const QString &title)
{
if (title.length() > 40) {
return title.left(40) + QLatin1String("..");
}
return title;
}
HistoryMenu::HistoryMenu(QWidget* parent)
: Menu(parent)
{
@ -113,7 +105,7 @@ void HistoryMenu::aboutToShowRecentlyVisited()
while (query.next()) {
const QUrl url = query.value(1).toUrl();
const QString title = truncatedTitle(query.value(0).toString());
const QString title = QzTools::truncatedText(query.value(0).toString(), 40);
Action* act = new Action(IconProvider::iconForUrl(url), title);
act->setData(url);
@ -135,7 +127,7 @@ void HistoryMenu::aboutToShowMostVisited()
const QVector<HistoryEntry> mostVisited = mApp->history()->mostVisited(10);
foreach (const HistoryEntry &entry, mostVisited) {
Action* act = new Action(IconProvider::iconForUrl(entry.url), truncatedTitle(entry.title));
Action* act = new Action(IconProvider::iconForUrl(entry.url), QzTools::truncatedText(entry.title, 40));
act->setData(entry.url);
connect(act, SIGNAL(triggered()), this, SLOT(historyEntryActivated()));
connect(act, SIGNAL(ctrlTriggered()), this, SLOT(historyEntryCtrlActivated()));
@ -155,31 +147,26 @@ void HistoryMenu::aboutToShowClosedTabs()
if (!m_window) {
return;
}
TabWidget* tabWidget = m_window->tabWidget();
QAction* arestore = new QAction(tr("Restore All Closed Tabs"), this);
QAction* aclrlist = new QAction(tr("Clear list"), this);
connect(arestore, SIGNAL(triggered()), tabWidget, SLOT(restoreAllClosedTabs()));
connect(aclrlist, SIGNAL(triggered()), tabWidget, SLOT(clearClosedTabsList()));
m_menuClosedTabs->addAction(arestore);
m_menuClosedTabs->addAction(aclrlist);
m_menuClosedTabs->addSeparator();
const QLinkedList<ClosedTabsManager::Tab> closedTabs = tabWidget->closedTabsManager()->allClosedTabs();
int i = 0;
const QLinkedList<ClosedTabsManager::Tab> closedTabs = tabWidget->closedTabsManager()->allClosedTabs();
foreach (const ClosedTabsManager::Tab &tab, closedTabs) {
const QString title = truncatedTitle(tab.title);
const QString title = QzTools::truncatedText(tab.title, 40);
QAction* act = m_menuClosedTabs->addAction(IconProvider::iconForUrl(tab.url), title, tabWidget, SLOT(restoreClosedTab()));
act->setData(i++);
}
if (i == 0) {
arestore->setVisible(false);
aclrlist->setVisible(false);
if (m_menuClosedTabs->isEmpty()) {
m_menuClosedTabs->addAction(tr("Empty"))->setEnabled(false);
}
else {
m_menuClosedTabs->addSeparator();
m_menuClosedTabs->addAction(tr("Restore All Closed Tabs"), tabWidget, SLOT(restoreAllClosedTabs()));
m_menuClosedTabs->addAction(tr("Clear list"), tabWidget, SLOT(clearClosedTabsList()));
}
}
void HistoryMenu::historyEntryActivated()

View File

@ -236,7 +236,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
ui->switchToNewTabs->setChecked(settings.value("OpenNewTabsSelected", false).toBool());
ui->dontCloseOnLastTab->setChecked(settings.value("dontCloseWithOneTab", false).toBool());
ui->askWhenClosingMultipleTabs->setChecked(settings.value("AskOnClosing", false).toBool());
ui->closedInsteadOpened->setChecked(settings.value("closedInsteadOpenedTabs", false).toBool());
ui->showClosedTabsButton->setChecked(settings.value("showClosedTabsButton", true).toBool());
ui->showTabPreviews->setChecked(settings.value("showTabPreviews", false).toBool());
ui->animatedTabPreviews->setChecked(settings.value("tabPreviewAnimationsEnabled", true).toBool());
ui->showCloseOnInactive->setCurrentIndex(settings.value("showCloseOnInactiveTabs", 0).toInt());
@ -917,7 +917,7 @@ void Preferences::saveSettings()
settings.setValue("OpenNewTabsSelected", ui->switchToNewTabs->isChecked());
settings.setValue("dontCloseWithOneTab", ui->dontCloseOnLastTab->isChecked());
settings.setValue("AskOnClosing", ui->askWhenClosingMultipleTabs->isChecked());
settings.setValue("closedInsteadOpenedTabs", ui->closedInsteadOpened->isChecked());
settings.setValue("showClosedTabsButton", ui->showClosedTabsButton->isChecked());
settings.setValue("showTabPreviews", ui->showTabPreviews->isChecked());
settings.setValue("tabPreviewAnimationsEnabled", ui->animatedTabPreviews->isChecked());
settings.setValue("showCloseOnInactiveTabs", ui->showCloseOnInactive->currentIndex());

View File

@ -757,9 +757,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="closedInsteadOpened">
<widget class="QCheckBox" name="showClosedTabsButton">
<property name="text">
<string>Closed tabs list instead of opened in tab bar</string>
<string>Show closed tabs button</string>
</property>
</widget>
</item>

View File

@ -384,6 +384,14 @@ QString QzTools::applyDirectionToPage(QString &pageContents)
return pageContents;
}
QString QzTools::truncatedText(const QString &text, int size)
{
if (text.length() > size) {
return text.left(size) + QL1S("..");
}
return text;
}
// Thanks to http://www.qtcentre.org/threads/3205-Toplevel-widget-with-rounded-corners?p=17492#post17492
QRegion QzTools::roundedRect(const QRect &rect, int radius)
{

View File

@ -59,6 +59,7 @@ public:
static QPixmap createPixmapForSite(const QIcon &icon, const QString &title, const QString &url);
static QString applyDirectionToPage(QString &pageContents);
static QString truncatedText(const QString &text, int size);
static QString resolveFromPath(const QString &name);
static QStringList splitCommandArguments(const QString &command);

View File

@ -243,7 +243,7 @@ QSize TabBar::tabSizeHint(int index, bool fast) const
else {
int availableWidth = mainTabBarWidth();
if (!m_tabWidget->buttonListTabs()->isForceHidden()) {
if (!m_tabWidget->buttonClosedTabs()->isForceHidden()) {
availableWidth -= comboTabBarPixelMetric(ExtraReservedWidth);
}
@ -350,7 +350,10 @@ int TabBar::comboTabBarPixelMetric(ComboTabBar::SizeType sizeType) const
return 250;
case ComboTabBar::ExtraReservedWidth:
return m_tabWidget->buttonListTabs()->width() + m_tabWidget->buttonAddTab()->width();
if (m_tabWidget->buttonClosedTabs()->isVisible()) {
return m_tabWidget->buttonClosedTabs()->width() + m_tabWidget->buttonAddTab()->width();
}
return m_tabWidget->buttonAddTab()->width();
default:
break;
@ -538,13 +541,13 @@ void TabBar::overFlowChange(bool overFlowed)
{
if (overFlowed) {
m_tabWidget->buttonAddTab()->setForceHidden(true);
m_tabWidget->buttonListTabs()->setForceHidden(true);
m_tabWidget->buttonClosedTabs()->setForceHidden(true);
m_tabWidget->setUpLayout();
ensureVisible(currentIndex());
}
else {
m_tabWidget->buttonAddTab()->setForceHidden(false);
m_tabWidget->buttonListTabs()->setForceHidden(false);
m_tabWidget->buttonClosedTabs()->setForceHidden(false);
m_tabWidget->showButtons();
m_tabWidget->setUpLayout();
}
@ -696,9 +699,9 @@ void TabBar::resizeEvent(QResizeEvent* e)
posit.setX(0);
}
else {
posit.setX(width() - m_tabWidget->buttonListTabs()->width());
posit.setX(width() - m_tabWidget->buttonClosedTabs()->width());
}
m_tabWidget->buttonListTabs()->move(posit);
m_tabWidget->buttonClosedTabs()->move(posit);
ComboTabBar::resizeEvent(e);
}

View File

@ -32,6 +32,7 @@
#include "settings.h"
#include "datapaths.h"
#include "qzsettings.h"
#include "qztools.h"
#include "qtwin.h"
#include "tabicon.h"
@ -117,14 +118,15 @@ void MenuTabs::mouseReleaseEvent(QMouseEvent* event)
TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
: TabStackedWidget(parent)
, m_window(window)
, m_locationBars(new QStackedWidget)
, m_closedTabsManager(new ClosedTabsManager)
, m_lastTabIndex(-1)
, m_lastBackgroundTabIndex(-1)
, m_isClosingToLastTabIndex(false)
, m_isRestoringState(false)
, m_closedTabsManager(new ClosedTabsManager)
, m_locationBars(new QStackedWidget)
{
setObjectName("tabwidget");
setObjectName(QSL("tabwidget"));
m_tabBar = new TabBar(m_window, this);
setTabBar(m_tabBar);
@ -146,8 +148,27 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
connect(mApp, SIGNAL(settingsReloaded()), this, SLOT(loadSettings()));
m_menuTabs = new MenuTabs(m_tabBar);
m_menuTabs = new MenuTabs(this);
connect(m_menuTabs, SIGNAL(closeTab(int)), this, SLOT(closeTab(int)));
m_menuClosedTabs = new QMenu(this);
// ClosedTabs button displayed in the right corner of tabbar
m_buttonClosedTabs = new ToolButton(m_tabBar);
m_buttonClosedTabs->setObjectName("tabwidget-button-closedtabs");
m_buttonClosedTabs->setMenu(m_menuClosedTabs);
m_buttonClosedTabs->setPopupMode(QToolButton::InstantPopup);
m_buttonClosedTabs->setToolTip(tr("Closed tabs"));
m_buttonClosedTabs->setAutoRaise(true);
m_buttonClosedTabs->setFocusPolicy(Qt::NoFocus);
m_buttonClosedTabs->setShowMenuInside(true);
connect(m_buttonClosedTabs, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowClosedTabsMenu()));
// AddTab button displayed next to last tab
m_buttonAddTab = new AddTabButton(this, m_tabBar);
connect(m_buttonAddTab, SIGNAL(clicked()), m_window, SLOT(addTab()));
// ListTabs button is showed only when tabbar overflows
m_buttonListTabs = new ToolButton(m_tabBar);
m_buttonListTabs->setObjectName("tabwidget-button-opentabs");
m_buttonListTabs->setMenu(m_menuTabs);
@ -156,31 +177,30 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
m_buttonListTabs->setAutoRaise(true);
m_buttonListTabs->setFocusPolicy(Qt::NoFocus);
m_buttonListTabs->setShowMenuInside(true);
connect(m_buttonListTabs, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowClosedTabsMenu()));
m_buttonAddTab = new AddTabButton(this, m_tabBar);
connect(m_buttonAddTab, SIGNAL(clicked()), m_window, SLOT(addTab()));
// Copy of buttons
m_buttonListTabs2 = new ToolButton(m_tabBar);
m_buttonListTabs2->setObjectName("tabwidget-button-opentabs");
m_buttonListTabs2->setProperty("outside-tabbar", true);
m_buttonListTabs2->setMenu(m_menuTabs);
m_buttonListTabs2->setPopupMode(QToolButton::InstantPopup);
m_buttonListTabs2->setToolTip(tr("List of tabs"));
m_buttonListTabs2->setAutoRaise(true);
m_buttonListTabs2->setFocusPolicy(Qt::NoFocus);
m_buttonListTabs2->setShowMenuInside(true);
connect(m_buttonListTabs2, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowClosedTabsMenu()));
m_buttonListTabs->hide();
connect(m_buttonListTabs, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowTabsMenu()));
// AddTab button displayed outside tabbar (as corner widget)
m_buttonAddTab2 = new AddTabButton(this, m_tabBar);
m_buttonAddTab2->setProperty("outside-tabbar", true);
m_buttonAddTab2->hide();
connect(m_buttonAddTab2, SIGNAL(clicked()), m_window, SLOT(addTab()));
// ClosedTabs button displayed outside tabbar (as corner widget)
m_buttonClosedTabs2 = new ToolButton(m_tabBar);
m_buttonClosedTabs2->setObjectName("tabwidget-button-closedtabs");
m_buttonClosedTabs2->setMenu(m_menuClosedTabs);
m_buttonClosedTabs2->setPopupMode(QToolButton::InstantPopup);
m_buttonClosedTabs2->setToolTip(tr("Closed tabs"));
m_buttonClosedTabs2->setAutoRaise(true);
m_buttonClosedTabs2->setFocusPolicy(Qt::NoFocus);
m_buttonClosedTabs2->setShowMenuInside(true);
m_buttonClosedTabs2->hide();
connect(m_buttonClosedTabs2, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowClosedTabsMenu()));
m_tabBar->addMainBarWidget(m_buttonAddTab2, Qt::AlignRight);
m_tabBar->addMainBarWidget(m_buttonListTabs2, Qt::AlignRight);
m_buttonAddTab2->hide();
m_buttonListTabs2->hide();
m_tabBar->addMainBarWidget(m_buttonClosedTabs2, Qt::AlignRight);
m_tabBar->addMainBarWidget(m_buttonListTabs, Qt::AlignRight);
connect(m_tabBar, SIGNAL(overFlowChanged(bool)), this, SLOT(tabBarOverFlowChanged(bool)));
loadSettings();
@ -191,7 +211,7 @@ void TabWidget::loadSettings()
Settings settings;
settings.beginGroup("Browser-Tabs-Settings");
m_dontCloseWithOneTab = settings.value("dontCloseWithOneTab", false).toBool();
m_closedInsteadOpened = settings.value("closedInsteadOpenedTabs", false).toBool();
m_showClosedTabsButton = settings.value("showClosedTabsButton", true).toBool();
m_newTabAfterActive = settings.value("newTabAfterActive", true).toBool();
m_newEmptyTabAfterActive = settings.value("newEmptyTabAfterActive", false).toBool();
settings.endGroup();
@ -202,12 +222,7 @@ void TabWidget::loadSettings()
m_tabBar->loadSettings();
if (m_closedInsteadOpened) {
disconnect(m_menuTabs, SIGNAL(closeTab(int)), this, SLOT(closeTab(int)));
}
else {
connect(m_menuTabs, SIGNAL(closeTab(int)), this, SLOT(closeTab(int)));
}
updateClosedTabsButton();
}
WebTab* TabWidget::weTab()
@ -233,56 +248,76 @@ TabIcon* TabWidget::tabIcon(int index)
return icon;
}
bool TabWidget::validIndex(int index) const
{
return index >= 0 && index < count();
}
void TabWidget::updateClosedTabsButton()
{
if (!m_showClosedTabsButton) {
m_buttonClosedTabs->hide();
m_buttonClosedTabs2->hide();
}
// Show closed tabs outside tabbar when overflowed
else if (m_buttonListTabs->isVisible()) {
m_buttonClosedTabs2->show();
}
m_buttonClosedTabs->setEnabled(canRestoreTab());
m_buttonClosedTabs2->setEnabled(canRestoreTab());
}
void TabWidget::showButtons()
{
m_buttonListTabs->show();
// Show buttons inside tabbar
m_buttonClosedTabs->setVisible(m_showClosedTabsButton);
m_buttonAddTab->show();
}
void TabWidget::hideButtons()
{
m_buttonListTabs->hide();
// Hide buttons inside tabbar
m_buttonClosedTabs->hide();
m_buttonAddTab->hide();
}
void TabWidget::tabBarOverFlowChanged(bool overFlowed)
{
// Show buttons displayed outside tabbar (corner widgets)
m_buttonAddTab2->setVisible(overFlowed);
m_buttonListTabs2->setVisible(overFlowed);
m_buttonClosedTabs2->setVisible(m_showClosedTabsButton && overFlowed);
m_buttonListTabs->setVisible(overFlowed);
}
void TabWidget::moveAddTabButton(int posX)
{
int posY = (m_tabBar->height() - m_buttonAddTab->height()) / 2;
//RTL Support
int buttonclosedTabsWidth = m_buttonClosedTabs->isVisible() ? m_buttonClosedTabs->width() : 0;
if (QApplication::layoutDirection() == Qt::RightToLeft) {
posX = qMax(posX - m_buttonAddTab->width(), m_buttonListTabs->width());
posX = qMax(posX - m_buttonAddTab->width(), buttonclosedTabsWidth);
}
else {
posX = qMin(posX, m_tabBar->width() - m_buttonAddTab->width() - m_buttonListTabs->width());
posX = qMin(posX, m_tabBar->width() - m_buttonAddTab->width() - buttonclosedTabsWidth);
}
m_buttonAddTab->move(posX, posY);
}
void TabWidget::aboutToShowTabsMenu()
{
m_menuTabs->clear();
WebTab* actTab = weTab();
if (!actTab) {
return;
}
for (int i = 0; i < count(); i++) {
WebTab* tab = weTab(i);
if (!tab) {
continue;
}
QAction* action = new QAction(this);
if (tab == actTab) {
action->setIcon(QIcon(":/icons/menu/dot.png"));
}
else {
action->setIcon(tab->icon());
}
action->setIcon(i == currentIndex() ? QIcon(QSL(":/icons/menu/dot.png")) : tab->icon());
if (tab->title().isEmpty()) {
if (tab->isLoading()) {
action->setText(tr("Loading..."));
@ -295,29 +330,47 @@ void TabWidget::aboutToShowTabsMenu()
else {
QString title = tab->title();
title.replace(QLatin1Char('&'), QLatin1String("&&"));
if (title.length() > 40) {
title.truncate(40);
title += QLatin1String("..");
}
action->setText(title);
action->setText(QzTools::truncatedText(title, 40));
}
action->setData(QVariant::fromValue(qobject_cast<QWidget*>(tab)));
connect(action, SIGNAL(triggered()), this, SLOT(actionChangeIndex()));
m_menuTabs->addAction(action);
}
m_menuTabs->addSeparator();
m_menuTabs->addAction(tr("Currently you have %n opened tab(s)", "", count()))->setEnabled(false);
}
void TabWidget::aboutToShowClosedTabsMenu()
{
m_menuClosedTabs->clear();
int i = 0;
const QLinkedList<ClosedTabsManager::Tab> closedTabs = closedTabsManager()->allClosedTabs();
foreach (const ClosedTabsManager::Tab &tab, closedTabs) {
const QString title = QzTools::truncatedText(tab.title, 40);
QAction* act = m_menuClosedTabs->addAction(IconProvider::iconForUrl(tab.url), title, this, SLOT(restoreClosedTab()));
act->setData(i++);
}
if (m_menuClosedTabs->isEmpty()) {
m_menuClosedTabs->addAction(tr("Empty"))->setEnabled(false);
}
else {
m_menuClosedTabs->addSeparator();
m_menuClosedTabs->addAction(tr("Restore All Closed Tabs"), this, SLOT(restoreAllClosedTabs()));
m_menuClosedTabs->addAction(tr("Clear list"), this, SLOT(clearClosedTabsList()));
}
}
void TabWidget::actionChangeIndex()
{
if (QAction* action = qobject_cast<QAction*>(sender())) {
WebTab* tab = qobject_cast<WebTab*>(qvariant_cast<QWidget*>(action->data()));
if (tab) {
// needed when clicking on action of the current tab
m_tabBar->ensureVisible(tab->tabIndex());
setCurrentIndex(tab->tabIndex());
}
}
@ -517,7 +570,7 @@ void TabWidget::closeTab(int index, bool force)
m_lastBackgroundTabIndex = -1;
if (!m_closedInsteadOpened && m_menuTabs->isVisible()) {
if (m_menuTabs->isVisible()) {
QAction* labelAction = m_menuTabs->actions().last();
labelAction->setText(tr("Currently you have %n opened tab(s)", "", count() - 1));
}
@ -525,6 +578,8 @@ void TabWidget::closeTab(int index, bool force)
removeTab(index);
delete webTab;
updateClosedTabsButton();
emit changed();
}
@ -724,6 +779,7 @@ void TabWidget::restoreClosedTab(QObject* obj)
if (!obj) {
obj = sender();
}
if (!m_closedTabsManager->isClosedTabAvailable()) {
return;
}
@ -745,6 +801,8 @@ void TabWidget::restoreClosedTab(QObject* obj)
int index = addView(QUrl(), tab.title, Qz::NT_CleanSelectedTab, false, tab.position);
WebTab* webTab = weTab(index);
webTab->p_restoreTab(tab.url, tab.history);
updateClosedTabsButton();
}
void TabWidget::restoreAllClosedTabs()
@ -761,12 +819,13 @@ void TabWidget::restoreAllClosedTabs()
webTab->p_restoreTab(tab.url, tab.history);
}
m_closedTabsManager->clearList();
clearClosedTabsList();
}
void TabWidget::clearClosedTabsList()
{
m_closedTabsManager->clearList();
updateClosedTabsButton();
}
bool TabWidget::canRestoreTab() const
@ -779,9 +838,9 @@ QStackedWidget* TabWidget::locationBars() const
return m_locationBars;
}
ToolButton* TabWidget::buttonListTabs() const
ToolButton* TabWidget::buttonClosedTabs() const
{
return m_buttonListTabs;
return m_buttonClosedTabs;
}
AddTabButton* TabWidget::buttonAddTab() const
@ -789,44 +848,6 @@ AddTabButton* TabWidget::buttonAddTab() const
return m_buttonAddTab;
}
void TabWidget::aboutToShowClosedTabsMenu()
{
if (!m_closedInsteadOpened) {
aboutToShowTabsMenu();
}
else {
m_menuTabs->clear();
QAction* arestore = new QAction(tr("Restore All Closed Tabs"), this);
QAction* aclrlist = new QAction(QIcon::fromTheme("user-trash-full"), tr("Clear list"), this);
connect(arestore, SIGNAL(triggered()), this, SLOT(restoreAllClosedTabs()));
connect(aclrlist, SIGNAL(triggered()), this, SLOT(clearClosedTabsList()));
m_menuTabs->addAction(arestore);
m_menuTabs->addAction(aclrlist);
m_menuTabs->addSeparator();
int i = 0;
foreach (const ClosedTabsManager::Tab &tab, closedTabsManager()->allClosedTabs()) {
QString title = tab.title;
if (title.length() > 40) {
title.truncate(40);
title += "..";
}
m_menuTabs->addAction(IconProvider::iconForUrl(tab.url), title, this, SLOT(restoreClosedTab()))->setData(i);
i++;
}
if (i == 0) {
arestore->setVisible(false);
aclrlist->setVisible(false);
m_menuTabs->addAction(QIcon::fromTheme("user-trash"), tr("Empty"))->setEnabled(false);
}
}
}
QList<WebTab*> TabWidget::allTabs(bool withPinned)
{
QList<WebTab*> allTabs;

View File

@ -19,23 +19,21 @@
#define TABWIDGET_H
#include <QTabWidget>
#include <QUrl>
#include <QNetworkRequest>
#include <QMenu>
#include "tabstackedwidget.h"
#include "toolbutton.h"
#include "qzcommon.h"
#include "webtab.h"
#include "qzcommon.h"
class QStackedWidget;
class QMenu;
class BrowserWindow;
class TabbedWebView;
class TabBar;
class TabIcon;
class TabWidget;
class BrowserWindow;
class TabbedWebView;
class ClosedTabsManager;
class QUPZILLA_EXPORT AddTabButton : public ToolButton
@ -98,7 +96,7 @@ public:
bool canRestoreTab() const;
QStackedWidget* locationBars() const;
ToolButton* buttonListTabs() const;
ToolButton* buttonClosedTabs() const;
AddTabButton* buttonAddTab() const;
public slots:
@ -121,7 +119,6 @@ public slots:
void restoreClosedTab(QObject* obj = 0);
void restoreAllClosedTabs();
void clearClosedTabsList();
void aboutToShowClosedTabsMenu();
void moveAddTabButton(int posX);
void showButtons();
@ -136,39 +133,42 @@ private slots:
void loadSettings();
void aboutToShowTabsMenu();
void aboutToShowClosedTabsMenu();
void actionChangeIndex();
void tabMoved(int before, int after);
private:
WebTab* weTab();
WebTab* weTab(int index);
TabIcon* tabIcon(int index);
inline bool validIndex(int index) const { return index >= 0 && index < count(); }
bool m_dontCloseWithOneTab;
bool m_closedInsteadOpened;
bool m_newTabAfterActive;
bool m_newEmptyTabAfterActive;
QUrl m_urlOnNewTab;
bool validIndex(int index) const;
void updateClosedTabsButton();
BrowserWindow* m_window;
TabBar* m_tabBar;
QStackedWidget* m_locationBars;
ClosedTabsManager* m_closedTabsManager;
MenuTabs* m_menuTabs;
ToolButton* m_buttonListTabs;
QMenu* m_menuClosedTabs;
ToolButton* m_buttonClosedTabs;
ToolButton* m_buttonClosedTabs2;
AddTabButton* m_buttonAddTab;
AddTabButton* m_buttonAddTab2;
int m_lastTabIndex;
int m_lastBackgroundTabIndex;
bool m_isClosingToLastTabIndex;
bool m_isRestoringState;
TabBar* m_tabBar;
MenuTabs* m_menuTabs;
ToolButton* m_buttonListTabs;
AddTabButton* m_buttonAddTab;
ToolButton* m_buttonListTabs2;
AddTabButton* m_buttonAddTab2;
ClosedTabsManager* m_closedTabsManager;
QStackedWidget* m_locationBars;
bool m_dontCloseWithOneTab;
bool m_showClosedTabsButton;
bool m_newTabAfterActive;
bool m_newEmptyTabAfterActive;
QUrl m_urlOnNewTab;
};
#endif // TABWIDGET_H