mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
made Link a struct
This commit is contained in:
parent
99aac9eb6a
commit
11775071b9
4 changed files with 10 additions and 28 deletions
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace messages {
|
namespace messages {
|
||||||
|
|
||||||
Link::Link()
|
Link::Link()
|
||||||
: type(None)
|
: type(None)
|
||||||
, value(QString())
|
, value(QString())
|
||||||
|
@ -19,16 +18,5 @@ bool Link::isValid() const
|
||||||
{
|
{
|
||||||
return this->type != None;
|
return this->type != None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Link::Type Link::getType() const
|
|
||||||
{
|
|
||||||
return this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString &Link::getValue() const
|
|
||||||
{
|
|
||||||
return this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace messages {
|
namespace messages {
|
||||||
|
struct Link {
|
||||||
class Link
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
None,
|
None,
|
||||||
|
@ -23,14 +21,10 @@ public:
|
||||||
Link();
|
Link();
|
||||||
Link(Type getType, const QString &getValue);
|
Link(Type getType, const QString &getValue);
|
||||||
|
|
||||||
bool isValid() const;
|
|
||||||
Type getType() const;
|
|
||||||
const QString &getValue() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Type type;
|
Type type;
|
||||||
QString value;
|
QString value;
|
||||||
};
|
|
||||||
|
|
||||||
|
bool isValid() const;
|
||||||
|
};
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -862,9 +862,9 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link,
|
void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link,
|
||||||
messages::MessageLayout *layout)
|
messages::MessageLayout *layout)
|
||||||
{
|
{
|
||||||
switch (link.getType()) {
|
switch (link.type) {
|
||||||
case messages::Link::UserInfo: {
|
case messages::Link::UserInfo: {
|
||||||
auto user = link.getValue();
|
auto user = link.value;
|
||||||
this->userPopupWidget.setName(user);
|
this->userPopupWidget.setName(user);
|
||||||
this->userPopupWidget.moveTo(this, event->screenPos().toPoint());
|
this->userPopupWidget.moveTo(this, event->screenPos().toPoint());
|
||||||
this->userPopupWidget.show();
|
this->userPopupWidget.show();
|
||||||
|
@ -886,16 +886,16 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link
|
||||||
[] { QApplication::clipboard()->setText(url); });
|
[] { QApplication::clipboard()->setText(url); });
|
||||||
}
|
}
|
||||||
|
|
||||||
url = link.getValue();
|
url = link.value;
|
||||||
menu->move(QCursor::pos());
|
menu->move(QCursor::pos());
|
||||||
menu->show();
|
menu->show();
|
||||||
} else {
|
} else {
|
||||||
QDesktopServices::openUrl(QUrl(link.getValue()));
|
QDesktopServices::openUrl(QUrl(link.value));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case messages::Link::UserAction: {
|
case messages::Link::UserAction: {
|
||||||
QString value = link.getValue();
|
QString value = link.value;
|
||||||
value.replace("{user}", layout->getMessage()->loginName);
|
value.replace("{user}", layout->getMessage()->loginName);
|
||||||
this->channel->sendMessage(value);
|
this->channel->sendMessage(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,8 @@ void SplitInput::initLayout()
|
||||||
if (!this->emotePopup) {
|
if (!this->emotePopup) {
|
||||||
this->emotePopup = std::make_unique<EmotePopup>(this->themeManager);
|
this->emotePopup = std::make_unique<EmotePopup>(this->themeManager);
|
||||||
this->emotePopup->linkClicked.connect([this](const messages::Link &link) {
|
this->emotePopup->linkClicked.connect([this](const messages::Link &link) {
|
||||||
if (link.getType() == messages::Link::InsertText) {
|
if (link.type == messages::Link::InsertText) {
|
||||||
this->insertText(link.getValue() + " ");
|
this->insertText(link.value + " ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue