qskinny/src/dialogs/QskMessageSubWindow.cpp

75 lines
2.0 KiB
C++
Raw Normal View History

2017-07-21 16:21:34 +00:00
/******************************************************************************
2024-01-17 13:31:45 +00:00
* QSkinny - Copyright (C) The authors
2023-04-06 07:23:37 +00:00
* SPDX-License-Identifier: BSD-3-Clause
2017-07-21 16:21:34 +00:00
*****************************************************************************/
#include "QskMessageSubWindow.h"
2018-11-06 17:54:21 +00:00
#include "QskTextLabel.h"
namespace
{
class TextLabel final : public QskTextLabel
{
public:
TextLabel()
2018-11-06 17:54:21 +00:00
{
setObjectName( QStringLiteral( "QskMessageSubWindowTextLabel" ) );
initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::ConstrainedExpanding );
setLayoutAlignmentHint( Qt::AlignLeft | Qt::AlignTop );
2018-11-06 17:54:21 +00:00
2018-11-06 18:00:42 +00:00
setAlignment( Qt::AlignLeft | Qt::AlignTop );
2018-11-06 17:54:21 +00:00
setWrapMode( QskTextOptions::WordWrap );
setElideMode( Qt::ElideRight );
2018-11-06 17:54:21 +00:00
}
};
}
2018-08-03 06:15:28 +00:00
QskMessageSubWindow::QskMessageSubWindow( QQuickItem* parent )
: Inherited( parent )
2017-07-21 16:21:34 +00:00
{
auto label = new TextLabel();
2018-11-06 17:54:21 +00:00
connect( label, &QskTextLabel::textChanged,
this, &QskMessageSubWindow::textChanged );
2018-11-06 17:54:21 +00:00
connect( label, &QskTextLabel::textOptionsChanged,
this, &QskMessageSubWindow::textOptionsChanged );
2018-11-06 17:54:21 +00:00
setContentItem( label );
2017-07-21 16:21:34 +00:00
}
QskMessageSubWindow::~QskMessageSubWindow()
{
}
2018-11-06 18:00:42 +00:00
void QskMessageSubWindow::setText( const QString& text )
2018-11-06 17:54:21 +00:00
{
if ( auto label = qobject_cast< QskTextLabel* >( contentItem() ) )
label->setText( text );
2018-11-06 17:54:21 +00:00
}
2018-11-06 18:00:42 +00:00
QString QskMessageSubWindow::text() const
2018-11-06 17:54:21 +00:00
{
if ( auto label = qobject_cast< const QskTextLabel* >( contentItem() ) )
return label->text();
return QString();
2018-11-06 17:54:21 +00:00
}
2018-11-06 18:00:42 +00:00
void QskMessageSubWindow::setTextOptions( const QskTextOptions& options )
2018-11-06 17:54:21 +00:00
{
if ( auto label = qobject_cast< QskTextLabel* >( contentItem() ) )
label->setTextOptions( options );
2018-11-06 17:54:21 +00:00
}
2018-11-06 18:00:42 +00:00
QskTextOptions QskMessageSubWindow::textOptions() const
2018-11-06 17:54:21 +00:00
{
if ( auto label = qobject_cast< const QskTextLabel* >( contentItem() ) )
return label->textOptions();
2018-11-06 17:54:21 +00:00
return QskTextOptions();
2018-11-06 17:54:21 +00:00
}
2017-07-21 16:21:34 +00:00
#include "moc_QskMessageSubWindow.cpp"