diff --git a/designsystems/fluent2/QskFluent2Skin.cpp b/designsystems/fluent2/QskFluent2Skin.cpp index 44b4d6a4..1225f447 100644 --- a/designsystems/fluent2/QskFluent2Skin.cpp +++ b/designsystems/fluent2/QskFluent2Skin.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/designsystems/fusion/QskFusionSkin.cpp b/designsystems/fusion/QskFusionSkin.cpp index 5bb5371f..2ea2e52c 100644 --- a/designsystems/fusion/QskFusionSkin.cpp +++ b/designsystems/fusion/QskFusionSkin.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/designsystems/material3/QskMaterial3Skin.cpp b/designsystems/material3/QskMaterial3Skin.cpp index 4ab7258c..7a50fd5d 100644 --- a/designsystems/material3/QskMaterial3Skin.cpp +++ b/designsystems/material3/QskMaterial3Skin.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/src/dialogs/QskDialogSubWindow.cpp b/src/dialogs/QskDialogSubWindow.cpp index 51b40dfb..3cde7a12 100644 --- a/src/dialogs/QskDialogSubWindow.cpp +++ b/src/dialogs/QskDialogSubWindow.cpp @@ -18,6 +18,8 @@ #include #include +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() diff --git a/src/dialogs/QskDialogSubWindow.h b/src/dialogs/QskDialogSubWindow.h index 8686c331..077ef65f 100644 --- a/src/dialogs/QskDialogSubWindow.h +++ b/src/dialogs/QskDialogSubWindow.h @@ -26,6 +26,8 @@ class QSK_EXPORT QskDialogSubWindow : public QskSubWindow using Inherited = QskSubWindow; public: + QSK_SUBCONTROLS( DialogTitle ) + QskDialogSubWindow( QQuickItem* parent = nullptr ); ~QskDialogSubWindow() override;