From 07e3cf7fd6d00c5a7a5745ebcd507d1896f706eb Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 12 Jul 2022 16:51:39 +0200 Subject: [PATCH] Add top level application view --- examples/gallery/main.cpp | 13 ++-- src/controls/QskApplicationView.cpp | 95 +++++++++++++++++++++++++++++ src/controls/QskApplicationView.h | 35 +++++++++++ src/src.pro | 2 + 4 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 src/controls/QskApplicationView.cpp create mode 100644 src/controls/QskApplicationView.h diff --git a/examples/gallery/main.cpp b/examples/gallery/main.cpp index 06639d77..1bbccc71 100644 --- a/examples/gallery/main.cpp +++ b/examples/gallery/main.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -42,7 +43,6 @@ namespace { setTabBarEdge( Qt::BottomEdge ); setAutoFitTabs( true ); - setSection( QskAspect::Footer ); } void setTabsEnabled( bool on ) @@ -164,8 +164,6 @@ namespace initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::Fixed ); setPanel( true ); - setSection( QskAspect::Header ); - new FileButton( "File", this ); new SkinButton( "Skin", this ); @@ -186,14 +184,12 @@ namespace void enabledToggled( bool ); }; - class ApplicationView : public QskLinearBox + class ApplicationView : public QskApplicationView { public: ApplicationView( QQuickItem* parent = nullptr ) - : QskLinearBox( Qt::Vertical, parent ) + : QskApplicationView( parent ) { - setSpacing( 0 ); - auto header = new Header( this ); auto tabView = new TabView( this ); @@ -207,6 +203,9 @@ namespace connect( header, &Header::enabledToggled, tabView, &TabView::setTabsEnabled ); + + setHeader( header ); + setFooter( tabView ); } }; } diff --git a/src/controls/QskApplicationView.cpp b/src/controls/QskApplicationView.cpp new file mode 100644 index 00000000..18c6b14f --- /dev/null +++ b/src/controls/QskApplicationView.cpp @@ -0,0 +1,95 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2022 Uwe Rathmann + * This file may be used under the terms of the QSkinny License, Version 1.0 + *****************************************************************************/ + +#include "QskApplicationView.h" + +class QskApplicationView::PrivateData +{ + public: + PrivateData() + { + } + + QskControl* header = nullptr; + QskControl* body = nullptr; + QskControl* footer = nullptr; +}; + +QskApplicationView::QskApplicationView( QQuickItem* parent ) + : Inherited( Qt::Vertical, parent ) + , m_data( new PrivateData ) +{ + setAutoAddChildren( false ); + setSpacing( 0 ); +} + +QskApplicationView::~QskApplicationView() +{ +} + +QskControl* QskApplicationView::header() const +{ + return m_data->header; +} + +void QskApplicationView::setHeader( QskControl* header ) +{ + if( m_data->header ) + { + removeItem( m_data->header ); + } + + m_data->header = header; + + if( m_data->header ) + { + m_data->header->setSection( QskAspect::Header ); + insertItem( 0, m_data->header ); + } +} + +QskControl* QskApplicationView::body() const +{ + return m_data->body; +} + +void QskApplicationView::setBody( QskControl* body ) +{ + if( m_data->body ) + { + removeItem( m_data->body ); + } + + m_data->body = body; + + if( m_data->body ) + { + m_data->body->setSection( QskAspect::Body ); + insertItem( 1, m_data->body ); + } +} + +QskControl* QskApplicationView::footer() const +{ + return m_data->footer; +} + +void QskApplicationView::setFooter( QskControl* footer ) +{ + if( m_data->footer ) + { + removeItem( m_data->footer ); + } + + m_data->footer = footer; + + if( m_data->footer ) + { + m_data->footer->setSection( QskAspect::Footer ); + insertItem( 2, m_data->footer ); + } +} + +#include "moc_QskApplicationView.cpp" diff --git a/src/controls/QskApplicationView.h b/src/controls/QskApplicationView.h new file mode 100644 index 00000000..c0cfa35e --- /dev/null +++ b/src/controls/QskApplicationView.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2022 Uwe Rathmann + * This file may be used under the terms of the QSkinny License, Version 1.0 + *****************************************************************************/ + +#ifndef QSK_APPLICATION_VIEW_H +#define QSK_APPLICATION_VIEW_H + +#include "QskLinearBox.h" + +class QSK_EXPORT QskApplicationView : public QskLinearBox +{ + Q_OBJECT + + using Inherited = QskLinearBox; + + public: + QskApplicationView( QQuickItem* parent = nullptr ); + ~QskApplicationView() override; + + QskControl* header() const; + void setHeader( QskControl* ); + + QskControl* body() const; + void setBody( QskControl* ); + + QskControl* footer() const; + void setFooter( QskControl* ); + + private: + class PrivateData; + std::unique_ptr< PrivateData > m_data; +}; + +#endif diff --git a/src/src.pro b/src/src.pro index 125283a3..da3723ec 100644 --- a/src/src.pro +++ b/src/src.pro @@ -146,6 +146,7 @@ HEADERS += \ controls/QskAbstractButton.h \ controls/QskAnimationHint.h \ controls/QskAnimator.h \ + controls/QskApplicationView.h \ controls/QskBoundedControl.h \ controls/QskBoundedInput.h \ controls/QskBoundedRangeInput.h \ @@ -230,6 +231,7 @@ SOURCES += \ controls/QskAbstractButton.cpp \ controls/QskAnimator.cpp \ controls/QskAnimationHint.cpp \ + controls/QskApplicationView.cpp \ controls/QskBoundedControl.cpp \ controls/QskBoundedInput.cpp \ controls/QskBoundedRangeInput.cpp \