1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/*
Copyright 2008-2010 Sebastian Kügler <sebas@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UIUTILS_H
#define UIUTILS_H
class QSizeF;
#include "knminternals_export.h"
#include "../client/remoteinterfaceconnection.h"
#include "../client/remoteactivatablelist.h"
#include <solid/control/networkinterface.h>
#include <solid/control/wirelessnetworkinterface.h>
#include <solid/control/wirelessaccesspoint.h>
#include <Solid/Device>
class KNMINTERNALS_EXPORT UiUtils
{
public:
/**
* @return a human-readable description for the network interface type for use as label
* @param type the type of the network interface
*/
static QString interfaceTypeLabel(const Solid::Control::NetworkInterface::Type type);
/**
* @return a human-readable name for a given network interface according to the configured
* naming style
* @param type the type of the network interface
*/
static QString interfaceNameLabel(const QString & uni);
/**
* @return a Solid::Device from a NetworkManager uni. The returned object must be deleted after use
* @param type the type of the network interface
*/
static Solid::Device* findSolidDevice(const QString & uni);
/**
* @return a human-readable description of the connection state of a given network interface
* @param state The connection state
*/
static QString connectionStateToString(Solid::Control::NetworkInterface::ConnectionState state, const QString &connectionName = QString());
/**
* @return the RemoteInterfaceConnection for a given network interface
* @param interface the Solid::Control::NetworkInterface state
* @param activatables the RemoteActivatableList of all connections
*/
static RemoteInterfaceConnection* connectionForInterface(RemoteActivatableList* activatables, Solid::Control::NetworkInterface *interface);
/**
* @return an icon name suitable for the interface type
* @param iface the network interface
*/
static QString iconName(Solid::Control::NetworkInterface *iface);
/** This method can be used to retrieve an icon size that fits into a given size.
* The resulting size can be used to render Pixmaps from KIconLoader without
* rescaling them (and thereby losing quality)
*
* @return a size available in KIconLoader.
* @param size The size of the rect it should fit in
*/
static int iconSize(const QSizeF size);
/** This method can be used to retrieve the progress of a connection attempt
* as a qreal, for painting progress bars.
*
* @return the progress between 0 (disconnected) and 1 (activated).
* @param interface the network interface
*/
static qreal interfaceState(const Solid::Control::NetworkInterface *interface);
/**
* @return a human-readable description of operation mode.
* @param mode the operation mode
*/
static QString operationModeToString(Solid::Control::WirelessNetworkInterface::OperationMode mode);
/**
* @return string list with a human-readable description of wpa flags.
* @param flags the wpa flags
*/
static QStringList wpaFlagsToStringList(Solid::Control::AccessPoint::WpaFlags flags);
/**
* @return localized string showing a human-readable connection speed. 1000 is used as base.
* @param bitrate bitrate of the connection per second
*/
static QString connectionSpeed(double bitrate);
};
#endif // UIUTILS_H
|