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 <QObject>
10
11#include "Unit.h"
12
13namespace KSysGuard
14{
15/**
16 * Tiny helper class to make Formatter usable from QML.
17 *
18 * An instance of this class will be exposed as a Singleton object to QML. It
19 * allows formatting of values from the QML side.
20 *
21 * This effectively wraps Formatter::formatValue, removing the FormatOptions flag
22 * that I couldn't get to work.
23 *
24 * It is accessible as `Formatter` inside the `org.kde.ksysguard.formatter` package
25 * @see Formatter
26 */
28{
30
31public:
32 Q_INVOKABLE QString formatValue(const QVariant &value, KSysGuard::Unit unit, KSysGuard::MetricPrefix targetPrefix = MetricPrefixAutoAdjust);
33
34 Q_INVOKABLE QString formatValueShowNull(const QVariant &value, KSysGuard::Unit unit, KSysGuard::MetricPrefix targetPrefix = MetricPrefixAutoAdjust);
35
36 Q_INVOKABLE qreal maximumLength(KSysGuard::Unit unit, const QFont &font);
37};
38
39}
Tiny helper class to make Formatter usable from QML.
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:21:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.