correctly wrap title content, buttons
This commit is contained in:
parent
1828503757
commit
2d19601715
@ -38,8 +38,9 @@
|
||||
|
||||
uint FullScreenDialog::s_numItems = 0;
|
||||
|
||||
FullScreenDialog::FullScreenDialog(QObject *parent)
|
||||
: QObject(parent)
|
||||
FullScreenDialog::FullScreenDialog(QDeclarativeItem *parent)
|
||||
: QDeclarativeItem(parent),
|
||||
m_declarativeItemContainer(0)
|
||||
{
|
||||
m_view = new QGraphicsView();
|
||||
m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
@ -90,7 +91,14 @@ FullScreenDialog::FullScreenDialog(QObject *parent)
|
||||
|
||||
QDeclarativeContext *creationContext = component->creationContext();
|
||||
m_rootObject = component->create(creationContext);
|
||||
|
||||
if (m_rootObject) {
|
||||
setMainItem(qobject_cast<QGraphicsObject *>(m_rootObject.data()));
|
||||
connect(m_rootObject.data(), SIGNAL(statusChanged()), this, SLOT(statusHasChanged()));
|
||||
connect(m_rootObject.data(), SIGNAL(accepted()), this, SIGNAL(accepted()));
|
||||
connect(m_rootObject.data(), SIGNAL(rejected()), this, SIGNAL(rejected()));
|
||||
connect(m_rootObject.data(), SIGNAL(clickedOutside()), this, SIGNAL(clickedOutside()));
|
||||
}
|
||||
}
|
||||
|
||||
FullScreenDialog::~FullScreenDialog()
|
||||
@ -199,31 +207,30 @@ void FullScreenDialog::setVisible(const bool visible)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QDeclarativeListProperty<QDeclarativeItem> FullScreenDialog::title() const
|
||||
QDeclarativeListProperty<QGraphicsObject> FullScreenDialog::title()
|
||||
{
|
||||
if (m_rootObject) {
|
||||
return m_rootObject.data()->property("title").value<QDeclarativeListProperty<QDeclarativeItem> >();
|
||||
return m_rootObject.data()->property("title").value<QDeclarativeListProperty<QGraphicsObject> >();
|
||||
} else {
|
||||
return QDeclarativeListProperty<QDeclarativeItem>();
|
||||
return QDeclarativeListProperty<QGraphicsObject>();
|
||||
}
|
||||
}
|
||||
|
||||
QDeclarativeListProperty<QDeclarativeItem> FullScreenDialog::content() const
|
||||
QDeclarativeListProperty<QGraphicsObject> FullScreenDialog::content() const
|
||||
{
|
||||
if (m_rootObject) {
|
||||
return m_rootObject.data()->property("content").value<QDeclarativeListProperty<QDeclarativeItem> >();
|
||||
return m_rootObject.data()->property("content").value<QDeclarativeListProperty<QGraphicsObject> >();
|
||||
} else {
|
||||
return QDeclarativeListProperty<QDeclarativeItem>();
|
||||
return QDeclarativeListProperty<QGraphicsObject>();
|
||||
}
|
||||
}
|
||||
|
||||
QDeclarativeListProperty<QDeclarativeItem> FullScreenDialog::buttons() const
|
||||
QDeclarativeListProperty<QGraphicsObject> FullScreenDialog::buttons() const
|
||||
{
|
||||
if (m_rootObject) {
|
||||
return m_rootObject.data()->property("buttons").value<QDeclarativeListProperty<QDeclarativeItem> >();
|
||||
return m_rootObject.data()->property("buttons").value<QDeclarativeListProperty<QGraphicsObject> >();
|
||||
} else {
|
||||
return QDeclarativeListProperty<QDeclarativeItem>();
|
||||
return QDeclarativeListProperty<QGraphicsObject>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,6 +244,47 @@ DialogStatus::Status FullScreenDialog::status() const
|
||||
}
|
||||
|
||||
|
||||
void FullScreenDialog::statusHasChanged()
|
||||
{
|
||||
if (status() == DialogStatus::Closed) {
|
||||
setVisible(false);
|
||||
} else {
|
||||
setVisible(true);
|
||||
}
|
||||
emit statusChanged();
|
||||
}
|
||||
|
||||
void FullScreenDialog::open()
|
||||
{
|
||||
if (m_rootObject) {
|
||||
QMetaObject::invokeMethod(m_rootObject.data(), "open");
|
||||
}
|
||||
}
|
||||
|
||||
void FullScreenDialog::accept()
|
||||
{
|
||||
if (m_rootObject) {
|
||||
QMetaObject::invokeMethod(m_rootObject.data(), "accept");
|
||||
}
|
||||
}
|
||||
|
||||
void FullScreenDialog::reject()
|
||||
{
|
||||
if (m_rootObject) {
|
||||
QMetaObject::invokeMethod(m_rootObject.data(), "reject");
|
||||
}
|
||||
}
|
||||
|
||||
void FullScreenDialog::close()
|
||||
{
|
||||
if (m_rootObject) {
|
||||
QMetaObject::invokeMethod(m_rootObject.data(), "close");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool FullScreenDialog::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == m_view &&
|
||||
|
@ -33,21 +33,18 @@ class QGraphicsView;
|
||||
class QGraphicsScene;
|
||||
class DeclarativeItemContainer;
|
||||
|
||||
class FullScreenDialog : public QObject
|
||||
class FullScreenDialog : public QDeclarativeItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> title READ title)
|
||||
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> content READ content)
|
||||
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeItem> buttons READ buttons)
|
||||
Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> title READ title DESIGNABLE false)
|
||||
Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> content READ content DESIGNABLE false)
|
||||
Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> buttons READ buttons DESIGNABLE false)
|
||||
Q_PROPERTY(DialogStatus::Status status READ status NOTIFY statusChanged)
|
||||
/*property alias content: contentItem.children
|
||||
property alias buttons: buttonItem.children
|
||||
property int status: DialogStatus.Closed*/
|
||||
|
||||
|
||||
public:
|
||||
FullScreenDialog(QObject *parent = 0);
|
||||
FullScreenDialog(QDeclarativeItem *parent = 0);
|
||||
~FullScreenDialog();
|
||||
|
||||
QGraphicsObject *mainItem() const;
|
||||
@ -56,12 +53,18 @@ public:
|
||||
bool isVisible() const;
|
||||
void setVisible(const bool visible);
|
||||
|
||||
|
||||
//QML properties
|
||||
QDeclarativeListProperty<QDeclarativeItem> title()const ;
|
||||
QDeclarativeListProperty<QDeclarativeItem> content() const;
|
||||
QDeclarativeListProperty<QDeclarativeItem> buttons() const;
|
||||
QDeclarativeListProperty<QGraphicsObject> title();
|
||||
QDeclarativeListProperty<QGraphicsObject> content() const;
|
||||
QDeclarativeListProperty<QGraphicsObject> buttons() const;
|
||||
DialogStatus::Status status() const;
|
||||
|
||||
Q_INVOKABLE void open();
|
||||
Q_INVOKABLE void accept();
|
||||
Q_INVOKABLE void reject();
|
||||
Q_INVOKABLE void close();
|
||||
|
||||
Q_SIGNALS:
|
||||
void accepted();
|
||||
void rejected();
|
||||
@ -69,8 +72,9 @@ Q_SIGNALS:
|
||||
void statusChanged();
|
||||
|
||||
|
||||
protected Q_SLOTS:
|
||||
private Q_SLOTS:
|
||||
void syncMainItem();
|
||||
void statusHasChanged();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
Loading…
Reference in New Issue
Block a user