QskDialogSubWindow configurable from skin hints

This commit is contained in:
Uwe Rathmann 2024-02-08 13:38:21 +01:00
parent c96b3dbbff
commit 5bc2f504cf
5 changed files with 77 additions and 22 deletions

View File

@ -56,6 +56,7 @@
#include <QskCheckBox.h>
#include <QskComboBox.h>
#include <QskDialogButtonBox.h>
#include <QskDialogSubWindow.h>
#include <QskDrawer.h>
#include <QskFocusIndicator.h>
#include <QskGraphicLabel.h>
@ -197,6 +198,7 @@ namespace
private:
void setupPopup( const QskFluent2Theme& );
void setupSubWindow( const QskFluent2Theme& );
void setupDialogSubWindow( const QskFluent2Theme& );
void setupBoxMetrics();
void setupBoxColors( QskAspect::Section, const QskFluent2Theme& );
@ -338,6 +340,7 @@ void Editor::setupColors( QskAspect::Section section, const QskFluent2Theme& the
// TODO
setupPopup( theme );
setupSubWindow( theme );
setupDialogSubWindow( theme );
}
setupBoxColors( section, theme );
@ -1920,6 +1923,15 @@ void Editor::setupSubWindow( const QskFluent2Theme& theme )
setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic );
}
void Editor::setupDialogSubWindow( const QskFluent2Theme& )
{
using Q = QskDialogSubWindow;
setFontRole( Q::DialogTitle, QskFluent2Skin::Subtitle );
setAlignment( Q::DialogTitle, Qt::AlignLeft | Qt::AlignVCenter );
setTextOptions( Q::DialogTitle, Qt::ElideRight, QskTextOptions::WordWrap );
}
void Editor::setupVirtualKeyboardMetrics()
{
using Q = QskVirtualKeyboard;

View File

@ -13,6 +13,7 @@
#include <QskComboBox.h>
#include <QskColorFilter.h>
#include <QskDialogButtonBox.h>
#include <QskDialogSubWindow.h>
#include <QskDrawer.h>
#include <QskFocusIndicator.h>
#include <QskFunctions.h>
@ -110,6 +111,7 @@ namespace
Q_INVOKABLE void setupCheckBox();
Q_INVOKABLE void setupComboBox();
Q_INVOKABLE void setupDialogButtonBox();
Q_INVOKABLE void setupDialogSubWindow();
Q_INVOKABLE void setupDrawer();
Q_INVOKABLE void setupFocusIndicator();
Q_INVOKABLE void setupGraphicLabel();
@ -735,6 +737,17 @@ void Editor::setupDialogButtonBox()
setGradient( Q::Panel | Q::Disabled, m_pal.disabled( P::Base ) );
}
void Editor::setupDialogSubWindow()
{
using Q = QskDialogSubWindow;
#if 1
setFontRole( Q::DialogTitle, QskFusionSkin::LargeFont );
#endif
setAlignment( Q::DialogTitle, Qt::AlignLeft | Qt::AlignVCenter );
setTextOptions( Q::DialogTitle, Qt::ElideRight, QskTextOptions::WordWrap );
}
void Editor::setupDrawer()
{
using Q = QskDrawer;

View File

@ -12,6 +12,7 @@
#include <QskComboBox.h>
#include <QskColorFilter.h>
#include <QskDialogButtonBox.h>
#include <QskDialogSubWindow.h>
#include <QskDrawer.h>
#include <QskFocusIndicator.h>
#include <QskFunctions.h>
@ -93,6 +94,7 @@ namespace
Q_INVOKABLE void setupCheckBox();
Q_INVOKABLE void setupComboBox();
Q_INVOKABLE void setupDialogButtonBox();
Q_INVOKABLE void setupDialogSubWindow();
Q_INVOKABLE void setupDrawer();
Q_INVOKABLE void setupFocusIndicator();
Q_INVOKABLE void setupInputPanel();
@ -779,6 +781,17 @@ void Editor::setupDialogButtonBox()
setBoxBorderMetrics( Q::Panel, 0 );
}
void Editor::setupDialogSubWindow()
{
using Q = QskDialogSubWindow;
#if 1
setFontRole( Q::DialogTitle, QskMaterial3Skin::M3BodyLarge );
#endif
setAlignment( Q::DialogTitle, Qt::AlignLeft | Qt::AlignVCenter );
setTextOptions( Q::DialogTitle, Qt::ElideRight, QskTextOptions::WordWrap );
}
void Editor::setupDrawer()
{
using Q = QskDrawer;

View File

@ -18,6 +18,8 @@
#include <qquickwindow.h>
#include <qpointer.h>
QSK_SUBCONTROL( QskDialogSubWindow, DialogTitle )
static inline void qskSetRejectOnClose( QskDialogSubWindow* subWindow, bool on )
{
if ( on )
@ -32,6 +34,22 @@ static inline void qskSetRejectOnClose( QskDialogSubWindow* subWindow, bool on )
}
}
namespace
{
class TitleLabel final : public QskTextLabel
{
protected:
QskAspect::Subcontrol substitutedSubcontrol(
QskAspect::Subcontrol subControl ) const override
{
if ( subControl == QskTextLabel::Text )
return QskDialogSubWindow::DialogTitle;
return QskTextLabel::substitutedSubcontrol( subControl );
}
};
}
class QskDialogSubWindow::PrivateData
{
public:
@ -121,36 +139,30 @@ QskDialog::Actions QskDialogSubWindow::dialogActions() const
void QskDialogSubWindow::setTitle( const QString& title )
{
bool changed = false;
auto& titleLabel = m_data->titleLabel;
if ( title.isEmpty() )
{
changed = m_data->titleLabel != nullptr;
delete m_data->titleLabel;
changed = ( titleLabel != nullptr );
delete titleLabel;
titleLabel = nullptr;
}
else
{
changed = m_data->titleLabel && m_data->titleLabel->text() == title;
if ( m_data->titleLabel == nullptr )
if ( titleLabel == nullptr )
{
auto label = new QskTextLabel();
label->setLayoutAlignmentHint( Qt::AlignLeft | Qt::AlignTop );
#if 1
// skin hints
label->setFontRole( QskSkin::LargeFont );
label->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
QskTextOptions options;
options.setElideMode( Qt::ElideRight );
options.setWrapMode( QskTextOptions::WordWrap );
label->setTextOptions( options );
#endif
m_data->titleLabel = label;
m_data->layout->insertItem( 0, label );
titleLabel = new TitleLabel();
m_data->layout->insertItem( 0, titleLabel );
changed = true;
}
else
{
changed = ( titleLabel->text() != title );
}
m_data->titleLabel->setText( title );
if ( changed )
titleLabel->setText( title );
}
if ( changed )
@ -164,7 +176,10 @@ void QskDialogSubWindow::setTitle( const QString& title )
QString QskDialogSubWindow::title() const
{
return m_data->titleLabel ? m_data->titleLabel->text() : QString();
if ( auto label = m_data->titleLabel )
return label->text();
return QString();
}
QskTextLabel* QskDialogSubWindow::titleLabel()

View File

@ -26,6 +26,8 @@ class QSK_EXPORT QskDialogSubWindow : public QskSubWindow
using Inherited = QskSubWindow;
public:
QSK_SUBCONTROLS( DialogTitle )
QskDialogSubWindow( QQuickItem* parent = nullptr );
~QskDialogSubWindow() override;