QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskMessageSubWindow.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskMessageSubWindow.h"
7#include "QskTextLabel.h"
8
9namespace
10{
11 class TextLabel final : public QskTextLabel
12 {
13 public:
14 TextLabel()
15 {
16 setObjectName( QStringLiteral( "QskMessageSubWindowTextLabel" ) );
17
18 initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::ConstrainedExpanding );
19 setLayoutAlignmentHint( Qt::AlignLeft | Qt::AlignTop );
20
21 setAlignment( Qt::AlignLeft | Qt::AlignTop );
22 setWrapMode( QskTextOptions::WordWrap );
23 setElideMode( Qt::ElideRight );
24 }
25 };
26}
27
28QskMessageSubWindow::QskMessageSubWindow( QQuickItem* parent )
29 : Inherited( parent )
30{
31 auto label = new TextLabel();
32
33 connect( label, &QskTextLabel::textChanged,
34 this, &QskMessageSubWindow::textChanged );
35
36 connect( label, &QskTextLabel::textOptionsChanged,
37 this, &QskMessageSubWindow::textOptionsChanged );
38
39 setContentItem( label );
40}
41
42QskMessageSubWindow::~QskMessageSubWindow()
43{
44}
45
46void QskMessageSubWindow::setText( const QString& text )
47{
48 if ( auto label = qobject_cast< QskTextLabel* >( contentItem() ) )
49 label->setText( text );
50}
51
52QString QskMessageSubWindow::text() const
53{
54 if ( auto label = qobject_cast< const QskTextLabel* >( contentItem() ) )
55 return label->text();
56
57 return QString();
58}
59
60void QskMessageSubWindow::setTextOptions( const QskTextOptions& options )
61{
62 if ( auto label = qobject_cast< QskTextLabel* >( contentItem() ) )
63 label->setTextOptions( options );
64}
65
66QskTextOptions QskMessageSubWindow::textOptions() const
67{
68 if ( auto label = qobject_cast< const QskTextLabel* >( contentItem() ) )
69 return label->textOptions();
70
71 return QskTextOptions();
72}
73
74#include "moc_QskMessageSubWindow.cpp"
void setLayoutAlignmentHint(Qt::Alignment)
void initSizePolicy(QskSizePolicy::Policy, QskSizePolicy::Policy)