From 27f1a7177b54f6ec4177ddb11804025740b745a7 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 10 Jan 2018 23:50:06 -0500 Subject: Get the window compositing/painting routine finished up with a seamless image provider system. --- .../src-desktop/QMLImageProvider.cpp | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp') diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp new file mode 100644 index 00000000..0899337c --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp @@ -0,0 +1,46 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include +#include "QMLImageProvider.h" + +QMLImageProvider::QMLImageProvider() : QQuickImageProvider(QQmlImageProviderBase::Image, 0){ + +} + +QMLImageProvider::~QMLImageProvider(){ + +} + +/*QMLImageProvider* QMLImageProvider::instance(){ + static QMLImageProvider *_prov = 0; + if(_prov==0){ _prov = new QMLImageProvider(); } + return _prov; +}*/ + +QImage QMLImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize){ + NativeWindowObject *win = Lumina::NWS->findWindow( id.section(":",1,1).toInt(), false); + qDebug() << "Request Image:" << id << win << requestedSize; + QImage img(requestedSize,QImage::Format_RGB32); + if(win==0){ img.fill("black"); } //invalid window ID (should never happen) + else if(id.startsWith("image:")){ img = Lumina::NWS->GetWindowImage(win); } + //else if(id.startsWith("icon:")){ img = Lumina::NWS->GetWindowIcon(win); } + qDebug() << "Got Window Image:" << img.size(); + if(img.size().isNull()){ + if(requestedSize.isValid()){ img = QImage(requestedSize,QImage::Format_RGB32); } + else{ img = QImage(QSize(64,64), QImage::Format_RGB32); } + img.fill("black"); + } + qDebug() << "Final Window Image:" << img.size(); + if(size!=0){ + size->setHeight(img.height()); + size->setWidth( img.width() ); + } + if(requestedSize.isValid() && !requestedSize.isNull() && img.size()!=requestedSize){ + img = img.scaled(requestedSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + } + return img; +} -- cgit From bbabaada12e6d7e355c396961fe180e8e5b2b911 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 11 Jan 2018 09:22:40 -0500 Subject: Get a lot more of the Native Window embed routine up and running. Actually usable now. --- .../src-desktop/QMLImageProvider.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp') diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp index 0899337c..3f595245 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp @@ -27,14 +27,25 @@ QImage QMLImageProvider::requestImage(const QString &id, QSize *size, const QSiz QImage img(requestedSize,QImage::Format_RGB32); if(win==0){ img.fill("black"); } //invalid window ID (should never happen) else if(id.startsWith("image:")){ img = Lumina::NWS->GetWindowImage(win); } + else if(id.startsWith("icon:")){ + QIcon ico = win->property(NativeWindowObject::Icon).value(); + QList sizes = ico.availableSizes(); + QSize sz(0,0); + //Just grab the largest size currently available + for(int i=0; iGetWindowIcon(win); } - qDebug() << "Got Window Image:" << img.size(); + //qDebug() << "Got Window Image:" << img.size(); if(img.size().isNull()){ if(requestedSize.isValid()){ img = QImage(requestedSize,QImage::Format_RGB32); } else{ img = QImage(QSize(64,64), QImage::Format_RGB32); } img.fill("black"); } - qDebug() << "Final Window Image:" << img.size(); + //qDebug() << "Final Window Image:" << img.size(); if(size!=0){ size->setHeight(img.height()); size->setWidth( img.width() ); -- cgit From 35a425977ca313e608950cdc25c7df727e47251d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 11 Jan 2018 14:47:08 -0800 Subject: Get the panels all setup and functional. The screen-dependent panels need to be moved to the RootDesktop QML object so the z-ordering is respected (panels on top), but other than that it seems to be working fine. --- .../src-desktop/QMLImageProvider.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp') diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp index 3f595245..a74d2585 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.cpp @@ -7,7 +7,7 @@ #include #include "QMLImageProvider.h" -QMLImageProvider::QMLImageProvider() : QQuickImageProvider(QQmlImageProviderBase::Image, 0){ +QMLImageProvider::QMLImageProvider(QQmlImageProviderBase::ImageType type) : QQuickImageProvider(type, 0){ } @@ -23,7 +23,10 @@ QMLImageProvider::~QMLImageProvider(){ QImage QMLImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize){ NativeWindowObject *win = Lumina::NWS->findWindow( id.section(":",1,1).toInt(), false); - qDebug() << "Request Image:" << id << win << requestedSize; + if(win==0){ win = Lumina::NWS->findTrayWindow(id.section(":",1,1).toInt()); } + + if(!id.startsWith("image:")){ qDebug() << "Request Image:" << id << win << requestedSize; } + QImage img(requestedSize,QImage::Format_RGB32); if(win==0){ img.fill("black"); } //invalid window ID (should never happen) else if(id.startsWith("image:")){ img = Lumina::NWS->GetWindowImage(win); } @@ -38,7 +41,6 @@ QImage QMLImageProvider::requestImage(const QString &id, QSize *size, const QSiz qDebug() << "Icon Sizes:" <GetWindowIcon(win); } //qDebug() << "Got Window Image:" << img.size(); if(img.size().isNull()){ if(requestedSize.isValid()){ img = QImage(requestedSize,QImage::Format_RGB32); } @@ -55,3 +57,9 @@ QImage QMLImageProvider::requestImage(const QString &id, QSize *size, const QSiz } return img; } + +QPixmap QMLImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize){ + qDebug() << "Pixmap Requested:" << id; + QImage img = requestImage(id, size, requestedSize); + return QPixmap::fromImage(img); +} -- cgit