mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Made links open in the standard browser.
This commit is contained in:
parent
663dfe5e9e
commit
dea9f64587
3 changed files with 13 additions and 3 deletions
|
@ -10,6 +10,8 @@ MessageBuilder::MessageBuilder()
|
|||
: _words()
|
||||
{
|
||||
_parseTime = std::chrono::system_clock::now();
|
||||
regex.setPattern("\\bhttps?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]");
|
||||
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||
}
|
||||
|
||||
SharedMessage MessageBuilder::build()
|
||||
|
@ -52,8 +54,8 @@ void MessageBuilder::appendTimestamp(time_t time)
|
|||
|
||||
QString MessageBuilder::matchLink(const QString &string)
|
||||
{
|
||||
// TODO: Implement this xD
|
||||
return QString();
|
||||
QRegularExpressionMatch match = regex.match(string);
|
||||
return match.captured();
|
||||
}
|
||||
|
||||
} // namespace messages
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "messages/message.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace chatterino {
|
||||
namespace messages {
|
||||
|
@ -19,6 +20,7 @@ public:
|
|||
void appendTimestamp(std::time_t time);
|
||||
|
||||
QString matchLink(const QString &string);
|
||||
QRegularExpression regex;
|
||||
|
||||
QString originalMessage;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "widgets/chatwidget.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QGraphicsBlurEffect>
|
||||
#include <QPainter>
|
||||
|
||||
|
@ -380,7 +381,7 @@ void ChatWidgetView::mouseReleaseEvent(QMouseEvent *event)
|
|||
auto &link = hoverWord.getLink();
|
||||
|
||||
switch (link.getType()) {
|
||||
case messages::Link::UserInfo:
|
||||
case messages::Link::UserInfo:{
|
||||
auto user = message->getMessage()->getUserName();
|
||||
this->userPopupWidget.setName(user);
|
||||
this->userPopupWidget.move(event->screenPos().toPoint());
|
||||
|
@ -389,6 +390,11 @@ void ChatWidgetView::mouseReleaseEvent(QMouseEvent *event)
|
|||
|
||||
qDebug() << "Clicked " << user << "s message";
|
||||
break;
|
||||
}
|
||||
case messages::Link::Url:{
|
||||
QDesktopServices::openUrl(QUrl(link.getValue()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue