Store the "tab auto hide" state in the controller, not the view

Added a signal for the QtQuick view too
This commit is contained in:
Sergio Martins
2022-07-07 13:52:03 +01:00
parent 448313b1e3
commit 019692fd2f
7 changed files with 47 additions and 15 deletions

View File

@@ -26,6 +26,8 @@
#include <QAbstractListModel>
#include <QVector>
#include "kdbindings/signal.h"
namespace KDDockWidgets {
namespace Controllers {
class DockWidget;
@@ -45,6 +47,7 @@ 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,
@@ -68,12 +71,16 @@ public:
/// @brief Returns the stack controller associated with this view
Controllers::Stack *stack() const;
/// 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 tabBarChanged();
void tabBarAutoHideChanged();
protected:
bool isPositionDraggable(QPoint p) const override;
void setTabBarAutoHide(bool) override;
void renameTab(int index, const QString &) override;
void changeTabIcon(int index, const QIcon &) override;
void init() override;
@@ -82,13 +89,15 @@ private:
Q_DISABLE_COPY(Stack_qtquick)
DockWidgetModel *const m_dockWidgetModel;
Controllers::DockWidget *m_currentDockWidget = nullptr;
KDBindings::ScopedConnection m_tabBarAutoHideChanged;
};
class DockWidgetModel : public QAbstractListModel
{
Q_OBJECT
public:
enum Role {
enum Role
{
Role_Title = Qt::UserRole
};