QskDialogSubWindow configurable from skin hints
This commit is contained in:
parent
c96b3dbbff
commit
5bc2f504cf
|
@ -56,6 +56,7 @@
|
||||||
#include <QskCheckBox.h>
|
#include <QskCheckBox.h>
|
||||||
#include <QskComboBox.h>
|
#include <QskComboBox.h>
|
||||||
#include <QskDialogButtonBox.h>
|
#include <QskDialogButtonBox.h>
|
||||||
|
#include <QskDialogSubWindow.h>
|
||||||
#include <QskDrawer.h>
|
#include <QskDrawer.h>
|
||||||
#include <QskFocusIndicator.h>
|
#include <QskFocusIndicator.h>
|
||||||
#include <QskGraphicLabel.h>
|
#include <QskGraphicLabel.h>
|
||||||
|
@ -197,6 +198,7 @@ namespace
|
||||||
private:
|
private:
|
||||||
void setupPopup( const QskFluent2Theme& );
|
void setupPopup( const QskFluent2Theme& );
|
||||||
void setupSubWindow( const QskFluent2Theme& );
|
void setupSubWindow( const QskFluent2Theme& );
|
||||||
|
void setupDialogSubWindow( const QskFluent2Theme& );
|
||||||
|
|
||||||
void setupBoxMetrics();
|
void setupBoxMetrics();
|
||||||
void setupBoxColors( QskAspect::Section, const QskFluent2Theme& );
|
void setupBoxColors( QskAspect::Section, const QskFluent2Theme& );
|
||||||
|
@ -338,6 +340,7 @@ void Editor::setupColors( QskAspect::Section section, const QskFluent2Theme& the
|
||||||
// TODO
|
// TODO
|
||||||
setupPopup( theme );
|
setupPopup( theme );
|
||||||
setupSubWindow( theme );
|
setupSubWindow( theme );
|
||||||
|
setupDialogSubWindow( theme );
|
||||||
}
|
}
|
||||||
|
|
||||||
setupBoxColors( section, theme );
|
setupBoxColors( section, theme );
|
||||||
|
@ -1920,6 +1923,15 @@ void Editor::setupSubWindow( const QskFluent2Theme& theme )
|
||||||
setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic );
|
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()
|
void Editor::setupVirtualKeyboardMetrics()
|
||||||
{
|
{
|
||||||
using Q = QskVirtualKeyboard;
|
using Q = QskVirtualKeyboard;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <QskComboBox.h>
|
#include <QskComboBox.h>
|
||||||
#include <QskColorFilter.h>
|
#include <QskColorFilter.h>
|
||||||
#include <QskDialogButtonBox.h>
|
#include <QskDialogButtonBox.h>
|
||||||
|
#include <QskDialogSubWindow.h>
|
||||||
#include <QskDrawer.h>
|
#include <QskDrawer.h>
|
||||||
#include <QskFocusIndicator.h>
|
#include <QskFocusIndicator.h>
|
||||||
#include <QskFunctions.h>
|
#include <QskFunctions.h>
|
||||||
|
@ -110,6 +111,7 @@ namespace
|
||||||
Q_INVOKABLE void setupCheckBox();
|
Q_INVOKABLE void setupCheckBox();
|
||||||
Q_INVOKABLE void setupComboBox();
|
Q_INVOKABLE void setupComboBox();
|
||||||
Q_INVOKABLE void setupDialogButtonBox();
|
Q_INVOKABLE void setupDialogButtonBox();
|
||||||
|
Q_INVOKABLE void setupDialogSubWindow();
|
||||||
Q_INVOKABLE void setupDrawer();
|
Q_INVOKABLE void setupDrawer();
|
||||||
Q_INVOKABLE void setupFocusIndicator();
|
Q_INVOKABLE void setupFocusIndicator();
|
||||||
Q_INVOKABLE void setupGraphicLabel();
|
Q_INVOKABLE void setupGraphicLabel();
|
||||||
|
@ -735,6 +737,17 @@ void Editor::setupDialogButtonBox()
|
||||||
setGradient( Q::Panel | Q::Disabled, m_pal.disabled( P::Base ) );
|
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()
|
void Editor::setupDrawer()
|
||||||
{
|
{
|
||||||
using Q = QskDrawer;
|
using Q = QskDrawer;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <QskComboBox.h>
|
#include <QskComboBox.h>
|
||||||
#include <QskColorFilter.h>
|
#include <QskColorFilter.h>
|
||||||
#include <QskDialogButtonBox.h>
|
#include <QskDialogButtonBox.h>
|
||||||
|
#include <QskDialogSubWindow.h>
|
||||||
#include <QskDrawer.h>
|
#include <QskDrawer.h>
|
||||||
#include <QskFocusIndicator.h>
|
#include <QskFocusIndicator.h>
|
||||||
#include <QskFunctions.h>
|
#include <QskFunctions.h>
|
||||||
|
@ -93,6 +94,7 @@ namespace
|
||||||
Q_INVOKABLE void setupCheckBox();
|
Q_INVOKABLE void setupCheckBox();
|
||||||
Q_INVOKABLE void setupComboBox();
|
Q_INVOKABLE void setupComboBox();
|
||||||
Q_INVOKABLE void setupDialogButtonBox();
|
Q_INVOKABLE void setupDialogButtonBox();
|
||||||
|
Q_INVOKABLE void setupDialogSubWindow();
|
||||||
Q_INVOKABLE void setupDrawer();
|
Q_INVOKABLE void setupDrawer();
|
||||||
Q_INVOKABLE void setupFocusIndicator();
|
Q_INVOKABLE void setupFocusIndicator();
|
||||||
Q_INVOKABLE void setupInputPanel();
|
Q_INVOKABLE void setupInputPanel();
|
||||||
|
@ -779,6 +781,17 @@ void Editor::setupDialogButtonBox()
|
||||||
setBoxBorderMetrics( Q::Panel, 0 );
|
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()
|
void Editor::setupDrawer()
|
||||||
{
|
{
|
||||||
using Q = QskDrawer;
|
using Q = QskDrawer;
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include <qquickwindow.h>
|
#include <qquickwindow.h>
|
||||||
#include <qpointer.h>
|
#include <qpointer.h>
|
||||||
|
|
||||||
|
QSK_SUBCONTROL( QskDialogSubWindow, DialogTitle )
|
||||||
|
|
||||||
static inline void qskSetRejectOnClose( QskDialogSubWindow* subWindow, bool on )
|
static inline void qskSetRejectOnClose( QskDialogSubWindow* subWindow, bool on )
|
||||||
{
|
{
|
||||||
if ( 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
|
class QskDialogSubWindow::PrivateData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -121,36 +139,30 @@ QskDialog::Actions QskDialogSubWindow::dialogActions() const
|
||||||
void QskDialogSubWindow::setTitle( const QString& title )
|
void QskDialogSubWindow::setTitle( const QString& title )
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
auto& titleLabel = m_data->titleLabel;
|
||||||
|
|
||||||
if ( title.isEmpty() )
|
if ( title.isEmpty() )
|
||||||
{
|
{
|
||||||
changed = m_data->titleLabel != nullptr;
|
changed = ( titleLabel != nullptr );
|
||||||
delete m_data->titleLabel;
|
|
||||||
|
delete titleLabel;
|
||||||
|
titleLabel = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
changed = m_data->titleLabel && m_data->titleLabel->text() == title;
|
if ( titleLabel == nullptr )
|
||||||
if ( m_data->titleLabel == nullptr )
|
|
||||||
{
|
{
|
||||||
auto label = new QskTextLabel();
|
titleLabel = new TitleLabel();
|
||||||
label->setLayoutAlignmentHint( Qt::AlignLeft | Qt::AlignTop );
|
m_data->layout->insertItem( 0, titleLabel );
|
||||||
#if 1
|
changed = true;
|
||||||
// skin hints
|
}
|
||||||
label->setFontRole( QskSkin::LargeFont );
|
else
|
||||||
label->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
{
|
||||||
|
changed = ( titleLabel->text() != title );
|
||||||
QskTextOptions options;
|
|
||||||
options.setElideMode( Qt::ElideRight );
|
|
||||||
options.setWrapMode( QskTextOptions::WordWrap );
|
|
||||||
|
|
||||||
label->setTextOptions( options );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_data->titleLabel = label;
|
|
||||||
m_data->layout->insertItem( 0, label );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->titleLabel->setText( title );
|
if ( changed )
|
||||||
|
titleLabel->setText( title );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( changed )
|
if ( changed )
|
||||||
|
@ -164,7 +176,10 @@ void QskDialogSubWindow::setTitle( const QString& title )
|
||||||
|
|
||||||
QString QskDialogSubWindow::title() const
|
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()
|
QskTextLabel* QskDialogSubWindow::titleLabel()
|
||||||
|
|
|
@ -26,6 +26,8 @@ class QSK_EXPORT QskDialogSubWindow : public QskSubWindow
|
||||||
using Inherited = QskSubWindow;
|
using Inherited = QskSubWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
QSK_SUBCONTROLS( DialogTitle )
|
||||||
|
|
||||||
QskDialogSubWindow( QQuickItem* parent = nullptr );
|
QskDialogSubWindow( QQuickItem* parent = nullptr );
|
||||||
~QskDialogSubWindow() override;
|
~QskDialogSubWindow() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue