mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
[ClosedTabsButton] No longer needed to have two copies of button
ClosedTabsButton is now permanent right corner widget
This commit is contained in:
parent
5c8afde4d9
commit
ed823d4d50
@ -847,9 +847,10 @@ void ComboTabBar::setMinimumWidths()
|
|||||||
comboTabBarPixelMetric(ActiveTabMinimumWidth) +
|
comboTabBarPixelMetric(ActiveTabMinimumWidth) +
|
||||||
comboTabBarPixelMetric(ExtraReservedWidth);
|
comboTabBarPixelMetric(ExtraReservedWidth);
|
||||||
|
|
||||||
// This is the full width that would be needed for the tabbar (including pinned tabbar)
|
// This is the full width that would be needed for the tabbar (including pinned tabbar and corner widgets)
|
||||||
int realTabBarWidth = mainTabBarWidth + m_pinnedTabBarWidget->width() +
|
int realTabBarWidth = mainTabBarWidth + m_pinnedTabBarWidget->width() +
|
||||||
cornerWidth(Qt::TopLeftCorner);
|
cornerWidth(Qt::TopLeftCorner) +
|
||||||
|
cornerWidth(Qt::TopRightCorner);
|
||||||
|
|
||||||
// Does it fit in our widget?
|
// Does it fit in our widget?
|
||||||
if (realTabBarWidth <= width()) {
|
if (realTabBarWidth <= width()) {
|
||||||
|
@ -684,22 +684,6 @@ bool TabBar::event(QEvent* event)
|
|||||||
return ComboTabBar::event(event);
|
return ComboTabBar::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabBar::resizeEvent(QResizeEvent* e)
|
|
||||||
{
|
|
||||||
QPoint posit;
|
|
||||||
posit.setY(0);
|
|
||||||
|
|
||||||
if (isRightToLeft()) {
|
|
||||||
posit.setX(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
posit.setX(width() - m_tabWidget->buttonClosedTabs()->width());
|
|
||||||
}
|
|
||||||
m_tabWidget->buttonClosedTabs()->move(posit);
|
|
||||||
|
|
||||||
ComboTabBar::resizeEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabBar::wheelEvent(QWheelEvent* event)
|
void TabBar::wheelEvent(QWheelEvent* event)
|
||||||
{
|
{
|
||||||
if (mApp->plugins()->processWheelEvent(Qz::ON_TabBar, this, event)) {
|
if (mApp->plugins()->processWheelEvent(Qz::ON_TabBar, this, event)) {
|
||||||
|
@ -92,7 +92,6 @@ private:
|
|||||||
void mouseMoveEvent(QMouseEvent* event);
|
void mouseMoveEvent(QMouseEvent* event);
|
||||||
void mouseReleaseEvent(QMouseEvent* event);
|
void mouseReleaseEvent(QMouseEvent* event);
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event);
|
||||||
void resizeEvent(QResizeEvent* e);
|
|
||||||
|
|
||||||
void dragEnterEvent(QDragEnterEvent* event);
|
void dragEnterEvent(QDragEnterEvent* event);
|
||||||
void dropEvent(QDropEvent* event);
|
void dropEvent(QDropEvent* event);
|
||||||
|
@ -145,7 +145,17 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
|
|||||||
|
|
||||||
m_menuClosedTabs = new QMenu(this);
|
m_menuClosedTabs = new QMenu(this);
|
||||||
|
|
||||||
// ClosedTabs button displayed in the right corner of tabbar
|
// AddTab button displayed next to last tab
|
||||||
|
m_buttonAddTab = new AddTabButton(this, m_tabBar);
|
||||||
|
connect(m_buttonAddTab, SIGNAL(clicked()), m_window, SLOT(addTab()));
|
||||||
|
|
||||||
|
// 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 as a permanent corner widget
|
||||||
m_buttonClosedTabs = new ToolButton(m_tabBar);
|
m_buttonClosedTabs = new ToolButton(m_tabBar);
|
||||||
m_buttonClosedTabs->setObjectName("tabwidget-button-closedtabs");
|
m_buttonClosedTabs->setObjectName("tabwidget-button-closedtabs");
|
||||||
m_buttonClosedTabs->setMenu(m_menuClosedTabs);
|
m_buttonClosedTabs->setMenu(m_menuClosedTabs);
|
||||||
@ -156,10 +166,6 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
|
|||||||
m_buttonClosedTabs->setShowMenuInside(true);
|
m_buttonClosedTabs->setShowMenuInside(true);
|
||||||
connect(m_buttonClosedTabs, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowClosedTabsMenu()));
|
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
|
// ListTabs button is showed only when tabbar overflows
|
||||||
m_buttonListTabs = new ToolButton(m_tabBar);
|
m_buttonListTabs = new ToolButton(m_tabBar);
|
||||||
m_buttonListTabs->setObjectName("tabwidget-button-opentabs");
|
m_buttonListTabs->setObjectName("tabwidget-button-opentabs");
|
||||||
@ -172,26 +178,8 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
|
|||||||
m_buttonListTabs->hide();
|
m_buttonListTabs->hide();
|
||||||
connect(m_buttonListTabs, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowTabsMenu()));
|
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->addCornerWidget(m_buttonAddTab2, Qt::TopRightCorner);
|
m_tabBar->addCornerWidget(m_buttonAddTab2, Qt::TopRightCorner);
|
||||||
m_tabBar->addCornerWidget(m_buttonClosedTabs2, Qt::TopRightCorner);
|
m_tabBar->addCornerWidget(m_buttonClosedTabs, Qt::TopRightCorner);
|
||||||
m_tabBar->addCornerWidget(m_buttonListTabs, Qt::TopRightCorner);
|
m_tabBar->addCornerWidget(m_buttonListTabs, Qt::TopRightCorner);
|
||||||
connect(m_tabBar, SIGNAL(overFlowChanged(bool)), this, SLOT(tabBarOverFlowChanged(bool)));
|
connect(m_tabBar, SIGNAL(overFlowChanged(bool)), this, SLOT(tabBarOverFlowChanged(bool)));
|
||||||
|
|
||||||
@ -241,35 +229,31 @@ void TabWidget::updateClosedTabsButton()
|
|||||||
{
|
{
|
||||||
if (!m_showClosedTabsButton) {
|
if (!m_showClosedTabsButton) {
|
||||||
m_buttonClosedTabs->hide();
|
m_buttonClosedTabs->hide();
|
||||||
m_buttonClosedTabs2->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_buttonClosedTabs->setEnabled(canRestoreTab());
|
m_buttonClosedTabs->setEnabled(canRestoreTab());
|
||||||
m_buttonClosedTabs2->setEnabled(canRestoreTab());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::tabBarOverFlowChanged(bool overflowed)
|
void TabWidget::tabBarOverFlowChanged(bool overflowed)
|
||||||
{
|
{
|
||||||
// Show buttons inside tabbar
|
// Show buttons inside tabbar
|
||||||
m_buttonClosedTabs->setVisible(m_showClosedTabsButton && !overflowed);
|
|
||||||
m_buttonAddTab->setVisible(!overflowed);
|
m_buttonAddTab->setVisible(!overflowed);
|
||||||
|
|
||||||
// Show buttons displayed outside tabbar (corner widgets)
|
// Show buttons displayed outside tabbar (corner widgets)
|
||||||
m_buttonAddTab2->setVisible(overflowed);
|
m_buttonAddTab2->setVisible(overflowed);
|
||||||
m_buttonClosedTabs2->setVisible(m_showClosedTabsButton && overflowed);
|
|
||||||
m_buttonListTabs->setVisible(overflowed);
|
m_buttonListTabs->setVisible(overflowed);
|
||||||
|
m_buttonClosedTabs->setVisible(m_showClosedTabsButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::moveAddTabButton(int posX)
|
void TabWidget::moveAddTabButton(int posX)
|
||||||
{
|
{
|
||||||
int posY = (m_tabBar->height() - m_buttonAddTab->height()) / 2;
|
int posY = (m_tabBar->height() - m_buttonAddTab->height()) / 2;
|
||||||
int buttonclosedTabsWidth = m_buttonClosedTabs->isVisible() ? m_buttonClosedTabs->width() : 0;
|
|
||||||
|
|
||||||
if (QApplication::layoutDirection() == Qt::RightToLeft) {
|
if (QApplication::layoutDirection() == Qt::RightToLeft) {
|
||||||
posX = qMax(posX - m_buttonAddTab->width(), buttonclosedTabsWidth);
|
posX = qMax(posX - m_buttonAddTab->width(), 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
posX = qMin(posX, m_tabBar->width() - m_buttonAddTab->width() - buttonclosedTabsWidth);
|
posX = qMin(posX, m_tabBar->width() - m_buttonAddTab->width());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_buttonAddTab->move(posX, posY);
|
m_buttonAddTab->move(posX, posY);
|
||||||
@ -616,8 +600,7 @@ int TabWidget::lastTabIndex() const
|
|||||||
|
|
||||||
int TabWidget::extraReservedWidth() const
|
int TabWidget::extraReservedWidth() const
|
||||||
{
|
{
|
||||||
int w = m_buttonAddTab->width();
|
return m_buttonAddTab->width();
|
||||||
return m_showClosedTabsButton ? w + m_buttonClosedTabs->width() : w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TabBar* TabWidget::getTabBar() const
|
TabBar* TabWidget::getTabBar() const
|
||||||
|
@ -150,7 +150,6 @@ private:
|
|||||||
ToolButton* m_buttonListTabs;
|
ToolButton* m_buttonListTabs;
|
||||||
QMenu* m_menuClosedTabs;
|
QMenu* m_menuClosedTabs;
|
||||||
ToolButton* m_buttonClosedTabs;
|
ToolButton* m_buttonClosedTabs;
|
||||||
ToolButton* m_buttonClosedTabs2;
|
|
||||||
AddTabButton* m_buttonAddTab;
|
AddTabButton* m_buttonAddTab;
|
||||||
AddTabButton* m_buttonAddTab2;
|
AddTabButton* m_buttonAddTab2;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user