Merge branch 'Plasma/5.17'

wilder-5.18
Kai Uwe Broulik 7 years ago
commit dba078d9ec
  1. 1
      applets/notifications/CMakeLists.txt
  2. 10
      applets/notifications/notificationapplet.cpp
  3. 5
      applets/notifications/notificationapplet.h
  4. 16
      applets/notifications/package/contents/ui/global/Globals.qml

@ -15,6 +15,7 @@ target_link_libraries(plasma_applet_notifications
Qt5::Quick # for QQmlParserStatus
KF5::I18n
KF5::Plasma
KF5::PlasmaQuick
KF5::KIOWidgets # for PreviewJob
)

@ -23,12 +23,15 @@
#include <QClipboard>
#include <QDrag>
#include <QGuiApplication>
#include <QMimeData>
#include <QQuickItem>
#include <QQuickWindow>
#include <QScreen>
#include <QStyleHints>
#include <PlasmaQuick/Dialog>
#include "filemenu.h"
#include "thumbnailer.h"
@ -43,6 +46,8 @@ NotificationApplet::NotificationApplet(QObject *parent, const QVariantList &data
qmlProtectModule(uri, 2);
s_typesRegistered = true;
}
connect(qApp, &QGuiApplication::focusWindowChanged, this, &NotificationApplet::focussedPlasmaDialogChanged);
}
NotificationApplet::~NotificationApplet() = default;
@ -105,6 +110,11 @@ void NotificationApplet::doDrag(QQuickItem *item, const QUrl &url, const QPixmap
emit dragActiveChanged();
}
QWindow *NotificationApplet::focussedPlasmaDialog() const
{
return qobject_cast<PlasmaQuick::Dialog *>(qApp->focusWindow());
}
void NotificationApplet::setSelectionClipboardText(const QString &text)
{
// FIXME KDeclarative Clipboard item uses QClipboard::Mode for "mode"

@ -33,6 +33,8 @@ class NotificationApplet : public Plasma::Applet
Q_PROPERTY(bool dragActive READ dragActive NOTIFY dragActiveChanged)
Q_PROPERTY(QWindow *focussedPlasmaDialog READ focussedPlasmaDialog NOTIFY focussedPlasmaDialogChanged)
public:
explicit NotificationApplet(QObject *parent, const QVariantList &data);
~NotificationApplet() override;
@ -44,12 +46,15 @@ public:
Q_INVOKABLE bool isDrag(int oldX, int oldY, int newX, int newY) const;
Q_INVOKABLE void startDrag(QQuickItem *item, const QUrl &url, const QPixmap &pixmap);
QWindow *focussedPlasmaDialog() const;
Q_INVOKABLE void setSelectionClipboardText(const QString &text);
Q_INVOKABLE bool isPrimaryScreen(const QRect &rect) const;
signals:
void dragActiveChanged();
void focussedPlasmaDialogChanged();
private slots:
void doDrag(QQuickItem *item, const QUrl &url, const QPixmap &pixmap);

@ -238,7 +238,7 @@ QtObject {
}
for (var i = 0; i < popupInstantiator.count; ++i) {
var popup = popupInstantiator.objectAt(i);
let popup = popupInstantiator.objectAt(i);
// Popup width is fixed, so don't rely on the actual window size
var popupEffectiveWidth = popupWidth + popup.margins.left + popup.margins.right;
@ -273,8 +273,18 @@ QtObject {
}
}
// TODO would be nice to hide popups when systray or panel controller is open
popup.visible = visible;
popup.visible = Qt.binding(function() {
const dialog = plasmoid.nativeInterface.focussedPlasmaDialog;
if (dialog && dialog.visible && dialog !== popup) {
// If the notification obscures any other Plasma dialog, hide it
// No rect intersects in JS...
if (dialog.x < popup.x + popup.width && popup.x < dialog.x + dialog.width && dialog.y < popup.y + popup.height && popup.y < dialog.y + dialog.height) {
return false;
}
}
return visible;
});
}
}

Loading…
Cancel
Save