6#include "QskSubWindow.h"
9#include "QskGraphicProvider.h"
10#include "QskTextOptions.h"
28class QskSubWindow::PrivateData
32 : isWindowIconSourceDirty( false )
38 QUrl windowIconSource;
41 bool isWindowIconSourceDirty : 1;
44QskSubWindow::QskSubWindow( QQuickItem* parent )
46 , m_data( new PrivateData() )
49 initSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::MinimumExpanding );
51 setAutoLayoutChildren(
true );
54QskSubWindow::~QskSubWindow()
58void QskSubWindow::setDecorations( Decorations decorations )
60 if (
setFlagHint( aspectDecoration(), decorations ) )
61 Q_EMIT decorationsChanged( decorations );
64QskSubWindow::Decorations QskSubWindow::decorations()
const
66 return flagHint< QskSubWindow::Decorations >( aspectDecoration() );
69void QskSubWindow::setDecoration( Decoration decoration,
bool on )
71 auto d = decorations();
81void QskSubWindow::resetDecorations()
84 Q_EMIT decorationsChanged( decorations() );
87bool QskSubWindow::hasDecoration( Decoration decoration )
const
89 return decorations() & decoration;
92void QskSubWindow::setWindowTitle(
const QString& title )
94 if ( m_data->windowTitle != title )
96 m_data->windowTitle = title;
99 Q_EMIT windowTitleChanged();
103QString QskSubWindow::windowTitle()
const
105 return m_data->windowTitle;
108void QskSubWindow::setWindowTitleTextOptions(
const QskTextOptions& options )
110 if ( setTextOptionsHint( TitleBarText, options ) )
111 Q_EMIT windowTitleTextOptionsChanged();
116 return textOptionsHint( TitleBarText );
119void QskSubWindow::setWindowIconSource(
const QString& url )
121 setWindowIconSource( QUrl( url ) );
124void QskSubWindow::setWindowIconSource(
const QUrl& url )
126 if ( m_data->windowIconSource == url )
129 m_data->windowIconSource = url;
130 m_data->windowIcon.reset();
132 m_data->isWindowIconSourceDirty =
true;
137 Q_EMIT windowIconSourceChanged();
140QUrl QskSubWindow::windowIconSource()
const
142 return m_data->windowIconSource;
145void QskSubWindow::setWindowIcon(
const QskGraphic& graphic )
147 if ( graphic != m_data->windowIcon )
149 m_data->windowIcon = graphic;
151 if ( !m_data->windowIconSource.isEmpty() )
153 m_data->windowIconSource = QString();
154 m_data->isWindowIconSourceDirty =
false;
156 Q_EMIT windowIconSourceChanged();
162 Q_EMIT windowIconChanged();
168 return m_data->windowIcon;
171bool QskSubWindow::hasWindowIcon()
const
173 return !( windowIcon().isEmpty() && windowIconSource().isEmpty() );
176QRectF QskSubWindow::titleBarRect()
const
181bool QskSubWindow::event( QEvent* event )
183 if ( event->type() == QEvent::LayoutRequest )
186 return Inherited::event( event );
189void QskSubWindow::updateLayout()
191 if ( m_data->isWindowIconSourceDirty )
193 if ( !m_data->windowIconSource.isEmpty() )
195 m_data->windowIcon = Qsk::loadGraphic( m_data->windowIconSource );
196 Q_EMIT windowIconChanged();
199 m_data->isWindowIconSourceDirty =
false;
202 Inherited::updateLayout();
208 rect.setSize( size );
214QSizeF QskSubWindow::layoutSizeHint(
215 Qt::SizeHint which,
const QSizeF& constraint )
const
218 auto hint = Inherited::layoutSizeHint( which, constraint );
220 if ( which == Qt::PreferredSize )
223 if ( hint.width() < 0.0 )
224 hint.setWidth( 100 );
226 if ( hint.height() < 0.0 )
227 hint.setHeight( 80 );
233void QskSubWindow::itemChange( QQuickItem::ItemChange change,
234 const QQuickItem::ItemChangeData& value )
236 Inherited::itemChange( change, value );
240 case QQuickItem::ItemChildAddedChange:
241 case QQuickItem::ItemChildRemovedChange:
243 if ( qskIsVisibleToLayout( value.item ) )
255void QskSubWindow::updateResources()
257 setOpacity( fadingFactor() );
258 Inherited::updateResources();
261QskAspect QskSubWindow::fadingAspect()
const
266#include "moc_QskSubWindow.cpp"
Lookup key for a QskSkinHintTable.
QRectF subControlRect(QskAspect::Subcontrol) const
A paint device for scalable graphics.
bool resetSkinHint(QskAspect)
Remove a hint from the local hint table.
bool setFlagHint(QskAspect, int flag)
Sets a flag hint.
QRectF innerBox(QskAspect, const QRectF &outerBox) const
Calculate the rectangle, whith paddings, indentations being subtracted.
QRectF layoutRectForSize(const QSizeF &) const override