summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-06 04:59:22 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-06 04:59:22 (GMT)
commit918141c9766e23ef13c0164352352f50a2cd419a (patch)
tree6566ec9550345444603333fc4cdb0d9fb6da5813
parent7e02020b8c10ebfff617a0c332da033dc9a0cfb3 (diff)
Minor optimization to get linkcolor
-rw-r--r--src/composer-ng/richtextcomposercontroler.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/composer-ng/richtextcomposercontroler.cpp b/src/composer-ng/richtextcomposercontroler.cpp
index 9d4e9a2..98dadfa 100644
--- a/src/composer-ng/richtextcomposercontroler.cpp
+++ b/src/composer-ng/richtextcomposercontroler.cpp
@@ -57,12 +57,21 @@ public:
{
delete nestedListHelper;
}
+ QColor linkColor()
+ {
+ if (mLinkColor.isValid()) {
+ return mLinkColor;
+ }
+ mLinkColor = KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color();
+ return mLinkColor;
+ }
void selectLinkText(QTextCursor *cursor) const;
void fixupTextEditString(QString &text) const;
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
QString addQuotesToText(const QString &inputText);
void updateLink(const QString &linkUrl, const QString &linkText);
QFont saveFont;
+ QColor mLinkColor;
QTextCharFormat painterFormat;
bool painterActive;
NestedListHelper *nestedListHelper;
@@ -444,8 +453,8 @@ void RichTextComposerControler::RichTextComposerControlerPrivate::updateLink(con
// Link formatting does not get applied immediately when setAnchor(true)
// is called. So the formatting needs to be applied manually.
format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
- format.setUnderlineColor(KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color());
- format.setForeground(KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color());
+ format.setUnderlineColor(linkColor());
+ format.setForeground(linkColor());
richtextComposer->activateRichText();
} else {
// Remove link details
@@ -585,8 +594,8 @@ void RichTextComposerControler::insertLink(const QString &url)
// Link formatting does not get applied immediately when setAnchor(true)
// is called. So the formatting needs to be applied manually.
format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
- format.setUnderlineColor(KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color());
- format.setForeground(KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color());
+ format.setUnderlineColor(d->linkColor());
+ format.setForeground(d->linkColor());
// Insert link text specified in dialog, otherwise write out url.
cursor.insertText(url, format);
@@ -622,8 +631,8 @@ void RichTextComposerControler::insertShareLink(const QString &url)
// Link formatting does not get applied immediately when setAnchor(true)
// is called. So the formatting needs to be applied manually.
format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
- format.setUnderlineColor(KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color());
- format.setForeground(KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color());
+ format.setUnderlineColor(d->linkColor());
+ format.setForeground(d->linkColor());
// Insert link text specified in dialog, otherwise write out url.
cursor.insertText(url, format);