summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-06 05:07:56 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-06 05:07:56 (GMT)
commit088aee386e31a154a2d894c797afe21b35d4d6d9 (patch)
tree708a0d9809bd4207a14c53ba697c9ddfa3c999d0
parent1462002520f7297a634ae9894ce6465d992a55eb (diff)
Minor optimization
-rw-r--r--src/autocorrection/autocorrection.cpp13
-rw-r--r--src/autocorrection/autocorrection.h2
2 files changed, 13 insertions, 2 deletions
diff --git a/src/autocorrection/autocorrection.cpp b/src/autocorrection/autocorrection.cpp
index 41be4bb..62a8b02 100644
--- a/src/autocorrection/autocorrection.cpp
+++ b/src/autocorrection/autocorrection.cpp
@@ -554,6 +554,15 @@ bool AutoCorrection::autoBoldUnderline()
return true;
}
+QColor AutoCorrection::linkColor()
+{
+ if (mLinkColor.isValid()) {
+ return mLinkColor;
+ }
+ mLinkColor = KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color();
+ return mLinkColor;
+}
+
bool AutoCorrection::autoFormatURLs()
{
if (!mAutoFormatUrl) {
@@ -575,8 +584,8 @@ bool AutoCorrection::autoFormatURLs()
format.setFontItalic(true);
format.setAnchor(true);
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());
mCursor.mergeCharFormat(format);
mWord = mCursor.selectedText();
diff --git a/src/autocorrection/autocorrection.h b/src/autocorrection/autocorrection.h
index 10369ed..63d9230 100644
--- a/src/autocorrection/autocorrection.h
+++ b/src/autocorrection/autocorrection.h
@@ -113,6 +113,7 @@ private:
QString autoDetectURL(const QString &_word) const;
void readAutoCorrectionXmlFile(bool forceGlobal = false);
bool excludeToUppercase(const QString &word) const;
+ QColor linkColor();
bool mSingleSpaces; // suppress double spaces.
bool mUppercaseFirstCharOfSentence; // convert first letter of a sentence automaticall to uppercase
@@ -144,6 +145,7 @@ private:
QHash<QString, QString> mSuperScriptEntries;
TypographicQuotes mTypographicSingleQuotes;
TypographicQuotes mTypographicDoubleQuotes;
+ QColor mLinkColor;
};
}