Commit 07ed743c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make sure to update link color when theme changed

parent b53b906f
Pipeline #160297 passed with stages
in 8 minutes and 2 seconds
......@@ -48,12 +48,18 @@ public:
delete nestedListHelper;
}
void regenerateColorScheme()
{
mLinkColor = KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color();
// TODO update existing link
}
QColor linkColor()
{
if (mLinkColor.isValid()) {
return mLinkColor;
}
mLinkColor = KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::LinkText).color();
regenerateColorScheme();
return mLinkColor;
}
......@@ -136,10 +142,18 @@ RichTextComposerControler::RichTextComposerControler(RichTextComposer *richtextC
: QObject(parent)
, d(new RichTextComposerControlerPrivate(richtextComposer, this))
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
connect(qApp, &QApplication::paletteChanged, this, &RichTextComposerControler::regenerateColorScheme);
#endif
}
RichTextComposerControler::~RichTextComposerControler() = default;
void RichTextComposerControler::regenerateColorScheme()
{
d->regenerateColorScheme();
}
bool RichTextComposerControler::painterActive() const
{
return d->painterActive;
......@@ -937,3 +951,14 @@ QString RichTextComposerControler::toWrappedPlainText(QTextDocument *doc) const
d->fixupTextEditString(temp);
return temp;
}
bool RichTextComposerControler::event(QEvent *ev)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (ev->type() == QEvent::ApplicationPaletteChange) {
regenerateColorScheme();
}
#endif
return QObject::event(ev);
}
......@@ -93,7 +93,11 @@ public Q_SLOTS:
void slotFormatPainter(bool active);
void ensureCursorVisibleDelayed();
protected:
bool event(QEvent *ev) override;
private:
void regenerateColorScheme();
class RichTextComposerControlerPrivate;
std::unique_ptr<RichTextComposerControlerPrivate> const d;
};
......
......@@ -738,6 +738,11 @@ bool RichTextEditor::event(QEvent *ev)
return true;
}
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
else if (ev->type() == QEvent::ApplicationPaletteChange) {
regenerateColorScheme();
}
#endif
return QTextEdit::event(ev);
}
......@@ -753,11 +758,6 @@ void RichTextEditor::wheelEvent(QWheelEvent *event)
event->accept();
return;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
else if (event->type() == QEvent::ApplicationPaletteChange) {
regenerateColorScheme();
}
#endif
QTextEdit::wheelEvent(event);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment