KIdentityManagementCore::Signature
#include <signature.h>
Public Types | |
using | AddedText = QFlags<AddedTextFlag> |
enum | AddedTextFlag { AddNothing = 0 , AddSeparator = 1 << 0 , AddNewLines = 1 << 1 } |
using | EmbeddedImagePtr = QSharedPointer<EmbeddedImage> |
enum | Placement { Start , End , AtCursor } |
enum | Type { Disabled = 0 , Inlined = 1 , FromFile = 2 , FromCommand = 3 } |
Public Member Functions | |
Signature () | |
Signature (const QString &path, bool isExecutable) | |
Signature (const QString &text) | |
Signature (const Signature &that) | |
~Signature () | |
void | addImage (const QImage &image, const QString &imageName) |
QList< Signature::EmbeddedImagePtr > | embeddedImages () const |
QString | imageLocation () const |
bool | isEnabledSignature () const |
bool | isInlinedHtml () const |
Signature & | operator= (const Signature &that) |
bool | operator== (const Signature &other) const |
QString | path () const |
QString | rawText (bool *ok=nullptr, QString *errorMessage=nullptr) const |
void | setEmbeddedImages (const QList< EmbeddedImagePtr > &embedded) |
void | setEnabledSignature (bool enabled) |
void | setImageLocation (const QString &path) |
void | setInlinedHtml (bool isHtml) |
void | setPath (const QString &path, bool isExecutable=false) |
void | setText (const QString &text) |
void | setType (Type type) |
QString | text () const |
QString | toPlainText () const |
Type | type () const |
QString | withSeparator (bool *ok=nullptr, QString *errorMessage=nullptr) const |
Protected Member Functions | |
void | readConfig (const KConfigGroup &config) |
void | writeConfig (KConfigGroup &config) const |
Detailed Description
Abstraction of a signature (aka "footer").
The signature can either be plain text, HTML text, text returned from a command or text stored in a file.
In case of HTML text, the signature can contain images. Since you set the HTML source with setText(), there also needs to be a way to add the images to the signature, as the HTML source contains only the img tags that reference those images. To add the image to the signature, call addImage(). The name given there must match the name of the img tag in the HTML source.
The images need to be stored somewhere. The Signature class handles that by storing all images in a directory. You must set that directory with setImageLocation(), before calling addImage(). The images added with addImage() are then saved to that directory when calling writeConfig(). When loading a signature, readConfig() automatically loads the images as well. To actually add the images to a text edit, call insertIntoTextEdit().
Example of creating a HTML signature and then inserting it into a text edit:
Definition at line 60 of file signature.h.
Member Typedef Documentation
◆ AddedText
Describes which additional parts should be added to the signature.
Definition at line 203 of file signature.h.
◆ EmbeddedImagePtr
using KIdentityManagementCore::Signature::EmbeddedImagePtr = QSharedPointer<EmbeddedImage> |
Definition at line 90 of file signature.h.
Member Enumeration Documentation
◆ AddedTextFlag
Definition at line 194 of file signature.h.
◆ Placement
Describes the placement of the signature text when it is to be inserted into a text edit.
Enumerator | |
---|---|
Start | The signature is placed at the start of the textedit. |
End | The signature is placed at the end of the textedit. |
AtCursor | The signature is placed at the current cursor position. |
Definition at line 80 of file signature.h.
◆ Type
Constructor & Destructor Documentation
◆ Signature() [1/4]
Signature::Signature | ( | ) |
Constructor for disabled signature.
Definition at line 200 of file signature.cpp.
◆ Signature() [2/4]
Signature::Signature | ( | const QString & | text | ) |
Constructor for inline text.
Definition at line 207 of file signature.cpp.
◆ Signature() [3/4]
Signature::Signature | ( | const QString & | path, |
bool | isExecutable ) |
Constructor for text from a file or from output of a command.
Definition at line 215 of file signature.cpp.
◆ Signature() [4/4]
Signature::Signature | ( | const Signature & | that | ) |
Copy constructor.
Definition at line 222 of file signature.cpp.
◆ ~Signature()
|
default |
Destructor.
Member Function Documentation
◆ addImage()
Adds the given image to the signature.
This is needed if you use setText() to set some HTML source that references images. Those referenced images needed to be added by calling this function. The @imageName has to match the src attribute of the img tag.
If you use SignatureConfigurator, you don't need to call this function, as the configurator will handle this for you. setImageLocation() needs to be called once before.
- Since
- 4.4
Definition at line 461 of file signature.cpp.
◆ embeddedImages()
|
nodiscard |
Definition at line 381 of file signature.cpp.
◆ imageLocation()
|
nodiscard |
Definition at line 475 of file signature.cpp.
◆ isEnabledSignature()
|
nodiscard |
Definition at line 515 of file signature.cpp.
◆ isInlinedHtml()
|
nodiscard |
- Returns
- boolean whether the inlined signature is html
- Since
- 4.1
Definition at line 299 of file signature.cpp.
◆ operator=()
Assignment operator.
Definition at line 228 of file signature.cpp.
◆ operator==()
bool Signature::operator== | ( | const Signature & | other | ) | const |
Used for comparison.
Definition at line 416 of file signature.cpp.
◆ path()
|
nodiscard |
Definition at line 487 of file signature.cpp.
◆ rawText()
|
nodiscard |
- Returns
- the raw signature text as entered resp. read from file.
- Parameters
-
ok set to true
if reading succeedederrorMessage If available, contains a human readable explanation for ok
beingfalse
.
Definition at line 240 of file signature.cpp.
◆ readConfig()
|
protected |
Definition at line 317 of file signature.cpp.
◆ setEmbeddedImages()
void Signature::setEmbeddedImages | ( | const QList< EmbeddedImagePtr > & | embedded | ) |
Definition at line 386 of file signature.cpp.
◆ setEnabledSignature()
void Signature::setEnabledSignature | ( | bool | enabled | ) |
setEnabledSignature
- Parameters
-
enabled enables signature if set as true
- Since
- 4.9
Definition at line 510 of file signature.cpp.
◆ setImageLocation()
void Signature::setImageLocation | ( | const QString & | path | ) |
Sets the location where the copies of the signature images will be stored.
The images will be stored there when calling writeConfig(). The image location is stored in the config, so the next readConfig() call knows where to look for images. It is recommended to use KStandardDirs::locateLocal( "data", "emailidentities/%1" ) for the location, where %1 is the unique identifier of the identity.
- Warning
- readConfig will delete all other PNG files in this directory, as they could be stale inline image files
Like with addImage(), the SignatureConfigurator will handle this for you.
- Parameters
-
path the path to set as image location
- Since
- 4.4
Definition at line 470 of file signature.cpp.
◆ setInlinedHtml()
void Signature::setInlinedHtml | ( | bool | isHtml | ) |
Sets the inlined signature to text or html.
- Parameters
-
isHtml sets the inlined signature to html
- Since
- 4.1
Definition at line 294 of file signature.cpp.
◆ setPath()
void Signature::setPath | ( | const QString & | path, |
bool | isExecutable = false ) |
Set the signature URL and mark this signature as being of "from file" resp.
"from output of command" type.
Definition at line 288 of file signature.cpp.
◆ setText()
void Signature::setText | ( | const QString & | text | ) |
Set the signature text and mark this signature as being of "inline text" type.
Definition at line 499 of file signature.cpp.
◆ setType()
void Signature::setType | ( | Type | type | ) |
Definition at line 505 of file signature.cpp.
◆ text()
|
nodiscard |
Definition at line 482 of file signature.cpp.
◆ toPlainText()
|
nodiscard |
Returns the text of the signature.
If the signature is HTML, the HTML tags will be stripped.
- Since
- 4.4
Definition at line 447 of file signature.cpp.
◆ type()
|
nodiscard |
- Returns
- the type of signature (ie. way to obtain the signature text)
Definition at line 492 of file signature.cpp.
◆ withSeparator()
|
nodiscard |
- Returns
- the signature text with a "-- \n" separator added, if necessary. A newline will not be appended or prepended.
- Parameters
-
ok set to true
if reading succeedederrorMessage If available, contains a human readable explanation for ok
beingfalse
.
Definition at line 262 of file signature.cpp.
◆ writeConfig()
|
protected |
Definition at line 355 of file signature.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.