diff --git a/src/plugins/backends/snore/notification.qml b/src/plugins/backends/snore/notification.qml index b3ba4d5..d556d43 100644 --- a/src/plugins/backends/snore/notification.qml +++ b/src/plugins/backends/snore/notification.qml @@ -4,13 +4,12 @@ import QtQuick.Window 2.2 Rectangle { id: root + signal dismissed() + signal invoked() + width: body.font.pixelSize * 30 height: body.font.pixelSize * 9 - signal dismissed() - - signal invoked() - function update(nTitle, bBody, nImage, nAppIcon, color, textColor, isUpdate) { title.text = nTitle @@ -21,12 +20,14 @@ Rectangle { image.source = nImage root.color = color - if (!isUpdate) { var corner = window.corner var id = window.id var space = (id + 1) * height * 0.025 + console.debug(snoreFont) + console.debug(body.font.family) + animation.target = window window.y = space + (space + height) * id @@ -79,6 +80,7 @@ Rectangle { anchors.left: image.right anchors.leftMargin: 5 textFormat: Text.RichText + font.family: snoreFont } Text { @@ -98,7 +100,7 @@ Rectangle { maximumLineCount: height / font.pixelSize - 1 onLinkActivated: Qt.openUrlExternally(link) textFormat: Text.RichText - + font.family: snoreFont } @@ -146,5 +148,4 @@ Rectangle { onClicked: root.dismissed() } } - } diff --git a/src/plugins/backends/snore/notifywidget.cpp b/src/plugins/backends/snore/notifywidget.cpp index 8630bdc..a4d1245 100644 --- a/src/plugins/backends/snore/notifywidget.cpp +++ b/src/plugins/backends/snore/notifywidget.cpp @@ -24,7 +24,6 @@ using namespace Snore; NotifyWidget::NotifyWidget(int pos, const SnoreNotifier *parent) : - QQuickView(QUrl::fromEncoded("qrc:/notification.qml")), m_id(pos), m_parent(parent), m_mem(QLatin1String("SnoreNotifyWidget_rev") + QString::number(SHARED_MEM_TYPE_REV()) + QLatin1String("_id") + QString::number(m_id)), @@ -32,7 +31,22 @@ NotifyWidget::NotifyWidget(int pos, const SnoreNotifier *parent) : { rootContext()->setContextProperty(QLatin1String("window"), this); rootContext()->setContextProperty(QLatin1String("utils"), new Utils(this)); - m_qmlNotification = rootObject(); + + QString font; + switch(QSysInfo::windowsVersion()){ + case QSysInfo::WV_WINDOWS8: + font = QLatin1String("Segoe UI Symbol"); + break; +#if QT_VERSION_CHECK(5,5,0) + case QSysInfo::WV_10_0: + font = QLatin1String("Segoe UI Emoji"); + break; +#endif + default: + font = qApp->font().family(); + } + rootContext()->setContextProperty(QLatin1String("snoreFont"), font); + setSource(QUrl::fromEncoded("qrc:/notification.qml")); setFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowDoesNotAcceptFocus #ifdef Q_OS_MAC @@ -63,8 +77,8 @@ NotifyWidget::NotifyWidget(int pos, const SnoreNotifier *parent) : setResizeMode(QQuickView::SizeViewToRootObject); - connect(m_qmlNotification, SIGNAL(invoked()), this, SLOT(slotInvoked())); - connect(m_qmlNotification, SIGNAL(dismissed()), this, SLOT(slotDismissed())); + connect(rootObject(), SIGNAL(invoked()), this, SLOT(slotInvoked())); + connect(rootObject(), SIGNAL(dismissed()), this, SLOT(slotDismissed())); } NotifyWidget::~NotifyWidget() @@ -86,7 +100,7 @@ void NotifyWidget::display(const Notification ¬ification) } QRgb gray = qGray(qGray(color.rgb()) - qGray(QColor(Qt::white).rgb())); QColor textColor = QColor(gray, gray, gray); - QMetaObject::invokeMethod(m_qmlNotification, "update", Qt::QueuedConnection, + QMetaObject::invokeMethod(rootObject(), "update", Qt::QueuedConnection, Q_ARG(QVariant, notification.title(Utils::ALL_MARKUP)), Q_ARG(QVariant, notification.text(Utils::ALL_MARKUP)), Q_ARG(QVariant, QUrl::fromLocalFile(notification.icon().localUrl())), diff --git a/src/plugins/backends/snore/notifywidget.h b/src/plugins/backends/snore/notifywidget.h index ea7d64c..a27f21a 100644 --- a/src/plugins/backends/snore/notifywidget.h +++ b/src/plugins/backends/snore/notifywidget.h @@ -72,7 +72,6 @@ private: QColor computeBackgrondColor(const QImage &img); Snore::Notification m_notification; - QObject *m_qmlNotification; int m_id; const SnoreNotifier *m_parent; QSharedMemory m_mem; diff --git a/src/plugins/backends/snore/snorenotifiersettings.cpp b/src/plugins/backends/snore/snorenotifiersettings.cpp index c1efe7f..f549d5b 100644 --- a/src/plugins/backends/snore/snorenotifiersettings.cpp +++ b/src/plugins/backends/snore/snorenotifiersettings.cpp @@ -26,7 +26,6 @@ SnoreNotifierSettings::SnoreNotifierSettings(SnorePlugin *snore, QWidget *parent PluginSettingsWidget(snore, parent), m_comboBox(new QComboBox) { - m_comboBox->addItem(tr("TopLeftCorner"), Qt::TopLeftCorner); m_comboBox->addItem(tr("TopRightCorner"), Qt::TopRightCorner); m_comboBox->addItem(tr("BottomLeftCorner"), Qt::BottomLeftCorner);