mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added Alt+LeftClick to move splits around
This commit is contained in:
parent
6f95a219a7
commit
0a3c6e29c7
|
@ -96,15 +96,14 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
||||||
|
|
||||||
this->tabs.newMessage = {
|
this->tabs.newMessage = {
|
||||||
tabFg,
|
tabFg,
|
||||||
{QBrush(blendColors(themeColor, windowBg, 0.5), Qt::DiagCrossPattern),
|
{QBrush(blendColors(themeColor, windowBg, 0.7), Qt::FDiagPattern),
|
||||||
QBrush(blendColors(themeColor, windowBg, 0.3), Qt::DiagCrossPattern),
|
QBrush(blendColors(themeColor, windowBg, 0.5), Qt::FDiagPattern),
|
||||||
QBrush(blendColors(themeColorNoSat, windowBg, 0.5), Qt::DiagCrossPattern)}};
|
QBrush(blendColors(themeColorNoSat, windowBg, 0.7), Qt::FDiagPattern)}};
|
||||||
|
|
||||||
this->tabs.highlighted = {
|
this->tabs.highlighted = {
|
||||||
tabFg,
|
tabFg,
|
||||||
{QBrush(blendColors(themeColor, windowBg, 0.5), Qt::DiagCrossPattern),
|
{blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5),
|
||||||
QBrush(blendColors(themeColor, windowBg, 0.3), Qt::DiagCrossPattern),
|
blendColors(themeColorNoSat, windowBg, 0.7)}};
|
||||||
QBrush(blendColors(themeColorNoSat, windowBg, 0.5), Qt::DiagCrossPattern)}};
|
|
||||||
|
|
||||||
// Split
|
// Split
|
||||||
bool flat = isLight;
|
bool flat = isLight;
|
||||||
|
|
|
@ -582,6 +582,13 @@ void ChannelView::leaveEvent(QEvent *)
|
||||||
|
|
||||||
void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if (event->modifiers() & (Qt::AltModifier | Qt::ControlModifier)) {
|
||||||
|
this->unsetCursor();
|
||||||
|
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (singletons::SettingManager::getInstance().pauseChatHover.getValue()) {
|
if (singletons::SettingManager::getInstance().pauseChatHover.getValue()) {
|
||||||
this->pause(300);
|
this->pause(300);
|
||||||
}
|
}
|
||||||
|
@ -639,6 +646,13 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void ChannelView::mousePressEvent(QMouseEvent *event)
|
void ChannelView::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if (event->modifiers() & (Qt::AltModifier | Qt::ControlModifier)) {
|
||||||
|
this->unsetCursor();
|
||||||
|
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (singletons::SettingManager::getInstance().linksDoubleClickOnly.getValue()) {
|
if (singletons::SettingManager::getInstance().linksDoubleClickOnly.getValue()) {
|
||||||
this->pause(200);
|
this->pause(200);
|
||||||
}
|
}
|
||||||
|
@ -689,6 +703,13 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if (event->modifiers() & (Qt::AltModifier | Qt::ControlModifier)) {
|
||||||
|
this->unsetCursor();
|
||||||
|
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this->isMouseDown) {
|
if (!this->isMouseDown) {
|
||||||
// We didn't grab the mouse press, so we shouldn't be handling the mouse
|
// We didn't grab the mouse press, so we shouldn't be handling the mouse
|
||||||
// release
|
// release
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//#include "widgets/helper/notebooktab.hpp"
|
#include "widgets/helper/notebooktab.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
@ -167,6 +167,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
// select the right tab colors
|
// select the right tab colors
|
||||||
singletons::ThemeManager::TabColors colors;
|
singletons::ThemeManager::TabColors colors;
|
||||||
|
singletons::ThemeManager::TabColors regular = this->themeManager.tabs.regular;
|
||||||
|
|
||||||
if (this->selected) {
|
if (this->selected) {
|
||||||
colors = this->themeManager.tabs.selected;
|
colors = this->themeManager.tabs.selected;
|
||||||
|
@ -181,9 +182,12 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||||
// || SettingsDialog::getHandle() == QApplication::activeWindow();
|
// || SettingsDialog::getHandle() == QApplication::activeWindow();
|
||||||
|
|
||||||
|
painter.fillRect(rect(), this->mouseOver ? regular.backgrounds.hover
|
||||||
|
: (windowFocused ? regular.backgrounds.regular
|
||||||
|
: regular.backgrounds.unfocused));
|
||||||
|
|
||||||
// fill the tab background
|
// fill the tab background
|
||||||
painter.fillRect(rect(),
|
painter.fillRect(rect(), this->mouseOver ? colors.backgrounds.hover
|
||||||
this->mouseOver ? colors.backgrounds.hover
|
|
||||||
: (windowFocused ? colors.backgrounds.regular
|
: (windowFocused ? colors.backgrounds.regular
|
||||||
: colors.backgrounds.unfocused));
|
: colors.backgrounds.unfocused));
|
||||||
|
|
||||||
|
|
|
@ -184,35 +184,11 @@ void SplitHeader::mouseMoveEvent(QMouseEvent *event)
|
||||||
if (this->dragging) {
|
if (this->dragging) {
|
||||||
if (std::abs(this->dragStart.x() - event->pos().x()) > 12 ||
|
if (std::abs(this->dragStart.x() - event->pos().x()) > 12 ||
|
||||||
std::abs(this->dragStart.y() - event->pos().y()) > 12) {
|
std::abs(this->dragStart.y() - event->pos().y()) > 12) {
|
||||||
auto page = static_cast<SplitContainer *>(this->split->parentWidget());
|
this->split->drag();
|
||||||
|
|
||||||
if (page != nullptr) {
|
|
||||||
SplitContainer::isDraggingSplit = true;
|
|
||||||
SplitContainer::draggingSplit = this->split;
|
|
||||||
|
|
||||||
auto originalLocation = page->removeFromLayout(this->split);
|
|
||||||
|
|
||||||
// page->update();
|
|
||||||
|
|
||||||
QDrag *drag = new QDrag(this->split);
|
|
||||||
QMimeData *mimeData = new QMimeData;
|
|
||||||
|
|
||||||
mimeData->setData("chatterino/split", "xD");
|
|
||||||
|
|
||||||
drag->setMimeData(mimeData);
|
|
||||||
|
|
||||||
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
|
|
||||||
|
|
||||||
if (dropAction == Qt::IgnoreAction) {
|
|
||||||
page->addToLayout(this->split, originalLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
SplitContainer::isDraggingSplit = false;
|
|
||||||
this->dragging = false;
|
this->dragging = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void SplitHeader::leaveEvent(QEvent *event)
|
void SplitHeader::leaveEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,10 +16,12 @@
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
|
#include <QDrag>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
#include <QMimeData>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
@ -49,6 +51,8 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||||
, flexSizeX(1)
|
, flexSizeX(1)
|
||||||
, flexSizeY(1)
|
, flexSizeY(1)
|
||||||
{
|
{
|
||||||
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
this->vbox.setSpacing(0);
|
this->vbox.setSpacing(0);
|
||||||
this->vbox.setMargin(1);
|
this->vbox.setMargin(1);
|
||||||
|
|
||||||
|
@ -234,6 +238,43 @@ void Split::paintEvent(QPaintEvent *)
|
||||||
painter.fillRect(this->rect(), this->themeManager.splits.background);
|
painter.fillRect(this->rect(), this->themeManager.splits.background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Split::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
this->handleModifiers(event, event->modifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->buttons() == Qt::LeftButton && event->modifiers() & Qt::AltModifier) {
|
||||||
|
this->drag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
this->view.unsetCursor();
|
||||||
|
this->handleModifiers(event, event->modifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split::keyReleaseEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
this->view.unsetCursor();
|
||||||
|
this->handleModifiers(event, event->modifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split::handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers)
|
||||||
|
{
|
||||||
|
if (modifiers == Qt::AltModifier) {
|
||||||
|
this->setCursor(Qt::SizeAllCursor);
|
||||||
|
event->accept();
|
||||||
|
// } else if (modifiers == Qt::ControlModifier) {
|
||||||
|
// this->setCursor(Qt::SplitHCursor);
|
||||||
|
// event->accept();
|
||||||
|
} else {
|
||||||
|
this->setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Slots
|
/// Slots
|
||||||
void Split::doAddSplit()
|
void Split::doAddSplit()
|
||||||
{
|
{
|
||||||
|
@ -509,5 +550,32 @@ void Split::doDecFlexY()
|
||||||
{
|
{
|
||||||
this->setFlexSizeY(this->getFlexSizeY() * (1 / 1.2));
|
this->setFlexSizeY(this->getFlexSizeY() * (1 / 1.2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Split::drag()
|
||||||
|
{
|
||||||
|
auto container = dynamic_cast<SplitContainer *>(this->parentWidget());
|
||||||
|
|
||||||
|
if (container != nullptr) {
|
||||||
|
SplitContainer::isDraggingSplit = true;
|
||||||
|
SplitContainer::draggingSplit = this;
|
||||||
|
|
||||||
|
auto originalLocation = container->removeFromLayout(this);
|
||||||
|
|
||||||
|
QDrag *drag = new QDrag(this);
|
||||||
|
QMimeData *mimeData = new QMimeData;
|
||||||
|
|
||||||
|
mimeData->setData("chatterino/split", "xD");
|
||||||
|
|
||||||
|
drag->setMimeData(mimeData);
|
||||||
|
|
||||||
|
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
|
||||||
|
|
||||||
|
if (dropAction == Qt::IgnoreAction) {
|
||||||
|
container->addToLayout(this, originalLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
SplitContainer::isDraggingSplit = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -68,8 +68,14 @@ public:
|
||||||
void layoutMessages();
|
void layoutMessages();
|
||||||
void updateGifEmotes();
|
void updateGifEmotes();
|
||||||
|
|
||||||
|
void drag();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent *) override;
|
virtual void paintEvent(QPaintEvent *) override;
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent *) override;
|
||||||
|
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
virtual void keyPressEvent(QKeyEvent *) override;
|
||||||
|
virtual void keyReleaseEvent(QKeyEvent *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SplitContainer &parentPage;
|
SplitContainer &parentPage;
|
||||||
|
@ -87,6 +93,7 @@ private:
|
||||||
void setChannel(SharedChannel newChannel);
|
void setChannel(SharedChannel newChannel);
|
||||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||||
void channelNameUpdated(const std::string &newChannelName);
|
void channelNameUpdated(const std::string &newChannelName);
|
||||||
|
void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Add new split to the notebook page that this chat widget is in
|
// Add new split to the notebook page that this chat widget is in
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "util/helpers.hpp"
|
#include "util/helpers.hpp"
|
||||||
|
#include "util/layoutcreator.hpp"
|
||||||
#include "widgets/helper/notebooktab.hpp"
|
#include "widgets/helper/notebooktab.hpp"
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
|
|
Loading…
Reference in a new issue