reducing the dialogs from what was once inspired from Qt/Widgets to
something simpler - inspired from QC2 dialogs - work i progress
This commit is contained in:
parent
69f42d8214
commit
955d2f6c20
@ -1902,7 +1902,6 @@ void Editor::setupSubWindow( const QskFluent2Theme& theme )
|
||||
|
||||
const auto& pal = theme.palette;
|
||||
|
||||
setPadding( Q::Panel, { 0, 31, 0, 0 } );
|
||||
setBoxShape( Q::Panel, 7 );
|
||||
setBoxBorderMetrics( Q::Panel, 1 );
|
||||
setBoxBorderColors( Q::Panel, pal.strokeColor.surface.defaultColor );
|
||||
@ -1910,7 +1909,7 @@ void Editor::setupSubWindow( const QskFluent2Theme& theme )
|
||||
setShadowMetrics( Q::Panel, theme.shadow.dialog.metrics );
|
||||
setShadowColor( Q::Panel, theme.shadow.dialog.color );
|
||||
|
||||
setHint( Q::TitleBarPanel | QskAspect::Style, Q::TitleBar | Q::Title );
|
||||
setHint( Q::TitleBarPanel | QskAspect::Style, Q::NoDecoration );
|
||||
setPadding( Q::TitleBarPanel, { 24, 31, 24, 0 } );
|
||||
|
||||
setFontRole( Q::TitleBarText, QskFluent2Skin::Subtitle );
|
||||
|
@ -1272,7 +1272,7 @@ void Editor::setupSubWindow()
|
||||
|
||||
// TitleBarPanel
|
||||
|
||||
setHint( Q::TitleBarPanel | QskAspect::Style, Q::TitleBar | Q::Title );
|
||||
setHint( Q::TitleBarPanel | QskAspect::Style, Q::NoDecoration );
|
||||
setMargin( Q::TitleBarPanel, -1 );
|
||||
|
||||
setGradient( Q::TitleBarPanel, m_pal.active( P::Mid ) );
|
||||
|
@ -1220,8 +1220,7 @@ void Editor::setupSubWindow()
|
||||
// TitleBarPanel
|
||||
setBoxShape( Q::TitleBarPanel, { 28_dp, 28_dp, 0, 0 } );
|
||||
setPadding( Q::TitleBarPanel, { 24_dp, 24_dp, 24_dp, 16_dp } );
|
||||
setHint( Q::TitleBarPanel | QskAspect::Style,
|
||||
Q::TitleBar | Q::Title | Q::Symbol );
|
||||
setHint( Q::TitleBarPanel | QskAspect::Style, Q::NoDecoration );
|
||||
|
||||
setGradient( Q::TitleBarPanel, m_pal.secondaryContainer );
|
||||
|
||||
|
@ -26,6 +26,7 @@ class SubWindow : public QskSubWindow
|
||||
: QskSubWindow( parent )
|
||||
{
|
||||
setObjectName( iconSource );
|
||||
setDecorations( TitleBar | Title | Symbol );
|
||||
|
||||
const QUrl url( iconSource );
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include <QskDialog.h>
|
||||
#include <QskLinearBox.h>
|
||||
#include <QskPushButton.h>
|
||||
#include <QskStandardSymbol.h>
|
||||
#include <QskBoxShapeMetrics.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -19,6 +17,7 @@ namespace
|
||||
Button( const QString& text, QQuickItem* parent = nullptr )
|
||||
: QskPushButton( text, parent )
|
||||
{
|
||||
setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
}
|
||||
};
|
||||
|
||||
@ -26,9 +25,10 @@ namespace
|
||||
{
|
||||
public:
|
||||
ButtonBox( QQuickItem* parent = nullptr )
|
||||
: QskLinearBox( Qt::Horizontal, 2, parent )
|
||||
: QskLinearBox( Qt::Vertical, parent )
|
||||
{
|
||||
setObjectName( "ButtonBox" );
|
||||
setDefaultAlignment( Qt::AlignCenter );
|
||||
|
||||
setMargins( 10 );
|
||||
setSpacing( 20 );
|
||||
@ -36,18 +36,9 @@ namespace
|
||||
auto messageButton = new Button( "Message", this );
|
||||
connect( messageButton, &Button::clicked, this, &ButtonBox::execMessage );
|
||||
|
||||
auto informationButton = new Button( "Information", this );
|
||||
connect( informationButton, &Button::clicked, this, &ButtonBox::execInformation );
|
||||
|
||||
auto questionButton = new Button( "Question", this );
|
||||
connect( questionButton, &Button::clicked, this, &ButtonBox::execQuestion );
|
||||
|
||||
auto warningButton = new Button( "Warning", this );
|
||||
connect( warningButton, &Button::clicked, this, &ButtonBox::execWarning );
|
||||
|
||||
auto criticalButton = new Button( "Critical", this );
|
||||
connect( criticalButton, &Button::clicked, this, &ButtonBox::execCritical );
|
||||
|
||||
auto selectButton = new Button( "Selection", this );
|
||||
connect( selectButton, &Button::clicked, this, &ButtonBox::execSelection );
|
||||
|
||||
@ -57,14 +48,7 @@ namespace
|
||||
private:
|
||||
void execMessage()
|
||||
{
|
||||
qskDialog->message( "Message", "Request vector, over.",
|
||||
QskStandardSymbol::NoSymbol, QskDialog::Close );
|
||||
}
|
||||
|
||||
void execInformation()
|
||||
{
|
||||
qskDialog->information( "Information",
|
||||
"We have clearance, Clarence." );
|
||||
qskDialog->information( "Message", "Request vector, over." );
|
||||
}
|
||||
|
||||
void execQuestion()
|
||||
@ -73,16 +57,6 @@ namespace
|
||||
"Roger, Roger. Do we have a vector, Victor ?" );
|
||||
}
|
||||
|
||||
void execWarning()
|
||||
{
|
||||
qskDialog->warning( "Warning", "We have clearance, Clarence." );
|
||||
}
|
||||
|
||||
void execCritical()
|
||||
{
|
||||
qskDialog->critical( "Critical", "That's Clarence Oveur. Over." );
|
||||
}
|
||||
|
||||
void execSelection()
|
||||
{
|
||||
// of course we all love "The Teens"
|
||||
|
@ -22,7 +22,7 @@ namespace
|
||||
{
|
||||
inline QskAspect aspectDecoration()
|
||||
{
|
||||
return QskSubWindow::TitleBarPanel | QskAspect::NoType | QskAspect::Style;
|
||||
return QskSubWindow::TitleBarPanel | QskAspect::Style;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,4 +108,7 @@ class QSK_EXPORT QskSubWindow : public QskPopup
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QskSubWindow::Decorations )
|
||||
Q_DECLARE_METATYPE( QskSubWindow::Decorations )
|
||||
|
||||
#endif
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "QskSelectionWindow.h"
|
||||
|
||||
#include "QskFocusIndicator.h"
|
||||
#include "QskStandardSymbol.h"
|
||||
|
||||
#include <qguiapplication.h>
|
||||
#include <qpointer.h>
|
||||
@ -79,7 +78,10 @@ static void qskSetupSubWindow(
|
||||
{
|
||||
subWindow->setPopupFlag( QskPopup::DeleteOnClose );
|
||||
subWindow->setModal( true );
|
||||
subWindow->setWindowTitle( title );
|
||||
#if 0
|
||||
subWindow->setWindowTitle( ... );
|
||||
#endif
|
||||
subWindow->setTitle( title );
|
||||
subWindow->setDialogActions( actions );
|
||||
|
||||
if ( actions != QskDialog::NoAction && defaultAction == QskDialog::NoAction )
|
||||
@ -126,11 +128,11 @@ static void qskSetupWindow(
|
||||
|
||||
static QskDialog::Action qskMessageSubWindow(
|
||||
QQuickWindow* window, const QString& title,
|
||||
const QString& text, int symbolType, QskDialog::Actions actions,
|
||||
const QString& text, uint priority, QskDialog::Actions actions,
|
||||
QskDialog::Action defaultAction )
|
||||
{
|
||||
auto subWindow = new QskMessageSubWindow( window->contentItem() );
|
||||
subWindow->setSymbolType( symbolType );
|
||||
subWindow->setPriority( priority );
|
||||
subWindow->setText( text );
|
||||
|
||||
qskSetupSubWindow( title, actions, defaultAction, subWindow );
|
||||
@ -148,11 +150,12 @@ static QskDialog::Action qskMessageSubWindow(
|
||||
|
||||
static QskDialog::Action qskMessageWindow(
|
||||
QWindow* transientParent, const QString& title,
|
||||
const QString& text, int symbolType, QskDialog::Actions actions,
|
||||
const QString& text, uint priority, QskDialog::Actions actions,
|
||||
QskDialog::Action defaultAction )
|
||||
{
|
||||
Q_UNUSED( priority ); // can we do something with it ?
|
||||
|
||||
QskMessageWindow messageWindow;
|
||||
messageWindow.setSymbolType( symbolType );
|
||||
messageWindow.setText( text );
|
||||
|
||||
qskSetupWindow( transientParent, title, actions, defaultAction, &messageWindow );
|
||||
@ -257,7 +260,7 @@ QWindow* QskDialog::transientParent() const
|
||||
}
|
||||
|
||||
QskDialog::Action QskDialog::message(
|
||||
const QString& title, const QString& text, int symbolType,
|
||||
const QString& title, const QString& text, uint priority,
|
||||
Actions actions, Action defaultAction ) const
|
||||
{
|
||||
if ( m_data->policy == EmbeddedBox )
|
||||
@ -270,44 +273,26 @@ QskDialog::Action QskDialog::message(
|
||||
if ( quickWindow )
|
||||
{
|
||||
return qskMessageSubWindow( quickWindow,
|
||||
title, text, symbolType, actions, defaultAction );
|
||||
title, text, priority, actions, defaultAction );
|
||||
}
|
||||
}
|
||||
|
||||
return qskMessageWindow( m_data->transientParent,
|
||||
title, text, symbolType, actions, defaultAction );
|
||||
title, text, priority, actions, defaultAction );
|
||||
}
|
||||
|
||||
QskDialog::Action QskDialog::information(
|
||||
const QString& title, const QString& text,
|
||||
Actions actions, Action defaultAction ) const
|
||||
{
|
||||
return QskDialog::message( title, text,
|
||||
QskStandardSymbol::Information, actions, defaultAction );
|
||||
}
|
||||
|
||||
QskDialog::Action QskDialog::warning(
|
||||
const QString& title, const QString& text,
|
||||
Actions actions, Action defaultAction ) const
|
||||
{
|
||||
return QskDialog::message( title, text,
|
||||
QskStandardSymbol::Warning, actions, defaultAction );
|
||||
}
|
||||
|
||||
QskDialog::Action QskDialog::critical(
|
||||
const QString& title, const QString& text,
|
||||
Actions actions, Action defaultAction ) const
|
||||
{
|
||||
return QskDialog::message( title, text,
|
||||
QskStandardSymbol::Critical, actions, defaultAction );
|
||||
return QskDialog::message( title, text, 0, actions, defaultAction );
|
||||
}
|
||||
|
||||
QskDialog::Action QskDialog::question(
|
||||
const QString& title, const QString& text,
|
||||
Actions actions, Action defaultAction ) const
|
||||
{
|
||||
return QskDialog::message( title, text,
|
||||
QskStandardSymbol::Question, actions, defaultAction );
|
||||
return QskDialog::message( title, text, 0, actions, defaultAction );
|
||||
}
|
||||
|
||||
QString QskDialog::select(
|
||||
|
@ -115,21 +115,13 @@ class QSK_EXPORT QskDialog : public QObject
|
||||
Q_INVOKABLE QWindow* transientParent() const;
|
||||
|
||||
Q_INVOKABLE Action message(
|
||||
const QString& title, const QString& text, int symbolType,
|
||||
const QString& title, const QString& text, uint priority = 0,
|
||||
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
||||
|
||||
Q_INVOKABLE Action information(
|
||||
const QString& title, const QString& text,
|
||||
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
||||
|
||||
Q_INVOKABLE Action warning(
|
||||
const QString& title, const QString& text,
|
||||
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
||||
|
||||
Q_INVOKABLE Action critical(
|
||||
const QString& title, const QString& text,
|
||||
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
||||
|
||||
Q_INVOKABLE Action question(
|
||||
const QString& title, const QString& text,
|
||||
Actions actions = Actions( Yes | No ),
|
||||
|
@ -5,9 +5,20 @@
|
||||
|
||||
#include "QskDialogSubWindow.h"
|
||||
#include "QskDialogButtonBox.h"
|
||||
#include "QskTextLabel.h"
|
||||
#include "QskPushButton.h"
|
||||
#include "QskLinearBox.h"
|
||||
#include "QskQuick.h"
|
||||
#include "QskEvent.h"
|
||||
#if 1
|
||||
#include "QskSkin.h"
|
||||
#include <QskPlatform.h>
|
||||
#endif
|
||||
|
||||
QSK_QT_PRIVATE_BEGIN
|
||||
#include <private/qquickitem_p.h>
|
||||
#include <private/qquickitemchangelistener_p.h>
|
||||
QSK_QT_PRIVATE_END
|
||||
|
||||
#include <qquickwindow.h>
|
||||
#include <qpointer.h>
|
||||
@ -26,15 +37,69 @@ static inline void qskSetRejectOnClose( QskDialogSubWindow* subWindow, bool on )
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class GeometryListener final : public QQuickItemChangeListener
|
||||
{
|
||||
public:
|
||||
GeometryListener( QskControl* control )
|
||||
: m_control( control )
|
||||
, m_parent( m_control->parentItem() )
|
||||
{
|
||||
setEnabled( true );
|
||||
m_control->polish();
|
||||
}
|
||||
|
||||
~GeometryListener()
|
||||
{
|
||||
setEnabled( false );
|
||||
}
|
||||
|
||||
private:
|
||||
void setEnabled( bool on )
|
||||
{
|
||||
const auto changeTypes = QQuickItemPrivate::Geometry;
|
||||
|
||||
auto d = QQuickItemPrivate::get( m_parent );
|
||||
if ( on )
|
||||
d->addItemChangeListener( this, changeTypes );
|
||||
else
|
||||
d->removeItemChangeListener( this, changeTypes );
|
||||
}
|
||||
|
||||
void itemGeometryChanged( QQuickItem*,
|
||||
QQuickGeometryChange, const QRectF& ) override
|
||||
{
|
||||
m_control->resetImplicitSize();
|
||||
m_control->polish();
|
||||
}
|
||||
|
||||
QskControl* m_control;
|
||||
QQuickItem* m_parent;
|
||||
};
|
||||
}
|
||||
|
||||
class QskDialogSubWindow::PrivateData
|
||||
{
|
||||
public:
|
||||
inline void resetListener( QskDialogSubWindow* subWindow )
|
||||
{
|
||||
delete listener;
|
||||
listener = nullptr;
|
||||
|
||||
if ( subWindow->parentItem() && subWindow->isVisible() )
|
||||
listener = new GeometryListener( subWindow );
|
||||
}
|
||||
|
||||
QskDialog::Actions actions = QskDialog::NoAction;
|
||||
|
||||
QPointer< QQuickItem > contentItem;
|
||||
QskTextLabel* titleLabel = nullptr;
|
||||
QskDialogButtonBox* buttonBox = nullptr;
|
||||
|
||||
QMarginsF contentPadding;
|
||||
QPointer< QQuickItem > contentItem;
|
||||
|
||||
QskLinearBox* layout = nullptr;
|
||||
GeometryListener* listener = nullptr;
|
||||
|
||||
QskDialog::DialogCode result = QskDialog::Rejected;
|
||||
};
|
||||
@ -43,12 +108,21 @@ QskDialogSubWindow::QskDialogSubWindow( QQuickItem* parent )
|
||||
: Inherited( parent )
|
||||
, m_data( new PrivateData() )
|
||||
{
|
||||
setPolishOnResize( true );
|
||||
qskSetRejectOnClose( this, true );
|
||||
|
||||
m_data->layout = new QskLinearBox( Qt::Vertical, this );
|
||||
m_data->layout->setSizePolicy(
|
||||
QskSizePolicy::MinimumExpanding, QskSizePolicy::Constrained );
|
||||
|
||||
setPolishOnResize( true );
|
||||
|
||||
if ( parent )
|
||||
m_data->listener = new GeometryListener( this );
|
||||
}
|
||||
|
||||
QskDialogSubWindow::~QskDialogSubWindow()
|
||||
{
|
||||
delete m_data->listener;
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::addDialogAction( QskDialog::Action action )
|
||||
@ -58,8 +132,7 @@ void QskDialogSubWindow::addDialogAction( QskDialog::Action action )
|
||||
if ( m_data->buttonBox == nullptr )
|
||||
initButtonBox();
|
||||
|
||||
if ( m_data->buttonBox )
|
||||
m_data->buttonBox->addAction( action );
|
||||
m_data->buttonBox->addAction( action );
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,8 +144,7 @@ void QskDialogSubWindow::addDialogButton(
|
||||
if ( m_data->buttonBox == nullptr )
|
||||
initButtonBox();
|
||||
|
||||
if ( m_data->buttonBox )
|
||||
m_data->buttonBox->addButton( button, actionRole );
|
||||
m_data->buttonBox->addButton( button, actionRole );
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,37 +157,17 @@ void QskDialogSubWindow::setDialogActions( QskDialog::Actions actions )
|
||||
|
||||
if ( actions == QskDialog::NoAction )
|
||||
{
|
||||
if ( m_data->buttonBox->parent() == this )
|
||||
{
|
||||
delete m_data->buttonBox;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data->buttonBox->setParentItem( nullptr );
|
||||
|
||||
disconnect( m_data->buttonBox, &QskDialogButtonBox::accepted,
|
||||
this, &QskDialogSubWindow::accept );
|
||||
|
||||
disconnect( m_data->buttonBox, &QskDialogButtonBox::rejected,
|
||||
this, &QskDialogSubWindow::reject );
|
||||
|
||||
}
|
||||
|
||||
delete m_data->buttonBox;
|
||||
m_data->buttonBox = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_data->buttonBox == nullptr )
|
||||
{
|
||||
initButtonBox();
|
||||
}
|
||||
|
||||
if ( m_data->buttonBox )
|
||||
m_data->buttonBox->setActions( actions );
|
||||
}
|
||||
|
||||
resetImplicitSize();
|
||||
polish();
|
||||
}
|
||||
|
||||
QskDialog::Actions QskDialogSubWindow::dialogActions() const
|
||||
@ -126,6 +178,65 @@ QskDialog::Actions QskDialogSubWindow::dialogActions() const
|
||||
return QskDialog::NoAction;
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::setTitle( const QString& title )
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
if ( title.isEmpty() )
|
||||
{
|
||||
changed = m_data->titleLabel != nullptr;
|
||||
delete m_data->titleLabel;
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = m_data->titleLabel && m_data->titleLabel->text() == title;
|
||||
if ( m_data->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 );
|
||||
}
|
||||
|
||||
m_data->titleLabel->setText( title );
|
||||
}
|
||||
|
||||
if ( changed )
|
||||
{
|
||||
resetImplicitSize();
|
||||
polish();
|
||||
|
||||
Q_EMIT titleChanged( title );
|
||||
}
|
||||
}
|
||||
|
||||
QString QskDialogSubWindow::title() const
|
||||
{
|
||||
return m_data->titleLabel ? m_data->titleLabel->text() : QString();
|
||||
}
|
||||
|
||||
QskTextLabel* QskDialogSubWindow::titleLabel()
|
||||
{
|
||||
return m_data->titleLabel;
|
||||
}
|
||||
|
||||
const QskTextLabel* QskDialogSubWindow::titleLabel() const
|
||||
{
|
||||
return m_data->titleLabel;
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::setContentItem( QQuickItem* item )
|
||||
{
|
||||
if ( item == m_data->contentItem )
|
||||
@ -133,24 +244,19 @@ void QskDialogSubWindow::setContentItem( QQuickItem* item )
|
||||
|
||||
if ( m_data->contentItem )
|
||||
{
|
||||
if ( m_data->contentItem->parent() == this )
|
||||
if ( m_data->contentItem->parent() == m_data->layout )
|
||||
delete m_data->contentItem;
|
||||
else
|
||||
m_data->contentItem->setParentItem( nullptr );
|
||||
m_data->layout->removeItem( m_data->contentItem );
|
||||
}
|
||||
|
||||
m_data->contentItem = item;
|
||||
|
||||
if ( item )
|
||||
{
|
||||
item->setParentItem( this );
|
||||
|
||||
if ( item->parent() == nullptr )
|
||||
item->setParent( this );
|
||||
const int index = m_data->titleLabel ? 1 : 0;
|
||||
m_data->layout->insertItem( index, m_data->contentItem );
|
||||
}
|
||||
|
||||
resetImplicitSize();
|
||||
polish();
|
||||
}
|
||||
|
||||
QQuickItem* QskDialogSubWindow::contentItem() const
|
||||
@ -161,19 +267,12 @@ QQuickItem* QskDialogSubWindow::contentItem() const
|
||||
void QskDialogSubWindow::setContentPadding( const QMarginsF& padding )
|
||||
{
|
||||
// should be a skin hint ???
|
||||
|
||||
if ( m_data->contentPadding != padding )
|
||||
{
|
||||
m_data->contentPadding = padding;
|
||||
|
||||
resetImplicitSize();
|
||||
polish();
|
||||
}
|
||||
m_data->layout->setMargins( padding );
|
||||
}
|
||||
|
||||
QMarginsF QskDialogSubWindow::contentPadding() const
|
||||
{
|
||||
return m_data->contentPadding;
|
||||
return m_data->layout->margins();
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::setDefaultDialogAction( QskDialog::Action action )
|
||||
@ -287,134 +386,91 @@ void QskDialogSubWindow::keyPressEvent( QKeyEvent* event )
|
||||
Inherited::keyPressEvent( event );
|
||||
}
|
||||
|
||||
QskDialogButtonBox* QskDialogSubWindow::createButtonBox()
|
||||
{
|
||||
return new QskDialogButtonBox();
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::initButtonBox()
|
||||
{
|
||||
m_data->buttonBox = createButtonBox();
|
||||
auto buttonBox = new QskDialogButtonBox();
|
||||
m_data->layout->addItem( buttonBox );
|
||||
|
||||
if ( m_data->buttonBox )
|
||||
{
|
||||
m_data->buttonBox->setParentItem( this );
|
||||
connect( buttonBox, &QskDialogButtonBox::accepted,
|
||||
this, &QskDialogSubWindow::accept );
|
||||
|
||||
if ( m_data->buttonBox->parent() == nullptr )
|
||||
m_data->buttonBox->setParent( this );
|
||||
connect( buttonBox, &QskDialogButtonBox::rejected,
|
||||
this, &QskDialogSubWindow::reject );
|
||||
|
||||
connect( m_data->buttonBox, &QskDialogButtonBox::accepted,
|
||||
this, &QskDialogSubWindow::accept, Qt::UniqueConnection );
|
||||
|
||||
connect( m_data->buttonBox, &QskDialogButtonBox::rejected,
|
||||
this, &QskDialogSubWindow::reject, Qt::UniqueConnection );
|
||||
}
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::aboutToShow()
|
||||
{
|
||||
if ( size().isEmpty() )
|
||||
{
|
||||
// setting an initial size from the hint, centered inside the window
|
||||
|
||||
const qreal cx = 0.5 * parentItem()->width();
|
||||
const qreal cy = 0.5 * parentItem()->height();
|
||||
|
||||
QRectF rect;
|
||||
rect.setSize( sizeConstraint() );
|
||||
rect.moveCenter( QPointF( cx, cy ) );
|
||||
|
||||
setGeometry( rect );
|
||||
}
|
||||
|
||||
Inherited::aboutToShow();
|
||||
m_data->buttonBox = buttonBox;
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::updateLayout()
|
||||
{
|
||||
Inherited::updateLayout();
|
||||
updateGeometry();
|
||||
m_data->layout->setGeometry( layoutRect() );
|
||||
}
|
||||
|
||||
auto rect = layoutRect();
|
||||
void QskDialogSubWindow::updateGeometry()
|
||||
{
|
||||
/*
|
||||
This code is for Preferred/Constrained without checking
|
||||
the actual sizePolicy. TODO ...
|
||||
*/
|
||||
const auto minSize = minimumSize();
|
||||
const auto maxSize = maximumSize();
|
||||
|
||||
if ( m_data->buttonBox && m_data->buttonBox->isVisibleToParent() )
|
||||
{
|
||||
const auto h = m_data->buttonBox->sizeConstraint().height();
|
||||
rect.setBottom( rect.bottom() - h );
|
||||
auto width = sizeHint().width();
|
||||
width = qMin( width, maxSize.width() );
|
||||
width = qMax( width, minSize.width() );
|
||||
|
||||
m_data->buttonBox->setGeometry( rect.x(), rect.bottom(), rect.width(), h );
|
||||
}
|
||||
auto height = heightForWidth( width );
|
||||
height = qMin( height, maxSize.height() );
|
||||
height = qMax( height, minSize.height() );
|
||||
|
||||
if ( m_data->contentItem )
|
||||
{
|
||||
rect = rect.marginsRemoved( m_data->contentPadding );
|
||||
qskSetItemGeometry( m_data->contentItem, rect );
|
||||
}
|
||||
QRectF rect( 0.0, 0.0, width, height );
|
||||
rect.moveCenter( qskItemRect( parentItem() ).center() );
|
||||
|
||||
setGeometry( rect );
|
||||
}
|
||||
|
||||
QSizeF QskDialogSubWindow::layoutSizeHint(
|
||||
Qt::SizeHint which, const QSizeF& constraint ) const
|
||||
{
|
||||
if ( which != Qt::PreferredSize )
|
||||
return QSizeF();
|
||||
if ( which == Qt::MaximumSize )
|
||||
return 0.9 * parentItem()->size();
|
||||
|
||||
QSizeF buttonBoxHint;
|
||||
auto size = m_data->layout->effectiveSizeHint( which, constraint );
|
||||
|
||||
qreal constraintHeight = constraint.height();
|
||||
|
||||
if ( auto buttonBox = m_data->buttonBox )
|
||||
if ( which == Qt::MinimumSize )
|
||||
{
|
||||
if ( buttonBox->isVisibleToLayout() )
|
||||
const auto w = qMax( qskDpToPixels( 300.0 ), size.width() );
|
||||
size.setWidth( w );
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::aboutToShow()
|
||||
{
|
||||
updateGeometry();
|
||||
Inherited::aboutToShow();
|
||||
}
|
||||
|
||||
void QskDialogSubWindow::itemChange( QQuickItem::ItemChange change,
|
||||
const QQuickItem::ItemChangeData& value )
|
||||
{
|
||||
Inherited::itemChange( change, value );
|
||||
|
||||
switch( static_cast< int >( change ) )
|
||||
{
|
||||
case QQuickItem::ItemParentHasChanged:
|
||||
case QQuickItem::ItemVisibleHasChanged:
|
||||
{
|
||||
buttonBoxHint = buttonBox->sizeConstraint(
|
||||
which, QSizeF( constraint.width(), -1 ) );
|
||||
delete m_data->listener;
|
||||
m_data->listener = nullptr;
|
||||
|
||||
if ( constraint.width() >= 0.0 )
|
||||
buttonBoxHint.rwidth() = constraint.width();
|
||||
if ( parentItem() && isVisible() )
|
||||
m_data->listener = new GeometryListener( this );
|
||||
|
||||
if ( constraintHeight >= 0.0 && buttonBoxHint.height() >= 0.0 )
|
||||
{
|
||||
constraintHeight -= buttonBoxHint.height();
|
||||
constraintHeight = qMax( constraintHeight, 0.0 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QSizeF contentHint;
|
||||
|
||||
if ( qskIsVisibleToLayout( m_data->contentItem ) )
|
||||
{
|
||||
const auto& m = m_data->contentPadding;
|
||||
const qreal dw = m.left() + m.right();
|
||||
const qreal dh = m.top() + m.bottom();
|
||||
|
||||
qreal constraintWidth = constraint.width();
|
||||
|
||||
if ( constraintWidth > 0.0 )
|
||||
constraintWidth = qMax( constraintWidth - dw, 0.0 );
|
||||
|
||||
if ( constraintHeight > 0.0 )
|
||||
constraintHeight = qMax( constraintHeight - dh, 0.0 );
|
||||
|
||||
contentHint = qskSizeConstraint( m_data->contentItem,
|
||||
which, QSizeF( constraintWidth, constraintHeight ) );
|
||||
|
||||
if ( contentHint.width() >= 0 )
|
||||
contentHint.rwidth() += dw;
|
||||
|
||||
if ( contentHint.height() >= 0 )
|
||||
contentHint.rheight() += dh;
|
||||
}
|
||||
|
||||
qreal w = -1;
|
||||
w = qMax( w, buttonBoxHint.width() );
|
||||
w = qMax( w, contentHint.width() );
|
||||
|
||||
qreal h = -1;
|
||||
|
||||
if ( buttonBoxHint.height() > 0.0 && contentHint.height() > 0.0 )
|
||||
h = buttonBoxHint.height() + contentHint.height();
|
||||
|
||||
return QSizeF( w, h );
|
||||
}
|
||||
|
||||
#include "moc_QskDialogSubWindow.cpp"
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
class QskDialogButtonBox;
|
||||
class QskPushButton;
|
||||
class QskTextLabel;
|
||||
|
||||
class QSK_EXPORT QskDialogSubWindow : public QskSubWindow
|
||||
{
|
||||
@ -19,6 +20,9 @@ class QSK_EXPORT QskDialogSubWindow : public QskSubWindow
|
||||
Q_PROPERTY( QskDialog::Actions dialogActions
|
||||
READ dialogActions WRITE setDialogActions )
|
||||
|
||||
Q_PROPERTY( QString title READ title
|
||||
WRITE setTitle NOTIFY titleChanged )
|
||||
|
||||
using Inherited = QskSubWindow;
|
||||
|
||||
public:
|
||||
@ -47,11 +51,19 @@ class QSK_EXPORT QskDialogSubWindow : public QskSubWindow
|
||||
void setContentItem( QQuickItem* );
|
||||
QQuickItem* contentItem() const;
|
||||
|
||||
void setTitle( const QString& );
|
||||
QString title() const;
|
||||
|
||||
QskTextLabel* titleLabel();
|
||||
const QskTextLabel* titleLabel() const;
|
||||
|
||||
// padding around the contentItem
|
||||
void setContentPadding( const QMarginsF& );
|
||||
QMarginsF contentPadding() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void titleChanged( const QString& );
|
||||
|
||||
void finished( QskDialog::DialogCode );
|
||||
void accepted();
|
||||
void rejected();
|
||||
@ -64,14 +76,16 @@ class QSK_EXPORT QskDialogSubWindow : public QskSubWindow
|
||||
|
||||
protected:
|
||||
void setResult( QskDialog::DialogCode );
|
||||
|
||||
void keyPressEvent( QKeyEvent* ) override;
|
||||
|
||||
virtual void updateGeometry();
|
||||
|
||||
void updateLayout() override;
|
||||
void aboutToShow() override;
|
||||
void itemChange( ItemChange, const ItemChangeData& ) override;
|
||||
|
||||
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
||||
|
||||
virtual QskDialogButtonBox* createButtonBox();
|
||||
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const;
|
||||
|
||||
private:
|
||||
void initButtonBox();
|
||||
|
@ -4,86 +4,39 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskMessageSubWindow.h"
|
||||
#include "QskGraphic.h"
|
||||
#include "QskGraphicLabel.h"
|
||||
#include "QskLinearBox.h"
|
||||
#include "QskStandardSymbol.h"
|
||||
#include "QskTextLabel.h"
|
||||
|
||||
#include <qfontmetrics.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
class TextLabel final : public QskTextLabel
|
||||
{
|
||||
public:
|
||||
TextLabel( QskMessageSubWindow* box )
|
||||
TextLabel()
|
||||
{
|
||||
setObjectName( QStringLiteral( "QskMessageSubWindowTextLabel" ) );
|
||||
initSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Preferred );
|
||||
|
||||
initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::ConstrainedExpanding );
|
||||
setLayoutAlignmentHint( Qt::AlignLeft | Qt::AlignTop );
|
||||
|
||||
setAlignment( Qt::AlignLeft | Qt::AlignTop );
|
||||
setWrapMode( QskTextOptions::WordWrap );
|
||||
|
||||
connect( this, &QskTextLabel::textChanged,
|
||||
box, &QskMessageSubWindow::textChanged );
|
||||
|
||||
connect( this, &QskTextLabel::textOptionsChanged,
|
||||
box, &QskMessageSubWindow::textOptionsChanged );
|
||||
}
|
||||
};
|
||||
|
||||
class SymbolLabel final : public QskGraphicLabel
|
||||
{
|
||||
public:
|
||||
SymbolLabel( QskMessageSubWindow* )
|
||||
{
|
||||
setObjectName( QStringLiteral( "QskMessageSubWindowSymbolLabel" ) );
|
||||
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
|
||||
setAlignment( Qt::AlignTop | Qt::AlignHCenter );
|
||||
updatePreferredSize();
|
||||
}
|
||||
|
||||
private:
|
||||
void updatePreferredSize()
|
||||
{
|
||||
// when there is no explicit size known,
|
||||
// we always adjust the icon according to the font
|
||||
|
||||
if ( graphicStrutSize().isEmpty() )
|
||||
{
|
||||
const QFont font = effectiveFont( QskTextLabel::Text );
|
||||
setPreferredSize( -1.0, 1.5 * QFontMetricsF( font ).height() );
|
||||
}
|
||||
setElideMode( Qt::ElideRight );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class QskMessageSubWindow::PrivateData
|
||||
{
|
||||
public:
|
||||
QskGraphicLabel* symbolLabel;
|
||||
QskTextLabel* textLabel;
|
||||
};
|
||||
|
||||
QskMessageSubWindow::QskMessageSubWindow( QQuickItem* parent )
|
||||
: Inherited( parent )
|
||||
, m_data( new PrivateData() )
|
||||
{
|
||||
m_data->textLabel = new TextLabel( this );
|
||||
auto label = new TextLabel();
|
||||
|
||||
m_data->symbolLabel = new SymbolLabel( this );
|
||||
m_data->symbolLabel->hide();
|
||||
connect( label, &QskTextLabel::textChanged,
|
||||
this, &QskMessageSubWindow::textChanged );
|
||||
|
||||
auto box = new QskLinearBox( Qt::Horizontal );
|
||||
box->setDefaultAlignment( Qt::AlignTop | Qt::AlignHCenter );
|
||||
box->setSpacing( 0 );
|
||||
box->addItem( m_data->symbolLabel );
|
||||
box->addItem( m_data->textLabel );
|
||||
box->setStretchFactor( m_data->textLabel, 10 );
|
||||
connect( label, &QskTextLabel::textOptionsChanged,
|
||||
this, &QskMessageSubWindow::textOptionsChanged );
|
||||
|
||||
setContentItem( box );
|
||||
setContentItem( label );
|
||||
}
|
||||
|
||||
QskMessageSubWindow::~QskMessageSubWindow()
|
||||
@ -92,58 +45,30 @@ QskMessageSubWindow::~QskMessageSubWindow()
|
||||
|
||||
void QskMessageSubWindow::setText( const QString& text )
|
||||
{
|
||||
m_data->textLabel->setText( text );
|
||||
if ( auto label = qobject_cast< QskTextLabel* >( contentItem() ) )
|
||||
label->setText( text );
|
||||
}
|
||||
|
||||
QString QskMessageSubWindow::text() const
|
||||
{
|
||||
return m_data->textLabel->text();
|
||||
if ( auto label = qobject_cast< const QskTextLabel* >( contentItem() ) )
|
||||
return label->text();
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
void QskMessageSubWindow::setTextOptions( const QskTextOptions& options )
|
||||
{
|
||||
m_data->textLabel->setTextOptions( options );
|
||||
if ( auto label = qobject_cast< QskTextLabel* >( contentItem() ) )
|
||||
label->setTextOptions( options );
|
||||
}
|
||||
|
||||
QskTextOptions QskMessageSubWindow::textOptions() const
|
||||
{
|
||||
return m_data->textLabel->textOptions();
|
||||
}
|
||||
if ( auto label = qobject_cast< const QskTextLabel* >( contentItem() ) )
|
||||
return label->textOptions();
|
||||
|
||||
void QskMessageSubWindow::setSymbolSource( const QUrl& url )
|
||||
{
|
||||
m_data->symbolLabel->setSource( url );
|
||||
m_data->symbolLabel->setVisible( !url.isEmpty() );
|
||||
|
||||
if ( auto box = qobject_cast< QskLinearBox* >( contentItem() ) )
|
||||
box->setSpacing( m_data->symbolLabel->isVisible() ? 15 : 0 ); // metrics !!
|
||||
}
|
||||
|
||||
void QskMessageSubWindow::setSymbolType( int symbolType )
|
||||
{
|
||||
#if 1
|
||||
const auto graphic = QskStandardSymbol::graphic(
|
||||
static_cast< QskStandardSymbol::Type >( symbolType ) );
|
||||
#else
|
||||
const auto graphic = symbolHint( ... ); // TODO
|
||||
#endif
|
||||
setSymbol( graphic );
|
||||
}
|
||||
|
||||
QUrl QskMessageSubWindow::symbolSource() const
|
||||
{
|
||||
return m_data->symbolLabel->source();
|
||||
}
|
||||
|
||||
void QskMessageSubWindow::setSymbol( const QskGraphic& symbol )
|
||||
{
|
||||
m_data->symbolLabel->setVisible( !symbol.isNull() );
|
||||
m_data->symbolLabel->setGraphic( symbol );
|
||||
}
|
||||
|
||||
QskGraphic QskMessageSubWindow::symbol() const
|
||||
{
|
||||
return m_data->symbolLabel->graphic();
|
||||
return QskTextOptions();
|
||||
}
|
||||
|
||||
#include "moc_QskMessageSubWindow.cpp"
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "QskDialogSubWindow.h"
|
||||
|
||||
class QskGraphic;
|
||||
class QskTextOptions;
|
||||
|
||||
class QSK_EXPORT QskMessageSubWindow : public QskDialogSubWindow
|
||||
@ -21,8 +20,6 @@ class QSK_EXPORT QskMessageSubWindow : public QskDialogSubWindow
|
||||
Q_PROPERTY( QskTextOptions textOptions READ textOptions
|
||||
WRITE setTextOptions NOTIFY textOptionsChanged )
|
||||
|
||||
Q_PROPERTY( QUrl symbolSource READ symbolSource WRITE setSymbolSource )
|
||||
|
||||
using Inherited = QskDialogSubWindow;
|
||||
|
||||
public:
|
||||
@ -34,24 +31,12 @@ class QSK_EXPORT QskMessageSubWindow : public QskDialogSubWindow
|
||||
|
||||
QString text() const;
|
||||
|
||||
void setSymbolSource( const QUrl& url );
|
||||
QUrl symbolSource() const;
|
||||
|
||||
void setSymbolType( int symbolType );
|
||||
|
||||
void setSymbol( const QskGraphic& );
|
||||
QskGraphic symbol() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setText( const QString& );
|
||||
|
||||
Q_SIGNALS:
|
||||
void textChanged( const QString& );
|
||||
void textOptionsChanged( const QskTextOptions& );
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -4,15 +4,9 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskMessageWindow.h"
|
||||
#include "QskGraphicLabel.h"
|
||||
#include "QskGraphic.h"
|
||||
#include "QskLinearBox.h"
|
||||
#include "QskStandardSymbol.h"
|
||||
#include "QskTextLabel.h"
|
||||
#include "QskTextOptions.h"
|
||||
|
||||
#include <qfontmetrics.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
class TextLabel final : public QskTextLabel
|
||||
@ -33,38 +27,11 @@ namespace
|
||||
box, &QskMessageWindow::textOptionsChanged );
|
||||
}
|
||||
};
|
||||
|
||||
class SymbolLabel final : public QskGraphicLabel
|
||||
{
|
||||
public:
|
||||
SymbolLabel( QskMessageWindow* )
|
||||
{
|
||||
setObjectName( QStringLiteral( "QskMessageWindowSymbolLabel" ) );
|
||||
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
|
||||
setAlignment( Qt::AlignTop | Qt::AlignHCenter );
|
||||
updatePreferredSize();
|
||||
}
|
||||
|
||||
private:
|
||||
void updatePreferredSize()
|
||||
{
|
||||
// when there is no explicit size known,
|
||||
// we always adjust the icon according to the font
|
||||
|
||||
if ( graphicStrutSize().isEmpty() )
|
||||
{
|
||||
const QFont font = effectiveFont( QskTextLabel::Text );
|
||||
setPreferredSize( -1.0, 1.5 * QFontMetricsF( font ).height() );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class QskMessageWindow::PrivateData
|
||||
{
|
||||
public:
|
||||
QskGraphicLabel* symbolLabel;
|
||||
QskTextLabel* textLabel;
|
||||
};
|
||||
|
||||
@ -76,19 +43,7 @@ QskMessageWindow::QskMessageWindow( QWindow* parent )
|
||||
Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint );
|
||||
|
||||
m_data->textLabel = new TextLabel( this );
|
||||
|
||||
m_data->symbolLabel = new SymbolLabel( this );
|
||||
m_data->symbolLabel->hide();
|
||||
|
||||
auto box = new QskLinearBox( Qt::Horizontal );
|
||||
|
||||
box->setDefaultAlignment( Qt::AlignTop | Qt::AlignHCenter );
|
||||
box->setSpacing( 0 );
|
||||
box->addItem( m_data->symbolLabel );
|
||||
box->addItem( m_data->textLabel );
|
||||
box->setStretchFactor( m_data->textLabel, 10 );
|
||||
|
||||
setDialogContentItem( box );
|
||||
setDialogContentItem( m_data->textLabel );
|
||||
}
|
||||
|
||||
QskMessageWindow::~QskMessageWindow()
|
||||
@ -115,41 +70,4 @@ QskTextOptions QskMessageWindow::textOptions() const
|
||||
return m_data->textLabel->textOptions();
|
||||
}
|
||||
|
||||
void QskMessageWindow::setSymbolSource( const QUrl& url )
|
||||
{
|
||||
m_data->symbolLabel->setSource( url );
|
||||
m_data->symbolLabel->setVisible( !url.isEmpty() );
|
||||
|
||||
if ( auto box = qobject_cast< QskLinearBox* >( contentItem() ) )
|
||||
box->setSpacing( m_data->symbolLabel->isVisible() ? 15 : 0 ); // metrics !!
|
||||
}
|
||||
|
||||
void QskMessageWindow::setSymbolType( int symbolType )
|
||||
{
|
||||
#if 1
|
||||
const auto graphic = QskStandardSymbol::graphic(
|
||||
static_cast< QskStandardSymbol::Type >( symbolType ) );
|
||||
#else
|
||||
const auto graphic = symbolHint( ... ); // TODO
|
||||
#endif
|
||||
|
||||
setSymbol( graphic );
|
||||
}
|
||||
|
||||
QUrl QskMessageWindow::symbolSource() const
|
||||
{
|
||||
return m_data->symbolLabel->source();
|
||||
}
|
||||
|
||||
void QskMessageWindow::setSymbol( const QskGraphic& symbol )
|
||||
{
|
||||
m_data->symbolLabel->setVisible( !symbol.isNull() );
|
||||
m_data->symbolLabel->setGraphic( symbol );
|
||||
}
|
||||
|
||||
QskGraphic QskMessageWindow::symbol() const
|
||||
{
|
||||
return m_data->symbolLabel->graphic();
|
||||
}
|
||||
|
||||
#include "moc_QskMessageWindow.cpp"
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "QskDialogWindow.h"
|
||||
|
||||
class QskTextOptions;
|
||||
class QskGraphic;
|
||||
|
||||
class QSK_EXPORT QskMessageWindow : public QskDialogWindow
|
||||
{
|
||||
@ -21,8 +20,6 @@ class QSK_EXPORT QskMessageWindow : public QskDialogWindow
|
||||
Q_PROPERTY( QskTextOptions textOptions READ textOptions
|
||||
WRITE setTextOptions NOTIFY textOptionsChanged )
|
||||
|
||||
Q_PROPERTY( QUrl symbolSource READ symbolSource WRITE setSymbolSource )
|
||||
|
||||
using Inherited = QskDialogWindow;
|
||||
|
||||
public:
|
||||
@ -34,14 +31,6 @@ class QSK_EXPORT QskMessageWindow : public QskDialogWindow
|
||||
|
||||
QString text() const;
|
||||
|
||||
void setSymbolSource( const QUrl& url );
|
||||
QUrl symbolSource() const;
|
||||
|
||||
void setSymbolType( int symbolType );
|
||||
|
||||
void setSymbol( const QskGraphic& );
|
||||
QskGraphic symbol() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setText( const QString& );
|
||||
|
||||
|
@ -61,132 +61,6 @@ static void qskCancelGraphic( QPainter* painter )
|
||||
painter->drawPath( path );
|
||||
}
|
||||
|
||||
static void qskCriticalGraphic( QPainter* painter )
|
||||
{
|
||||
QPainterPath path;
|
||||
path.addEllipse( 0, 5, 40, 40 );
|
||||
path.addRect( 5, 22, 30, 5 );
|
||||
|
||||
painter->setPen( Qt::NoPen );
|
||||
// painter->setBrush( QColor( Qt::black ) );
|
||||
painter->setBrush( QColor( Qt::red ) );
|
||||
painter->drawPath( path );
|
||||
}
|
||||
|
||||
static void qskWarningGraphic( QPainter* painter )
|
||||
{
|
||||
const QRectF outerRect( 0, 2, 40, 36 );
|
||||
|
||||
const double off = 0.2 * qMin( outerRect.width(), outerRect.height() );
|
||||
|
||||
const double offBottom = 0.5 * ( outerRect.width() / outerRect.height() ) * off;
|
||||
const QRectF innerRect = outerRect.adjusted( off, off, -off, -offBottom );
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
path.moveTo( outerRect.center().x(), outerRect.top() );
|
||||
path.lineTo( outerRect.right(), outerRect.bottom() );
|
||||
path.lineTo( outerRect.left(), outerRect.bottom() );
|
||||
path.closeSubpath();
|
||||
|
||||
path.moveTo( innerRect.left(), innerRect.bottom() );
|
||||
path.lineTo( innerRect.right(), innerRect.bottom() );
|
||||
path.lineTo( innerRect.center().x(), innerRect.top() );
|
||||
path.closeSubpath();
|
||||
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( QColor( Qt::red ) );
|
||||
painter->drawPath( path );
|
||||
|
||||
const double d = 0.25 * off;
|
||||
|
||||
const QRectF r1(
|
||||
innerRect.center().x() - d,
|
||||
innerRect.top() + 0.25 * innerRect.height(),
|
||||
2 * d,
|
||||
0.5 * innerRect.height() );
|
||||
|
||||
painter->fillRect( r1, Qt::black );
|
||||
|
||||
const QRectF r2(
|
||||
r1.x(),
|
||||
r1.bottom() + 0.05 * innerRect.height(),
|
||||
r1.width(),
|
||||
r1.width() );
|
||||
|
||||
painter->fillRect( r2, Qt::black );
|
||||
}
|
||||
|
||||
static void qskQuestionGraphic( QPainter* painter )
|
||||
{
|
||||
const double w = 40;
|
||||
const double h = 50;
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
path.addRect( 0, 0, 1.0, 1.0 );
|
||||
|
||||
path.moveTo( 0.55, 0.63 );
|
||||
path.lineTo( 0.325, 0.63 );
|
||||
path.cubicTo( 0.325, 0.578, 0.33, 0.554, 0.3425, 0.532 );
|
||||
path.cubicTo( 0.3575, 0.51, 0.385, 0.484, 0.43, 0.452 );
|
||||
path.cubicTo( 0.495, 0.406, 0.5125, 0.388, 0.5225, 0.374 );
|
||||
path.cubicTo( 0.5325, 0.358, 0.54, 0.342, 0.54, 0.328 );
|
||||
path.cubicTo( 0.54, 0.304, 0.53, 0.286, 0.51, 0.272 );
|
||||
path.cubicTo( 0.49, 0.258, 0.46, 0.252, 0.425, 0.252 );
|
||||
path.cubicTo( 0.3925, 0.252, 0.355, 0.258, 0.315, 0.27 );
|
||||
path.cubicTo( 0.275, 0.28, 0.235, 0.298, 0.1925, 0.32 );
|
||||
path.lineTo( 0.195, 0.162 );
|
||||
path.cubicTo( 0.245, 0.148, 0.29, 0.138, 0.3325, 0.132 );
|
||||
path.cubicTo( 0.3725, 0.124, 0.4125, 0.122, 0.4525, 0.122 );
|
||||
path.cubicTo( 0.5525, 0.122, 0.63, 0.138, 0.685, 0.172 );
|
||||
path.cubicTo( 0.7375, 0.204, 0.765, 0.252, 0.765, 0.316 );
|
||||
path.cubicTo( 0.7625, 0.348, 0.755, 0.378, 0.74, 0.404 );
|
||||
path.cubicTo( 0.725, 0.43, 0.695, 0.458, 0.6575, 0.488 );
|
||||
path.cubicTo( 0.5875, 0.536, 0.57, 0.552, 0.5625, 0.566 );
|
||||
path.cubicTo( 0.55, 0.578, 0.55, 0.592, 0.55, 0.63 );
|
||||
|
||||
path.closeSubpath();
|
||||
|
||||
path.addRect( 0.325, 0.66, 0.55 - 0.325, ( 0.55 - 0.325 ) * w / h );
|
||||
|
||||
painter->scale( w, h );
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( QColor( Qt::black ) );
|
||||
painter->drawPath( path );
|
||||
}
|
||||
|
||||
static void qskInformationGraphic( QPainter* painter )
|
||||
{
|
||||
const double w = 40;
|
||||
const double h = 50;
|
||||
|
||||
const QRectF dotRect( 0.3 * w, 0.15 * h, 0.4 * w, 0.2 * h );
|
||||
const QRectF barRect( 0.3 * w, 0.4 * h, 0.4 * w, 0.5 * h );
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
path.addRect( 0, 0, w, h );
|
||||
path.addEllipse( dotRect );
|
||||
|
||||
const double dx = 0.33 * barRect.width();
|
||||
const double dy = 0.25 * dotRect.height();
|
||||
|
||||
path.moveTo( barRect.left(), barRect.top() );
|
||||
path.cubicTo(
|
||||
barRect.left() + dx, barRect.top() + dy,
|
||||
barRect.left() + 2 * dx, barRect.top() + dy,
|
||||
barRect.right(), barRect.top() );
|
||||
|
||||
path.lineTo( barRect.right(), barRect.bottom() );
|
||||
path.lineTo( barRect.left(), barRect.bottom() );
|
||||
path.closeSubpath();
|
||||
|
||||
painter->setPen( Qt::NoPen );
|
||||
painter->setBrush( QColor( Qt::black ) );
|
||||
painter->drawPath( path );
|
||||
}
|
||||
|
||||
static void qskCheckMarkGraphic( QPainter* painter )
|
||||
{
|
||||
QPainterPath path;
|
||||
@ -288,26 +162,6 @@ QskGraphic QskStandardSymbol::graphic( Type symbolType )
|
||||
qskCancelGraphic( &painter );
|
||||
break;
|
||||
}
|
||||
case QskStandardSymbol::Warning:
|
||||
{
|
||||
qskWarningGraphic( &painter );
|
||||
break;
|
||||
}
|
||||
case QskStandardSymbol::Critical:
|
||||
{
|
||||
qskCriticalGraphic( &painter );
|
||||
break;
|
||||
}
|
||||
case QskStandardSymbol::Question:
|
||||
{
|
||||
qskQuestionGraphic( &painter );
|
||||
break;
|
||||
}
|
||||
case QskStandardSymbol::Information:
|
||||
{
|
||||
qskInformationGraphic( &painter );
|
||||
break;
|
||||
}
|
||||
case QskStandardSymbol::CheckMark:
|
||||
{
|
||||
qskCheckMarkGraphic( &painter );
|
||||
|
@ -22,11 +22,6 @@ namespace QskStandardSymbol
|
||||
Ok,
|
||||
Cancel,
|
||||
|
||||
Information,
|
||||
Warning,
|
||||
Critical,
|
||||
Question,
|
||||
|
||||
CheckMark,
|
||||
CrossMark,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user