Use font awesome icons for global stats in plasmoid
This commit is contained in:
parent
2ab88c5766
commit
3e97a65bae
|
@ -17,6 +17,7 @@ set(PLASMOID_FILES
|
|||
../package/contents/ui/TinyButton.qml
|
||||
../package/contents/ui/TinyButtonStyle.qml
|
||||
../package/contents/ui/ButtonShadow.qml
|
||||
../package/contents/ui/StatisticsView.qml
|
||||
../package/contents/ui/main.qml)
|
||||
list(APPEND QML_SRC_FILES ${PLASMOID_FILES})
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <qtutilities/resources/resources.h>
|
||||
|
||||
#include <c++utilities/application/argumentparser.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
||||
#include <KConfigGroup>
|
||||
|
||||
|
@ -41,6 +42,7 @@ using namespace Data;
|
|||
using namespace Plasma;
|
||||
using namespace Dialogs;
|
||||
using namespace QtGui;
|
||||
using namespace ConversionUtilities;
|
||||
using namespace ChronoUtilities;
|
||||
|
||||
namespace Plasmoid {
|
||||
|
@ -146,14 +148,14 @@ bool SyncthingApplet::hasOutgoingTraffic() const
|
|||
return m_connection.totalOutgoingRate() > 0.0;
|
||||
}
|
||||
|
||||
QString SyncthingApplet::globalStatistics() const
|
||||
SyncthingStatistics SyncthingApplet::globalStatistics() const
|
||||
{
|
||||
return directoryStatusString(m_overallStats.global);
|
||||
return m_overallStats.global;
|
||||
}
|
||||
|
||||
QString SyncthingApplet::localStatistics() const
|
||||
SyncthingStatistics SyncthingApplet::localStatistics() const
|
||||
{
|
||||
return directoryStatusString(m_overallStats.local);
|
||||
return m_overallStats.local;
|
||||
}
|
||||
|
||||
QStringList SyncthingApplet::connectionConfigNames() const
|
||||
|
@ -239,9 +241,14 @@ void SyncthingApplet::updateStatusIconAndTooltip()
|
|||
emit connectionStatusChanged();
|
||||
}
|
||||
|
||||
QIcon SyncthingApplet::loadFontAwesomeIcon(const QString &name)
|
||||
QIcon SyncthingApplet::loadFontAwesomeIcon(const QString &name, bool solid) const
|
||||
{
|
||||
return Data::renderSvgImage(Data::loadFontAwesomeIcon(name, QGuiApplication::palette().color(QPalette::Foreground)), QSize(16, 13));
|
||||
return Data::renderSvgImage(Data::loadFontAwesomeIcon(name, QGuiApplication::palette().color(QPalette::Foreground), solid), QSize(32, 32), 8);
|
||||
}
|
||||
|
||||
QString SyncthingApplet::formatFileSize(quint64 fileSizeInByte) const
|
||||
{
|
||||
return QString::fromStdString(dataSizeToString(fileSizeInByte));
|
||||
}
|
||||
|
||||
void SyncthingApplet::showSettingsDlg()
|
||||
|
|
|
@ -55,8 +55,8 @@ class SyncthingApplet : public Plasma::Applet {
|
|||
Q_PROPERTY(bool hasIncomingTraffic READ hasIncomingTraffic NOTIFY trafficChanged)
|
||||
Q_PROPERTY(QString outgoingTraffic READ outgoingTraffic NOTIFY trafficChanged)
|
||||
Q_PROPERTY(bool hasOutgoingTraffic READ hasOutgoingTraffic NOTIFY trafficChanged)
|
||||
Q_PROPERTY(QString globalStatistics READ globalStatistics NOTIFY statisticsChanged)
|
||||
Q_PROPERTY(QString localStatistics READ localStatistics NOTIFY statisticsChanged)
|
||||
Q_PROPERTY(Data::SyncthingStatistics globalStatistics READ globalStatistics NOTIFY statisticsChanged)
|
||||
Q_PROPERTY(Data::SyncthingStatistics localStatistics READ localStatistics NOTIFY statisticsChanged)
|
||||
Q_PROPERTY(QStringList connectionConfigNames READ connectionConfigNames NOTIFY settingsChanged)
|
||||
Q_PROPERTY(QString currentConnectionConfigName READ currentConnectionConfigName NOTIFY currentConnectionConfigIndexChanged)
|
||||
Q_PROPERTY(int currentConnectionConfigIndex READ currentConnectionConfigIndex WRITE setCurrentConnectionConfigIndex NOTIFY
|
||||
|
@ -86,8 +86,8 @@ public:
|
|||
bool hasIncomingTraffic() const;
|
||||
QString outgoingTraffic() const;
|
||||
bool hasOutgoingTraffic() const;
|
||||
QString globalStatistics() const;
|
||||
QString localStatistics() const;
|
||||
Data::SyncthingStatistics globalStatistics() const;
|
||||
Data::SyncthingStatistics localStatistics() const;
|
||||
QStringList connectionConfigNames() const;
|
||||
QString currentConnectionConfigName() const;
|
||||
int currentConnectionConfigIndex() const;
|
||||
|
@ -115,7 +115,8 @@ public Q_SLOTS:
|
|||
void showDirectoryErrors(unsigned int directoryIndex);
|
||||
void copyToClipboard(const QString &text);
|
||||
void updateStatusIconAndTooltip();
|
||||
QIcon loadFontAwesomeIcon(const QString &name);
|
||||
QIcon loadFontAwesomeIcon(const QString &name, bool solid = true) const;
|
||||
QString formatFileSize(quint64 fileSizeInByte) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/// \remarks Never emitted, just to silence "... depends on non-NOTIFYable ..."
|
||||
|
|
|
@ -430,6 +430,7 @@ ColumnLayout {
|
|||
|
||||
// global statistics and traffic
|
||||
GridLayout {
|
||||
Layout.leftMargin: 5
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: false
|
||||
columns: 4
|
||||
|
@ -441,8 +442,9 @@ ColumnLayout {
|
|||
Layout.preferredHeight: 16
|
||||
source: "globe"
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: plasmoid.nativeInterface.globalStatistics
|
||||
StatisticsView {
|
||||
Layout.leftMargin: 4
|
||||
statistics: plasmoid.nativeInterface.globalStatistics
|
||||
}
|
||||
|
||||
PlasmaCore.IconItem {
|
||||
|
@ -462,8 +464,9 @@ ColumnLayout {
|
|||
Layout.preferredHeight: 16
|
||||
source: "user-home-symbolic"
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: plasmoid.nativeInterface.localStatistics
|
||||
StatisticsView {
|
||||
Layout.leftMargin: 4
|
||||
statistics: plasmoid.nativeInterface.localStatistics
|
||||
}
|
||||
|
||||
PlasmaCore.IconItem {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Layouts 1.1
|
||||
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
|
||||
RowLayout {
|
||||
property var statistics
|
||||
|
||||
PlasmaCore.IconItem {
|
||||
Layout.preferredWidth: 16
|
||||
Layout.preferredHeight: 16
|
||||
source: plasmoid.nativeInterface.loadFontAwesomeIcon("file", false)
|
||||
opacity: 0.7
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: statistics.files !== undefined ? statistics.files : "?"
|
||||
}
|
||||
PlasmaCore.IconItem {
|
||||
Layout.preferredWidth: 16
|
||||
Layout.preferredHeight: 16
|
||||
source: plasmoid.nativeInterface.loadFontAwesomeIcon("folder", false)
|
||||
opacity: 0.7
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: statistics.dirs !== undefined ? statistics.dirs : "?"
|
||||
}
|
||||
PlasmaCore.IconItem {
|
||||
Layout.preferredWidth: 16
|
||||
Layout.preferredHeight: 16
|
||||
source: plasmoid.nativeInterface.loadFontAwesomeIcon("hdd", false)
|
||||
opacity: 0.7
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
text: statistics.bytes !== undefined ? plasmoid.nativeInterface.formatFileSize(
|
||||
statistics.bytes) : "?"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue