LeechCraft  %{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LeechCraft::Util Namespace Reference

Namespaces

 SysInfo
 

Classes

class  BackendSelector
 A common dialog to select storage backend. More...
 
class  BaseHookInterconnector
 Base class for signal-slot relays in plugin APIs. More...
 
class  CustomCookieJar
 A customized cookie jar with additional features. More...
 
class  CustomNetworkReply
 A network reply with customizable content and reply headers. More...
 
class  DBLock
 Provides database transaction lock. More...
 
class  DefaultHookProxy
 Standard implementation of IHookProxy. More...
 
class  FileRemoveGuard
 QFile removing itself from file system on destruction. More...
 
class  AutoResizeMixin
 
class  ClearLineEditAddon
 Provides a "clear text" action for line edits. More...
 
class  FindNotification
 A horizontal bar with typical widgets for text search. More...
 
class  FlowLayout
 A simple flow layout implementation. More...
 
class  PageNotification
 
class  SelectableBrowser
 A "browser" that shows HTML either via QTextBrowser or a browser plugin. More...
 
class  UnhoverDeleteMixin
 Allows to hide a widget or popup after mouse leave. More...
 
class  IDPool
 A simple pool of identificators of the given type. More...
 
class  FlattenFilterModel
 
class  FlatToFoldersProxyModel
 
class  ListModelItem
 
class  ListModel
 
class  MergeModel
 
class  TreeItem
 
class  NotificationActionHandler
 Aids in adding actions to notifications. More...
 
class  ColorThemeProxy
 Proxy for QML files to use colors from current color theme. More...
 
class  ThemeImageProvider
 Provides icons from the current theme by their FDO name. More...
 
class  UnhideListModel
 
class  UnhideListViewBase
 
class  WidthIconProvider
 Provides scalable icons to QML. More...
 
class  QueueManager
 A simple scheduling manager for a queue of functors. More...
 
class  ResourceLoader
 Utility class for loading a file from a set of locations. More...
 
class  ShortcutManager
 Aids in providing configurable shortcuts. More...
 
class  SyncDeltaManager
 
class  VersionActionMapper
 
class  CategorySelector
 The CategorySelector widget provides a way to select amongst a group of items. More...
 
class  TagsCompleter
 Completer suitable for tag completion. More...
 
class  TagsCompletionModel
 A QStringListModel providing additional methods for tags. More...
 
class  TagsFilterModel
 Provides filter model with additional tags filter mode. More...
 
class  TagsLineEdit
 A line edit class suitable for use with TagsCompleter. More...
 
struct  ValueFinder
 
class  StdDataFilterMenuCreator
 

Typedefs

typedef std::shared_ptr
< XmlSettingsDialog > 
XmlSettingsDialog_ptr
 
typedef std::shared_ptr
< DefaultHookProxy
DefaultHookProxy_ptr
 
typedef std::shared_ptr
< QIODevice > 
QIODevice_ptr
 

Enumerations

enum  FitFlag {
  NoFlags,
  NoOverlap = 0x01
}
 
enum  SysPath {
  SysPath::QML,
  SysPath::Share
}
 Describes various root paths recognized by GetSysPath(). More...
 

Functions

QPoint FitRectScreen (QPoint pos, const QSize &size, FitFlags flags=NoFlags, const QPoint &shiftAdd=QPoint(0, 0))
 Tries to fit a rectangle (like a dialog or popup) into screen. More...
 
QPoint FitRect (QPoint pos, const QSize &size, const QRect &geometry, FitFlags flags=NoFlags, const QPoint &shiftAdd=QPoint(0, 0))
 Tries to fit a rectangle (like a dialog or popup) into geometry. More...
 
QLabel * ShowPixmapLabel (const QPixmap &pixmap, const QPoint &pos=QPoint())
 Shows a pixmap at the given pos. More...
 
 Q_DECLARE_FLAGS (FitFlags, FitFlag)
 
QString GetPassword (const QString &keyName, const QString &dialogText, QObject *emitter, bool useStore=true)
 Returns password for the key, possibly asking the user. More...
 
void SavePassword (const QString &password, const QString &keyName, QObject *emitter)
 Saves the password to be retrieved later via GetPassword(). More...
 
QString GetSocketErrorString (QAbstractSocket::SocketError error)
 Returns an error string for the given socket error. More...
 
QStringList GetPathCandidates (SysPath path, QString subfolder)
 Returns possible full paths for the path and subfolder. More...
 
QString GetSysPath (SysPath path, const QString &subfolder, const QString &filename)
 Returns path to the file in the given root path and subfolder. More...
 
QString FromStdString (const std::string &str)
 An utility function that creates a QString from UTF8-encoded std::string. More...
 
UTIL_API QString GetAsBase64Src (const QImage &image)
 Returns the given image in a Base64-encoded form. More...
 
UTIL_API QString GetUserText (const Entity &entity)
 Return the user-readable representation of the entity. More...
 
UTIL_API QString MakePrettySize (qint64)
 Makes a formatted size from number. More...
 
UTIL_API QString MakeTimeFromLong (ulong)
 Makes a formatted time from number. More...
 
UTIL_API QTranslator * InstallTranslator (const QString &base, const QString &prefix="leechcraft", const QString &appname="leechcraft")
 Loads and installs a translator. More...
 
UTIL_API QString GetLocaleName ()
 Returns the current locale name, like en_US. More...
 
UTIL_API QString GetInternetLocaleName (const QLocale &)
 
UTIL_API QString GetLanguage ()
 Returns the current language name. More...
 
UTIL_API QDir CreateIfNotExists (const QString &path)
 Creates a path if it doesn't exist. More...
 
UTIL_API QDir GetUserDir (const QString &path)
 Returns the path relative to user directory. More...
 
UTIL_API QString GetTemporaryName (const QString &pattern=QString("lc_temp.XXXXXX"))
 Returns a temporary filename. More...
 
UTIL_API Entity MakeEntity (const QVariant &entity, const QString &location, LeechCraft::TaskParameters tp, const QString &mime=QString())
 An utility function to make a Entity. More...
 
UTIL_API Entity MakeNotification (const QString &header, const QString &text, Priority priority)
 An utility function to make a Entity with notification. More...
 
UTIL_API Entity MakeANCancel (const Entity &event)
 Makes an event for canceling another Advanced Notifications event. More...
 
UTIL_API Entity MakeANCancel (const QString &senderId, const QString &eventId)
 Makes an event for canceling another Advanced Notifications event. More...
 
UTIL_API QModelIndexList GetSummarySelectedRows (QObject *sender)
 
UTIL_API QAction * CreateSeparator (QObject *parent)
 Returns the action that is set to act as a separator. More...
 
UTIL_API QVariantList GetPersistentData (const QList< QVariant > &keys, QObject *object)
 
UTIL_API QPixmap DrawOverlayText (QPixmap px, const QString &text, QFont font, const QPen &pen, const QBrush &brush)
 
template<typename TagGetter , typename TagSetter >
QDomElement GetElementForTags (const QStringList &tags, QDomNode &node, QDomDocument &document, const QString &elementName, TagGetter tagGetter, TagSetter tagSetter)
 Returns an element for a given tags list. More...
 
template<typename K , typename V >
QMap< K, V > MakeMap (std::initializer_list< QPair< K, V >> l)
 
Entity MakeAN (const QString &header, const QString &text, Priority priority, const QString &senderID, const QString &cat, const QString &type, const QString &id, const QStringList &visualPath, int delta=1, int count=0, const QString &fullText=QString(), const QString &extendedText=QString())
 Creates an Advanced Notifications-enabled notify entity. More...
 

Typedef Documentation

Definition at line 117 of file defaulthookproxy.h.

typedef std::shared_ptr<QIODevice> LeechCraft::Util::QIODevice_ptr

Definition at line 50 of file resourceloader.h.

typedef std::shared_ptr<XmlSettingsDialog> LeechCraft::Util::XmlSettingsDialog_ptr

Definition at line 39 of file ihavesettings.h.

Enumeration Type Documentation

Additional fitting options used by FitRect() and FitRectScreen().

Enumerator
NoFlags 

Default fitting options.

NoOverlap 

The fitted rectangle should never overlap with the original top left position.

This option may be useful if a menu or tooltip is fitted, since it's generally undesirable to cover the corresponding UI element with the menu or tooltip.

Definition at line 46 of file util.h.

Describes various root paths recognized by GetSysPath().

See Also
GetPathCandidates(), GetSysPath()
Enumerator
QML 

Root path for QML files.

Plugins are expected to install their files into a subdirectory of this directory.

Share 

Directory with shared data files.

Corresponds to /usr/[local/]share/leechcraft on Linux, for example.

Definition at line 43 of file paths.h.

Function Documentation

QDir LeechCraft::Util::CreateIfNotExists ( const QString &  path)

Creates a path if it doesn't exist.

Creates a relative path ~/.leechcraft/path and throws an exception if this could not be done or if such path already exists and it is not readable.

Parameters
[in]pathThe path to create.
Returns
The newly created dir.
Exceptions
std::runtime_errorThrows if the path could not be created.

Definition at line 233 of file util.cpp.

QAction * LeechCraft::Util::CreateSeparator ( QObject *  parent)

Returns the action that is set to act as a separator.

That is the action with setSeparator(true);

Parameters
[in]parentThe parent of the action.
Returns
The separator action.

Definition at line 340 of file util.cpp.

QPixmap LeechCraft::Util::DrawOverlayText ( QPixmap  px,
const QString &  text,
QFont  font,
const QPen &  pen,
const QBrush &  brush 
)

Definition at line 366 of file util.cpp.

UTIL_API QPoint LeechCraft::Util::FitRect ( QPoint  pos,
const QSize &  size,
const QRect &  geometry,
FitFlags  flags = NoFlags,
const QPoint &  shiftAdd = QPoint(0, 0) 
)

Tries to fit a rectangle (like a dialog or popup) into geometry.

This function tries to move the rectangle with top left point at pos and with given size so that it fits completely into the rectangle given by the geometry parameter. It leaves the size intact, instead returning the new top left position.

If the rectangle is actually moved by this function, the shiftAdd parameter is used to customize how it is moved: the shiftAdd.x() component is added to the result iff pos.x() is changed, and shiftAdd.y() is added to the result iff pos.y() is changed.

Parameters
[in]posThe original top left position of the rect to fit.
[in]sizeThe size of the rectangle to fit.
[in]geometryThe rectangle into which the source rectangle should be fitted.
[in]flagsAdditional fitting parameters.
[in]shiftAddAdditional components to be added if the rectangle is actually moved in the corresponding directions.
Returns
The new top left position of the rectangle.
See Also
FitRectScreen()

Definition at line 49 of file util.cpp.

References NoOverlap.

Referenced by FitRectScreen().

+ Here is the caller graph for this function:

UTIL_API QPoint LeechCraft::Util::FitRectScreen ( QPoint  pos,
const QSize &  size,
FitFlags  flags = NoFlags,
const QPoint &  shiftAdd = QPoint(0, 0) 
)

Tries to fit a rectangle (like a dialog or popup) into screen.

This function tries to move the rectangle with top left point at pos and with given size so that it fits completely into the available geometry of the screen that contains the point pos. It leaves the rectangle size intact, instead returning the new top left position.

Calling this function is equivalent to calling FitRect() with the geometry parameter set to QDesktopWidget::availableGeometry(pos). See the documentation for FitRect() for more details.

Parameters
[in]posThe original top left position of the rect to fit.
[in]sizeThe size of the rectangle to fit.
[in]flagsAdditional fitting parameters.
[in]shiftAddAdditional components to be added if the rectangle is actually moved in the corresponding directions.
Returns
The new top left position of the rectangle.
See Also
FitRect()

Definition at line 44 of file util.cpp.

References FitRect().

+ Here is the call graph for this function:

QString LeechCraft::Util::FromStdString ( const std::string &  str)
inline

An utility function that creates a QString from UTF8-encoded std::string.

Parameters
[in]strThe UTF-8 encoded std::string.
Returns
The QString containing the same string.

Definition at line 53 of file util.h.

QString LeechCraft::Util::GetAsBase64Src ( const QImage &  image)

Returns the given image in a Base64-encoded form.

The return result is suitable for inserting into 's src attribute as is.

Parameters
[in]imageThe image to represent as Base64-encoded form.
Returns
The source string.

Definition at line 54 of file util.cpp.

template<typename TagGetter , typename TagSetter >
QDomElement LeechCraft::Util::GetElementForTags ( const QStringList &  tags,
QDomNode &  node,
QDomDocument &  document,
const QString &  elementName,
TagGetter  tagGetter,
TagSetter  tagSetter 
)

Returns an element for a given tags list.

This function tries to implement projection from tags to a hierarchical structure in form of XML. It traverses the tags list and creates child nodes from the document, appending the hierarchical structure's tree root to the node. It returns the parent element to which the item should be appended.

For empty tags list it just returns node converted to the QDomElement.

tagSetter is a function or functor that should be able to take two parameters, a QDomElement and a QString, and set tags for it.

tagGetter is a function or functor that should be able to take one parameter, a QDomElement, and return a QString for it with tags previously set with tagSetter.

Parameters
[in]tagsList of tags.
[in]nodeThe parent-most node to which all other nodes are appended.
[in]documentThe document containing all these nodes.
[in]elementNameThe name of the XML element that carries info about the tags.
[in]tagSetterSetter function for the tags for the given element.
[in]tagGetterGetter function for the tags for the given element.
Returns
Parent element of the item with tags.

Definition at line 334 of file util.h.

QString LeechCraft::Util::GetInternetLocaleName ( const QLocale &  locale)

Definition at line 216 of file util.cpp.

QString LeechCraft::Util::GetLanguage ( )

Returns the current language name.

This function works as GetLocaleName() except it doesn't return (and doesn't query for) country name.

Returns
Current language name.
See Also
GetLocaleName()

Definition at line 228 of file util.cpp.

References GetLocaleName().

+ Here is the call graph for this function:

QString LeechCraft::Util::GetLocaleName ( )

Returns the current locale name, like en_US.

First, this function checks the locale value stored in "Language" key of settings object with organizationName() and applicationName(). If it's equal to "system", this function queries the LANG environment variable, and if it is empty or in invalid format (not like en_US), it takes the value of QLocale::system().name().

Then, if the resulting name the name of the language only, GetLocaleName() tries to find any countries for that language. If any countries are found, the code of the first found country is appended, else "_00" is appended.

Returns
Current locale name.
See Also
GetLanguage()

Definition at line 189 of file util.cpp.

Referenced by GetLanguage(), and InstallTranslator().

+ Here is the caller graph for this function:

UTIL_API QString LeechCraft::Util::GetPassword ( const QString &  keyName,
const QString &  dialogText,
QObject *  emitter,
bool  useStore = true 
)

Returns password for the key, possibly asking the user.

This function returns password for the given keyName and using the given emitter object. The password is typically stored in a storage plugin like SecMan.

If the password isn't found in any password stores (or there are no password stores) or useStore is set to false, this function asks the user for the password instead using the dialogText for the dialog and returns the user input instead. If user has canceled the dialog it returns an null string. Otherwise, if the user has entered some text this function automatically stores the password under the keyName.

The emitter object is used to send the corresponding internal Entity objects around, so it should have its gotEntity() and delegateEntity() signals both relayed to the corresponding plugin instance object.

Note
Despite the name this function can be used to retrieve arbitrary string data saved via SavePassword().
Parameters
[in]keyNameThe name of the key uniquely identifying the password.
[in]dialogTextThe text of the dialog to present to the user if the password isn't found or useStore is false.
[in]emitterThe object used to emit the gotEntity() and delegateEntity() signals.
[in]useStoreWhether stored password should be used at all. Calling code may explicitly set this to false if the saved password is known to be invalid, for instance.
Returns
The password or a null string.
See Also
SavePassword()

Definition at line 74 of file passutils.cpp.

References SavePassword().

+ Here is the call graph for this function:

UTIL_API QStringList LeechCraft::Util::GetPathCandidates ( SysPath  path,
QString  subfolder 
)

Returns possible full paths for the path and subfolder.

This function returns a list of paths formed as the given root path identified by path plus the subfolder in it. The paths in the returned list aren't checked for existence.

For example, on Linux

* const auto& paths = GetPathCandidates (SysPath::Share, "flags");
*

will return { "/usr/share/leechcraft/flags", "/usr/local/share/leechcraft/flags" }.

The subfolder can actually be a relative path, like flags/countries, not just a single subfolder name.

This function hardly needs to be called from user code, consider using GetSysPath() instead.

Parameters
[in]pathThe root path.
[in]subfolderThe subfolder inside the root path.
Returns
The list of possible paths to the subfolder in the root path identified by path.
See Also
GetSysPath()

Definition at line 41 of file paths.cpp.

References QML, and Share.

Referenced by GetSysPath(), and LeechCraft::Util::UnhideListViewBase::UnhideListViewBase().

+ Here is the caller graph for this function:

QVariantList LeechCraft::Util::GetPersistentData ( const QList< QVariant > &  keys,
QObject *  object 
)

Definition at line 347 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::Internal, and MakeEntity().

+ Here is the call graph for this function:

UTIL_API QString LeechCraft::Util::GetSocketErrorString ( QAbstractSocket::SocketError  error)

Returns an error string for the given socket error.

This function returns a human-readable localized string describing the given socket error.

Parameters
[in]errorThe socket error to describe.
Returns
The human-readable localized error string.

Definition at line 37 of file socketerrorstrings.cpp.

QModelIndexList LeechCraft::Util::GetSummarySelectedRows ( QObject *  sender)

Definition at line 322 of file util.cpp.

UTIL_API QString LeechCraft::Util::GetSysPath ( SysPath  path,
const QString &  subfolder,
const QString &  filename 
)

Returns path to the file in the given root path and subfolder.

This function returns path to a file named filename and located in the path specified by path + subfolder. It actually checks whether the file exists and if it doesn't, returns a null string instead.

If LeechCraft is running on a system where multiple paths correspond to a single path, they are checked from more user-accessible to less user-accessible. For example, SysPath::Share corresponds to /usr/local/share/leechcraft and then /usr/share/leechcraft.

The subfolder can actually be a relative path, like flags/countries, not just a single subfolder name.

Refer to GetPathCandidates() for more information.

Parameters
[in]pathThe identifier of the root path.
[in]subfolderThe subfolder inside the path.
[in]filenameThe filename inside the path + subfolder.
Returns
Path to the filename located in path + subfolder, or an empty string if there is no such file.
See Also
GetPathCandidates()

Definition at line 77 of file paths.cpp.

References GetPathCandidates().

Referenced by LeechCraft::Util::UnhideListViewBase::UnhideListViewBase().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QString LeechCraft::Util::GetTemporaryName ( const QString &  pattern = QString ("lc_temp.XXXXXX"))

Returns a temporary filename.

This function returns a name of a temporary file that could be created, not createing the file itself.

Parameters
[in]patternPattern of the filename.
Returns
The filename.

Definition at line 269 of file util.cpp.

QDir LeechCraft::Util::GetUserDir ( const QString &  path)

Returns the path relative to user directory.

Returns a QDir object that represents the ~/.leechcraft/path or throws an exceptions if this path doesn't exist.

Parameters
[in]pathThe path to return relative to ~/.leechcraft
Returns
The QDir object for that path.
Exceptions
std::runtime_errorThrows if the path doesn't exist.

Definition at line 252 of file util.cpp.

QString LeechCraft::Util::GetUserText ( const Entity &  entity)

Return the user-readable representation of the entity.

Parameters
[in]entityThe Entity from which to make the user-readable representation.
Returns
The user-readable string describing the entity.

Definition at line 63 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::Entity::Entity_, and LeechCraft::Entity::Mime_.

QTranslator * LeechCraft::Util::InstallTranslator ( const QString &  base,
const QString &  prefix = "leechcraft",
const QString &  appname = "leechcraft" 
)

Loads and installs a translator.

Attempts to load and install a translator for the current locale. The name is formed like this: 'prefix_' + base + '_' + locale If base is an empty string, the second _ isn't appended.

First resources are searched (:/), then APPDIR/translations on Windows and /usr/[local/]share/appname/translations on Unix.

Parameters
[in]baseBase name of the translation file.
[in]prefixThe optional prefix of the translation (useful if it's not LC's one).
[in]appnameBase name of the application.
Returns
The translator object if loading is successful, NULL otherwise.

Definition at line 145 of file util.cpp.

References GetLocaleName().

+ Here is the call graph for this function:

UTIL_API Entity LeechCraft::Util::MakeAN ( const QString &  header,
const QString &  text,
Priority  priority,
const QString &  senderID,
const QString &  cat,
const QString &  type,
const QString &  id,
const QStringList &  visualPath,
int  delta = 1,
int  count = 0,
const QString &  fullText = QString(),
const QString &  extendedText = QString() 
)

Creates an Advanced Notifications-enabled notify entity.

Returns an entity with the given header, text and a bunch of other parameters that can be handled by Advanced Notifications.

The returned entity will also be handled by a visual notifications plugin if AN is not present. To avoid this set the MIME type of the result to x-leechcraft/notification+advanced.

Refer to the hand-written documentation for more information about using Advanced Notifications.

Parameters
[in]headerThe header of the notification. This field will also be used if AN is not present.
[in]textThe text of the notification. This field will also be used if AN is not present.
[in]priorityThe priority of this notification.
[in]senderIDThe ID of the plugin sending this notification.
[in]catThe category of this notification (one of Cat constants in interfaces/an/constants.h).
[in]typeThe type of this notification (one of Type constants in interfaces/an/constants.h).
[in]idThe ID of this notification, used to group consecutive notifications about similar events like incoming message from the same IM contact.
[in]visualPathThe list of names for a menu-like structure wishing to show this notification.
[in]deltaThe change of count of events with this id, or 0 to use count.
[in]countThe total count of events with this id, used if delta is 0.
[in]fullTextThe full text of this notification. If null, the text parameter is used.
[in]extendedTextThe extended text of this notification. If null, the text parameter is used.
See Also
MakeANCancel()

Definition at line 37 of file util.cpp.

References MakeNotification().

+ Here is the call graph for this function:

LeechCraft::Entity LeechCraft::Util::MakeANCancel ( const Entity &  event)

Makes an event for canceling another Advanced Notifications event.

Creates an Entity that cancels a previously generated Advanced Notifications event. The returned entity can be then emitted to notify plugins that the given event has been canceled.

Parameters
[in]eventThe event to cancel.
Returns
The Entity canceling the given event.

Definition at line 304 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::Entity::Entity_, MakeNotification(), and LeechCraft::PInfo_.

+ Here is the call graph for this function:

LeechCraft::Entity LeechCraft::Util::MakeANCancel ( const QString &  senderId,
const QString &  eventId 
)

Makes an event for canceling another Advanced Notifications event.

Creates an Entity that cancels a previously generated Advanced Notifications event. The returned entity can be then emitted to notify plugins that the given event has been canceled.

This function doesn't take a previously created entity as the other overload does. Instead, it plainly creates the required entity from the given senderId and eventId. They should match those of the event in question.

Parameters
[in]senderIdThe ID of the sender of the event that is to be canceled.
[in]eventIdThe ID of the event that is to be canceled.
Returns
The Entity canceling the given event.

Definition at line 313 of file util.cpp.

References LeechCraft::Entity::Additional_, MakeNotification(), and LeechCraft::PInfo_.

+ Here is the call graph for this function:

LeechCraft::Entity LeechCraft::Util::MakeEntity ( const QVariant &  entity,
const QString &  location,
LeechCraft::TaskParameters  tp,
const QString &  mime = QString () 
)

An utility function to make a Entity.

Creates a Entity that wraps the given entity from given location with parameterrs identified by tp and given mime type (which is null by default).

This function is provided for convenience and is equivalent to manually filling the Entity.

Parameters
[in]entityThe Entity_ field of the Entity.
[in]locationThe Location_ field of the Entity.
[in]tpThe Params_ field of the Entity.
[in]mimeThe Mime_ field of the Entity.
Returns
The resulting Entity.
See Also
Entity, MakeNotification()

Definition at line 279 of file util.cpp.

References LeechCraft::Entity::Entity_, LeechCraft::Entity::Location_, LeechCraft::Entity::Mime_, and LeechCraft::Entity::Parameters_.

Referenced by GetPersistentData(), MakeNotification(), SavePassword(), and LeechCraft::Util::StdDataFilterMenuCreator::StdDataFilterMenuCreator().

+ Here is the caller graph for this function:

template<typename K , typename V >
QMap<K, V> LeechCraft::Util::MakeMap ( std::initializer_list< QPair< K, V >>  l)

Definition at line 384 of file util.h.

LeechCraft::Entity LeechCraft::Util::MakeNotification ( const QString &  header,
const QString &  text,
Priority  priority 
)

An utility function to make a Entity with notification.

Creates a Entity that holds information about user-visible notification. These notifications have "x-leechcraft/notification" MIME.

You can further customize the returned Entity to suit your exact needs. See the documentation for Entity about such entities.

Parameters
[in]headerThe header of the notification.
[in]textThe text of the notification.
[in]priorityThe priority level of the notification.
Returns
The Entity containing the corresponding notification.
See Also
Entity, MakeEntity()

Definition at line 292 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::AutoAccept, MakeEntity(), and LeechCraft::OnlyHandle.

Referenced by MakeAN(), and MakeANCancel().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QString LeechCraft::Util::MakePrettySize ( qint64  sourcesize)

Makes a formatted size from number.

Converts, for example, 1048576 to 1.0 MB.

Parameters
[in]sourcesizeSize in bytes.
Returns
Formatted string.
See Also
SetStrings
MakeTimeFromLong

Definition at line 99 of file util.cpp.

QString LeechCraft::Util::MakeTimeFromLong ( ulong  time)

Makes a formatted time from number.

Converts, for example 256 to 00:04:16.

Parameters
[in]timeTime interval in seconds.
Returns
DateTime object.
See Also
MakePrettySize

Definition at line 134 of file util.cpp.

LeechCraft::Util::Q_DECLARE_FLAGS ( FitFlags  ,
FitFlag   
)
UTIL_API void LeechCraft::Util::SavePassword ( const QString &  password,
const QString &  keyName,
QObject *  emitter 
)

Saves the password to be retrieved later via GetPassword().

This function stores the password under the given keyName and using the given emitter object. The password is typically stored in a storage plugin like SecMan.

If there are no storage plugins, this function does nothing.

The emitter object is used to send the corresponding internal Entity objects around, so it should have its gotEntity() and delegateEntity() signals both relayed to the corresponding plugin instance object.

Note
Despite the name this function can be used to save arbitrary string data in secure storages like SecMan.
Parameters
[in]passwordThe password string to save.
[in]keyNameThe name of the key uniquely identifying the password.
[in]emitterThe object used to emit the gotEntity() and delegateEntity() signals.
See Also
GetPassword()

Definition at line 93 of file passutils.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::Internal, and MakeEntity().

Referenced by GetPassword().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UTIL_API QLabel * LeechCraft::Util::ShowPixmapLabel ( const QPixmap &  pixmap,
const QPoint &  pos = QPoint() 
)

Shows a pixmap at the given pos.

This function shows a dialog with the given pixmap at the given position. If the pixmap is too big, it is scaled down. A QLabel created with window decorations is used as the dialog. The created label is returned from the function, so one could also set the window title and further customize the label.

This function is useful to display full version of album art in a media player or a user avatar in an IM application.

Parameters
[in]pixmapThe pixmap to show.
[in]posThe position where the dialog should be shown.
Returns
The created dialog.

Definition at line 119 of file util.cpp.