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()
|
: _words()
|
||||||
{
|
{
|
||||||
_parseTime = std::chrono::system_clock::now();
|
_parseTime = std::chrono::system_clock::now();
|
||||||
|
regex.setPattern("\\bhttps?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]");
|
||||||
|
regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedMessage MessageBuilder::build()
|
SharedMessage MessageBuilder::build()
|
||||||
|
@ -52,8 +54,8 @@ void MessageBuilder::appendTimestamp(time_t time)
|
||||||
|
|
||||||
QString MessageBuilder::matchLink(const QString &string)
|
QString MessageBuilder::matchLink(const QString &string)
|
||||||
{
|
{
|
||||||
// TODO: Implement this xD
|
QRegularExpressionMatch match = regex.match(string);
|
||||||
return QString();
|
return match.captured();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace messages {
|
namespace messages {
|
||||||
|
@ -19,6 +20,7 @@ public:
|
||||||
void appendTimestamp(std::time_t time);
|
void appendTimestamp(std::time_t time);
|
||||||
|
|
||||||
QString matchLink(const QString &string);
|
QString matchLink(const QString &string);
|
||||||
|
QRegularExpression regex;
|
||||||
|
|
||||||
QString originalMessage;
|
QString originalMessage;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "widgets/chatwidget.hpp"
|
#include "widgets/chatwidget.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
#include <QGraphicsBlurEffect>
|
#include <QGraphicsBlurEffect>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
@ -380,7 +381,7 @@ void ChatWidgetView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
auto &link = hoverWord.getLink();
|
auto &link = hoverWord.getLink();
|
||||||
|
|
||||||
switch (link.getType()) {
|
switch (link.getType()) {
|
||||||
case messages::Link::UserInfo:
|
case messages::Link::UserInfo:{
|
||||||
auto user = message->getMessage()->getUserName();
|
auto user = message->getMessage()->getUserName();
|
||||||
this->userPopupWidget.setName(user);
|
this->userPopupWidget.setName(user);
|
||||||
this->userPopupWidget.move(event->screenPos().toPoint());
|
this->userPopupWidget.move(event->screenPos().toPoint());
|
||||||
|
@ -390,6 +391,11 @@ void ChatWidgetView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
qDebug() << "Clicked " << user << "s message";
|
qDebug() << "Clicked " << user << "s message";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case messages::Link::Url:{
|
||||||
|
QDesktopServices::openUrl(QUrl(link.getValue()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatWidgetView::tryGetMessageAt(QPoint p, std::shared_ptr<messages::MessageRef> &_message,
|
bool ChatWidgetView::tryGetMessageAt(QPoint p, std::shared_ptr<messages::MessageRef> &_message,
|
||||||
|
|
Loading…
Reference in a new issue