mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixes #234 links
This commit is contained in:
parent
f35ca0d2c8
commit
de9e1b641d
4 changed files with 61 additions and 8 deletions
|
@ -387,9 +387,9 @@ void BaseWindow::showEvent(QShowEvent *event)
|
|||
|
||||
void BaseWindow::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
BaseWidget::paintEvent(event);
|
||||
|
||||
if (this->hasCustomWindowFrame()) {
|
||||
BaseWidget::paintEvent(event);
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||
|
|
|
@ -813,7 +813,44 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
|||
}
|
||||
|
||||
auto &link = hoverLayoutElement->getLink();
|
||||
if (!singletons::SettingManager::getInstance().linksDoubleClickOnly) {
|
||||
this->handleLinkClick(event, link, layout.get());
|
||||
}
|
||||
|
||||
this->linkClicked.invoke(link);
|
||||
}
|
||||
|
||||
void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (singletons::SettingManager::getInstance().linksDoubleClickOnly) {
|
||||
std::shared_ptr<messages::MessageLayout> layout;
|
||||
QPoint relativePos;
|
||||
int messageIndex;
|
||||
|
||||
if (!tryGetMessageAt(event->pos(), layout, relativePos, messageIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// message under cursor is collapsed
|
||||
if (layout->getFlags() & MessageLayout::Collapsed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const messages::MessageLayoutElement *hoverLayoutElement =
|
||||
layout->getElementAt(relativePos);
|
||||
|
||||
if (hoverLayoutElement == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto &link = hoverLayoutElement->getLink();
|
||||
this->handleLinkClick(event, link, layout.get());
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link,
|
||||
messages::MessageLayout *layout)
|
||||
{
|
||||
switch (link.getType()) {
|
||||
case messages::Link::UserInfo: {
|
||||
auto user = link.getValue();
|
||||
|
@ -852,8 +889,6 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
|||
this->channel->sendMessage(value);
|
||||
}
|
||||
}
|
||||
|
||||
this->linkClicked.invoke(link);
|
||||
}
|
||||
|
||||
bool ChannelView::tryGetMessageAt(QPoint p, std::shared_ptr<messages::MessageLayout> &_message,
|
||||
|
|
|
@ -66,6 +66,10 @@ protected:
|
|||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
|
||||
void handleLinkClick(QMouseEvent *event, const messages::Link &link,
|
||||
messages::MessageLayout *layout);
|
||||
|
||||
bool tryGetMessageAt(QPoint p, std::shared_ptr<messages::MessageLayout> &message,
|
||||
QPoint &relativePos, int &index);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "behaviourpage.hpp"
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
@ -22,7 +23,9 @@ BehaviourPage::BehaviourPage()
|
|||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
util::LayoutCreator<BehaviourPage> layoutCreator(this);
|
||||
|
||||
auto form = layoutCreator.emplace<QFormLayout>().withoutMargin();
|
||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||
|
||||
auto form = layout.emplace<QFormLayout>().withoutMargin();
|
||||
{
|
||||
form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, settings.windowTopMost));
|
||||
form->addRow("Messages:", this->createCheckBox(INPUT_EMPTY, settings.hideEmptyInput));
|
||||
|
@ -30,10 +33,21 @@ BehaviourPage::BehaviourPage()
|
|||
form->addRow("Pause chat:", this->createCheckBox(PAUSE_HOVERING, settings.pauseChatHover));
|
||||
|
||||
form->addRow("Mouse scroll speed:", this->createMouseScrollSlider());
|
||||
form->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath));
|
||||
form->addRow("Prefered quality:",
|
||||
this->createComboBox({STREAMLINK_QUALITY}, settings.preferredQuality));
|
||||
form->addRow("Links:", this->createCheckBox("Open links only on double click",
|
||||
settings.linksDoubleClickOnly));
|
||||
}
|
||||
|
||||
layout->addSpacing(16);
|
||||
|
||||
auto group = layout.emplace<QGroupBox>("Streamlink");
|
||||
{
|
||||
auto groupLayout = group.setLayoutType<QFormLayout>();
|
||||
groupLayout->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath));
|
||||
groupLayout->addRow("Prefered quality:",
|
||||
this->createComboBox({STREAMLINK_QUALITY}, settings.preferredQuality));
|
||||
}
|
||||
|
||||
layout->addStretch(1);
|
||||
}
|
||||
|
||||
QSlider *BehaviourPage::createMouseScrollSlider()
|
||||
|
|
Loading…
Reference in a new issue