From e2c40d6693d12e34ddfa11791bea3c4a8977c645 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sun, 13 Dec 2015 02:01:06 +0100 Subject: [PATCH] Greentext color is defined in stylesheet, and can be overridden with qss files --- retroshare-gui/src/gui/common/MimeTextEdit.cpp | 1 + retroshare-gui/src/gui/common/MimeTextEdit.h | 9 +++++++++ retroshare-gui/src/gui/common/RSTextBrowser.h | 5 +++++ retroshare-gui/src/gui/qss/stylesheet/qss.default | 5 +++++ retroshare-gui/src/util/RsSyntaxHighlighter.cpp | 8 +++++++- retroshare-gui/src/util/RsSyntaxHighlighter.h | 5 +++++ 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/MimeTextEdit.cpp b/retroshare-gui/src/gui/common/MimeTextEdit.cpp index 78e19cbe1..4d292a87e 100644 --- a/retroshare-gui/src/gui/common/MimeTextEdit.cpp +++ b/retroshare-gui/src/gui/common/MimeTextEdit.cpp @@ -41,6 +41,7 @@ MimeTextEdit::MimeTextEdit(QWidget *parent) mCompleterKeyModifiers = Qt::ControlModifier; mCompleterKey = Qt::Key_Space; mForceCompleterShowNextKeyEvent = false; + highliter = new RsSyntaxHighlighter(this); } bool MimeTextEdit::canInsertFromMimeData(const QMimeData* source) const diff --git a/retroshare-gui/src/gui/common/MimeTextEdit.h b/retroshare-gui/src/gui/common/MimeTextEdit.h index f327e4a6f..de992ecd3 100644 --- a/retroshare-gui/src/gui/common/MimeTextEdit.h +++ b/retroshare-gui/src/gui/common/MimeTextEdit.h @@ -24,11 +24,14 @@ #include #include "RSTextEdit.h" +#include "util/RsSyntaxHighlighter.h" class MimeTextEdit : public RSTextEdit { Q_OBJECT + Q_PROPERTY(QColor textColorQuote READ textColorQuote WRITE setTextColorQuote) + public: MimeTextEdit(QWidget *parent = 0); @@ -44,6 +47,11 @@ public: // Add QAction to context menu (action won't be deleted) void addContextMenuAction(QAction *action); + QColor textColorQuote() const { return highliter->textColorQuote();} + +public slots: + void setTextColorQuote(QColor textColorQuote) { highliter->setTextColorQuote(textColorQuote);} + signals: void calculateContextMenuActions(); @@ -71,6 +79,7 @@ private: bool mForceCompleterShowNextKeyEvent; QString mCompleterStartString; QList mContextMenuActions; + RsSyntaxHighlighter *highliter; }; #endif // MIMETEXTEDIT_H diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.h b/retroshare-gui/src/gui/common/RSTextBrowser.h index 47fbd5d9b..f9e218b77 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.h +++ b/retroshare-gui/src/gui/common/RSTextBrowser.h @@ -10,6 +10,8 @@ class RSTextBrowser : public QTextBrowser { Q_OBJECT + Q_PROPERTY(QColor textColorQuote READ textColorQuote WRITE setTextColorQuote) + public: explicit RSTextBrowser(QWidget *parent = 0); @@ -21,8 +23,11 @@ public: virtual QVariant loadResource(int type, const QUrl &name); + QColor textColorQuote() const { return highliter->textColorQuote();} + public slots: void showImages(); + void setTextColorQuote(QColor textColorQuote) { highliter->setTextColorQuote(textColorQuote);} private slots: void linkClicked(const QUrl &url); diff --git a/retroshare-gui/src/gui/qss/stylesheet/qss.default b/retroshare-gui/src/gui/qss/stylesheet/qss.default index 8d6babc88..32aa7446a 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/qss.default +++ b/retroshare-gui/src/gui/qss/stylesheet/qss.default @@ -188,6 +188,11 @@ NetworkDialog qproperty-backgroundColorDenied: lightGray; } +RSTextBrowser, MimeTextEdit +{ + qproperty-textColorQuote: rgb(120, 153, 34); +} + QLabel#headerTextLabel { qproperty-fontSizeFactor: 225; diff --git a/retroshare-gui/src/util/RsSyntaxHighlighter.cpp b/retroshare-gui/src/util/RsSyntaxHighlighter.cpp index a7c39ae72..ee90d6e52 100644 --- a/retroshare-gui/src/util/RsSyntaxHighlighter.cpp +++ b/retroshare-gui/src/util/RsSyntaxHighlighter.cpp @@ -3,7 +3,7 @@ RsSyntaxHighlighter::RsSyntaxHighlighter(QTextEdit *parent) : QSyntaxHighlighter(parent) { - quotationFormat.setForeground(QColor(120,153,34)); + } void RsSyntaxHighlighter::highlightBlock(const QString &text) @@ -26,6 +26,12 @@ void RsSyntaxHighlighter::highlightBlock(const QString &text) } } +void RsSyntaxHighlighter::setTextColorQuote(QColor textColorQuote) +{ + quotationFormat.setForeground(textColorQuote); + this->rehighlight(); +} + //Dumping the raw unicode string into the console in Base64 encoding /* QByteArray uniline; diff --git a/retroshare-gui/src/util/RsSyntaxHighlighter.h b/retroshare-gui/src/util/RsSyntaxHighlighter.h index c17544ecd..3719f3222 100644 --- a/retroshare-gui/src/util/RsSyntaxHighlighter.h +++ b/retroshare-gui/src/util/RsSyntaxHighlighter.h @@ -9,8 +9,11 @@ class RsSyntaxHighlighter : public QSyntaxHighlighter { Q_OBJECT + Q_PROPERTY(QColor textColorQuote READ textColorQuote WRITE setTextColorQuote) + public: RsSyntaxHighlighter(QTextEdit *parent = 0); + QColor textColorQuote() const { return quotationFormat.foreground().color(); }; protected: void highlightBlock(const QString &text); @@ -21,6 +24,8 @@ private: signals: public slots: + void setTextColorQuote(QColor textColorQuote); + }; #endif // RSSYNTAXHIGHLIGHTER_H