added a checkbox to load emoticons in forums as an option, so as to avoid crazy loading times. Disabled by default until we fix the RsHtml code

This commit is contained in:
csoler 2017-01-18 21:22:38 +01:00
parent 8568199497
commit 34962c343a
6 changed files with 34 additions and 5 deletions

View File

@ -31,6 +31,7 @@
#include "GxsForumsDialog.h" #include "GxsForumsDialog.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "gui/common/RSTreeWidgetItem.h" #include "gui/common/RSTreeWidgetItem.h"
#include "gui/settings/rsharesettings.h"
#include "gui/common/RSElidedItemDelegate.h" #include "gui/common/RSElidedItemDelegate.h"
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/gxs/GxsIdTreeWidgetItem.h" #include "gui/gxs/GxsIdTreeWidgetItem.h"
@ -1622,7 +1623,11 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
} }
else else
{ {
QString extraTxt = RsHtml().formatText(ui->postText->document(), QString::fromUtf8(msg.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); uint32_t flags = RSHTML_FORMATTEXT_EMBED_LINKS;
if(Settings->getForumLoadEmoticons())
flags |= RSHTML_FORMATTEXT_EMBED_SMILEYS ;
QString extraTxt = RsHtml().formatText(ui->postText->document(), QString::fromUtf8(msg.mMsg.c_str()),flags);
ui->postText->setHtml(extraTxt); ui->postText->setHtml(extraTxt);
} }
// ui->threadTitle->setText(QString::fromUtf8(msg.mMeta.mMsgName.c_str())); // ui->threadTitle->setText(QString::fromUtf8(msg.mMeta.mMsgName.c_str()));

View File

@ -42,6 +42,7 @@ bool ForumPage::save(QString &/*errmsg*/)
Settings->setForumMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); Settings->setForumMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked());
Settings->setForumExpandNewMessages(ui.expandNewMessages->isChecked()); Settings->setForumExpandNewMessages(ui.expandNewMessages->isChecked());
Settings->setForumLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); Settings->setForumLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
Settings->setForumLoadEmoticons(ui.loadEmoticons->isChecked());
ui.groupFrameSettingsWidget->saveSettings(GroupFrameSettings::Forum); ui.groupFrameSettingsWidget->saveSettings(GroupFrameSettings::Forum);
@ -54,6 +55,7 @@ void ForumPage::load()
ui.setMsgToReadOnActivate->setChecked(Settings->getForumMsgSetToReadOnActivate()); ui.setMsgToReadOnActivate->setChecked(Settings->getForumMsgSetToReadOnActivate());
ui.expandNewMessages->setChecked(Settings->getForumExpandNewMessages()); ui.expandNewMessages->setChecked(Settings->getForumExpandNewMessages());
ui.loadEmbeddedImages->setChecked(Settings->getForumLoadEmbeddedImages()); ui.loadEmbeddedImages->setChecked(Settings->getForumLoadEmbeddedImages());
ui.loadEmoticons->setChecked(Settings->getForumLoadEmoticons());
ui.groupFrameSettingsWidget->loadSettings(GroupFrameSettings::Forum); ui.groupFrameSettingsWidget->loadSettings(GroupFrameSettings::Forum);
} }

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>423</width> <width>507</width>
<height>340</height> <height>340</height>
</rect> </rect>
</property> </property>
@ -38,6 +38,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QCheckBox" name="loadEmoticons">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This option is costly and it's in the dev's plans to improve it. In the mean time it's disabled by default. If you enable it and long forum posts take a while to display, then disable it again. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Load emoticons (costly)</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -1041,12 +1041,18 @@ bool RshareSettings::getForumLoadEmbeddedImages()
{ {
return valueFromGroup("Forum", "LoadEmbeddedImages", false).toBool(); return valueFromGroup("Forum", "LoadEmbeddedImages", false).toBool();
} }
bool RshareSettings::getForumLoadEmoticons()
{
return valueFromGroup("Forum", "LoadEmoticons", false).toBool();
}
void RshareSettings::setForumLoadEmbeddedImages(bool value) void RshareSettings::setForumLoadEmbeddedImages(bool value)
{ {
setValueToGroup("Forum", "LoadEmbeddedImages", value); setValueToGroup("Forum", "LoadEmbeddedImages", value);
} }
void RshareSettings::setForumLoadEmoticons(bool value)
{
setValueToGroup("Forum", "LoadEmoticons", value);
}
/* Channel */ /* Channel */
bool RshareSettings::getChannelLoadThread() bool RshareSettings::getChannelLoadThread()
{ {

View File

@ -305,6 +305,8 @@ public:
void setForumExpandNewMessages(bool value); void setForumExpandNewMessages(bool value);
bool getForumLoadEmbeddedImages(); bool getForumLoadEmbeddedImages();
void setForumLoadEmbeddedImages(bool value); void setForumLoadEmbeddedImages(bool value);
bool getForumLoadEmoticons();
void setForumLoadEmoticons(bool value);
/* Channel */ /* Channel */
bool getChannelLoadThread(); bool getChannelLoadThread();

View File

@ -1004,13 +1004,17 @@ void RsHtml::optimizeHtml(QTextEdit *textEdit, QString &text, unsigned int flag
{ {
if (textEdit->toHtml() == QTextDocument(textEdit->toPlainText()).toHtml()) { if (textEdit->toHtml() == QTextDocument(textEdit->toPlainText()).toHtml()) {
text = textEdit->toPlainText(); text = textEdit->toPlainText();
// std::cerr << "Optimized text to " << text.length() << " bytes , instead of " << textEdit->toHtml().length() << std::endl; //std::cerr << "Optimized text to " << text.length() << " bytes , instead of " << textEdit->toHtml().length() << std::endl;
return; return;
} }
text = textEdit->toHtml(); text = textEdit->toHtml();
//std::cerr << "Optimized text from " << text.length() << " bytes , into " ;
optimizeHtml(text, flag); optimizeHtml(text, flag);
//std::cerr << text.length() << " bytes" << std::endl;
} }
/** /**