File indexing completed on 2024-05-05 17:39:47
0001 /* 0002 SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 0011 #include "Unit.h" 0012 0013 namespace KSysGuard 0014 { 0015 /** 0016 * Tiny helper class to make Formatter usable from QML. 0017 * 0018 * An instance of this class will be exposed as a Singleton object to QML. It 0019 * allows formatting of values from the QML side. 0020 * 0021 * This effectively wraps Formatter::formatValue, removing the FormatOptions flag 0022 * that I couldn't get to work. 0023 * 0024 * It is accessible as `Formatter` inside the `org.kde.ksysguard.formatter` package 0025 * @see Formatter 0026 */ 0027 class FormatterWrapper : public QObject 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 Q_INVOKABLE QString formatValue(const QVariant &value, KSysGuard::Unit unit, KSysGuard::MetricPrefix targetPrefix = MetricPrefixAutoAdjust); 0033 0034 Q_INVOKABLE QString formatValueShowNull(const QVariant &value, KSysGuard::Unit unit, KSysGuard::MetricPrefix targetPrefix = MetricPrefixAutoAdjust); 0035 0036 Q_INVOKABLE qreal maximumLength(KSysGuard::Unit unit, const QFont &font); 0037 }; 0038 0039 }