diff options
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified')
15 files changed, 188 insertions, 23 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/screensaver.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/screensaver.conf index b4bfec59..98e6f20a 100644 --- a/src-qt5/core/lumina-desktop-unified/defaults/desktop/screensaver.conf +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/screensaver.conf @@ -1,3 +1,2 @@ [General] default_plugin="random" -plugin_VGA-0="random" diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp index eefe6d7e..bfded781 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp @@ -84,10 +84,6 @@ void DesktopManager::updateWallpaper(QString screen_id, int wkspace){ RootDesktopObject::instance()->ChangeWallpaper(screen_id,QUrl::fromLocalFile(wpaper).toString() ); } -void DesktopManager::updatePanels(QString panel_id){ - -} - void DesktopManager::updatePlugins(QString plugin_id){ } @@ -103,13 +99,13 @@ void DesktopManager::settingsChanged(DesktopSettings::File type){ case DesktopSettings::Desktop: QTimer::singleShot(0, this, SLOT(updateDesktopSettings()) ); case DesktopSettings::Panels: - QTimer::singleShot(0, this, SLOT(updatePanelSettings()) ); + QTimer::singleShot(1, this, SLOT(updatePanelSettings()) ); case DesktopSettings::Plugins: - QTimer::singleShot(0, this, SLOT(updatePluginSettings()) ); + QTimer::singleShot(2, this, SLOT(updatePluginSettings()) ); case DesktopSettings::ContextMenu: - QTimer::singleShot(0, this, SLOT(updateMenuSettings()) ); + QTimer::singleShot(3, this, SLOT(updateMenuSettings()) ); case DesktopSettings::Animation: - QTimer::singleShot(0, this, SLOT(updateAnimationSettings()) ); + QTimer::singleShot(4, this, SLOT(updateAnimationSettings()) ); default: break; //Do nothing - not a settings change we care about here @@ -148,14 +144,28 @@ void DesktopManager::syncTrayWindowList(){ // === PRIVATE SLOTS === void DesktopManager::updateDesktopSettings(){ qDebug() << "Update Desktop Settings..."; - QList<QScreen*> scrns= QApplication::screens(); + QList<QScreen*> scrns = QGuiApplication::screens(); int wkspace = Lumina::NWS->currentWorkspace(); for(int i=0; i<scrns.length(); i++){ updateWallpaper(scrns[i]->name(), wkspace); } } void DesktopManager::updatePanelSettings(){ - + QList<QScreen*> scrns = QGuiApplication::screens(); + int primary = QApplication::desktop()->primaryScreen(); + for(int i=0; i<scrns.length(); i++){ + ScreenObject *sObj = RootDesktopObject::instance()->screen(scrns[i]->name()); + if(sObj == 0){ continue; } //screen is not managed directly - skip it + QStringList ids = DesktopSettings::instance()->value(DesktopSettings::Panels, scrns[i]->name().replace("-","_")+"/active_ids", QStringList()).toStringList(); + if(ids.isEmpty() && (scrns.length()==1 || i==primary)){ + //Also look for the "default" panel id's for the primary/default screen + ids = DesktopSettings::instance()->value(DesktopSettings::Panels, "default/active_ids", QStringList()).toStringList(); + } + sObj->setPanels(ids); + } + //Now do the global-session panels + QStringList ids = DesktopSettings::instance()->value(DesktopSettings::Panels, "session/active_ids", QStringList()).toStringList(); + RootDesktopObject::instance()->setPanels(ids); //put the new ones in place } void DesktopManager::updatePluginSettings(){ diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h index d4a0cf79..da42e477 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h @@ -23,7 +23,6 @@ public: private: void updateWallpaper(QString screen_id, int wkspace); - void updatePanels(QString panel_id); void updatePlugins(QString plugin_id); public slots: 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 <global-objects.h> #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:" <<sizes; img = ico.pixmap(sz).toImage(); } - //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); } @@ -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); +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.h b/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.h index d0ab74ff..8719176e 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/QMLImageProvider.h @@ -14,13 +14,13 @@ class QMLImageProvider : public QQuickImageProvider{ public: - QMLImageProvider(); + QMLImageProvider(QQmlImageProviderBase::ImageType); ~QMLImageProvider(); //static QMLImageProvider* instance(); virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize); - + virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); }; #endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp index 5a9b8e09..2ceff4a0 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp @@ -6,6 +6,7 @@ //=========================================== #include "RootWindow.h" #include "QMLImageProvider.h" +#include <QQmlImageProviderBase> RootWindow::RootWindow() : QObject(){ root_win = QWindow::fromWinId( QX11Info::appRootWindow() ); // @@ -17,7 +18,8 @@ RootWindow::RootWindow() : QObject(){ //Now setup the QQuickView root_view->setResizeMode(QQuickView::SizeRootObjectToView); root_view->engine()->rootContext()->setContextProperty("RootObject", root_obj); - root_view->engine()->addImageProvider("native_window", new QMLImageProvider() ); + root_view->engine()->addImageProvider("native_window", new QMLImageProvider(QQmlImageProviderBase::Image) ); + //root_view->engine()->addImageProvider("native_window_icon", new QMLImageProvider(QQmlImageProviderBase::Pixmap) ); RootDesktopObject::RegisterType(); //make sure object classes are registered with the QML subsystems } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp index 471da58f..9054f528 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp @@ -5,6 +5,8 @@ // See the LICENSE file for full details //=========================================== #include "PanelObject.h" +#include <global-objects.h> + #include <QQmlEngine> #include <QDebug> @@ -42,3 +44,41 @@ void PanelObject::setGeometry( QRect newgeom ){ emit geomChanged(); } } + +void PanelObject::syncWithSettings(QRect parent_geom){ + //Read off all the settings + //qDebug() << "Sync Panel Settings:" << panel_id << parent_geom; + QString anchor = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/anchor", "bottom").toString().toLower(); + QString align = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/align", "center").toString().toLower(); + double length = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/length_percent", 100).toDouble()/100.0; + double width = DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/width_font_percent", 2.1).toDouble(); + width = qRound(width * QApplication::fontMetrics().height() ); + this->setBackground( DesktopSettings::instance()->value(DesktopSettings::Panels, panel_id+"/background", "rgba(0,0,0,120)").toString() ); + // qDebug() << "Update Panel:" << panel_id << anchor+"/"+align << length << width; + //Now calculate the geometry of the panel + QRect newgeom; + //Figure out the size of the panel + if(anchor=="top" || anchor=="bottom"){ newgeom.setWidth( parent_geom.width()*length ); newgeom.setHeight(width); } + else{ newgeom.setWidth(width); newgeom.setHeight(parent_geom.height()*length); } + //qDebug() << " - Size:" << newgeom; + //Now figure out the location of the panel + if(align=="left" || align=="top"){ + if(anchor=="top" || anchor=="left"){ newgeom.moveTopLeft(QPoint(0,0)); } + else if(anchor=="right"){ newgeom.moveTopRight(QPoint(parent_geom.width(), 0)); } + else{ newgeom.moveBottomLeft(QPoint(0, parent_geom.height()) ); } //bottom by default + + }else if(align=="right" || align=="bottom"){ + if(anchor=="top"){ newgeom.moveTopRight(QPoint(parent_geom.width(),0)); } + else if(anchor=="left"){ newgeom.moveBottomLeft(QPoint(0, parent_geom.height())); } + else if(anchor=="right"){ newgeom.moveBottomRight(QPoint(parent_geom.width(), parent_geom.height())); } + else{ newgeom.moveBottomRight(QPoint(parent_geom.width(), parent_geom.height()) ); } + + }else{ //center + if(anchor=="top"){ newgeom.moveTopLeft(QPoint( (parent_geom.width()-newgeom.width())/2,0)); } + else if(anchor=="left"){ newgeom.moveTopLeft(QPoint(0, (parent_geom.height()-newgeom.height())/2 )); } + else if(anchor=="right"){ newgeom.moveTopRight(QPoint(parent_geom.width(), (parent_geom.height()-newgeom.height())/2 )); } + else{ newgeom.moveBottomLeft(QPoint( (parent_geom.width()-newgeom.width())/2, parent_geom.height()) ); } + } + //qDebug() << " - Calculated Geometry:" << newgeom; + this->setGeometry(newgeom); //Note: This is in parent-relative coordinates (not global) +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h index a788fa07..8cf59dee 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h @@ -40,6 +40,7 @@ public: public slots: void setBackground(QString fileOrColor); void setGeometry(QRect newgeom); + void syncWithSettings(QRect parent_geom); signals: void backgroundChanged(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp index 39dc30c1..07d4e463 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp @@ -14,6 +14,7 @@ // === PUBLIC === RootDesktopObject::RootDesktopObject(QObject *parent) : QObject(parent){ updateScreens(); //make sure the internal list is updated right away + connect(this, SIGNAL(changePanels(QStringList)), this, SLOT(setPanels(QStringList)) ); } RootDesktopObject::~RootDesktopObject(){ @@ -87,6 +88,41 @@ void RootDesktopObject::setPanels(QList<PanelObject*> list){ emit panelsChanged(); } +void RootDesktopObject::setPanels(QStringList ids){ + //Make this thread-safe for object creation + if(this->thread() != QThread::currentThread()){ + //use internal signal/slot combo to change threads + this->emit changePanels(ids); + return; + } + + //Get the current bounding rectangle for the session + QRect total; + for(int i=0; i<s_objects.length(); i++){ + total = total.united(s_objects[i]->geometry()); + } + //First update/remove any current panel objects + bool change = false; + for(int i=0; i<panel_objects.length(); i++){ + if(ids.contains(panel_objects[i]->name()) ){ + ids.removeAll(panel_objects[i]->name()); //already handled + panel_objects[i]->syncWithSettings(total); + }else{ + panel_objects.takeAt(i)->deleteLater(); + i--; + change = true; //list changed + } + } + //Now create any new panel objects as needed + for(int i=0; i<ids.length(); i++){ + PanelObject *tmp = new PanelObject(ids[i], this); + tmp->syncWithSettings(total); + panel_objects << tmp; + change = true; //list changed + } + if(change){ emit panelsChanged(); } +} + void RootDesktopObject::setWindows(QList<NativeWindowObject*> list){ window_objects = list; emit windowsChanged(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h index a4236596..ad0e538b 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h @@ -10,6 +10,7 @@ #define _LUMINA_DESKTOP_QML_BACKEND_ROOT_DESKTOP_OBJECT_H #include <global-includes.h> #include <ScreenObject.h> +#include <QThread> class RootDesktopObject : public QObject{ Q_OBJECT @@ -53,6 +54,9 @@ public slots: QString CurrentWallpaper(QString screen); void setPanels(QList<PanelObject*> list); + void setPanels(QStringList ids); + QList<PanelObject*> panelObjectList(){ return panel_objects; } + void setWindows(QList<NativeWindowObject*> list); private slots: @@ -66,5 +70,8 @@ signals: void mouseMoved(); void lockScreen(); void launchApplication(QString); + + //Internal signals for thread-safety + void changePanels(QStringList); }; #endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp index 1b22c450..c754906d 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp @@ -10,6 +10,7 @@ ScreenObject::ScreenObject(QScreen *scrn, QObject *parent) : QObject(parent){ bg_screen = scrn; + connect(this, SIGNAL(changePanels(QStringList)), this, SLOT(setPanels(QStringList)) ); } void ScreenObject::RegisterType(){ @@ -40,6 +41,37 @@ void ScreenObject::setPanels(QList<PanelObject*> list){ emit panelsChanged(); } +void ScreenObject::setPanels(QStringList ids){ + //Make this thread-safe for object creation + if(this->thread() != QThread::currentThread()){ + //use internal signal/slot combo to change threads + this->emit changePanels(ids); + return; + } + + //First update/remove any current panel objects + bool change = false; + for(int i=0; i<panel_objects.length(); i++){ + if(ids.contains(panel_objects[i]->name()) ){ + ids.removeAll(panel_objects[i]->name()); //already handled + panel_objects[i]->syncWithSettings(bg_screen->geometry()); + }else{ + panel_objects.takeAt(i)->deleteLater(); + i--; + change = true; //list changed + } + } + //Now create any new panel objects as needed + for(int i=0; i<ids.length(); i++){ + PanelObject *tmp = new PanelObject(ids[i], this); + tmp->syncWithSettings(bg_screen->geometry()); + panel_objects << tmp; + change = true; //list changed + } + if(change){ emit panelsChanged(); } +} + + //QML Read Functions QStringList ScreenObject::panels(){ //qDebug() << "Request Panels:" << panel_objects.length(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h index 1afff6d2..250c9403 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h @@ -11,6 +11,7 @@ #include <QObject> #include <QString> #include <QScreen> +#include <QThread> #include "PanelObject.h" @@ -42,16 +43,24 @@ public: Q_INVOKABLE int height(); Q_INVOKABLE QStringList panels(); Q_INVOKABLE PanelObject* panel(QString id); + Q_INVOKABLE QRect geometry(){ return bg_screen->geometry(); } void setPanels(QList<PanelObject*> list); + QList<PanelObject*> panelObjectList(){ return panel_objects; } + public slots: + void setPanels(QStringList ids); void setBackground(QString fileOrColor); signals: void backgroundChanged(); void geomChanged(); void panelsChanged(); + + //Internal signals for thread-safety + void changePanels(QStringList); + }; #endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml index 846b5b55..556da5ec 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Panel.qml @@ -10,15 +10,13 @@ import QtQuick.Controls 1 import Lumina.Backend.PanelObject 2.0 -AnimatedImage { +Rectangle { //C++ backend object - property string screen_id + property string panel_id property PanelObject object //Normal geometries/placements - asynchronous: true - clip: true - source: object.background + color: object.background x: object.x y: object.y width: object.width diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml index 9122ce5b..f48f7751 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml @@ -66,4 +66,14 @@ Rectangle { z: 100+index } } + + //Setup the Panels + Repeater{ + model: RootObject.panels + QML.Panel{ + panel_id: modelData + object: RootObject.panel(panel_id) + z: 10100+index + } + } } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml index 3b83653a..82e7c89d 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/Screen.qml @@ -9,6 +9,9 @@ import QtQuick.Window 2.2 import QtQuick.Controls 1 import Lumina.Backend.ScreenObject 2.0 +import Lumina.Backend.PanelObject 2.0 + +import "." as QML AnimatedImage { //C++ backend object @@ -23,4 +26,15 @@ AnimatedImage { y: object.y width: object.width height: object.height + + //Setup the Panels + Repeater{ + model: object.panels + QML.Panel{ + panel_id: modelData + object: parent.object.panel(panel_id) + z: 10000+index + } + } + } |