aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.kdev4/dchat.kdev42
-rw-r--r--include/WebPagePreview.hpp3
-rw-r--r--project.conf2
-rw-r--r--src/Cache.cpp10
-rw-r--r--src/Chatbar.cpp2
-rw-r--r--src/MessageBoard.cpp2
-rw-r--r--src/Text.cpp10
-rw-r--r--src/WebPagePreview.cpp5
8 files changed, 25 insertions, 11 deletions
diff --git a/.kdev4/dchat.kdev4 b/.kdev4/dchat.kdev4
index 63d87da..b45716a 100644
--- a/.kdev4/dchat.kdev4
+++ b/.kdev4/dchat.kdev4
@@ -16,7 +16,7 @@ Name=Clang
3=/home/dec05eba/.cache/sibs/lib/sibs-serializer/1.0.1
4=/home/dec05eba/.cache/sibs/lib/ntpclient/0.2.1/include
5=/home/dec05eba/.cache/sibs/lib/fmt/4.1.0
-6=/home/dec05eba/.cache/sibs/lib/libpreview/0.1.1/include
+6=/home/dec05eba/.cache/sibs/lib/libpreview/0.2.0/include
[Project]
VersionControlSupport=kdevgit
diff --git a/include/WebPagePreview.hpp b/include/WebPagePreview.hpp
index 749308c..6f6c0f0 100644
--- a/include/WebPagePreview.hpp
+++ b/include/WebPagePreview.hpp
@@ -8,8 +8,9 @@ namespace dchat
class WebPagePreview
{
public:
- WebPagePreview(const sf::String &title);
+ WebPagePreview(const sf::String &title, const sf::String &description);
Text title;
+ Text description;
};
}
diff --git a/project.conf b/project.conf
index 116c0c1..cf60d63 100644
--- a/project.conf
+++ b/project.conf
@@ -14,4 +14,4 @@ mpv = "1.25.0"
gl = "17.3"
x11 = "1.6.5"
libnsgif = "0.2.0"
-libpreview = "0.1.1"
+libpreview = "0.2.0"
diff --git a/src/Cache.cpp b/src/Cache.cpp
index 15af6e7..cf1510a 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -126,6 +126,7 @@ namespace dchat
fileContent = getFileContent(filepath);
sf::String webPageTitle;
+ sf::String webPageDescription;
bool foundHtmlContent = false;
preview_state state;
preview_init(&state);
@@ -160,11 +161,12 @@ namespace dchat
else if(state.step_result == PREVIEW_FOUND_TITLE)
{
foundHtmlContent = true;
- webPageTitle = sf::String::fromUtf8(state.title, state.title + state.title_length);
+ webPageTitle = sf::String::fromUtf8(state.meta_content, state.meta_content + state.meta_content_length);
}
- else if(state.step_result == PREVIEW_FOUND_PARAGRAPH)
+ else if(state.step_result == PREVIEW_FOUND_DESCRIPTION)
{
foundHtmlContent = true;
+ webPageDescription = sf::String::fromUtf8(state.meta_content, state.meta_content + state.meta_content_length);
}
} while(offset < fileContent.size);
@@ -173,8 +175,8 @@ namespace dchat
if(foundHtmlContent)
{
- // TODO: Use move semantics for webPageTitle when SFML supports it
- WebPagePreview *webPagePreview = new WebPagePreview(webPageTitle);
+ // TODO: Use move semantics for webPageTitle and webPageDescription when SFML supports it
+ WebPagePreview *webPagePreview = new WebPagePreview(webPageTitle, webPageDescription);
return { webPagePreview, ContentByUrlResult::Type::CACHED };
}
}
diff --git a/src/Chatbar.cpp b/src/Chatbar.cpp
index 5f17c28..bd510f7 100644
--- a/src/Chatbar.cpp
+++ b/src/Chatbar.cpp
@@ -15,7 +15,7 @@ using namespace std;
namespace dchat
{
- const float FONT_SIZE = 20;
+ const float FONT_SIZE = 18.0f;
const float BOX_PADDING_X = 15.0f;
const float BOX_PADDING_Y = 5.0f;
const int BLINK_TIME_VISIBLE_MS = 500;
diff --git a/src/MessageBoard.cpp b/src/MessageBoard.cpp
index bc53ae3..8e1525f 100644
--- a/src/MessageBoard.cpp
+++ b/src/MessageBoard.cpp
@@ -215,7 +215,7 @@ namespace dchat
}
// No need to perform culling here, that is done in @Text draw function
- message->text.setCharacterSize(18 * Settings::getScaling());
+ message->text.setCharacterSize(18.0f * Settings::getScaling());
message->text.setMaxWidth(backgroundSize.x - (AVATAR_DIAMETER + AVATAR_PADDING_SIDE) * Settings::getScaling());
message->text.setPosition(sf::Vector2f(floor(position.x + (AVATAR_DIAMETER + AVATAR_PADDING_SIDE) * Settings::getScaling()), floor(position.y)));
message->text.setLineSpacing(LINE_SPACING);
diff --git a/src/Text.cpp b/src/Text.cpp
index 5191ca5..7503d61 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -845,6 +845,7 @@ namespace dchat
}
*/
+
states.transform.translate(pos);
states.texture = &font->getTexture(characterSize);
target.draw(vertices, states);
@@ -951,6 +952,15 @@ namespace dchat
contentByUrlResult.webPagePreview->title.setLineSpacing(0.0f);
contentByUrlResult.webPagePreview->title.setFillColor(URL_COLOR);
contentByUrlResult.webPagePreview->title.draw(target, cache);
+
+ pos.y += contentByUrlResult.webPagePreview->title.getHeight();
+
+ contentByUrlResult.webPagePreview->description.setCharacterSize(characterSize);
+ contentByUrlResult.webPagePreview->description.setMaxWidth(previewWidth);
+ contentByUrlResult.webPagePreview->description.setPosition(pos);
+ contentByUrlResult.webPagePreview->description.setLineSpacing(0.0f);
+ contentByUrlResult.webPagePreview->description.setFillColor(color);
+ contentByUrlResult.webPagePreview->description.draw(target, cache);
break;
}
}
diff --git a/src/WebPagePreview.cpp b/src/WebPagePreview.cpp
index 0d23285..3922e73 100644
--- a/src/WebPagePreview.cpp
+++ b/src/WebPagePreview.cpp
@@ -3,8 +3,9 @@
namespace dchat
{
- WebPagePreview::WebPagePreview(const sf::String &_title) :
- title(_title, ResourceCache::getFont("fonts/Roboto-Regular.ttf"), 10, 0)
+ WebPagePreview::WebPagePreview(const sf::String &_title, const sf::String &_description) :
+ title(_title, ResourceCache::getFont("fonts/Roboto-Regular.ttf"), 10, 0),
+ description(_description, ResourceCache::getFont("fonts/Roboto-Regular.ttf"), 10, 0)
{
}