Fixed to update the changed color

This commit is contained in:
defnax 2025-07-03 22:22:46 +02:00
parent cbec62ccc7
commit 02f2f4e075
2 changed files with 19 additions and 3 deletions

View file

@ -51,9 +51,7 @@ RSTextBrowser::RSTextBrowser(QWidget *parent) :
highlighter = new RsSyntaxHighlighter(this);
linkColor = Settings->getLinkColor();
QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());
document()->setDefaultStyleSheet(sheet);
updateLinkColor();
connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
}
@ -364,3 +362,18 @@ void RSTextBrowser::copyImage()
QTextCursor cursor = cursorForPosition(point);
ImageUtil::copyImage(window(), cursor);
}
void RSTextBrowser::showEvent(QShowEvent *event)
{
if (!event->spontaneous()) {
updateLinkColor();
}
}
void RSTextBrowser::updateLinkColor()
{
linkColor = Settings->getLinkColor();
QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());
document()->setDefaultStyleSheet(sheet);
}

View file

@ -60,6 +60,8 @@ public:
QMenu *createStandardContextMenuFromPoint(const QPoint &widgetPos);
virtual void showEvent(QShowEvent *) ;
Q_SIGNALS:
void calculateContextMenuActions();
@ -74,6 +76,7 @@ private slots:
void viewSource();
void saveImage();
void copyImage();
void updateLinkColor();
protected:
void paintEvent(QPaintEvent *event);