diff options
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified')
6 files changed, 72 insertions, 38 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 9b7b8da7..e8830bde 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 @@ -34,6 +34,10 @@ bool PanelObject::isVertical(){ return ( geom.width() < geom.height() ); } +QStringList PanelObject::plugins(){ + return panel_plugins; +} + void PanelObject::setBackground(QString fileOrColor){ if(bg!=fileOrColor){ bg = fileOrColor; @@ -48,6 +52,30 @@ void PanelObject::setGeometry( QRect newgeom ){ } } +void PanelObject::setPlugins( QStringList plist){ + //Iterate through the list and find the URL's for the files + QStringList dirs; dirs << ":/qml/plugins/"; //add local directories here + for(int i=0; i<plist.length(); i++){ + bool found = false; + for(int j=0; j<dirs.length() && !found; j++){ + if(QFile::exists(dirs[j]+plist[i]+".qml")){ + plist[i] = QUrl::fromLocalFile(dirs[j]+plist[i]+".qml").url(); + found = true; + } + } + if(!found){ + qWarning() << "Could not find panel plugin on system:" << plist[i]; + plist.removeAt(i); + i--; + } + } + //Now update the internal list if it has changed + if(panel_plugins != plist){ + panel_plugins = plist; + this->emit pluginsChanged(); + } +} + void PanelObject::syncWithSettings(QRect parent_geom){ //Read off all the settings QString id = panel_id.section("/",-1); //last section (allow for prefixes to distinguish multiple monitors with the same profile but different screens) @@ -88,4 +116,5 @@ void PanelObject::syncWithSettings(QRect parent_geom){ newgeom.translate(parent_geom.x(), parent_geom.y()); //qDebug() << " - Calculated Geometry (global):" << newgeom; this->setGeometry(newgeom); //shift to global coordinates + this->setPlugins( DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/plugins", QStringList()).toStringList() ); } 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 04c47e06..945deec0 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 @@ -21,10 +21,12 @@ class PanelObject : public QObject { Q_PROPERTY( int width READ width NOTIFY geomChanged) Q_PROPERTY( int height READ height NOTIFY geomChanged) Q_PROPERTY( bool isVertical READ isVertical NOTIFY geomChanged) + Q_PROPERTY( QStringList plugins READ plugins NOTIFY pluginsChanged) private: QString panel_id, bg; QRect geom; + QStringList panel_plugins; public: PanelObject(QString id = "", QObject *parent = 0); @@ -38,15 +40,18 @@ public: Q_INVOKABLE int width(); Q_INVOKABLE int height(); Q_INVOKABLE bool isVertical(); + Q_INVOKABLE QStringList plugins(); public slots: void setBackground(QString fileOrColor); void setGeometry(QRect newgeom); void syncWithSettings(QRect parent_geom); + void setPlugins(QStringList plist); signals: void backgroundChanged(); void geomChanged(); + void pluginsChanged(); }; #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 2a8579a8..65c8a0eb 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,13 +10,13 @@ import QtQuick.Controls 1 import QtQuick.Layouts 1.3 import Lumina.Backend.PanelObject 2.0 -import "./plugins" as PLUGINS Rectangle { //C++ backend object property string panel_id property PanelObject object + id: panel //Normal geometries/placements color: object.background x: object.x @@ -26,30 +26,24 @@ Rectangle { GridLayout{ id: layout - anchors.fill: parent; - columns: parent.object.isVertical ? 1 : -1 - rows: parent.object.isVertical ? -1 : 1 + anchors.fill: parent + //columns: parent.object.isVertical ? 1 : -1 + //rows: parent.object.isVertical ? -1 : 1 + flow: parent.isVertical ? GridLayout.TopToBottom : GridLayout.LeftToRight + //horizontalItemAlignment: parent.object.isVertical ? Grid.AlignHCenter : Qt.AlignLeft + //verticalItemAlignment: parent.object.isVertical ? Grid.AlignTop : Qt.AlignVCenter + Repeater { + model: panel.object.plugins + Loader{ + asynchronous: true + property bool vertical : layout.parent.object.isVertical + property bool isspacer : modelData.endsWith("/Spacer.qml"); + source: modelData + Layout.fillWidth : (vertical || isspacer) ? true : false + Layout.fillHeight : (vertical && ! isspacer) ? false : true + Layout.alignment : Qt.AlignVCenter | Qt.AlignHCenter + } - //hardcode some plugins for the moment - //PLUGINS.Spacer{} - - PLUGINS.StatusTray{ - id: "statustray" - vertical: layout.parent.object.isVertical - //Layout.fillWidth: layout.parent.object.isVertical ? true : false - //Layout.fillHeight: layout.parent.object.isVertical ? false : true - } - - //PLUGINS.Spacer{} - - PLUGINS.Clock_Digital{ - id: "clock" - vertical: layout.parent.object.isVertical - //Layout.fillWidth: layout.parent.object.isVertical ? true : false - //Layout.fillHeight: layout.parent.object.isVertical ? false : true } - - //PLUGINS.Spacer{} - } //end of grid layout } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/Clock_Digital.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/Clock_Digital.qml index f82d398b..e68788f6 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/Clock_Digital.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/Clock_Digital.qml @@ -13,9 +13,11 @@ import QtQuick.Controls 1 import Lumina.Backend.RootDesktopObject 2.0 Label{ - property bool vertical + anchors.fill: parent text: RootObject.currentTime - wrapMode: Text.WrapWord - rotation: vertical ? 90 : 0 + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + rotation: parent.vertical ? 90 : 0 transformOrigin: Item.Center } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/Spacer.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/Spacer.qml index d46e486c..93556790 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/Spacer.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/Spacer.qml @@ -4,13 +4,12 @@ // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== -// This is the QML plugin that displays the OS status/system tray +// This is a tiny QML plugin for a basic Item which can be set to grow //=========================================== import QtQuick 2.2 import QtQuick.Layouts 1.3 Item{ - Layout.fillWidth: true - Layout.fillHeight: true + anchors.fill: parent } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/StatusTray.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/StatusTray.qml index a2d49b35..f4063ed9 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/StatusTray.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/StatusTray.qml @@ -17,42 +17,47 @@ import "./status_tray" as QML Item { - property bool vertical - property int prefsize: vertical ? parent.width : parent.height + property int prefsize: parent.vertical ? parent.width : parent.height id: "status_tray" + anchors.fill: parent GridLayout{ anchors.fill: parent - flow: parent.vertical ? GridLayout.TopToBottom : GridLayout.LeftToRight - columns: vertical ? 2 : -1 - rows: vertical ? -1 : 2 - //columnSpacing: 2 - //rowSpacing: 2 + flow: status_tray.parent.vertical ? GridLayout.TopToBottom : GridLayout.LeftToRight + //columns: vertical ? 1 : -1 + //rows: vertical ? -1 : 1 + columnSpacing: 2 + rowSpacing: 2 //Volume Status QML.VolumeButton{ //Layout.preferredHeight: status_tray.prefsize //Layout.preferredWidth: status_tray.prefsize + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter } //Network Status QML.NetworkButton{ //Layout.preferredHeight: status_tray.prefsize //Layout.preferredWidth: status_tray.prefsize + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter } //Battery Status QML.BatteryButton{ //Layout.preferredHeight: status_tray.prefsize //Layout.preferredWidth: status_tray.prefsize + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter } //Update Status QML.UpdateButton{ //Layout.preferredHeight: status_tray.prefsize //Layout.preferredWidth: status_tray.prefsize + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter } //System Tray Menu Button ToolButton{ id: "trayButton" text: "Tray" + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter //iconName: "view-more-vertical" visible: RootObject.hasTrayWindows onClicked: trayMenu.open() @@ -60,7 +65,7 @@ Item { id: "trayMenu" //MenuItem{ text: "sample" } //MenuItem{ text: "sample2" } - //Rectangle{ color: "blue"; width: 50; height: 50 } + Rectangle{ color: "blue"; width: 48; height: 48 } GridLayout{ columns: 4 Repeater{ |