diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index 8417c5cb8..9ef8cb871 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -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(); diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index ed9c5374b..c6eb3a512 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -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 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 &_message, diff --git a/src/widgets/helper/channelview.hpp b/src/widgets/helper/channelview.hpp index a57691154..113e3b981 100644 --- a/src/widgets/helper/channelview.hpp +++ b/src/widgets/helper/channelview.hpp @@ -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 &message, QPoint &relativePos, int &index); diff --git a/src/widgets/settingspages/behaviourpage.cpp b/src/widgets/settingspages/behaviourpage.cpp index f9caa5e24..e45c5b0eb 100644 --- a/src/widgets/settingspages/behaviourpage.cpp +++ b/src/widgets/settingspages/behaviourpage.cpp @@ -1,6 +1,7 @@ #include "behaviourpage.hpp" #include +#include #include #include @@ -22,7 +23,9 @@ BehaviourPage::BehaviourPage() singletons::SettingManager &settings = singletons::SettingManager::getInstance(); util::LayoutCreator layoutCreator(this); - auto form = layoutCreator.emplace().withoutMargin(); + auto layout = layoutCreator.setLayoutType(); + + auto form = layout.emplace().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("Streamlink"); + { + auto groupLayout = group.setLayoutType(); + groupLayout->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath)); + groupLayout->addRow("Prefered quality:", + this->createComboBox({STREAMLINK_QUALITY}, settings.preferredQuality)); + } + + layout->addStretch(1); } QSlider *BehaviourPage::createMouseScrollSlider()