Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send all required properties with events #88

Open
wants to merge 1 commit into
base: mart/clientsideTimeout
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions import/abstractdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ bool AbstractDelegate::childMouseEventFilter(QQuickItem *item, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress) {
forceActiveFocus(Qt::MouseFocusReason);
triggerGuiEvent(QStringLiteral("system.gui.user.interaction"), QVariantMap({{QStringLiteral("skillId"), m_skillId}}));
triggerGuiEvent(QStringLiteral("system.gui.user.interaction"),
QVariantMap({{QStringLiteral("skillId"), m_skillId},
{QStringLiteral("skillPage"), m_qmlUrl},
{QStringLiteral("skillTimeout"), m_timeout}}));
emit userInteraction();
}
return QQuickItem::childMouseEventFilter(item, event);
Expand All @@ -290,13 +293,19 @@ bool AbstractDelegate::childMouseEventFilter(QQuickItem *item, QEvent *event)
void AbstractDelegate::mousePressEvent(QMouseEvent *event)
{
forceActiveFocus(Qt::MouseFocusReason);
triggerGuiEvent(QStringLiteral("system.gui.user.interaction"), QVariantMap({{QStringLiteral("skillId"), m_skillId}}));
triggerGuiEvent(QStringLiteral("system.gui.user.interaction"),
QVariantMap({{QStringLiteral("skillId"), m_skillId},
{QStringLiteral("skillPage"), m_qmlUrl},
{QStringLiteral("skillTimeout"), m_timeout}}));
emit userInteraction();
}

void AbstractDelegate::keyReleaseEvent(QKeyEvent *event)
{
triggerGuiEvent(QStringLiteral("system.gui.user.interaction"), QVariantMap({{QStringLiteral("skillId"), m_skillId}}));
triggerGuiEvent(QStringLiteral("system.gui.user.interaction"),
QVariantMap({{QStringLiteral("skillId"), m_skillId},
{QStringLiteral("skillPage"), m_qmlUrl},
{QStringLiteral("skillTimeout"), m_timeout}}));
emit userInteraction();
}

Expand All @@ -319,7 +328,11 @@ void AbstractDelegate::focusInEvent(QFocusEvent *event)

int index = context->contextProperty(QStringLiteral("index")).toInt();
if (index >= 0) {
triggerGuiEvent(QStringLiteral("page_gained_focus"), QVariantMap({{QStringLiteral("number"), index}, {QStringLiteral("skillId"), m_skillId}}));
triggerGuiEvent(QStringLiteral("page_gained_focus"),
QVariantMap({{QStringLiteral("number"), index},
{QStringLiteral("skillId"), m_skillId},
{QStringLiteral("skillPage"), m_qmlUrl},
{QStringLiteral("skillTimeout"), m_timeout}}));
}
}

Expand Down
2 changes: 1 addition & 1 deletion import/abstractdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ class AbstractDelegate: public QQuickItem
* @internal Url of the qml file that generated this instance
*/
void setQmlUrl(const QUrl &url);
QUrl qmlUrl() const;

/**
* @internal skill id this delegate belongs to
Expand All @@ -186,6 +185,7 @@ public Q_SLOTS:
*/
void triggerGuiEvent(const QString &eventName, const QVariantMap &parameters);
QString skillId() const;
QUrl qmlUrl() const;

protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
Expand Down
6 changes: 4 additions & 2 deletions import/abstractskillview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ void AbstractSkillView::deleteProperty(const QString &skillId, const QString &pr
m_guiWebSocket->sendTextMessage(QString::fromUtf8(doc.toJson()));
}

void AbstractSkillView::showHomeScreen()
void AbstractSkillView::showHomeScreen(const QString &skillId, const QString &skillPage)
{
m_controller->sendRequest(QStringLiteral("mycroft.device.show.idle"), {});
m_controller->sendRequest(QStringLiteral("mycroft.device.display.timeout"),
QVariantMap({{QStringLiteral("skillId"), skillId},
{QStringLiteral("skillPage"), skillPage}}));
}

MycroftController::Status AbstractSkillView::status() const
Expand Down
2 changes: 1 addition & 1 deletion import/abstractskillview.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AbstractSkillView: public QQuickItem
void writeProperties(const QString &skillId, const QVariantMap &data);
void deleteProperty(const QString &skillId, const QString &property);

Q_INVOKABLE void showHomeScreen();
Q_INVOKABLE void showHomeScreen(const QString &skillId, const QString &skillPage);

Q_SIGNALS:
/**
Expand Down
2 changes: 1 addition & 1 deletion import/qml/SkillView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Mycroft.AbstractSkillView {
running = false;
}
}
onTriggered: root.showHomeScreen();
onTriggered: root.showHomeScreen(currentItem.contentItem.skillId(), currentItem.contentItem.qmlUrl());
}

Item {
Expand Down