Commit 91ef7469 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): add `Notification` component, restore `DesktopPopup` component without notification deps

parent 80e643e8
...@@ -118,6 +118,7 @@ ...@@ -118,6 +118,7 @@
<file>ui/modules/Linphone/Contact/ContactDescription.qml</file> <file>ui/modules/Linphone/Contact/ContactDescription.qml</file>
<file>ui/modules/Linphone/Contact/Contact.qml</file> <file>ui/modules/Linphone/Contact/Contact.qml</file>
<file>ui/modules/Linphone/Notifications/CallNotification.qml</file> <file>ui/modules/Linphone/Notifications/CallNotification.qml</file>
<file>ui/modules/Linphone/Notifications/Notification.qml</file>
<file>ui/modules/Linphone/Presence/PresenceLevel.qml</file> <file>ui/modules/Linphone/Presence/PresenceLevel.qml</file>
<file>ui/modules/Linphone/Presence/PresenceString.qml</file> <file>ui/modules/Linphone/Presence/PresenceString.qml</file>
<file>ui/modules/Linphone/qmldir</file> <file>ui/modules/Linphone/qmldir</file>
...@@ -127,6 +128,7 @@ ...@@ -127,6 +128,7 @@
<file>ui/modules/Linphone/Styles/Contact/AvatarStyle.qml</file> <file>ui/modules/Linphone/Styles/Contact/AvatarStyle.qml</file>
<file>ui/modules/Linphone/Styles/Contact/ContactDescriptionStyle.qml</file> <file>ui/modules/Linphone/Styles/Contact/ContactDescriptionStyle.qml</file>
<file>ui/modules/Linphone/Styles/Contact/ContactStyle.qml</file> <file>ui/modules/Linphone/Styles/Contact/ContactStyle.qml</file>
<file>ui/modules/Linphone/Styles/NotificationStyle.qml</file>
<file>ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml</file> <file>ui/modules/Linphone/Styles/Presence/PresenceStringStyle.qml</file>
<file>ui/modules/Linphone/Styles/qmldir</file> <file>ui/modules/Linphone/Styles/qmldir</file>
<file>ui/modules/Linphone/Styles/TimelineStyle.qml</file> <file>ui/modules/Linphone/Styles/TimelineStyle.qml</file>
......
...@@ -7,14 +7,12 @@ ...@@ -7,14 +7,12 @@
// Notifications QML properties/methods. // Notifications QML properties/methods.
#define NOTIFICATION_SHOW_METHOD_NAME "show" #define NOTIFICATION_SHOW_METHOD_NAME "show"
#define NOTIFICATION_EDGE_PROPERTY_NAME "edge" #define NOTIFICATION_HEIGHT_PROPERTY "notificationHeight"
#define NOTIFICATION_HEIGHT_PROPERTY "popupHeight" #define NOTIFICATION_OFFSET_PROPERTY_NAME "notificationOffset"
#define NOTIFICATION_OFFSET_PROPERTY_NAME "edgeOffset"
// Arbitrary hardcoded values. // Arbitrary hardcoded values.
#define NOTIFICATION_SPACING 10 #define NOTIFICATION_SPACING 10
#define NOTIFICATION_START_OFFSET 30 #define N_MAX_NOTIFICATIONS 15
#define N_MAX_NOTIFICATIONS 3
// =================================================================== // ===================================================================
...@@ -47,7 +45,7 @@ bool setProperty (QObject &object, const char *property, const T &value) { ...@@ -47,7 +45,7 @@ bool setProperty (QObject &object, const char *property, const T &value) {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
Notifier::Notifier (QObject *parent) : Notifier::Notifier (QObject *parent) :
QObject(parent), m_offset(NOTIFICATION_START_OFFSET) { QObject(parent) {
QQmlEngine *engine = App::getInstance()->getEngine(); QQmlEngine *engine = App::getInstance()->getEngine();
// Build components. // Build components.
...@@ -95,7 +93,6 @@ void Notifier::showCallMessage ( ...@@ -95,7 +93,6 @@ void Notifier::showCallMessage (
if ( if (
offset == -1 || offset == -1 ||
!::setProperty(*object, NOTIFICATION_EDGE_PROPERTY_NAME, Qt::TopEdge | Qt::RightEdge) ||
!::setProperty(*object, NOTIFICATION_OFFSET_PROPERTY_NAME, m_offset) !::setProperty(*object, NOTIFICATION_OFFSET_PROPERTY_NAME, m_offset)
) { ) {
delete object; delete object;
...@@ -108,7 +105,7 @@ void Notifier::showCallMessage ( ...@@ -108,7 +105,7 @@ void Notifier::showCallMessage (
m_mutex.unlock(); m_mutex.unlock();
// Display popup. // Display notification.
QMetaObject::invokeMethod(object, "show", Qt::DirectConnection); QMetaObject::invokeMethod(object, "show", Qt::DirectConnection);
// Destroy it after timeout. // Destroy it after timeout.
...@@ -119,7 +116,7 @@ void Notifier::showCallMessage ( ...@@ -119,7 +116,7 @@ void Notifier::showCallMessage (
m_n_instances--; m_n_instances--;
if (m_n_instances == 0) if (m_n_instances == 0)
m_offset = NOTIFICATION_START_OFFSET; m_offset = 0;
m_mutex.unlock(); m_mutex.unlock();
}); });
......
...@@ -24,8 +24,6 @@ public slots: ...@@ -24,8 +24,6 @@ public slots:
void showCallMessage (int timeout, const QString &sip_address); void showCallMessage (int timeout, const QString &sip_address);
private: private:
void computePositions ();
QQmlComponent *m_components[MaxNbTypes]; QQmlComponent *m_components[MaxNbTypes];
int m_offset = 0; int m_offset = 0;
......
...@@ -8,13 +8,10 @@ import Common.Styles 1.0 ...@@ -8,13 +8,10 @@ import Common.Styles 1.0
Item { Item {
id: wrapper id: wrapper
property int popupX: 0 property alias popupX: popup.x
property int popupY: 0 property alias popupY: popup.y
property int edge: 0 property int flags: Qt.SplashScreen
property int edgeOffset: 0
property int flags: Qt.Popup
readonly property alias popupWidth: popup.width readonly property alias popupWidth: popup.width
readonly property alias popupHeight: popup.height readonly property alias popupHeight: popup.height
...@@ -30,34 +27,6 @@ Item { ...@@ -30,34 +27,6 @@ Item {
_isOpen = false _isOpen = false
} }
function _applyXEdge () {
var screen = popup.Screen
if (screen == null) {
return popupX
}
if (edge & Qt.LeftEdge) {
return PopupStyle.desktop.edgeMargin
}
return screen.width - popup.width - PopupStyle.desktop.edgeMargin
}
function _applyYEdge () {
var screen = popup.Screen
if (screen == null) {
return popupY
}
if (edge & Qt.TopEdge) {
return edgeOffset + PopupStyle.desktop.edgeMargin
}
return screen.height - popup.height - edgeOffset - PopupStyle.desktop.edgeMargin
}
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// DO NOT TOUCH THIS PROPERTIES. // DO NOT TOUCH THIS PROPERTIES.
...@@ -79,9 +48,6 @@ Item { ...@@ -79,9 +48,6 @@ Item {
height: _content[0] != null ? _content[0].height : 0 height: _content[0] != null ? _content[0].height : 0
width: _content[0] != null ? _content[0].width : 0 width: _content[0] != null ? _content[0].width : 0
x: edge ? _applyXEdge() : popupX
y: edge ? _applyYEdge() : popupY
Item { Item {
id: content id: content
......
...@@ -90,7 +90,6 @@ Item { ...@@ -90,7 +90,6 @@ Item {
return point return point
} }
flags: Qt.SplashScreen
popupX: coords.x popupX: coords.x
popupY: coords.y popupY: coords.y
......
...@@ -13,10 +13,6 @@ QtObject { ...@@ -13,10 +13,6 @@ QtObject {
property int closingDuration: 250 property int closingDuration: 250
} }
property QtObject desktop: QtObject {
property int edgeMargin: 10
}
property QtObject shadow: QtObject { property QtObject shadow: QtObject {
property color color: Colors.l property color color: Colors.l
property int horizontalOffset: 4 property int horizontalOffset: 4
......
import QtQuick 2.7 import QtQuick 2.7
import Common 1.0 Notification {
DesktopPopup {
Rectangle { Rectangle {
color: 'red' color: 'red'
......
import QtQuick 2.7
// Warning: This import is necessary to use the attached property `Screen`.
// See: https://doc-snapshots.qt.io/qt5-5.7/qml-qtquick-window-screen.html
import QtQuick.Window 2.2
import Common 1.0
import Linphone.Styles 1.0
import Utils 1.0
// ===================================================================
DesktopPopup {
id: notification
property int notificationOffset: 0
property alias notificationHeight: notification.popupHeight
flags: Qt.Popup
Component.onCompleted: {
var window = data[0]
Utils.assert(
Utils.qmlTypeof(window, 'QQuickWindowQmlImpl'), true,
'Unable to found `Window` object in `DesktopPopup`.'
)
window.x = Qt.binding(function () {
var screen = window.Screen
return screen != null
? screen.width - window.width - NotificationStyle.margin
: 0
})
window.y = Qt.binding(function () {
var screen = window.Screen
return screen != null
? screen.desktopAvailableHeight - window.height - notificationOffset
: 0
})
}
}
pragma Singleton
import QtQuick 2.7
// ===================================================================
QtObject {
property int margin: 10
}
...@@ -12,6 +12,8 @@ singleton AvatarStyle 1.0 Contact/AvatarStyle.qml ...@@ -12,6 +12,8 @@ singleton AvatarStyle 1.0 Contact/AvatarStyle.qml
singleton ContactDescriptionStyle 1.0 Contact/ContactDescriptionStyle.qml singleton ContactDescriptionStyle 1.0 Contact/ContactDescriptionStyle.qml
singleton ContactStyle 1.0 Contact/ContactStyle.qml singleton ContactStyle 1.0 Contact/ContactStyle.qml
singleton NotificationStyle 1.0 NotificationStyle.qml
singleton PresenceStringStyle 1.0 Presence/PresenceStringStyle.qml singleton PresenceStringStyle 1.0 Presence/PresenceStringStyle.qml
singleton TimelineStyle 1.0 TimelineStyle.qml singleton TimelineStyle 1.0 TimelineStyle.qml
...@@ -20,9 +20,6 @@ Avatar 1.0 Contact/Avatar.qml ...@@ -20,9 +20,6 @@ Avatar 1.0 Contact/Avatar.qml
Contact 1.0 Contact/Contact.qml Contact 1.0 Contact/Contact.qml
ContactDescription 1.0 Contact/ContactDescription.qml ContactDescription 1.0 Contact/ContactDescription.qml
# Notifications
CallNotification 1.0 Notifications/CallNotification.qml
# Presence # Presence
PresenceLevel 1.0 Presence/PresenceLevel.qml PresenceLevel 1.0 Presence/PresenceLevel.qml
PresenceString 1.0 Presence/PresenceString.qml PresenceString 1.0 Presence/PresenceString.qml
......
...@@ -78,6 +78,10 @@ TestCase { ...@@ -78,6 +78,10 @@ TestCase {
component: 'import QtQuick 2.7; MouseArea {}', component: 'import QtQuick 2.7; MouseArea {}',
result: true, result: true,
type: 'QQuickMouseArea' type: 'QQuickMouseArea'
}, {
component: 'import QtQuick 2.7; import QtQuick.Window 2.2; Window {}',
result: true,
type: 'QQuickWindowQmlImpl'
} }
] ]
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment