style diagram

This commit is contained in:
Peter Hartmann 2021-04-07 10:38:03 +02:00
parent f9d60a11bf
commit f5c018ac43
3 changed files with 31 additions and 32 deletions

View File

@ -14,43 +14,22 @@
QSK_SUBCONTROL( WeekdayBox, Panel )
WeekdayBox::WeekdayBox( QQuickItem* parent )
: QskBox( true, parent )
CaptionItem::CaptionItem( const QColor& color, const QString& text, QQuickItem* parent )
: QskLinearBox( Qt::Horizontal, parent )
{
setBoxBorderMetricsHint( WeekdayBox::Panel, {0, 0, 3, 3} );
}
setSpacing( 10 );
auto* box = new QskBox( true, this );
box->setGradientHint( QskBox::Panel, color );
QskAspect::Subcontrol WeekdayBox::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const
{
if( subControl == QskBox::Panel )
{
return WeekdayBox::Panel;
}
auto* textLabel = new QskTextLabel( text, this );
textLabel->setFontRole( QskSkin::TinyFont );
return subControl;
box->setFixedSize( 8, 8 );
box->setBoxShapeHint( QskBox::Panel, 4 );
}
namespace
{
class CaptionItem : public QskLinearBox
{
Q_OBJECT
public:
CaptionItem( const QColor& color, const QString& text, QQuickItem* parent )
: QskLinearBox( Qt::Horizontal, parent )
{
setSpacing( 10 );
auto* box = new QskBox( true, this );
box->setGradientHint( QskBox::Panel, color );
auto* textLabel = new QskTextLabel( text, this );
textLabel->setFontRole( QskSkin::TinyFont );
box->setFixedSize( 8, 8 );
box->setBoxShapeHint( QskBox::Panel, 4 );
}
};
float distance( const QPointF& pt1, const QPointF& pt2 )
{

View File

@ -15,10 +15,27 @@ class WeekdayBox : public QskBox
public:
QSK_SUBCONTROLS( Panel )
WeekdayBox( QQuickItem* parent );
WeekdayBox( QQuickItem* parent ) : QskBox( true, parent )
{
}
QskAspect::Subcontrol effectiveSubcontrol(
QskAspect::Subcontrol subControl ) const override final;
QskAspect::Subcontrol subControl ) const override final
{
if( subControl == QskBox::Panel )
{
return WeekdayBox::Panel;
}
return subControl;
}
};
class CaptionItem : public QskLinearBox
{
Q_OBJECT
public:
CaptionItem( const QColor& color, const QString& text, QQuickItem* parent );
};
class Diagram : public Box

View File

@ -109,6 +109,9 @@ void Skin::initHints( const Palette& palette )
ed.setMetric( RoundedIcon::Panel | RoundedIcon::Small | QskAspect::Size, 60 );
ed.setMetric( RoundedIcon::Icon | QskAspect::Size, 36 );
// diagram:
ed.setBoxBorderMetrics( WeekdayBox::Panel, {0, 0, 3, 3} );
// palette dependent skin hints:
ed.setGradient( MenuBar::Panel, palette.menuBar );
ed.setGradient( MainContent::Panel, palette.mainContent );