text box reimplemented
This commit is contained in:
parent
a40ca46556
commit
ff8b4245a6
|
@ -8,29 +8,51 @@
|
||||||
#include <QskGraphicLabel.h>
|
#include <QskGraphicLabel.h>
|
||||||
#include <QskSeparator.h>
|
#include <QskSeparator.h>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
#include <QskSkin.h>
|
||||||
|
|
||||||
namespace
|
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
|
class TextBox : public QskLinearBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextBox( QQuickItem* parent = nullptr )
|
TextBox( QQuickItem* parent = nullptr )
|
||||||
: QskLinearBox( Qt::Vertical, 3, parent )
|
: QskLinearBox( Qt::Horizontal, 3, parent )
|
||||||
{
|
{
|
||||||
setMargins( 10 );
|
setMargins( 10 );
|
||||||
//setDefaultAlignment( Qt::AlignTop );
|
setDefaultAlignment( Qt::AlignCenter );
|
||||||
setExtraSpacingAt( Qt::BottomEdge );
|
|
||||||
|
|
||||||
const QStringList texts =
|
for ( int i = 0; i <= QskSkin::HugeFont; i++ )
|
||||||
{ "Default", "Tiny", "Small", "Medium", "Large", "Huge" };
|
( void ) new TextLabel( i, this );
|
||||||
|
|
||||||
for ( int i = 0; i < texts.size(); i++ )
|
|
||||||
{
|
|
||||||
auto label = new QskTextLabel( texts[ i ] + " Font", this );
|
|
||||||
|
|
||||||
//label->setPanel( true );
|
|
||||||
label->setFontRole( i );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue