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 messages {
|
||||
|
||||
Link::Link()
|
||||
: type(None)
|
||||
, value(QString())
|
||||
|
@ -19,16 +18,5 @@ bool Link::isValid() const
|
|||
{
|
||||
return this->type != None;
|
||||
}
|
||||
|
||||
Link::Type Link::getType() const
|
||||
{
|
||||
return this->type;
|
||||
}
|
||||
|
||||
const QString &Link::getValue() const
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
} // namespace messages
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
namespace chatterino {
|
||||
namespace messages {
|
||||
|
||||
class Link
|
||||
{
|
||||
struct Link {
|
||||
public:
|
||||
enum Type {
|
||||
None,
|
||||
|
@ -23,14 +21,10 @@ public:
|
|||
Link();
|
||||
Link(Type getType, const QString &getValue);
|
||||
|
||||
bool isValid() const;
|
||||
Type getType() const;
|
||||
const QString &getValue() const;
|
||||
|
||||
private:
|
||||
Type type;
|
||||
QString value;
|
||||
};
|
||||
|
||||
bool isValid() const;
|
||||
};
|
||||
} // namespace messages
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -862,9 +862,9 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link,
|
||||
messages::MessageLayout *layout)
|
||||
{
|
||||
switch (link.getType()) {
|
||||
switch (link.type) {
|
||||
case messages::Link::UserInfo: {
|
||||
auto user = link.getValue();
|
||||
auto user = link.value;
|
||||
this->userPopupWidget.setName(user);
|
||||
this->userPopupWidget.moveTo(this, event->screenPos().toPoint());
|
||||
this->userPopupWidget.show();
|
||||
|
@ -886,16 +886,16 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link
|
|||
[] { QApplication::clipboard()->setText(url); });
|
||||
}
|
||||
|
||||
url = link.getValue();
|
||||
url = link.value;
|
||||
menu->move(QCursor::pos());
|
||||
menu->show();
|
||||
} else {
|
||||
QDesktopServices::openUrl(QUrl(link.getValue()));
|
||||
QDesktopServices::openUrl(QUrl(link.value));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case messages::Link::UserAction: {
|
||||
QString value = link.getValue();
|
||||
QString value = link.value;
|
||||
value.replace("{user}", layout->getMessage()->loginName);
|
||||
this->channel->sendMessage(value);
|
||||
}
|
||||
|
|
|
@ -74,8 +74,8 @@ void SplitInput::initLayout()
|
|||
if (!this->emotePopup) {
|
||||
this->emotePopup = std::make_unique<EmotePopup>(this->themeManager);
|
||||
this->emotePopup->linkClicked.connect([this](const messages::Link &link) {
|
||||
if (link.getType() == messages::Link::InsertText) {
|
||||
this->insertText(link.getValue() + " ");
|
||||
if (link.type == messages::Link::InsertText) {
|
||||
this->insertText(link.value + " ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue