qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
Public Member Functions | Static Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
SmileyPack Class Reference

Maps emoticons to smileys. More...

#include <smileypack.h>

Inheritance diagram for SmileyPack:
Inheritance graph
Collaboration diagram for SmileyPack:
Collaboration graph

Public Member Functions

QString smileyfied (const QString &msg)
 Replaces all found text emoticons to HTML reference with its according icon filename. More...
 
QList< QStringList > getEmoticons () const
 Returns all emoticons that was extracted from files, grouped by according icon file. More...
 
std::shared_ptr< QIcon > getAsIcon (const QString &key) const
 Gets icon accoring to passed emoticon. More...
 

Static Public Member Functions

static SmileyPackgetInstance ()
 Returns the singleton instance. More...
 
static QList< QPair< QString, QString > > listSmileyPacks (const QStringList &paths)
 Searches all files called "emoticons.xml" within the every passed path in the depth of 2. More...
 
static QList< QPair< QString, QString > > listSmileyPacks ()
 Does the same as listSmileyPaths, but with default paths. More...
 

Private Slots

void onSmileyPackChanged ()
 
void cleanupIconsCache ()
 

Private Member Functions

 SmileyPack ()
 
 SmileyPack (SmileyPack &)=delete
 
SmileyPackoperator= (const SmileyPack &)=delete
 
 ~SmileyPack () override
 
bool load (const QString &filename)
 Load smile pack. More...
 
void constructRegex ()
 Creates the regex for replacing emoticons with the path to their pictures. More...
 

Private Attributes

std::map< QString, std::shared_ptr< QIcon > > cachedIcon
 
QHash< QString, QString > emoticonToPath
 
QList< QStringList > emoticons
 {{ ":)", ":-)" }, {":(", ...}, ... } More...
 
QString path
 directory containing the cfg and image files More...
 
QTimer * cleanupTimer
 
QRegularExpression smilify
 
QMutex loadingMutex
 

Detailed Description

Maps emoticons to smileys.

Definition at line 31 of file smileypack.h.

Constructor & Destructor Documentation

◆ SmileyPack() [1/2]

SmileyPack::SmileyPack ( )
private

Definition at line 115 of file smileypack.cpp.

◆ SmileyPack() [2/2]

SmileyPack::SmileyPack ( SmileyPack )
privatedelete

◆ ~SmileyPack()

SmileyPack::~SmileyPack ( )
overrideprivate

Definition at line 126 of file smileypack.cpp.

Member Function Documentation

◆ cleanupIconsCache

void SmileyPack::cleanupIconsCache ( )
privateslot

Definition at line 131 of file smileypack.cpp.

◆ constructRegex()

void SmileyPack::constructRegex ( )
private

Creates the regex for replacing emoticons with the path to their pictures.

Definition at line 264 of file smileypack.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAsIcon()

std::shared_ptr< QIcon > SmileyPack::getAsIcon ( const QString &  emoticon) const

Gets icon accoring to passed emoticon.

Parameters
emoticonPassed emoticon
Returns
Returns cached icon according to passed emoticon, null if no icon mapped to this emoticon

Definition at line 336 of file smileypack.cpp.

Here is the caller graph for this function:

◆ getEmoticons()

QList< QStringList > SmileyPack::getEmoticons ( ) const

Returns all emoticons that was extracted from files, grouped by according icon file.

Definition at line 325 of file smileypack.cpp.

Here is the caller graph for this function:

◆ getInstance()

SmileyPack & SmileyPack::getInstance ( )
static

Returns the singleton instance.

Definition at line 147 of file smileypack.cpp.

Here is the caller graph for this function:

◆ listSmileyPacks() [1/2]

QList< QPair< QString, QString > > SmileyPack::listSmileyPacks ( )
static

Does the same as listSmileyPaths, but with default paths.

Definition at line 156 of file smileypack.cpp.

Here is the caller graph for this function:

◆ listSmileyPacks() [2/2]

QList< QPair< QString, QString > > SmileyPack::listSmileyPacks ( const QStringList &  paths)
static

Searches all files called "emoticons.xml" within the every passed path in the depth of 2.

Parameters
pathsPaths where to search for file
Returns
Vector of pairs: {directoryName, absolutePathToFile}

Definition at line 166 of file smileypack.cpp.

◆ load()

bool SmileyPack::load ( const QString &  filename)
private

Load smile pack.

Note
The caller must lock loadingMutex and should run it in a thread
Parameters
filenameFilename of smilepack.
Returns
False if cannot open file, true otherwise.

Definition at line 203 of file smileypack.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onSmileyPackChanged

void SmileyPack::onSmileyPackChanged ( )
privateslot

Definition at line 354 of file smileypack.cpp.

Here is the call graph for this function:

◆ operator=()

SmileyPack& SmileyPack::operator= ( const SmileyPack )
privatedelete

◆ smileyfied()

QString SmileyPack::smileyfied ( const QString &  msg)

Replaces all found text emoticons to HTML reference with its according icon filename.

Parameters
msgMessage where to search for emoticons
Returns
Formatted copy of message

Definition at line 303 of file smileypack.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ cachedIcon

std::map<QString, std::shared_ptr<QIcon> > SmileyPack::cachedIcon
mutableprivate

Definition at line 57 of file smileypack.h.

◆ cleanupTimer

QTimer* SmileyPack::cleanupTimer
private

Definition at line 61 of file smileypack.h.

◆ emoticons

SmileyPack::emoticons
private

{{ ":)", ":-)" }, {":(", ...}, ... }

Definition at line 59 of file smileypack.h.

◆ emoticonToPath

QHash<QString, QString> SmileyPack::emoticonToPath
private

Definition at line 58 of file smileypack.h.

◆ loadingMutex

QMutex SmileyPack::loadingMutex
mutableprivate

Definition at line 63 of file smileypack.h.

◆ path

SmileyPack::path
private

directory containing the cfg and image files

Definition at line 60 of file smileypack.h.

◆ smilify

QRegularExpression SmileyPack::smilify
private

Definition at line 62 of file smileypack.h.


The documentation for this class was generated from the following files: