each window might have its own skin
This commit is contained in:
parent
2fceca2385
commit
e1a4e1fec3
|
@ -16,6 +16,7 @@
|
|||
#include "QskSkinHintTable.h"
|
||||
#include "QskSkinTransition.h"
|
||||
#include "QskSkinlet.h"
|
||||
#include "QskWindow.h"
|
||||
|
||||
#include "QskBoxShapeMetrics.h"
|
||||
#include "QskBoxBorderMetrics.h"
|
||||
|
@ -276,7 +277,7 @@ const QskSkinlet* QskSkinnable::effectiveSkinlet() const
|
|||
{
|
||||
if ( m_data->skinlet == nullptr )
|
||||
{
|
||||
m_data->skinlet = qskSetup->skin()->skinlet( metaObject() );
|
||||
m_data->skinlet = effectiveSkin()->skinlet( metaObject() );
|
||||
m_data->hasLocalSkinlet = false;
|
||||
}
|
||||
|
||||
|
@ -1198,6 +1199,17 @@ QskSkin* QskSkinnable::effectiveSkin() const
|
|||
if ( m_data->skinlet )
|
||||
skin = m_data->skinlet->skin();
|
||||
|
||||
if ( skin == nullptr )
|
||||
{
|
||||
if ( const auto control = owningControl() )
|
||||
{
|
||||
if ( auto window = qobject_cast< const QskWindow* >( control->window() ) )
|
||||
{
|
||||
skin = window->skin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return skin ? skin : qskSetup->skin();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "QskEvent.h"
|
||||
#include "QskQuick.h"
|
||||
#include "QskSetup.h"
|
||||
#include "QskSkin.h"
|
||||
#include "QskSkinManager.h"
|
||||
|
||||
#include <qmath.h>
|
||||
#include <qpointer.h>
|
||||
|
@ -144,6 +146,8 @@ class QskWindowPrivate : public QQuickWindowPrivate
|
|||
QElapsedTimer renderInterval;
|
||||
#endif
|
||||
|
||||
QPointer< QskSkin > skin;
|
||||
|
||||
ChildListener contentItemListener;
|
||||
QLocale locale;
|
||||
|
||||
|
@ -643,4 +647,35 @@ QskWindow::EventAcceptance QskWindow::eventAcceptance() const
|
|||
return d_func()->eventAcceptance;
|
||||
}
|
||||
|
||||
void QskWindow::setSkin( const QString& skinName )
|
||||
{
|
||||
// we should compare the skinName with the previous one
|
||||
auto skin = QskSkinManager::instance()->createSkin( skinName );
|
||||
setSkin( skin );
|
||||
}
|
||||
|
||||
void QskWindow::setSkin( QskSkin* skin )
|
||||
{
|
||||
Q_D( QskWindow );
|
||||
|
||||
if ( d->skin == skin )
|
||||
return;
|
||||
|
||||
if ( d->skin )
|
||||
{
|
||||
if ( d->skin->parent() == this )
|
||||
delete d->skin;
|
||||
}
|
||||
|
||||
if ( skin && skin->parent() == nullptr )
|
||||
skin->setParent( this );
|
||||
|
||||
d->skin = skin;
|
||||
}
|
||||
|
||||
QskSkin* QskWindow::skin() const
|
||||
{
|
||||
return d_func()->skin;
|
||||
}
|
||||
|
||||
#include "moc_QskWindow.cpp"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
class QskWindowPrivate;
|
||||
class QskObjectAttributes;
|
||||
class QskSkin;
|
||||
|
||||
class QSK_EXPORT QskWindow : public QQuickWindow
|
||||
{
|
||||
|
@ -69,6 +70,11 @@ class QSK_EXPORT QskWindow : public QQuickWindow
|
|||
void setEventAcceptance( EventAcceptance );
|
||||
EventAcceptance eventAcceptance() const;
|
||||
|
||||
// each window might have its own skin
|
||||
void setSkin( QskSkin* );
|
||||
void setSkin( const QString& );
|
||||
QskSkin* skin() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void localeChanged( const QLocale& );
|
||||
void autoLayoutChildrenChanged();
|
||||
|
|
Loading…
Reference in New Issue