qtquick: Move the "tabbar autohide" property to TabBar
It's a better location than in Stack
This commit is contained in:
@@ -30,6 +30,7 @@ Controllers::TabBar::TabBar(Stack *tabWidget)
|
||||
, Draggable(view())
|
||||
, m_tabWidget(tabWidget)
|
||||
{
|
||||
view()->init();
|
||||
}
|
||||
|
||||
Controllers::TabBar::~TabBar()
|
||||
@@ -177,6 +178,11 @@ Group *Controllers::TabBar::group() const
|
||||
return m_tabWidget->group();
|
||||
}
|
||||
|
||||
Stack *TabBar::stack() const
|
||||
{
|
||||
return m_tabWidget;
|
||||
}
|
||||
|
||||
void Controllers::TabBar::moveTabTo(int from, int to)
|
||||
{
|
||||
dynamic_cast<Views::TabBarViewInterface *>(view())->moveTabTo(from, to);
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
bool isMDI() const override;
|
||||
|
||||
Group *group() const;
|
||||
Stack *stack() const;
|
||||
|
||||
void moveTabTo(int from, int to);
|
||||
QString text(int index) const;
|
||||
|
||||
@@ -47,8 +47,6 @@ class DOCKS_EXPORT Stack_qtquick
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(DockWidgetModel *dockWidgetModel READ dockWidgetModel CONSTANT)
|
||||
Q_PROPERTY(QObject *tabBar READ tabBarViewObj NOTIFY tabBarChanged)
|
||||
Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide NOTIFY tabBarAutoHideChanged)
|
||||
|
||||
public:
|
||||
explicit Stack_qtquick(Controllers::Stack *controller,
|
||||
QQuickItem *parent = nullptr);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "TabBar_qtquick.h"
|
||||
#include "kddockwidgets/controllers/TabBar.h"
|
||||
#include "kddockwidgets/controllers/Stack.h"
|
||||
|
||||
#include <QMetaObject>
|
||||
#include <QMouseEvent>
|
||||
@@ -32,6 +33,13 @@ TabBar_qtquick::TabBar_qtquick(Controllers::TabBar *controller, QQuickItem *pare
|
||||
{
|
||||
}
|
||||
|
||||
void TabBar_qtquick::init()
|
||||
{
|
||||
m_tabBarAutoHideChanged = m_tabBar->stack()->tabBarAutoHideChanged.connect([this] {
|
||||
Q_EMIT tabBarAutoHideChanged();
|
||||
});
|
||||
}
|
||||
|
||||
QHash<int, QQuickItem *> TabBar_qtquick::qmlTabs() const
|
||||
{
|
||||
if (!m_tabBarQmlItem) {
|
||||
@@ -171,3 +179,8 @@ bool TabBar_qtquick::tabsAreMovable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TabBar_qtquick::tabBarAutoHide() const
|
||||
{
|
||||
return m_tabBar->stack()->tabBarAutoHide();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <QPointer>
|
||||
#include <QHash>
|
||||
|
||||
#include "kdbindings/signal.h"
|
||||
|
||||
namespace KDDockWidgets::Controllers {
|
||||
class TabBar;
|
||||
}
|
||||
@@ -42,6 +44,7 @@ class DOCKS_EXPORT TabBar_qtquick
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QQuickItem *tabBarQmlItem READ tabBarQmlItem WRITE setTabBarQmlItem NOTIFY tabBarQmlItemChanged)
|
||||
Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide NOTIFY tabBarAutoHideChanged)
|
||||
public:
|
||||
explicit TabBar_qtquick(Controllers::TabBar *controller, QQuickItem *parent = nullptr);
|
||||
int tabAt(QPoint localPos) const override;
|
||||
@@ -56,17 +59,24 @@ public:
|
||||
Controllers::DockWidget *currentDockWidget() const override;
|
||||
bool tabsAreMovable() const override;
|
||||
|
||||
/// Returns whether the tab bar should hide when there's only 1 tab visible
|
||||
/// Default true, unless Flag_HideTitleBarWhenTabsVisible
|
||||
bool tabBarAutoHide() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void tabBarQmlItemChanged();
|
||||
void tabBarAutoHideChanged();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *ev) override;
|
||||
void init() override;
|
||||
|
||||
private:
|
||||
QHash<int, QQuickItem *> qmlTabs() const;
|
||||
QQuickItem *tabAt(int index) const;
|
||||
QQuickItem *listView() const;
|
||||
QPointer<QQuickItem> m_tabBarQmlItem;
|
||||
KDBindings::ScopedConnection m_tabBarAutoHideChanged;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user