Fixes #259 dropping split on + button

This commit is contained in:
fourtf 2018-01-24 22:09:26 +01:00
parent de9e1b641d
commit 8ab0fa4378
4 changed files with 58 additions and 7 deletions

View file

@ -256,12 +256,12 @@ void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message)
twitch::TwitchMessageBuilder builder(c.get(), message, args); twitch::TwitchMessageBuilder builder(c.get(), message, args);
if (!builder.isIgnored()) { if (!builder.isIgnored()) {
messages::MessagePtr message = builder.build(); messages::MessagePtr _message = builder.build();
if (message->hasFlags(messages::Message::Highlighted)) { if (_message->hasFlags(messages::Message::Highlighted)) {
singletons::ChannelManager::getInstance().mentionsChannel->addMessage(message); singletons::ChannelManager::getInstance().mentionsChannel->addMessage(_message);
} }
c->addMessage(message); c->addMessage(_message);
} }
} }

View file

@ -813,7 +813,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
} }
auto &link = hoverLayoutElement->getLink(); auto &link = hoverLayoutElement->getLink();
if (!singletons::SettingManager::getInstance().linksDoubleClickOnly) { if (event->button() != Qt::LeftButton ||
!singletons::SettingManager::getInstance().linksDoubleClickOnly) {
this->handleLinkClick(event, link, layout.get()); this->handleLinkClick(event, link, layout.get());
} }

View file

@ -1,12 +1,16 @@
#include "widgets/helper/notebookbutton.hpp" #include "widgets/helper/notebookbutton.hpp"
#include "singletons/thememanager.hpp" #include "singletons/thememanager.hpp"
#include "widgets/helper/rippleeffectbutton.hpp" #include "widgets/helper/rippleeffectbutton.hpp"
#include "widgets/notebook.hpp"
#include "widgets/splitcontainer.hpp"
#include <QMouseEvent> #include <QMouseEvent>
#include <QPainter> #include <QPainter>
#include <QPainterPath> #include <QPainterPath>
#include <QRadialGradient> #include <QRadialGradient>
#define nuuls nullptr
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
@ -14,6 +18,8 @@ NotebookButton::NotebookButton(BaseWidget *parent)
: RippleEffectButton(parent) : RippleEffectButton(parent)
{ {
setMouseEffectColor(QColor(0, 0, 0)); setMouseEffectColor(QColor(0, 0, 0));
this->setAcceptDrops(true);
} }
void NotebookButton::paintEvent(QPaintEvent *) void NotebookButton::paintEvent(QPaintEvent *)
@ -97,5 +103,46 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
RippleEffectButton::mouseReleaseEvent(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 widgets
} // namespace chatterino } // namespace chatterino

View file

@ -21,8 +21,11 @@ public:
NotebookButton(BaseWidget *parent); NotebookButton(BaseWidget *parent);
protected: protected:
void paintEvent(QPaintEvent *) override; virtual void paintEvent(QPaintEvent *) override;
void mouseReleaseEvent(QMouseEvent *event) override; virtual void mouseReleaseEvent(QMouseEvent *) override;
virtual void dragEnterEvent(QDragEnterEvent *) override;
virtual void dragLeaveEvent(QDragLeaveEvent *) override;
virtual void dropEvent(QDropEvent *) override;
signals: signals:
void clicked(); void clicked();