text box reimplemented
This commit is contained in:
parent
a40ca46556
commit
ff8b4245a6
@ -8,29 +8,51 @@
|
||||
#include <QskGraphicLabel.h>
|
||||
#include <QskSeparator.h>
|
||||
#include <QskRgbValue.h>
|
||||
#include <QskSkin.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
class TextLabel : public QskTextLabel
|
||||
{
|
||||
public:
|
||||
TextLabel( int role, QQuickItem* parent = nullptr )
|
||||
: QskTextLabel( parent )
|
||||
{
|
||||
setText( textFromRole( role ) );
|
||||
setFontRole( role );
|
||||
|
||||
setSizePolicy( Qt::Horizontal, QskSizePolicy::Ignored );
|
||||
}
|
||||
|
||||
private:
|
||||
QString textFromRole( int role ) const
|
||||
{
|
||||
static QMetaEnum metaEnum;
|
||||
|
||||
if ( !metaEnum.isValid() )
|
||||
{
|
||||
const auto& mo = QskSkin::staticMetaObject;
|
||||
metaEnum = mo.enumerator( mo.indexOfEnumerator( "SkinFontRole" ) );
|
||||
}
|
||||
|
||||
QString s( metaEnum.valueToKey( role ) );
|
||||
s.remove( QStringLiteral( "Font" ) );
|
||||
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
class TextBox : public QskLinearBox
|
||||
{
|
||||
public:
|
||||
TextBox( QQuickItem* parent = nullptr )
|
||||
: QskLinearBox( Qt::Vertical, 3, parent )
|
||||
: QskLinearBox( Qt::Horizontal, 3, parent )
|
||||
{
|
||||
setMargins( 10 );
|
||||
//setDefaultAlignment( Qt::AlignTop );
|
||||
setExtraSpacingAt( Qt::BottomEdge );
|
||||
setDefaultAlignment( Qt::AlignCenter );
|
||||
|
||||
const QStringList texts =
|
||||
{ "Default", "Tiny", "Small", "Medium", "Large", "Huge" };
|
||||
|
||||
for ( int i = 0; i < texts.size(); i++ )
|
||||
{
|
||||
auto label = new QskTextLabel( texts[ i ] + " Font", this );
|
||||
|
||||
//label->setPanel( true );
|
||||
label->setFontRole( i );
|
||||
}
|
||||
for ( int i = 0; i <= QskSkin::HugeFont; i++ )
|
||||
( void ) new TextLabel( i, this );
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user