KDE 4.9 PyKDE API Reference

- KDE's Python API

# KEmoticonsTheme Class Reference

`from PyKDE4.kutils import *`

## Detailed Description

This class contains the emoticons theme

## Enumerations

ParseModeEnum | { DefaultParse, StrictParse, RelaxedParse, SkipHTML }
TokenType | { Undefined, Image, Text }

## Methods

| __init__ (self)
| __init__ (self, KEmoticonsTheme ket)
| __init__ (self, KEmoticonsProvider p)
bool | addEmoticon (self, QString emo, QString text, KEmoticonsProvider.AddEmoticonOption option=KEmoticonsProvider.DoNotCopy)
| createNew (self)
{QString:QStringList} | emoticonsMap (self)
QString | fileName (self)
bool | isNull (self)
bool | loadTheme (self, QString path)
QString | parseEmoticons (self, QString text, KEmoticonsTheme.ParseMode mode=KEmoticonsTheme.DefaultParse, QStringList exclude=QStringList())
bool | removeEmoticon (self, QString emo)
| save (self)
| setThemeName (self, QString name)
QString | themeName (self)
QString | themePath (self)
[KEmoticonsTheme.Token] | tokenize (self, QString message, KEmoticonsTheme.ParseMode mode=KEmoticonsTheme.DefaultParse)

## Method Documentation

__init__ | ( |  | self ) |

Default constructor, it creates a null emoticons theme you should probably never use this, instead use KEmoticons.theme()

__init__ | ( | self, |
|  | KEmoticonsTheme | ket
| ) |  |  |

Copy constructor

__init__ | ( | self, |
|  | KEmoticonsProvider | p
| ) |  |  |

Another constructor where you set the KEmoticonsProvider p you should probably never use this, instead use KEmoticons.theme()

bool addEmoticon | ( | self, |
|  | QString | emo,
|  | QString | text,
|  | KEmoticonsProvider.AddEmoticonOption | option=KEmoticonsProvider.DoNotCopy
| ) |  |  |

Add the emoticon emo with text text

     KEmoticonsTheme theme = KEmoticons().theme();
     theme.addEmoticon("/path/to/smiley.png", ":) :-)");

Parameters:

  | emo | path to the emoticon image
  | text | the text of the emoticon separated by space for multiple text
  | copy | whether or not copy emo into the theme directory

Returns:
  true if it can add the emoticon

createNew | ( |  | self ) |

Create a new theme

{QString:QStringList} emoticonsMap | ( |  | self ) |

Returns a QHash that contains the emoticons path as keys and the text as values

QString fileName | ( |  | self ) |

Returns the file name of the theme

bool isNull | ( |  | self ) |

Check if the theme has a valid provider and it returns true if it can't find it

bool loadTheme | ( | self, |
|  | QString | path
| ) |  |  |

Load the theme inside the directory path

Parameters:

  | path | path to the directory

QString parseEmoticons | ( | self, |
|  | QString | text,
|  | KEmoticonsTheme.ParseMode | mode=KEmoticonsTheme.DefaultParse,
|  | QStringList | exclude=QStringList()
| ) |  |  |

Parse emoticons in text text with ParseMode mode and optionally excluding emoticons from exclude

     KEmoticonsTheme theme = KEmoticons().theme();
     QString text = ":D hi :)";
     QStringList exclude(":)");
     QString parsed = theme.parseEmoticons(text, KEmoticonsTheme.DefaultParse, exclude);
     // parsed will be "<img align="center" title=":D" alt=":D" src="/path/to/:D.png" width="24" height="24" /> hi :)"

Parameters:

  | text | the text to parse
  | mode | how to parse the text
  | exclude | a list of emoticons to exclude from the parsing

Returns:
  the text with emoticons replaced by html images

Note:
  SkipHTML is forced when using this function

bool removeEmoticon | ( | self, |
|  | QString | emo
| ) |  |  |

Remove the emoticon emo, this will not delete the image file too

     KEmoticonsTheme theme = KEmoticons().theme();
     theme.removeEmoticon(":)");

Parameters:

  | emo | the emoticon text to remove

Returns:
  true if it can delete the emoticon

save | ( |  | self ) |

Save the emoticon theme

setThemeName | ( | self, |
|  | QString | name
| ) |  |  |

Set the theme name

Parameters:

  | name | name of the theme

QString themeName | ( |  | self ) |

Returns the theme name

QString themePath | ( |  | self ) |

Returns the theme path

[KEmoticonsTheme.Token] tokenize | ( | self, |
|  | QString | message,
|  | KEmoticonsTheme.ParseMode | mode=KEmoticonsTheme.DefaultParse
| ) |  |  |

Tokenize the message message with ParseMode mode

     KEmoticonsTheme theme = KEmoticons().theme();
     QString text = "hi :)";
     QList<Token> tokens = theme.tokenize(text, KEmoticonsTheme.DefaultParse);
     // tokens[0].text = "hi "
     // tokens[1].text = ":)"
     // tokens[1].picPath = "/path/to/:).png"
     // tokens[1].picHTMLCode = "<img align="center" title=":)" alt=":)" src="/path/to/:).png" width="24" height="24" />"

## Enumeration Documentation

ParseModeEnum

The possible parse modes

Enumerator:

  DefaultParse = 0x0 |
  StrictParse = 0x1 |
  RelaxedParse = 0x2 |
  SkipHTML = 0x4 |

TokenType

TokenType, a token might be an image ( emoticon ) or text.

Enumerator:

  Undefined |
  Image |
  Text |