diff --git a/src/plugins/backends/snore/notification.qml b/src/plugins/backends/snore/notification.qml index dea1e09..340f34b 100644 --- a/src/plugins/backends/snore/notification.qml +++ b/src/plugins/backends/snore/notification.qml @@ -23,13 +23,26 @@ Rectangle { if (!isUpdate) { + var corner = window.corner var id = window.id var space = (id + 1) * height * 0.025 - window.y = space + (space + height) * id animation.target = window - animation.from = Screen.desktopAvailableWidth - animation.to = Screen.desktopAvailableWidth - width + + window.y = space + (space + height) * id + if (corner == Qt.TopRightCorner || corner == Qt.BottomRightCorner) { + animation.from = Screen.desktopAvailableWidth + animation.to = Screen.desktopAvailableWidth - width + } else if(corner == Qt.TopLeftCorner || corner == Qt.BottomLeftCorner) { + animation.from = -width + animation.to = 0 + } + if (corner == Qt.TopRightCorner || corner == Qt.TopLeftCorner) { + window.y = space + (space + height) * id + } else { + window.y = Screen.desktopAvailableHeight - (space + (space + height) * (id + 1)) + } + animation.start() window.visible = true } diff --git a/src/plugins/backends/snore/notifywidget.cpp b/src/plugins/backends/snore/notifywidget.cpp index 196002c..f90c53e 100644 --- a/src/plugins/backends/snore/notifywidget.cpp +++ b/src/plugins/backends/snore/notifywidget.cpp @@ -26,9 +26,10 @@ #include using namespace Snore; -NotifyWidget::NotifyWidget(int pos, QWindow *parent) : +NotifyWidget::NotifyWidget(int pos, Qt::Corner corner, QWindow *parent) : QQuickView(QUrl("qrc:/notification.qml"),parent), m_id(pos), + m_corner(corner), m_mem(QString("SnoreNotifyWidget_rev%1_id%2").arg(QString::number(SHARED_MEM_TYPE_REV()), QString::number(m_id))), m_ready(true) { @@ -147,6 +148,11 @@ int NotifyWidget::id() return m_id; } +Qt::Corner NotifyWidget::corner() +{ + return m_corner; +} + void NotifyWidget::slotDismissed() { emit dismissed(); diff --git a/src/plugins/backends/snore/notifywidget.h b/src/plugins/backends/snore/notifywidget.h index f3b805a..9354b41 100644 --- a/src/plugins/backends/snore/notifywidget.h +++ b/src/plugins/backends/snore/notifywidget.h @@ -44,7 +44,8 @@ class NotifyWidget : public QQuickView public: Q_PROPERTY(int id READ id) - explicit NotifyWidget(int pos, QWindow *parent = 0); + Q_PROPERTY(Qt::Corner corner READ corner) + explicit NotifyWidget(int pos, Qt::Corner corner, QWindow *parent = 0); ~NotifyWidget(); void display(const Snore::Notification ¬ification); @@ -55,6 +56,7 @@ public: Snore::Notification ¬ification(); int id(); + Qt::Corner corner(); signals: void invoked(); @@ -71,6 +73,7 @@ private: Snore::Notification m_notification; QObject *m_qmlNotification; int m_id; + Qt::Corner m_corner; QSharedMemory m_mem; bool m_ready; }; diff --git a/src/plugins/backends/snore/snorenotifier.cpp b/src/plugins/backends/snore/snorenotifier.cpp index 11d5486..df84624 100644 --- a/src/plugins/backends/snore/snorenotifier.cpp +++ b/src/plugins/backends/snore/snorenotifier.cpp @@ -123,8 +123,9 @@ void SnoreNotifier::slotProcessQueue() void SnoreNotifier::setup() { + Qt::Corner displayPos = static_cast(value("Position").toInt()); for (int i = 0; i < m_widgets.size(); ++i) { - NotifyWidget *w = new NotifyWidget(i); + NotifyWidget *w = new NotifyWidget(i,displayPos); m_widgets[i] = w; connect(w, SIGNAL(dismissed()), this, SLOT(slotDismissed())); connect(w, SIGNAL(invoked()), this, SLOT(slotInvoked())); @@ -138,6 +139,7 @@ void SnoreNotifier::setup() bool SnoreNotifier::initialize(SnoreCore *snore) { if (SnoreBackend::initialize(snore)) { + setDefaultValue("Position", Qt::TopRightCorner, "The position for the notification."); return metaObject()->invokeMethod(this, "setup", Qt::QueuedConnection); } return false;