aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-01-11 14:47:08 -0800
committerKen Moore <ken@ixsystems.com>2018-01-11 14:47:08 -0800
commit35a425977ca313e608950cdc25c7df727e47251d (patch)
tree4b44496622a8b3b5166355e3b24e97c2c0a0a7ff /src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp
parentGet a lot more of the Native Window embed routine up and running. Actually us... (diff)
downloadlumina-35a425977ca313e608950cdc25c7df727e47251d.tar.gz
lumina-35a425977ca313e608950cdc25c7df727e47251d.tar.bz2
lumina-35a425977ca313e608950cdc25c7df727e47251d.zip
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.
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp40
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.h1
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp36
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h7
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp32
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.h9
6 files changed, 125 insertions, 0 deletions
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
bgstack15