diff options
author | Ken Moore <ken@ixsystems.com> | 2018-01-31 12:04:36 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-01-31 12:04:36 -0500 |
commit | 4a2a6f3af5dab7effdb7c512e8b03adf2724b401 (patch) | |
tree | d0a4777680df4dc8573722643ed28c5de6f000d0 /src-qt5 | |
parent | Get the volume button/backend functional. (diff) | |
download | lumina-4a2a6f3af5dab7effdb7c512e8b03adf2724b401.tar.gz lumina-4a2a6f3af5dab7effdb7c512e8b03adf2724b401.tar.bz2 lumina-4a2a6f3af5dab7effdb7c512e8b03adf2724b401.zip |
Get a lot more cache system setup for OSInterface backend.
Add a new "UpdateButton" to the StatusTray plugin.
Diffstat (limited to 'src-qt5')
7 files changed, 120 insertions, 33 deletions
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 254ffff2..e1e7cd10 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 @@ -40,6 +40,11 @@ Rectangle { Layout.preferredHeight: status_tray.prefsize Layout.preferredWidth: status_tray.prefsize } + //Update Status + QML.UpdateButton{ + Layout.preferredHeight: status_tray.prefsize + Layout.preferredWidth: status_tray.prefsize + } //System Tray Menu Popup } //end of layout diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/plugins.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/plugins.pri index 36cc581b..50eb9c5c 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/plugins.pri +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/plugins.pri @@ -4,6 +4,7 @@ lupdate_only{ $${PWD}/status_tray/TrayIcon.qml \ $${PWD}/status_tray/VolumeButton.qml \ $${PWD}/status_tray/NetworkButton.qml \ - $${PWD}/status_tray/BatteryButton.qml + $${PWD}/status_tray/BatteryButton.qml \ + $${PWD}/status_tray/UpdateButton.qml } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/TrayIcon.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/TrayIcon.qml index 8b8367b0..26c50907 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/TrayIcon.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/TrayIcon.qml @@ -5,10 +5,21 @@ // See the LICENSE file for full details //=========================================== import QtQuick 2.2 -import QtQuick.Controls 2 +import QtQuick.Controls 1 import Lumina.Backend.NativeWindowObject 2.0 -Rectangle{ - color: "white" +Image{ + property NativeWindowObject winObj + source: winObj.icon + + MouseArea{ + anchors.fill: parent + acceptedButtons: Qt.NoButton + onEntered: { + //Need to ensure the invisible native window is over this place right now + point pt: parent.mapToGlobal(0,0) + winObj.updateGeometry( pt.x(), pt.y(), parent.width(), parent.height(), true); + } + } } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/UpdateButton.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/UpdateButton.qml new file mode 100644 index 00000000..881f164f --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/plugins/status_tray/UpdateButton.qml @@ -0,0 +1,24 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +import QtQuick 2.2 +import QtQuick.Controls 1 + +import Lumina.Backend.RootDesktopObject 2.0 +import Lumina.Backend.OSInterface 2.0 + +ToolButton{ + id: "updateButton" + property OSInterface os: RootObject.os_interface() + iconName: os.updateIcon + tooltip: os.networkStatus + visible: (os.updateStatus == "") + /*enabled: os.hasUpdateManager() + onClicked: { + RootObject.launchApplication(os.updateManagerUtility()) + }*/ + //TODO - add a menu with update manager and start/view updates options +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc index ba143027..1da9d5bd 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/src-qml.qrc @@ -10,5 +10,6 @@ <file>plugins/status_tray/VolumeButton.qml</file> <file>plugins/status_tray/NetworkButton.qml</file> <file>plugins/status_tray/BatteryButton.qml</file> + <file>plugins/status_tray/UpdateButton.qml</file> </qresource> </RCC> diff --git a/src-qt5/src-cpp/framework-OSInterface.h b/src-qt5/src-cpp/framework-OSInterface.h index 52ef6af7..2f1795a1 100644 --- a/src-qt5/src-cpp/framework-OSInterface.h +++ b/src-qt5/src-cpp/framework-OSInterface.h @@ -57,9 +57,9 @@ class OSInterface : public QObject{ //Media Q_PROPERTY( QStringList mediaShortcuts READ mediaShortcuts NOTIFY mediaShortcutsChanged) //Updates - Q_PROPERTY( bool updatesAvailable READ updatesAvailable NOTIFY updateStatusChanged) - Q_PROPERTY( bool updatesRunning READ updatesRunning NOTIFY updateStatusChanged) - Q_PROPERTY( bool updatesFinished READ updatesFinished NOTIFY updateStatusChanged) + Q_PROPERTY( QString updateStatus READ updateStatus NOTIFY updateStatusChanged) + Q_PROPERTY( QString updateIcon READ updateIcon NOTIFY updateStatusChanged) + //Power options Q_PROPERTY( bool canReboot READ canReboot NOTIFY powerAvailableChanged) Q_PROPERTY( bool canShutdown READ canShutdown NOTIFY powerAvailableChanged) @@ -108,11 +108,11 @@ public: // = Updates = Q_INVOKABLE bool updatesSupported(); //is thie subsystem supported for the OS? - Q_INVOKABLE bool updatesAvailable(); + Q_INVOKABLE QString updateStatus(); //Current status ["","available","running","finished"] + Q_INVOKABLE QString updateIcon(); + Q_INVOKABLE QString updateStatusInfo(); //Extra information corresponding to the current status Q_INVOKABLE QString updateDetails(); //Information about any available updates - Q_INVOKABLE bool updatesRunning(); Q_INVOKABLE QString updateLog(); //Information about any currently-running update - Q_INVOKABLE bool updatesFinished(); Q_INVOKABLE QString updateResults(); //Information about any finished update Q_INVOKABLE void startUpdates(); Q_INVOKABLE bool updateOnlyOnReboot(); //Should the startUpdates function be called only when rebooting the system? diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp index 7b328849..733fc61f 100644 --- a/src-qt5/src-cpp/framework-OSInterface_private.cpp +++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp @@ -405,7 +405,21 @@ void OSInterface::syncBatteryInfo(OSInterface *os, QHash<QString, QVariant> *has } void OSInterface::syncUpdateInfo(OSInterface *os, QHash<QString, QVariant> *hash, QTimer *timer){ - + //Get the current status + QString status, icon; + if(OS_updatesRunning()){ + status="running"; icon="sync"; + }else if(OS_updatesFinished()){ + status="finished"; icon="security-high"; + }else if(OS_updatesAvailable()){ + status="available"; icon="security-medium"; + } + //Save the current info into the hash (if different) + if(status != updateStatus()){ + hash->insert("updates/status", status); + hash->insert("updates/icon", icon); + os->emit updateStatusChanged(); + } QTimer::singleShot(0, timer, SLOT(start())); } @@ -486,34 +500,65 @@ QStringList OSInterface::mediaDirectories(){ return OS_mediaDirectories(); } QStringList OSInterface::mediaShortcuts(){ return autoHandledMediaFiles(); } //List of currently-available XDG shortcut file paths // = Updates = -bool OSInterface::updatesSupported(){ return false; } -bool OSInterface::updatesAvailable(){ return false; } -QString OSInterface::updateDetails(){ return QString(); } //Information about any available updates -bool OSInterface::updatesRunning(){ return false; } -QString OSInterface::updateLog(){ return QString(); } //Information about any currently-running update -bool OSInterface::updatesFinished(){ return false; } -QString OSInterface::updateResults(){ return QString(); } //Information about any finished update -void OSInterface::startUpdates(){} -bool OSInterface::updateOnlyOnReboot(){ return false; } //Should the startUpdates function be called only when rebooting the system? -bool OSInterface::updateCausesReboot(){ return false; } -QDateTime OSInterface::lastUpdate(){ return QDateTime(); } //The date/time of the previous updates -QString OSInterface::lastUpdateResults(){ return QString(); } //Information about the previously-finished update +bool OSInterface::updatesSupported(){ return OS_updatesSupported(); } +QString OSInterface::updateStatus(){ + if(INFO.contains("updates/status")){ return INFO.value("updates/status").toString(); } + return ""; +} + +QString OSInterface::updateIcon(){ + if(INFO.contains("updates/icon")){ return INFO.value("updates/icon").toString(); } + return ""; +} + +QString OSInterface::updateStatusInfo(){ + QString status = updateStatus(); + if(status=="available"){ return updateDetails(); } + else if(status=="running"){ return updateLog(); } + else if(status=="finished"){ return updateResults(); } + return ""; +} + +QString OSInterface::updateDetails(){ + return OS_updateDetails(); //don't cache these types of logs - too large +} + +QString OSInterface::updateLog(){ + return OS_updateLog(); //don't cache these types of logs - too large and change too often +} + +QString OSInterface::updateResults(){ + return OS_updateResults(); //don't cache these types of logs - too large +} + +void OSInterface::startUpdates(){ OS_startUpdates(); } +bool OSInterface::updateOnlyOnReboot(){ return OS_updateOnlyOnReboot(); } +bool OSInterface::updateCausesReboot(){ return OS_updateCausesReboot(); } + +QDateTime OSInterface::lastUpdate(){ return OS_lastUpdate(); } +QString OSInterface::lastUpdateResults(){ return OS_lastUpdateResults(); } // = System Power = -bool OSInterface::canReboot(){ return false; } -void OSInterface::startReboot(){} -bool OSInterface::canShutdown(){ return false; } -void OSInterface::startShutdown(){} -bool OSInterface::canSuspend(){ return false; } -void OSInterface::startSuspend(){} +bool OSInterface::canReboot(){ return OS_canReboot(); } +void OSInterface::startReboot(){ OS_startReboot(); } +bool OSInterface::canShutdown(){ return OS_canShutdown(); } +void OSInterface::startShutdown(){ OS_startShutdown(); } +bool OSInterface::canSuspend(){ return OS_canSuspend(); } +void OSInterface::startSuspend(){ OS_startSuspend(); } // = Screen Brightness = -bool OSInterface::brightnessSupported(){ return false; } -int OSInterface::brightness(){ return -1; } //percentage: 0-100 with -1 for errors -void OSInterface::setBrightness(int){} +bool OSInterface::brightnessSupported(){ return OS_brightnessSupported(); } +int OSInterface::brightness(){ + if(INFO.contains("brightness/percent")){ return INFO.value("brightness/percent").toInt(); } + return 100; +} +void OSInterface::setBrightness(int percent){ + OS_setBrightness(percent); + BrightnessTimerUpdate(); //update internal cache ASAP +} // = System Status Monitoring -bool OSInterface::cpuSupported(){ return false; } +bool OSInterface::cpuSupported(){ return OS_cpuSupported(); } QList<int> OSInterface::cpuPercentage(){ return QList<int>(); } // (one per CPU) percentage: 0-100 with empty list for errors QStringList OSInterface::cpuTemperatures(){ return QStringList(); } // (one per CPU) Temperature of CPU ("50C" for example) |