diff --git a/CMakeLists.txt b/CMakeLists.txt index 72c6364..fe2d0a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ include(KDECompilerSettings) find_package(Qt5Core REQUIRED) find_package(Qt5Widgets REQUIRED) find_package(Qt5Network REQUIRED) -find_package(Qt5Declarative REQUIRED) +find_package(Qt5Quick REQUIRED) diff --git a/src/core/snore.cpp b/src/core/snore.cpp index d39b1fd..f1c9ce6 100644 --- a/src/core/snore.cpp +++ b/src/core/snore.cpp @@ -63,6 +63,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) case SnorePlugin::FRONTEND: case SnorePlugin::PLUGIN: if (!info->load()->initialize(this)) { + info->load()->deinitialize(); info->unload(); break; } diff --git a/src/plugins/backends/snore/CMakeLists.txt b/src/plugins/backends/snore/CMakeLists.txt index 9f78ff0..92f4940 100644 --- a/src/plugins/backends/snore/CMakeLists.txt +++ b/src/plugins/backends/snore/CMakeLists.txt @@ -8,7 +8,7 @@ set( SNORE_SRC add_library(libsnore_backend_snore MODULE ${SNORE_SRC} ) -target_link_libraries(libsnore_backend_snore Snore::Libsnore Qt5::Declarative) +target_link_libraries(libsnore_backend_snore Snore::Libsnore Qt5::Quick) install(TARGETS libsnore_backend_snore ${SNORE_PLUGIN_INSTALL_PATH}) diff --git a/src/plugins/backends/snore/notification.qml b/src/plugins/backends/snore/notification.qml index 058ffd0..b124efe 100644 --- a/src/plugins/backends/snore/notification.qml +++ b/src/plugins/backends/snore/notification.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.3 diff --git a/src/plugins/backends/snore/notifywidget.cpp b/src/plugins/backends/snore/notifywidget.cpp index ce35d24..20eedc9 100644 --- a/src/plugins/backends/snore/notifywidget.cpp +++ b/src/plugins/backends/snore/notifywidget.cpp @@ -25,19 +25,18 @@ #include #include #include - using namespace Snore; -NotifyWidget::NotifyWidget(int pos, QWidget *parent) : - QDeclarativeView(QUrl("qrc:/notification.qml"), parent), - m_animation(new QPropertyAnimation(this, "pos")), +NotifyWidget::NotifyWidget(int pos, QWindow *parent) : + QQuickView(QUrl("qrc:/notification.qml"), parent), + m_animationX(new QPropertyAnimation(this, "x")), m_id(pos), m_mem(QString("SnoreNotifyWidget_rev%1_id%2").arg(QString::number(SHARED_MEM_TYPE_REV()), QString::number(m_id))), m_ready(true) { m_qmlNotification = rootObject(); - this->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowDoesNotAcceptFocus + setFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowDoesNotAcceptFocus #ifdef Q_OS_MAC | Qt::SubWindow #else @@ -45,8 +44,8 @@ NotifyWidget::NotifyWidget(int pos, QWidget *parent) : #endif ); - setFocusPolicy(Qt::NoFocus); - setAttribute(Qt::WA_ShowWithoutActivating, true); +// setFocusPolicy(Qt::NoFocus); +// setAttribute(Qt::WA_ShowWithoutActivating, true); if (m_mem.create(sizeof(SHARED_MEM_TYPE))) { m_mem.lock(); @@ -64,7 +63,7 @@ NotifyWidget::NotifyWidget(int pos, QWidget *parent) : snoreDebug(SNORE_DEBUG) << "Status" << data->free << data->date.elapsed() / 1000; } - setResizeMode(QDeclarativeView::SizeRootObjectToView); + setResizeMode(QQuickView::SizeRootObjectToView); connect(m_qmlNotification, SIGNAL(invoked()), this, SLOT(slotInvoked())); connect(m_qmlNotification, SIGNAL(dismissed()), this, SLOT(slotDismissed())); @@ -83,17 +82,17 @@ void NotifyWidget::display(const Notification ¬ification) QRect desktop = QDesktopWidget().availableGeometry(); +// snoreDebug( SNORE_DEBUG ) << computeSize() << devicePixelRatio(); resize(computeSize()); - int space = 10 * logicalDpiY() / dpisScale(); + int space = 10 * devicePixelRatio(); - QPoint dest(desktop.topRight().x() - width(), desktop.topRight().y() + space + (space + height()) * m_id); - QPoint start(desktop.topRight().x(), dest.y()); + setY(desktop.topRight().y() + space + (space + height()) * m_id); - m_animation->setDuration(500); - m_animation->setStartValue(start); - m_animation->setEndValue(dest); - m_animation->start(); + m_animationX->setDuration(500); + m_animationX->setStartValue(desktop.topRight().x()); + m_animationX->setEndValue(desktop.topRight().x() - width()); + m_animationX->start(); } void NotifyWidget::update(const Notification ¬ification) @@ -202,5 +201,5 @@ QSize NotifyWidget::computeSize() { int width = 365; int height = 100; - return QSize(width * logicalDpiX() / dpisScale(), height * logicalDpiY() / dpisScale()); + return QSize(width * devicePixelRatio(), height * devicePixelRatio()); } diff --git a/src/plugins/backends/snore/notifywidget.h b/src/plugins/backends/snore/notifywidget.h index f581714..e30d0a0 100644 --- a/src/plugins/backends/snore/notifywidget.h +++ b/src/plugins/backends/snore/notifywidget.h @@ -24,7 +24,7 @@ #include #include "core/notification/notification.h" -#include +#include #include typedef struct { @@ -38,12 +38,12 @@ inline int SHARED_MEM_TYPE_REV() return 1; } -class NotifyWidget : public QDeclarativeView +class NotifyWidget : public QQuickView { Q_OBJECT public: - explicit NotifyWidget(int pos, QWidget *parent = 0); + explicit NotifyWidget(int pos, QWindow *parent = 0); ~NotifyWidget(); void display(const Snore::Notification ¬ification); @@ -76,7 +76,7 @@ protected: private: QColor computeBackgrondColor(const QImage &img); - QPropertyAnimation *m_animation; + QPropertyAnimation *m_animationX; Snore::Notification m_notification; QObject *m_qmlNotification; int m_id; diff --git a/src/plugins/secondary_backends/toasty/toasty.cpp b/src/plugins/secondary_backends/toasty/toasty.cpp index 0115ee6..91713a0 100644 --- a/src/plugins/secondary_backends/toasty/toasty.cpp +++ b/src/plugins/secondary_backends/toasty/toasty.cpp @@ -65,7 +65,7 @@ bool Toasty::initialize(SnoreCore *snore) if (SnoreSecondaryBackend::initialize(snore)) { setDefaultValue("DeviceID", "", "The ID provided for your device by Toasty"); m_key = value("DeviceID").toString(); - snoreDebug(SNORE_DEBUG) << m_key; + snoreDebug(SNORE_DEBUG) << m_key << !m_key.isEmpty(); return !m_key.isEmpty(); } return false;