mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fixes #259 dropping split on + button
This commit is contained in:
parent
de9e1b641d
commit
8ab0fa4378
|
@ -256,12 +256,12 @@ void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
|||
twitch::TwitchMessageBuilder builder(c.get(), message, args);
|
||||
|
||||
if (!builder.isIgnored()) {
|
||||
messages::MessagePtr message = builder.build();
|
||||
if (message->hasFlags(messages::Message::Highlighted)) {
|
||||
singletons::ChannelManager::getInstance().mentionsChannel->addMessage(message);
|
||||
messages::MessagePtr _message = builder.build();
|
||||
if (_message->hasFlags(messages::Message::Highlighted)) {
|
||||
singletons::ChannelManager::getInstance().mentionsChannel->addMessage(_message);
|
||||
}
|
||||
|
||||
c->addMessage(message);
|
||||
c->addMessage(_message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -813,7 +813,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
|||
}
|
||||
|
||||
auto &link = hoverLayoutElement->getLink();
|
||||
if (!singletons::SettingManager::getInstance().linksDoubleClickOnly) {
|
||||
if (event->button() != Qt::LeftButton ||
|
||||
!singletons::SettingManager::getInstance().linksDoubleClickOnly) {
|
||||
this->handleLinkClick(event, link, layout.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
#include "widgets/helper/notebookbutton.hpp"
|
||||
#include "singletons/thememanager.hpp"
|
||||
#include "widgets/helper/rippleeffectbutton.hpp"
|
||||
#include "widgets/notebook.hpp"
|
||||
#include "widgets/splitcontainer.hpp"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QRadialGradient>
|
||||
|
||||
#define nuuls nullptr
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
|
@ -14,6 +18,8 @@ NotebookButton::NotebookButton(BaseWidget *parent)
|
|||
: RippleEffectButton(parent)
|
||||
{
|
||||
setMouseEffectColor(QColor(0, 0, 0));
|
||||
|
||||
this->setAcceptDrops(true);
|
||||
}
|
||||
|
||||
void NotebookButton::paintEvent(QPaintEvent *)
|
||||
|
@ -97,5 +103,46 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
|||
RippleEffectButton::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (!event->mimeData()->hasFormat("chatterino/split"))
|
||||
return;
|
||||
|
||||
event->acceptProposedAction();
|
||||
|
||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonPress,
|
||||
QPointF(this->width() / 2, this->height() / 2), Qt::LeftButton,
|
||||
Qt::LeftButton, 0);
|
||||
RippleEffectButton::mousePressEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
|
||||
{
|
||||
this->mouseDown = true;
|
||||
this->update();
|
||||
|
||||
auto e = new QMouseEvent(QMouseEvent::MouseButtonRelease,
|
||||
QPointF(this->width() / 2, this->height() / 2), Qt::LeftButton,
|
||||
Qt::LeftButton, 0);
|
||||
RippleEffectButton::mouseReleaseEvent(e);
|
||||
delete e;
|
||||
}
|
||||
|
||||
void NotebookButton::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (SplitContainer::isDraggingSplit) {
|
||||
event->acceptProposedAction();
|
||||
|
||||
Notebook *notebook = dynamic_cast<Notebook *>(this->parentWidget());
|
||||
|
||||
if (notebook != nuuls) {
|
||||
SplitContainer *tab = notebook->addNewPage();
|
||||
|
||||
SplitContainer::draggingSplit->setParent(tab);
|
||||
tab->addToLayout(SplitContainer::draggingSplit);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -21,8 +21,11 @@ public:
|
|||
NotebookButton(BaseWidget *parent);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
virtual void paintEvent(QPaintEvent *) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *) override;
|
||||
virtual void dragEnterEvent(QDragEnterEvent *) override;
|
||||
virtual void dragLeaveEvent(QDragLeaveEvent *) override;
|
||||
virtual void dropEvent(QDropEvent *) override;
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
|
Loading…
Reference in a new issue