This commit is contained in:
defnax 2025-12-08 12:51:32 +01:00 committed by GitHub
commit 2afc1de9db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 264 additions and 96 deletions

View file

@ -34,6 +34,7 @@
#include "util/qtthreadsutils.h" #include "util/qtthreadsutils.h"
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "gui/Identity/IdDialog.h" #include "gui/Identity/IdDialog.h"
#include "gui/settings/rsharesettings.h"
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
#include "util/DateTime.h" #include "util/DateTime.h"
@ -234,8 +235,10 @@ void BoardPostDisplayWidgetBase::baseSetup()
if (urlOkay) if (urlOkay)
{ {
QString siteurl = url.toEncoded(); QString siteurl = url.toEncoded();
linkColor = Settings->getLinkColor();
label->setStyleSheet("text-decoration: underline; color:#2255AA;"); QString colorstring = QString("%1;").arg(linkColor.name());
label->setStyleSheet("text-decoration: underline; color:" + colorstring );
label->setCursor(QCursor(Qt::PointingHandCursor)); label->setCursor(QCursor(Qt::PointingHandCursor));
label->setToolTip(siteurl); label->setToolTip(siteurl);

View file

@ -107,6 +107,8 @@ signals:
protected: protected:
RsPostedPost mPost; RsPostedPost mPost;
uint8_t mDisplayFlags; uint8_t mDisplayFlags;
private:
QColor linkColor;
}; };
class BoardPostDisplayWidget_compact : public BoardPostDisplayWidgetBase class BoardPostDisplayWidget_compact : public BoardPostDisplayWidgetBase
@ -146,6 +148,8 @@ protected:
void setup() override; // to be overloaded by the different views void setup() override; // to be overloaded by the different views
private: private:
QColor linkColor;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::BoardPostDisplayWidget_compact *ui; Ui::BoardPostDisplayWidget_compact *ui;
}; };

View file

@ -228,9 +228,14 @@ void PostedCardView::fill()
if (urlOkay) if (urlOkay)
{ {
linkColor = Settings->getLinkColor();
QString colorstring = QString("%1;").arg(linkColor.name());
QString urlstr = QString("<a href=\""); QString urlstr = QString("<a href=\"");
urlstr += QString(url.toEncoded()); urlstr += QString(url.toEncoded());
urlstr += QString("\" ><span style=\" text-decoration: underline; color:#2255AA;\"> "); urlstr += QString("\" ><span style=\" text-decoration: underline; color:");
urlstr += colorstring;
urlstr += QString("\"> ");
urlstr += messageName(); urlstr += messageName();
urlstr += QString(" </span></a>"); urlstr += QString(" </span></a>");

View file

@ -57,6 +57,8 @@ protected:
void toggleNotes() override; void toggleNotes() override;
private: private:
QColor linkColor;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::PostedCardView *ui; Ui::PostedCardView *ui;
}; };

View file

@ -911,7 +911,7 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group)
ui->infoAdministrator->setId(group.mMeta.mAuthorId) ; ui->infoAdministrator->setId(group.mMeta.mAuthorId) ;
link = RetroShareLink::createMessage(group.mMeta.mAuthorId, ""); link = RetroShareLink::createMessage(group.mMeta.mAuthorId, "");
ui->infoAdministrator->setText(link.toHtml()); ui->infoAdministrator->setText(link.toHtmlColored());
ui->createdinfolabel->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs)); ui->createdinfolabel->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs));

View file

@ -36,6 +36,7 @@
#include "msgs/MessageComposer.h" #include "msgs/MessageComposer.h"
#include "Posted/PostedDialog.h" #include "Posted/PostedDialog.h"
#include "util/misc.h" #include "util/misc.h"
#include "gui/settings/rsharesettings.h"
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
#include <retroshare/rsgxsforums.h> #include <retroshare/rsgxsforums.h>
@ -430,6 +431,7 @@ void RetroShareLink::fromUrl(const QUrl& url)
RetroShareLink::RetroShareLink() RetroShareLink::RetroShareLink()
{ {
clear(); clear();
linkColor = Settings->getLinkColor();
} }
RetroShareLink RetroShareLink::createFile(const QString& name, uint64_t size, const QString& hash) RetroShareLink RetroShareLink::createFile(const QString& name, uint64_t size, const QString& hash)
@ -1131,6 +1133,22 @@ QString RetroShareLink::toHtml() const
return html; return html;
} }
QString RetroShareLink::toHtmlColored() const
{
//linkColor = Settings->getLinkColor();
QString colorstring = QString("%1;").arg(linkColor.name());
QString html = "<a href=\"" + toString() + "\"";
QString linkTitle = title();
if (!linkTitle.isEmpty()) {
html += " title=\"" + linkTitle + "\"";
}
html += "style=\"color:" + colorstring + "\"> " + niceName() + "</a>" ;
return html;
}
QString RetroShareLink::toHtmlFull() const QString RetroShareLink::toHtmlFull() const
{ {
return QString("<a href=\"") + toString() + "\">" + toString() + "</a>" ; return QString("<a href=\"") + toString() + "\">" + toString() + "</a>" ;

View file

@ -41,6 +41,7 @@
#include <QString> #include <QString>
#include <QUrl> #include <QUrl>
#include <QVector> #include <QVector>
#include <QColor>
#include <stdint.h> #include <stdint.h>
@ -138,6 +139,8 @@ class RetroShareLink
QString toHtmlSize() const ; QString toHtmlSize() const ;
QString toHtmlColored() const;
QUrl toUrl() const ; QUrl toUrl() const ;
bool operator==(const RetroShareLink& l) const { return _type == l._type && _hash == l._hash ; } bool operator==(const RetroShareLink& l) const { return _type == l._type && _hash == l._hash ; }
@ -176,6 +179,7 @@ class RetroShareLink
time_t _time_stamp ; // time stamp at which the link will expire. time_t _time_stamp ; // time stamp at which the link will expire.
QString _radix_group_data; QString _radix_group_data;
uint32_t _count ; uint32_t _count ;
QColor linkColor;
unsigned int _subType; // for general use as sub type for _type (RSLINK_SUBTYPE_...) unsigned int _subType; // for general use as sub type for _type (RSLINK_SUBTYPE_...)
}; };

View file

@ -33,6 +33,7 @@
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "util/imageutil.h" #include "util/imageutil.h"
#include "gui/settings/rsharesettings.h"
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
@ -44,6 +45,10 @@ MimeTextEdit::MimeTextEdit(QWidget *parent)
mForceCompleterShowNextKeyEvent = false; mForceCompleterShowNextKeyEvent = false;
highliter = new RsSyntaxHighlighter(this); highliter = new RsSyntaxHighlighter(this);
mOnlyPlainText = false; mOnlyPlainText = false;
linkColor = Settings->getLinkColor();
QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());
document()->setDefaultStyleSheet(sheet);
} }
bool MimeTextEdit::canInsertFromMimeData(const QMimeData* source) const bool MimeTextEdit::canInsertFromMimeData(const QMimeData* source) const

View file

@ -91,6 +91,7 @@ private:
RsSyntaxHighlighter *highliter; RsSyntaxHighlighter *highliter;
bool mOnlyPlainText; bool mOnlyPlainText;
int mMaxBytes = -1; //limit content size, for pasting images int mMaxBytes = -1; //limit content size, for pasting images
QColor linkColor;
}; };
#endif // MIMETEXTEDIT_H #endif // MIMETEXTEDIT_H

View file

@ -23,6 +23,7 @@
#include "RSImageBlockWidget.h" #include "RSImageBlockWidget.h"
#include "gui/common/FilesDefs.h" #include "gui/common/FilesDefs.h"
#include "util/imageutil.h" #include "util/imageutil.h"
#include "gui/settings/rsharesettings.h"
#include <retroshare/rsinit.h> //To get RsAccounts #include <retroshare/rsinit.h> //To get RsAccounts
@ -51,6 +52,8 @@ RSTextBrowser::RSTextBrowser(QWidget *parent) :
highlighter = new RsSyntaxHighlighter(this); highlighter = new RsSyntaxHighlighter(this);
updateLinkColor();
connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl))); connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
} }
@ -360,3 +363,18 @@ void RSTextBrowser::copyImage()
QTextCursor cursor = cursorForPosition(point); QTextCursor cursor = cursorForPosition(point);
ImageUtil::copyImage(window(), cursor); 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); QMenu *createStandardContextMenuFromPoint(const QPoint &widgetPos);
virtual void showEvent(QShowEvent *) ;
Q_SIGNALS: Q_SIGNALS:
void calculateContextMenuActions(); void calculateContextMenuActions();
@ -74,6 +76,7 @@ private slots:
void viewSource(); void viewSource();
void saveImage(); void saveImage();
void copyImage(); void copyImage();
void updateLinkColor();
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
@ -89,6 +92,8 @@ private:
RSImageBlockWidget *mImageBlockWidget; RSImageBlockWidget *mImageBlockWidget;
bool mLinkClickActive; bool mLinkClickActive;
RsSyntaxHighlighter *highlighter; RsSyntaxHighlighter *highlighter;
QColor linkColor;
QList<QAction*> mContextMenuActions; QList<QAction*> mContextMenuActions;
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG #ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
QRect mCursorRectStart; QRect mCursorRectStart;

View file

@ -1330,7 +1330,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
if(!group.mMeta.mAuthorId.isNull()) if(!group.mMeta.mAuthorId.isNull())
{ {
RetroShareLink link = RetroShareLink::createMessage(group.mMeta.mAuthorId, ""); RetroShareLink link = RetroShareLink::createMessage(group.mMeta.mAuthorId, "");
ui->infoAdministrator->setText(link.toHtml()); ui->infoAdministrator->setText(link.toHtmlColored());
} }
else else
ui->infoAdministrator->setText("[No contact author]"); ui->infoAdministrator->setText("[No contact author]");

View file

@ -705,7 +705,7 @@ void MessageWidget::fill(const std::string &msgId)
} }
else else
{ {
ui.fromText->setText(link.toHtml()); ui.fromText->setText(link.toHtmlColored());
ui.fromText->setToolTip(tooltip_string) ; ui.fromText->setToolTip(tooltip_string) ;
if (toolButtonReply) toolButtonReply->setEnabled(true); if (toolButtonReply) toolButtonReply->setEnabled(true);
} }

View file

@ -39,6 +39,7 @@
#include "util/misc.h" #include "util/misc.h"
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QColorDialog>
#include <QComboBox> #include <QComboBox>
#include <QCheckBox> #include <QCheckBox>
#include <QDir> #include <QDir>
@ -363,6 +364,11 @@ void AppearancePage::load()
whileBlocking(ui.checkBoxShowSystrayOnStatus)->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool()); whileBlocking(ui.checkBoxShowSystrayOnStatus)->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool());
whileBlocking(ui.minimumFontSize_SB)->setValue(Settings->getFontSize()); whileBlocking(ui.minimumFontSize_SB)->setValue(Settings->getFontSize());
rgbLinkColor=Settings->getLinkColor();
QPixmap colorpix(24, 24);
colorpix.fill(rgbLinkColor);
ui.linkColorButton->setIcon(colorpix);
} }
void AppearancePage::updateFontSize() void AppearancePage::updateFontSize()
@ -371,3 +377,25 @@ void AppearancePage::updateFontSize()
RsGUIEventManager::getInstance()->notifySettingsChanged(); RsGUIEventManager::getInstance()->notifySettingsChanged();
} }
void AppearancePage::on_linkColorButton_clicked()
{
QColor color = QColorDialog::getColor(QColor::fromRgba(rgbLinkColor), window(), "", QColorDialog::ShowAlphaChannel);
if (color.isValid()) {
rgbLinkColor = color.rgba();
QPixmap pix(24, 24);
pix.fill(color);
ui.linkColorButton->setIcon(pix);
Settings->setLinkColor(rgbLinkColor);
}
}
void AppearancePage::on_resetButton_clicked()
{
QRgb color = QString::number(QColor(3, 155, 198).rgba()).toUInt();
defaultColor = color;
QPixmap pix(24, 24);
pix.fill(color);
ui.linkColorButton->setIcon(pix);
Settings->setLinkColor(defaultColor);
}

View file

@ -73,9 +73,15 @@ private slots:
void updateStyle() ; void updateStyle() ;
void updateFontSize(); void updateFontSize();
void on_linkColorButton_clicked();
void on_resetButton_clicked();
private: private:
void switch_status(MainWindow::StatusElement s,const QString& key,bool b); void switch_status(MainWindow::StatusElement s,const QString& key,bool b);
QRgb rgbLinkColor;
QRgb defaultColor;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::AppearancePage ui; Ui::AppearancePage ui;
}; };

View file

@ -71,7 +71,92 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="grpStyle">
<property name="minimumSize">
<size>
<width>0</width>
<height>64</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="toolTip">
<string/>
</property>
<property name="title">
<string>Style</string>
</property>
<layout class="QGridLayout" name="grpStyleGLayout">
<item row="0" column="0">
<widget class="RSComboBox" name="cmboStyle">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Choose RetroShare's interface style</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="grpStyleHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>215</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="grpStyleSheet">
<property name="minimumSize">
<size>
<width>0</width>
<height>64</height>
</size>
</property>
<property name="title">
<string>Style Sheet</string>
</property>
<layout class="QGridLayout" name="grpStyleSheetGLayout">
<item row="0" column="0">
<widget class="RSComboBox" name="cmboStyleSheet">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="grpStyleSheetHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>215</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" rowspan="2">
<widget class="QGroupBox" name="grpToolBar"> <widget class="QGroupBox" name="grpToolBar">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -289,8 +374,8 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>188</width> <width>20</width>
<height>96</height> <height>40</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -298,7 +383,62 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="4" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Link Color</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Color of the links</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="linkColorButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Set link color</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="resetButton">
<property name="toolTip">
<string>Reset to default color</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/textedit/undo.png</normaloff>:/icons/textedit/undo.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="grpStatus"> <widget class="QGroupBox" name="grpStatus">
<property name="title"> <property name="title">
<string>Status Bar</string> <string>Status Bar</string>
@ -407,7 +547,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="6" column="0" colspan="2">
<spacer name="AppearancePageVSpacer"> <spacer name="AppearancePageVSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -420,91 +560,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="grpStyle">
<property name="minimumSize">
<size>
<width>0</width>
<height>64</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="toolTip">
<string/>
</property>
<property name="title">
<string>Style</string>
</property>
<layout class="QGridLayout" name="grpStyleGLayout">
<item row="0" column="0">
<widget class="RSComboBox" name="cmboStyle">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Choose RetroShare's interface style</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="grpStyleHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>215</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="grpStyleSheet">
<property name="minimumSize">
<size>
<width>0</width>
<height>64</height>
</size>
</property>
<property name="title">
<string>Style Sheet</string>
</property>
<layout class="QGridLayout" name="grpStyleSheetGLayout">
<item row="0" column="0">
<widget class="RSComboBox" name="cmboStyleSheet">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="grpStyleSheetHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>215</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
@ -514,6 +569,8 @@
<header>gui/common/RSComboBox.h</header> <header>gui/common/RSComboBox.h</header>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources>
<include location="../icons.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View file

@ -1225,6 +1225,15 @@ void RshareSettings::setMessageFontSize(int value)
setValueToGroup("Message", "FontSize", value); setValueToGroup("Message", "FontSize", value);
} }
void RshareSettings::setLinkColor(QRgb rgbValue)
{
setValueToGroup("Chat", "LinkColor", QString::number(rgbValue));
}
QRgb RshareSettings::getLinkColor()
{
return valueFromGroup("Chat", "LinkColor", QString::number(QColor(3, 155, 198).rgba())).toUInt();
}
#ifdef RS_JSONAPI #ifdef RS_JSONAPI
bool RshareSettings::getJsonApiEnabled() bool RshareSettings::getJsonApiEnabled()
{ {

View file

@ -381,6 +381,9 @@ public:
int getMessageFontSize(); int getMessageFontSize();
void setMessageFontSize(int value); void setMessageFontSize(int value);
void setLinkColor(QRgb rgbValue);
QRgb getLinkColor();
#ifdef RS_JSONAPI #ifdef RS_JSONAPI
bool getJsonApiEnabled(); bool getJsonApiEnabled();
void setJsonApiEnabled(bool enabled); void setJsonApiEnabled(bool enabled);