Libksysguard

FormatterWrapper.h
1/*
2 SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QFont>
10#include <QObject>
11#include <QVariant>
12
13#include "Unit.h"
14
15namespace KSysGuard
16{
17/**
18 * Tiny helper class to make Formatter usable from QML.
19 *
20 * An instance of this class will be exposed as a Singleton object to QML. It
21 * allows formatting of values from the QML side.
22 *
23 * This effectively wraps Formatter::formatValue, removing the FormatOptions flag
24 * that I couldn't get to work.
25 *
26 * It is accessible as `Formatter` inside the `org.kde.ksysguard.formatter` package
27 * @see Formatter
28 */
30{
32 QML_NAMED_ELEMENT(Formatter)
33 QML_SINGLETON
34
35public:
36 Q_INVOKABLE QString formatValue(const QVariant &value, KSysGuard::Unit unit, KSysGuard::MetricPrefix targetPrefix = MetricPrefixAutoAdjust);
37
38 Q_INVOKABLE QString formatValueShowNull(const QVariant &value, KSysGuard::Unit unit, KSysGuard::MetricPrefix targetPrefix = MetricPrefixAutoAdjust);
39
40 Q_INVOKABLE QString formatValueWithPrecision(const QVariant &value, KSysGuard::Unit unit, int precision = 1);
41
42 Q_INVOKABLE qreal maximumLength(KSysGuard::Unit unit, const QFont &font);
43};
44
45}
Tiny helper class to make Formatter usable from QML.
A class for formatting sensor values.
Definition Formatter.h:36
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.