ported to qtquick, no dpi scaling yet
This commit is contained in:
parent
b331644379
commit
11d875ac89
|
@ -33,7 +33,7 @@ include(KDECompilerSettings)
|
||||||
find_package(Qt5Core REQUIRED)
|
find_package(Qt5Core REQUIRED)
|
||||||
find_package(Qt5Widgets REQUIRED)
|
find_package(Qt5Widgets REQUIRED)
|
||||||
find_package(Qt5Network REQUIRED)
|
find_package(Qt5Network REQUIRED)
|
||||||
find_package(Qt5Declarative REQUIRED)
|
find_package(Qt5Quick REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
||||||
case SnorePlugin::FRONTEND:
|
case SnorePlugin::FRONTEND:
|
||||||
case SnorePlugin::PLUGIN:
|
case SnorePlugin::PLUGIN:
|
||||||
if (!info->load()->initialize(this)) {
|
if (!info->load()->initialize(this)) {
|
||||||
|
info->load()->deinitialize();
|
||||||
info->unload();
|
info->unload();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ set( SNORE_SRC
|
||||||
|
|
||||||
|
|
||||||
add_library(libsnore_backend_snore MODULE ${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})
|
install(TARGETS libsnore_backend_snore ${SNORE_PLUGIN_INSTALL_PATH})
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import QtQuick 1.1
|
import QtQuick 2.3
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,19 +25,18 @@
|
||||||
#include <QtDeclarative/QDeclarativeView>
|
#include <QtDeclarative/QDeclarativeView>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
|
||||||
using namespace Snore;
|
using namespace Snore;
|
||||||
|
|
||||||
NotifyWidget::NotifyWidget(int pos, QWidget *parent) :
|
NotifyWidget::NotifyWidget(int pos, QWindow *parent) :
|
||||||
QDeclarativeView(QUrl("qrc:/notification.qml"), parent),
|
QQuickView(QUrl("qrc:/notification.qml"), parent),
|
||||||
m_animation(new QPropertyAnimation(this, "pos")),
|
m_animationX(new QPropertyAnimation(this, "x")),
|
||||||
m_id(pos),
|
m_id(pos),
|
||||||
m_mem(QString("SnoreNotifyWidget_rev%1_id%2").arg(QString::number(SHARED_MEM_TYPE_REV()), QString::number(m_id))),
|
m_mem(QString("SnoreNotifyWidget_rev%1_id%2").arg(QString::number(SHARED_MEM_TYPE_REV()), QString::number(m_id))),
|
||||||
m_ready(true)
|
m_ready(true)
|
||||||
{
|
{
|
||||||
m_qmlNotification = rootObject();
|
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
|
#ifdef Q_OS_MAC
|
||||||
| Qt::SubWindow
|
| Qt::SubWindow
|
||||||
#else
|
#else
|
||||||
|
@ -45,8 +44,8 @@ NotifyWidget::NotifyWidget(int pos, QWidget *parent) :
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
setFocusPolicy(Qt::NoFocus);
|
// setFocusPolicy(Qt::NoFocus);
|
||||||
setAttribute(Qt::WA_ShowWithoutActivating, true);
|
// setAttribute(Qt::WA_ShowWithoutActivating, true);
|
||||||
|
|
||||||
if (m_mem.create(sizeof(SHARED_MEM_TYPE))) {
|
if (m_mem.create(sizeof(SHARED_MEM_TYPE))) {
|
||||||
m_mem.lock();
|
m_mem.lock();
|
||||||
|
@ -64,7 +63,7 @@ NotifyWidget::NotifyWidget(int pos, QWidget *parent) :
|
||||||
snoreDebug(SNORE_DEBUG) << "Status" << data->free << data->date.elapsed() / 1000;
|
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(invoked()), this, SLOT(slotInvoked()));
|
||||||
connect(m_qmlNotification, SIGNAL(dismissed()), this, SLOT(slotDismissed()));
|
connect(m_qmlNotification, SIGNAL(dismissed()), this, SLOT(slotDismissed()));
|
||||||
|
@ -83,17 +82,17 @@ void NotifyWidget::display(const Notification ¬ification)
|
||||||
|
|
||||||
QRect desktop = QDesktopWidget().availableGeometry();
|
QRect desktop = QDesktopWidget().availableGeometry();
|
||||||
|
|
||||||
|
// snoreDebug( SNORE_DEBUG ) << computeSize() << devicePixelRatio();
|
||||||
resize(computeSize());
|
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);
|
setY(desktop.topRight().y() + space + (space + height()) * m_id);
|
||||||
QPoint start(desktop.topRight().x(), dest.y());
|
|
||||||
|
|
||||||
m_animation->setDuration(500);
|
m_animationX->setDuration(500);
|
||||||
m_animation->setStartValue(start);
|
m_animationX->setStartValue(desktop.topRight().x());
|
||||||
m_animation->setEndValue(dest);
|
m_animationX->setEndValue(desktop.topRight().x() - width());
|
||||||
m_animation->start();
|
m_animationX->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyWidget::update(const Notification ¬ification)
|
void NotifyWidget::update(const Notification ¬ification)
|
||||||
|
@ -202,5 +201,5 @@ QSize NotifyWidget::computeSize()
|
||||||
{
|
{
|
||||||
int width = 365;
|
int width = 365;
|
||||||
int height = 100;
|
int height = 100;
|
||||||
return QSize(width * logicalDpiX() / dpisScale(), height * logicalDpiY() / dpisScale());
|
return QSize(width * devicePixelRatio(), height * devicePixelRatio());
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
#include "core/notification/notification.h"
|
#include "core/notification/notification.h"
|
||||||
|
|
||||||
#include <QtDeclarative>
|
#include <QtQuick/QtQuick>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -38,12 +38,12 @@ inline int SHARED_MEM_TYPE_REV()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
class NotifyWidget : public QDeclarativeView
|
class NotifyWidget : public QQuickView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NotifyWidget(int pos, QWidget *parent = 0);
|
explicit NotifyWidget(int pos, QWindow *parent = 0);
|
||||||
~NotifyWidget();
|
~NotifyWidget();
|
||||||
|
|
||||||
void display(const Snore::Notification ¬ification);
|
void display(const Snore::Notification ¬ification);
|
||||||
|
@ -76,7 +76,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
QColor computeBackgrondColor(const QImage &img);
|
QColor computeBackgrondColor(const QImage &img);
|
||||||
|
|
||||||
QPropertyAnimation *m_animation;
|
QPropertyAnimation *m_animationX;
|
||||||
Snore::Notification m_notification;
|
Snore::Notification m_notification;
|
||||||
QObject *m_qmlNotification;
|
QObject *m_qmlNotification;
|
||||||
int m_id;
|
int m_id;
|
||||||
|
|
|
@ -65,7 +65,7 @@ bool Toasty::initialize(SnoreCore *snore)
|
||||||
if (SnoreSecondaryBackend::initialize(snore)) {
|
if (SnoreSecondaryBackend::initialize(snore)) {
|
||||||
setDefaultValue("DeviceID", "", "The ID provided for your device by Toasty");
|
setDefaultValue("DeviceID", "", "The ID provided for your device by Toasty");
|
||||||
m_key = value("DeviceID").toString();
|
m_key = value("DeviceID").toString();
|
||||||
snoreDebug(SNORE_DEBUG) << m_key;
|
snoreDebug(SNORE_DEBUG) << m_key << !m_key.isEmpty();
|
||||||
return !m_key.isEmpty();
|
return !m_key.isEmpty();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue