Renamed private members
This commit is contained in:
@@ -43,29 +43,29 @@ Qt::KeyboardModifiers Split::modifierStatus = Qt::NoModifier;
|
||||
Split::Split(SplitContainer *parent)
|
||||
: Split(static_cast<QWidget *>(parent))
|
||||
{
|
||||
this->container = parent;
|
||||
this->container_ = parent;
|
||||
}
|
||||
|
||||
Split::Split(QWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
, container(nullptr)
|
||||
, channel(Channel::getEmpty())
|
||||
, vbox(this)
|
||||
, header(this)
|
||||
, view(this)
|
||||
, input(this)
|
||||
, overlay(new SplitOverlay(this))
|
||||
, container_(nullptr)
|
||||
, channel_(Channel::getEmpty())
|
||||
, vbox_(this)
|
||||
, header_(this)
|
||||
, view_(this)
|
||||
, input_(this)
|
||||
, overlay_(new SplitOverlay(this))
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
this->setMouseTracking(true);
|
||||
|
||||
this->vbox.setSpacing(0);
|
||||
this->vbox.setMargin(1);
|
||||
this->vbox_.setSpacing(0);
|
||||
this->vbox_.setMargin(1);
|
||||
|
||||
this->vbox.addWidget(&this->header);
|
||||
this->vbox.addWidget(&this->view, 1);
|
||||
this->vbox.addWidget(&this->input);
|
||||
this->vbox_.addWidget(&this->header_);
|
||||
this->vbox_.addWidget(&this->view_, 1);
|
||||
this->vbox_.addWidget(&this->input_);
|
||||
|
||||
// Initialize chat widget-wide hotkeys
|
||||
// CTRL+W: Close Split
|
||||
@@ -90,148 +90,148 @@ Split::Split(QWidget *parent)
|
||||
// CreateShortcut(this, "ALT+SHIFT+UP", &Split::doIncFlexY);
|
||||
// CreateShortcut(this, "ALT+SHIFT+DOWN", &Split::doDecFlexY);
|
||||
|
||||
this->input.ui_.textEdit->installEventFilter(parent);
|
||||
this->input_.ui_.textEdit->installEventFilter(parent);
|
||||
|
||||
this->view.mouseDown.connect([this](QMouseEvent *) {
|
||||
this->view_.mouseDown.connect([this](QMouseEvent *) {
|
||||
//
|
||||
this->giveFocus(Qt::MouseFocusReason);
|
||||
});
|
||||
this->view.selectionChanged.connect([this]() {
|
||||
if (view.hasSelection()) {
|
||||
this->input.clearSelection();
|
||||
this->view_.selectionChanged.connect([this]() {
|
||||
if (view_.hasSelection()) {
|
||||
this->input_.clearSelection();
|
||||
}
|
||||
});
|
||||
|
||||
this->input.textChanged.connect([=](const QString &newText) {
|
||||
this->input_.textChanged.connect([=](const QString &newText) {
|
||||
if (app->settings->showEmptyInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newText.length() == 0) {
|
||||
this->input.hide();
|
||||
} else if (this->input.isHidden()) {
|
||||
this->input.show();
|
||||
this->input_.hide();
|
||||
} else if (this->input_.isHidden()) {
|
||||
this->input_.show();
|
||||
}
|
||||
});
|
||||
|
||||
app->settings->showEmptyInput.connect(
|
||||
[this](const bool &showEmptyInput, auto) {
|
||||
if (!showEmptyInput && this->input.getInputText().length() == 0) {
|
||||
this->input.hide();
|
||||
if (!showEmptyInput && this->input_.getInputText().length() == 0) {
|
||||
this->input_.hide();
|
||||
} else {
|
||||
this->input.show();
|
||||
this->input_.show();
|
||||
}
|
||||
},
|
||||
this->managedConnections);
|
||||
this->managedConnections_);
|
||||
|
||||
this->header.updateModerationModeIcon();
|
||||
this->overlay->hide();
|
||||
this->header_.updateModerationModeIcon();
|
||||
this->overlay_->hide();
|
||||
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
this->managedConnect(modifierStatusChanged, [this](Qt::KeyboardModifiers status) {
|
||||
if ((status == showSplitOverlayModifiers /*|| status == showAddSplitRegions*/) &&
|
||||
this->isMouseOver) {
|
||||
this->overlay->show();
|
||||
this->isMouseOver_) {
|
||||
this->overlay_->show();
|
||||
} else {
|
||||
this->overlay->hide();
|
||||
this->overlay_->hide();
|
||||
}
|
||||
});
|
||||
|
||||
this->input.ui_.textEdit->focused.connect([this] { this->focused.invoke(); });
|
||||
this->input.ui_.textEdit->focusLost.connect([this] { this->focusLost.invoke(); });
|
||||
this->input_.ui_.textEdit->focused.connect([this] { this->focused.invoke(); });
|
||||
this->input_.ui_.textEdit->focusLost.connect([this] { this->focusLost.invoke(); });
|
||||
}
|
||||
|
||||
Split::~Split()
|
||||
{
|
||||
this->usermodeChangedConnection.disconnect();
|
||||
this->roomModeChangedConnection.disconnect();
|
||||
this->channelIDChangedConnection.disconnect();
|
||||
this->indirectChannelChangedConnection.disconnect();
|
||||
this->usermodeChangedConnection_.disconnect();
|
||||
this->roomModeChangedConnection_.disconnect();
|
||||
this->channelIDChangedConnection_.disconnect();
|
||||
this->indirectChannelChangedConnection_.disconnect();
|
||||
}
|
||||
|
||||
ChannelView &Split::getChannelView()
|
||||
{
|
||||
return this->view;
|
||||
return this->view_;
|
||||
}
|
||||
|
||||
SplitContainer *Split::getContainer()
|
||||
{
|
||||
return this->container;
|
||||
return this->container_;
|
||||
}
|
||||
|
||||
bool Split::isInContainer() const
|
||||
{
|
||||
return this->container != nullptr;
|
||||
return this->container_ != nullptr;
|
||||
}
|
||||
|
||||
void Split::setContainer(SplitContainer *_container)
|
||||
void Split::setContainer(SplitContainer *container)
|
||||
{
|
||||
this->container = _container;
|
||||
this->container_ = container;
|
||||
}
|
||||
|
||||
IndirectChannel Split::getIndirectChannel()
|
||||
{
|
||||
return this->channel;
|
||||
return this->channel_;
|
||||
}
|
||||
|
||||
ChannelPtr Split::getChannel()
|
||||
{
|
||||
return this->channel.get();
|
||||
return this->channel_.get();
|
||||
}
|
||||
|
||||
void Split::setChannel(IndirectChannel newChannel)
|
||||
{
|
||||
this->channel = newChannel;
|
||||
this->channel_ = newChannel;
|
||||
|
||||
this->view.setChannel(newChannel.get());
|
||||
this->view_.setChannel(newChannel.get());
|
||||
|
||||
this->usermodeChangedConnection.disconnect();
|
||||
this->roomModeChangedConnection.disconnect();
|
||||
this->indirectChannelChangedConnection.disconnect();
|
||||
this->usermodeChangedConnection_.disconnect();
|
||||
this->roomModeChangedConnection_.disconnect();
|
||||
this->indirectChannelChangedConnection_.disconnect();
|
||||
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(newChannel.get().get());
|
||||
|
||||
if (tc != nullptr) {
|
||||
this->usermodeChangedConnection = tc->userStateChanged.connect([this] {
|
||||
this->header.updateModerationModeIcon();
|
||||
this->header.updateRoomModes();
|
||||
this->usermodeChangedConnection_ = tc->userStateChanged.connect([this] {
|
||||
this->header_.updateModerationModeIcon();
|
||||
this->header_.updateRoomModes();
|
||||
});
|
||||
|
||||
this->roomModeChangedConnection =
|
||||
tc->roomModesChanged.connect([this] { this->header.updateRoomModes(); });
|
||||
this->roomModeChangedConnection_ =
|
||||
tc->roomModesChanged.connect([this] { this->header_.updateRoomModes(); });
|
||||
}
|
||||
|
||||
this->indirectChannelChangedConnection = newChannel.getChannelChanged().connect([this] { //
|
||||
QTimer::singleShot(0, [this] { this->setChannel(this->channel); });
|
||||
this->indirectChannelChangedConnection_ = newChannel.getChannelChanged().connect([this] { //
|
||||
QTimer::singleShot(0, [this] { this->setChannel(this->channel_); });
|
||||
});
|
||||
|
||||
this->header.updateModerationModeIcon();
|
||||
this->header.updateChannelText();
|
||||
this->header.updateRoomModes();
|
||||
this->header_.updateModerationModeIcon();
|
||||
this->header_.updateChannelText();
|
||||
this->header_.updateRoomModes();
|
||||
|
||||
this->channelChanged.invoke();
|
||||
}
|
||||
|
||||
void Split::setModerationMode(bool value)
|
||||
{
|
||||
if (value != this->moderationMode) {
|
||||
this->moderationMode = value;
|
||||
this->header.updateModerationModeIcon();
|
||||
this->view.layoutMessages();
|
||||
if (value != this->moderationMode_) {
|
||||
this->moderationMode_ = value;
|
||||
this->header_.updateModerationModeIcon();
|
||||
this->view_.layoutMessages();
|
||||
}
|
||||
}
|
||||
|
||||
bool Split::getModerationMode() const
|
||||
{
|
||||
return this->moderationMode;
|
||||
return this->moderationMode_;
|
||||
}
|
||||
|
||||
void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
||||
std::function<void(bool)> callback)
|
||||
{
|
||||
if (this->selectChannelDialog.hasElement()) {
|
||||
this->selectChannelDialog->raise();
|
||||
if (this->selectChannelDialog_.hasElement()) {
|
||||
this->selectChannelDialog_->raise();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -246,39 +246,39 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
||||
if (dialog->hasSeletedChannel()) {
|
||||
this->setChannel(dialog->getSelectedChannel());
|
||||
if (this->isInContainer()) {
|
||||
this->container->refreshTabTitle();
|
||||
this->container_->refreshTabTitle();
|
||||
}
|
||||
}
|
||||
|
||||
callback(dialog->hasSeletedChannel());
|
||||
this->selectChannelDialog = nullptr;
|
||||
this->selectChannelDialog_ = nullptr;
|
||||
});
|
||||
this->selectChannelDialog = dialog;
|
||||
this->selectChannelDialog_ = dialog;
|
||||
}
|
||||
|
||||
void Split::layoutMessages()
|
||||
{
|
||||
this->view.layoutMessages();
|
||||
this->view_.layoutMessages();
|
||||
}
|
||||
|
||||
void Split::updateGifEmotes()
|
||||
{
|
||||
this->view.queueUpdate();
|
||||
this->view_.queueUpdate();
|
||||
}
|
||||
|
||||
void Split::updateLastReadMessage()
|
||||
{
|
||||
this->view.updateLastReadMessage();
|
||||
this->view_.updateLastReadMessage();
|
||||
}
|
||||
|
||||
void Split::giveFocus(Qt::FocusReason reason)
|
||||
{
|
||||
this->input.ui_.textEdit->setFocus(reason);
|
||||
this->input_.ui_.textEdit->setFocus(reason);
|
||||
}
|
||||
|
||||
bool Split::hasFocus() const
|
||||
{
|
||||
return this->input.ui_.textEdit->hasFocus();
|
||||
return this->input_.ui_.textEdit->hasFocus();
|
||||
}
|
||||
|
||||
void Split::paintEvent(QPaintEvent *)
|
||||
@@ -296,13 +296,13 @@ void Split::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
void Split::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
this->view.unsetCursor();
|
||||
this->view_.unsetCursor();
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
}
|
||||
|
||||
void Split::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
this->view.unsetCursor();
|
||||
this->view_.unsetCursor();
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
}
|
||||
|
||||
@@ -310,29 +310,29 @@ void Split::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
BaseWidget::resizeEvent(event);
|
||||
|
||||
this->overlay->setGeometry(this->rect());
|
||||
this->overlay_->setGeometry(this->rect());
|
||||
}
|
||||
|
||||
void Split::enterEvent(QEvent *event)
|
||||
{
|
||||
this->isMouseOver = true;
|
||||
this->isMouseOver_ = true;
|
||||
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
|
||||
if (modifierStatus == showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/) {
|
||||
this->overlay->show();
|
||||
this->overlay_->show();
|
||||
}
|
||||
|
||||
if (this->container != nullptr) {
|
||||
this->container->resetMouseStatus();
|
||||
if (this->container_ != nullptr) {
|
||||
this->container_->resetMouseStatus();
|
||||
}
|
||||
}
|
||||
|
||||
void Split::leaveEvent(QEvent *event)
|
||||
{
|
||||
this->isMouseOver = false;
|
||||
this->isMouseOver_ = false;
|
||||
|
||||
this->overlay->hide();
|
||||
this->overlay_->hide();
|
||||
|
||||
this->handleModifiers(QGuiApplication::queryKeyboardModifiers());
|
||||
}
|
||||
@@ -353,15 +353,15 @@ void Split::handleModifiers(Qt::KeyboardModifiers modifiers)
|
||||
/// Slots
|
||||
void Split::doAddSplit()
|
||||
{
|
||||
if (this->container) {
|
||||
this->container->appendNewSplit(true);
|
||||
if (this->container_) {
|
||||
this->container_->appendNewSplit(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Split::doCloseSplit()
|
||||
{
|
||||
if (this->container) {
|
||||
this->container->deleteSplit(this);
|
||||
if (this->container_) {
|
||||
this->container_->deleteSplit(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ void Split::doPopup()
|
||||
|
||||
void Split::doClearChat()
|
||||
{
|
||||
this->view.clearMessages();
|
||||
this->view_.clearMessages();
|
||||
}
|
||||
|
||||
void Split::doOpenChannel()
|
||||
@@ -418,7 +418,7 @@ void Split::doOpenPopupPlayer()
|
||||
void Split::doOpenStreamlink()
|
||||
{
|
||||
try {
|
||||
Start(this->getChannel()->name);
|
||||
openStreamlinkForChannel(this->getChannel()->name);
|
||||
} catch (const Exception &ex) {
|
||||
Log("Error in doOpenStreamlink: {}", ex.what());
|
||||
}
|
||||
@@ -431,8 +431,8 @@ void Split::doOpenViewerList()
|
||||
viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar |
|
||||
QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable);
|
||||
viewerDock->resize(0.5 * this->width(),
|
||||
this->height() - this->header.height() - this->input.height());
|
||||
viewerDock->move(0, this->header.height());
|
||||
this->height() - this->header_.height() - this->input_.height());
|
||||
viewerDock->move(0, this->header_.height());
|
||||
|
||||
auto multiWidget = new QWidget(viewerDock);
|
||||
auto dockVbox = new QVBoxLayout(viewerDock);
|
||||
@@ -521,7 +521,7 @@ void Split::doOpenUserInfoPopup(const QString &user)
|
||||
|
||||
void Split::doCopy()
|
||||
{
|
||||
QApplication::clipboard()->setText(this->view.getSelectedText());
|
||||
QApplication::clipboard()->setText(this->view_.getSelectedText());
|
||||
}
|
||||
|
||||
void Split::doSearch()
|
||||
|
||||
@@ -88,34 +88,34 @@ protected:
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
|
||||
private:
|
||||
SplitContainer *container;
|
||||
IndirectChannel channel;
|
||||
|
||||
QVBoxLayout vbox;
|
||||
SplitHeader header;
|
||||
ChannelView view;
|
||||
SplitInput input;
|
||||
SplitOverlay *overlay;
|
||||
|
||||
NullablePtr<SelectChannelDialog> selectChannelDialog;
|
||||
|
||||
bool moderationMode = false;
|
||||
|
||||
bool isMouseOver = false;
|
||||
bool isDragging = false;
|
||||
|
||||
pajlada::Signals::Connection channelIDChangedConnection;
|
||||
pajlada::Signals::Connection usermodeChangedConnection;
|
||||
pajlada::Signals::Connection roomModeChangedConnection;
|
||||
|
||||
pajlada::Signals::Connection indirectChannelChangedConnection;
|
||||
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
|
||||
|
||||
void doOpenUserInfoPopup(const QString &user);
|
||||
void channelNameUpdated(const QString &newChannelName);
|
||||
void handleModifiers(Qt::KeyboardModifiers modifiers);
|
||||
|
||||
SplitContainer *container_;
|
||||
IndirectChannel channel_;
|
||||
|
||||
QVBoxLayout vbox_;
|
||||
SplitHeader header_;
|
||||
ChannelView view_;
|
||||
SplitInput input_;
|
||||
SplitOverlay *overlay_;
|
||||
|
||||
NullablePtr<SelectChannelDialog> selectChannelDialog_;
|
||||
|
||||
bool moderationMode_ = false;
|
||||
|
||||
bool isMouseOver_ = false;
|
||||
bool isDragging_ = false;
|
||||
|
||||
pajlada::Signals::Connection channelIDChangedConnection_;
|
||||
pajlada::Signals::Connection usermodeChangedConnection_;
|
||||
pajlada::Signals::Connection roomModeChangedConnection_;
|
||||
|
||||
pajlada::Signals::Connection indirectChannelChangedConnection_;
|
||||
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||
|
||||
public slots:
|
||||
// Add new split to the notebook page that this chat widget is in
|
||||
// This is only activated from the menu now. Hotkey is handled in Notebook
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
#include "widgets/helper/DropPreview.hpp"
|
||||
#include "widgets/helper/NotebookTab.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
|
||||
@@ -41,14 +40,14 @@ public:
|
||||
struct Position final {
|
||||
private:
|
||||
Position() = default;
|
||||
Position(Node *_relativeNode, Direction _direcion)
|
||||
: relativeNode(_relativeNode)
|
||||
, direction(_direcion)
|
||||
Position(Node *relativeNode, Direction direcion)
|
||||
: relativeNode_(relativeNode)
|
||||
, direction_(direcion)
|
||||
{
|
||||
}
|
||||
|
||||
Node *relativeNode;
|
||||
Direction direction;
|
||||
Node *relativeNode_;
|
||||
Direction direction_;
|
||||
|
||||
friend struct Node;
|
||||
friend class SplitContainer;
|
||||
@@ -91,15 +90,6 @@ public:
|
||||
const std::vector<std::unique_ptr<Node>> &getChildren();
|
||||
|
||||
private:
|
||||
Type type;
|
||||
Split *split;
|
||||
Node *preferedFocusTarget;
|
||||
Node *parent;
|
||||
QRectF geometry;
|
||||
qreal flexH = 1;
|
||||
qreal flexV = 1;
|
||||
std::vector<std::unique_ptr<Node>> children;
|
||||
|
||||
Node();
|
||||
Node(Split *_split, Node *_parent);
|
||||
|
||||
@@ -107,17 +97,26 @@ public:
|
||||
Node *findNodeContainingSplit(Split *_split);
|
||||
void insertSplitRelative(Split *_split, Direction _direction);
|
||||
void nestSplitIntoCollection(Split *_split, Direction _direction);
|
||||
void _insertNextToThis(Split *_split, Direction _direction);
|
||||
void insertNextToThis(Split *_split, Direction _direction);
|
||||
void setSplit(Split *_split);
|
||||
Position releaseSplit();
|
||||
qreal getFlex(bool isVertical);
|
||||
qreal getSize(bool isVertical);
|
||||
qreal getChildrensTotalFlex(bool isVertical);
|
||||
void layout(bool addSpacing, float _scale, std::vector<DropRect> &dropRects,
|
||||
void layout(bool addSpacing, float _scale, std::vector<DropRect> &dropRects_,
|
||||
std::vector<ResizeRect> &resizeRects);
|
||||
|
||||
static Type toContainerType(Direction _dir);
|
||||
|
||||
Type type_;
|
||||
Split *split_;
|
||||
Node *preferedFocusTarget_;
|
||||
Node *parent_;
|
||||
QRectF geometry_;
|
||||
qreal flexH_ = 1;
|
||||
qreal flexV_ = 1;
|
||||
std::vector<std::unique_ptr<Node>> children_;
|
||||
|
||||
friend class SplitContainer;
|
||||
};
|
||||
|
||||
@@ -139,9 +138,9 @@ private:
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
|
||||
private:
|
||||
std::vector<DropRect> rects;
|
||||
QPoint mouseOverPoint;
|
||||
SplitContainer *parent;
|
||||
std::vector<DropRect> rects_;
|
||||
QPoint mouseOverPoint_;
|
||||
SplitContainer *parent_;
|
||||
};
|
||||
|
||||
class ResizeHandle final : public QWidget
|
||||
@@ -161,8 +160,8 @@ private:
|
||||
friend class SplitContainer;
|
||||
|
||||
private:
|
||||
bool vertical;
|
||||
bool isMouseDown = false;
|
||||
bool vertical_;
|
||||
bool isMouseDown_ = false;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -186,7 +185,7 @@ public:
|
||||
NotebookTab *getTab() const;
|
||||
Node *getBaseNode();
|
||||
|
||||
void setTab(NotebookTab *tab);
|
||||
void setTab(NotebookTab *tab_);
|
||||
void hideResizeHandles();
|
||||
void resetMouseStatus();
|
||||
|
||||
@@ -206,6 +205,16 @@ protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
void layout();
|
||||
void setSelected(Split *selected_);
|
||||
void selectSplitRecursive(Node *node, Direction direction);
|
||||
void focusSplitRecursive(Node *node, Direction direction);
|
||||
void setPreferedTargetRecursive(Node *node);
|
||||
|
||||
void addSplit(Split *split);
|
||||
|
||||
void decodeNodeRecusively(QJsonObject &obj, Node *node);
|
||||
|
||||
struct DropRegion {
|
||||
QRect rect;
|
||||
std::pair<int, int> position;
|
||||
@@ -217,30 +226,19 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
void addSplit(Split *split);
|
||||
std::vector<DropRect> dropRects_;
|
||||
std::vector<DropRegion> dropRegions_;
|
||||
DropOverlay overlay_;
|
||||
std::vector<std::unique_ptr<ResizeHandle>> resizeHandles_;
|
||||
QPoint mouseOverPoint_;
|
||||
|
||||
std::vector<DropRect> dropRects;
|
||||
std::vector<DropRegion> dropRegions;
|
||||
NotebookPageDropPreview dropPreview;
|
||||
DropOverlay overlay;
|
||||
std::vector<std::unique_ptr<ResizeHandle>> resizeHandles;
|
||||
QPoint mouseOverPoint;
|
||||
Node baseNode_;
|
||||
Split *selected_;
|
||||
|
||||
void layout();
|
||||
NotebookTab *tab_;
|
||||
std::vector<Split *> splits_;
|
||||
|
||||
Node baseNode;
|
||||
Split *selected;
|
||||
void setSelected(Split *selected);
|
||||
void selectSplitRecursive(Node *node, Direction direction);
|
||||
void focusSplitRecursive(Node *node, Direction direction);
|
||||
void setPreferedTargetRecursive(Node *node);
|
||||
|
||||
NotebookTab *tab;
|
||||
std::vector<Split *> splits;
|
||||
|
||||
bool isDragging = false;
|
||||
|
||||
void decodeNodeRecusively(QJsonObject &obj, Node *node);
|
||||
bool isDragging_ = false;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace chatterino {
|
||||
|
||||
SplitHeader::SplitHeader(Split *_split)
|
||||
: BaseWidget(_split)
|
||||
, split(_split)
|
||||
, split_(_split)
|
||||
{
|
||||
this->split->focused.connect([this]() { this->themeChangedEvent(); });
|
||||
this->split->focusLost.connect([this]() { this->themeChangedEvent(); });
|
||||
this->split_->focused.connect([this]() { this->themeChangedEvent(); });
|
||||
this->split_->focusLost.connect([this]() { this->themeChangedEvent(); });
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
@@ -44,7 +44,7 @@ SplitHeader::SplitHeader(Split *_split)
|
||||
title->setHasOffset(false);
|
||||
|
||||
// mode button
|
||||
auto mode = layout.emplace<RippleEffectLabel>(nullptr).assign(&this->modeButton);
|
||||
auto mode = layout.emplace<RippleEffectLabel>(nullptr).assign(&this->modeButton_);
|
||||
|
||||
mode->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
mode->hide();
|
||||
@@ -53,38 +53,38 @@ SplitHeader::SplitHeader(Split *_split)
|
||||
|
||||
QObject::connect(mode.getElement(), &RippleEffectLabel::clicked, this, [this] {
|
||||
QTimer::singleShot(80, this, [&, this] {
|
||||
ChannelPtr _channel = this->split->getChannel();
|
||||
ChannelPtr _channel = this->split_->getChannel();
|
||||
if (_channel->hasModRights()) {
|
||||
this->modeMenu.move(
|
||||
this->modeButton->mapToGlobal(QPoint(0, this->modeButton->height())));
|
||||
this->modeMenu.show();
|
||||
this->modeMenu_.move(
|
||||
this->modeButton_->mapToGlobal(QPoint(0, this->modeButton_->height())));
|
||||
this->modeMenu_.show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// moderation mode
|
||||
auto moderator = layout.emplace<RippleEffectButton>(this).assign(&this->moderationButton);
|
||||
auto moderator = layout.emplace<RippleEffectButton>(this).assign(&this->moderationButton_);
|
||||
|
||||
QObject::connect(moderator.getElement(), &RippleEffectButton::clicked, this,
|
||||
[this, moderator]() mutable {
|
||||
this->split->setModerationMode(!this->split->getModerationMode());
|
||||
this->split_->setModerationMode(!this->split_->getModerationMode());
|
||||
|
||||
moderator->setDim(!this->split->getModerationMode());
|
||||
moderator->setDim(!this->split_->getModerationMode());
|
||||
});
|
||||
|
||||
this->updateModerationModeIcon();
|
||||
|
||||
// dropdown label
|
||||
auto dropdown = layout.emplace<RippleEffectButton>(this).assign(&this->dropdownButton);
|
||||
auto dropdown = layout.emplace<RippleEffectButton>(this).assign(&this->dropdownButton_);
|
||||
dropdown->setMouseTracking(true);
|
||||
// dropdown->setPixmap(*app->resources->splitHeaderContext->getPixmap());
|
||||
// dropdown->setScaleIndependantSize(23, 23);
|
||||
this->addDropdownItems(dropdown.getElement());
|
||||
QObject::connect(dropdown.getElement(), &RippleEffectButton::leftMousePress, this, [this] {
|
||||
QTimer::singleShot(80, [&, this] {
|
||||
this->dropdownMenu.move(
|
||||
this->dropdownButton->mapToGlobal(QPoint(0, this->dropdownButton->height())));
|
||||
this->dropdownMenu.show();
|
||||
this->dropdownMenu_.move(
|
||||
this->dropdownButton_->mapToGlobal(QPoint(0, this->dropdownButton_->height())));
|
||||
this->dropdownMenu_.show();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -97,34 +97,34 @@ SplitHeader::SplitHeader(Split *_split)
|
||||
|
||||
this->initializeChannelSignals();
|
||||
|
||||
this->split->channelChanged.connect([this]() {
|
||||
this->split_->channelChanged.connect([this]() {
|
||||
this->initializeChannelSignals(); //
|
||||
});
|
||||
|
||||
this->managedConnect(app->accounts->twitch.currentUserChanged,
|
||||
[this] { this->updateModerationModeIcon(); });
|
||||
|
||||
this->addModeActions(this->modeMenu);
|
||||
this->addModeActions(this->modeMenu_);
|
||||
|
||||
this->setMouseTracking(true);
|
||||
}
|
||||
|
||||
SplitHeader::~SplitHeader()
|
||||
{
|
||||
this->onlineStatusChangedConnection.disconnect();
|
||||
this->onlineStatusChangedConnection_.disconnect();
|
||||
}
|
||||
|
||||
void SplitHeader::addDropdownItems(RippleEffectButton *)
|
||||
{
|
||||
// clang-format off
|
||||
this->dropdownMenu.addAction("New split", this->split, &Split::doAddSplit, QKeySequence(tr("Ctrl+T")));
|
||||
this->dropdownMenu.addAction("Close split", this->split, &Split::doCloseSplit, QKeySequence(tr("Ctrl+W")));
|
||||
this->dropdownMenu.addAction("Change channel", this->split, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R")));
|
||||
this->dropdownMenu.addSeparator();
|
||||
this->dropdownMenu.addAction("Viewer list", this->split, &Split::doOpenViewerList);
|
||||
this->dropdownMenu.addAction("Search", this->split, &Split::doSearch, QKeySequence(tr("Ctrl+F")));
|
||||
this->dropdownMenu.addSeparator();
|
||||
this->dropdownMenu.addAction("Popup", this->split, &Split::doPopup);
|
||||
this->dropdownMenu_.addAction("New split", this->split_, &Split::doAddSplit, QKeySequence(tr("Ctrl+T")));
|
||||
this->dropdownMenu_.addAction("Close split", this->split_, &Split::doCloseSplit, QKeySequence(tr("Ctrl+W")));
|
||||
this->dropdownMenu_.addAction("Change channel", this->split_, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R")));
|
||||
this->dropdownMenu_.addSeparator();
|
||||
this->dropdownMenu_.addAction("Viewer list", this->split_, &Split::doOpenViewerList);
|
||||
this->dropdownMenu_.addAction("Search", this->split_, &Split::doSearch, QKeySequence(tr("Ctrl+F")));
|
||||
this->dropdownMenu_.addSeparator();
|
||||
this->dropdownMenu_.addAction("Popup", this->split_, &Split::doPopup);
|
||||
#ifdef USEWEBENGINE
|
||||
this->dropdownMenu.addAction("Start watching", this, [this]{
|
||||
ChannelPtr _channel = this->split->getChannel();
|
||||
@@ -137,15 +137,15 @@ void SplitHeader::addDropdownItems(RippleEffectButton *)
|
||||
}
|
||||
});
|
||||
#endif
|
||||
this->dropdownMenu.addAction("Open browser", this->split, &Split::doOpenChannel);
|
||||
this->dropdownMenu_.addAction("Open browser", this->split_, &Split::doOpenChannel);
|
||||
#ifndef USEWEBENGINE
|
||||
this->dropdownMenu.addAction("Open browser popup", this->split, &Split::doOpenPopupPlayer);
|
||||
this->dropdownMenu_.addAction("Open browser popup", this->split_, &Split::doOpenPopupPlayer);
|
||||
#endif
|
||||
this->dropdownMenu.addAction("Open streamlink", this->split, &Split::doOpenStreamlink);
|
||||
this->dropdownMenu.addSeparator();
|
||||
this->dropdownMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
|
||||
this->dropdownMenu.addAction("Reconnect", this, SLOT(menuManualReconnect()));
|
||||
this->dropdownMenu.addAction("Clear messages", this->split, &Split::doClearChat);
|
||||
this->dropdownMenu_.addAction("Open streamlink", this->split_, &Split::doOpenStreamlink);
|
||||
this->dropdownMenu_.addSeparator();
|
||||
this->dropdownMenu_.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes()));
|
||||
this->dropdownMenu_.addAction("Reconnect", this, SLOT(menuManualReconnect()));
|
||||
this->dropdownMenu_.addAction("Clear messages", this->split_, &Split::doClearChat);
|
||||
// this->dropdownMenu.addSeparator();
|
||||
// this->dropdownMenu.addAction("Show changelog", this, SLOT(menuShowChangelog()));
|
||||
// clang-format on
|
||||
@@ -158,8 +158,8 @@ void SplitHeader::updateRoomModes()
|
||||
|
||||
void SplitHeader::setupModeLabel(RippleEffectLabel &label)
|
||||
{
|
||||
this->managedConnections.push_back(this->modeUpdateRequested_.connect([this, &label] {
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(this->split->getChannel().get());
|
||||
this->managedConnections_.push_back(this->modeUpdateRequested_.connect([this, &label] {
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
|
||||
|
||||
// return if the channel is not a twitch channel
|
||||
if (twitchChannel == nullptr) {
|
||||
@@ -224,11 +224,11 @@ void SplitHeader::addModeActions(QMenu &menu)
|
||||
menu.addAction(setSlow);
|
||||
menu.addAction(setR9k);
|
||||
|
||||
this->managedConnections.push_back(this->modeUpdateRequested_.connect( //
|
||||
this->managedConnections_.push_back(this->modeUpdateRequested_.connect( //
|
||||
[this, setSub, setEmote, setSlow, setR9k]() {
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(this->split->getChannel().get());
|
||||
auto twitchChannel = dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
|
||||
if (twitchChannel == nullptr) {
|
||||
this->modeButton->hide();
|
||||
this->modeButton_->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ void SplitHeader::addModeActions(QMenu &menu)
|
||||
action->setChecked(!action->isChecked());
|
||||
|
||||
qDebug() << command;
|
||||
this->split->getChannel().get()->sendMessage(command);
|
||||
this->split_->getChannel().get()->sendMessage(command);
|
||||
};
|
||||
|
||||
QObject::connect(setSub, &QAction::triggered, this,
|
||||
@@ -260,7 +260,7 @@ void SplitHeader::addModeActions(QMenu &menu)
|
||||
|
||||
QObject::connect(setSlow, &QAction::triggered, this, [setSlow, this]() {
|
||||
if (!setSlow->isChecked()) {
|
||||
this->split->getChannel().get()->sendMessage("/slowoff");
|
||||
this->split_->getChannel().get()->sendMessage("/slowoff");
|
||||
setSlow->setChecked(false);
|
||||
return;
|
||||
};
|
||||
@@ -268,7 +268,7 @@ void SplitHeader::addModeActions(QMenu &menu)
|
||||
int slowSec =
|
||||
QInputDialog::getInt(this, "", "Seconds:", 10, 0, 500, 1, &ok, Qt::FramelessWindowHint);
|
||||
if (ok) {
|
||||
this->split->getChannel().get()->sendMessage(QString("/slow %1").arg(slowSec));
|
||||
this->split_->getChannel().get()->sendMessage(QString("/slow %1").arg(slowSec));
|
||||
} else {
|
||||
setSlow->setChecked(false);
|
||||
}
|
||||
@@ -281,13 +281,13 @@ void SplitHeader::addModeActions(QMenu &menu)
|
||||
void SplitHeader::initializeChannelSignals()
|
||||
{
|
||||
// Disconnect any previous signal first
|
||||
this->onlineStatusChangedConnection.disconnect();
|
||||
this->onlineStatusChangedConnection_.disconnect();
|
||||
|
||||
auto channel = this->split->getChannel();
|
||||
auto channel = this->split_->getChannel();
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
this->managedConnections.emplace_back(twitchChannel->updateLiveInfo.connect([this]() {
|
||||
this->managedConnections_.emplace_back(twitchChannel->updateLiveInfo.connect([this]() {
|
||||
this->updateChannelText(); //
|
||||
}));
|
||||
}
|
||||
@@ -298,16 +298,16 @@ void SplitHeader::scaleChangedEvent(float scale)
|
||||
int w = int(28 * scale);
|
||||
|
||||
this->setFixedHeight(w);
|
||||
this->dropdownButton->setFixedWidth(w);
|
||||
this->moderationButton->setFixedWidth(w);
|
||||
this->dropdownButton_->setFixedWidth(w);
|
||||
this->moderationButton_->setFixedWidth(w);
|
||||
// this->titleLabel->setFont(
|
||||
// FontManager::getInstance().getFont(FontStyle::Medium, scale));
|
||||
}
|
||||
|
||||
void SplitHeader::updateChannelText()
|
||||
{
|
||||
auto indirectChannel = this->split->getIndirectChannel();
|
||||
auto channel = this->split->getChannel();
|
||||
auto indirectChannel = this->split_->getIndirectChannel();
|
||||
auto channel = this->split_->getChannel();
|
||||
|
||||
QString title = channel->name;
|
||||
|
||||
@@ -321,8 +321,8 @@ void SplitHeader::updateChannelText()
|
||||
const auto streamStatus = twitchChannel->getStreamStatus();
|
||||
|
||||
if (streamStatus.live) {
|
||||
this->isLive = true;
|
||||
this->tooltip = "<style>.center { text-align: center; }</style>"
|
||||
this->isLive_ = true;
|
||||
this->tooltip_ = "<style>.center { text-align: center; }</style>"
|
||||
"<p class = \"center\">" +
|
||||
streamStatus.title + "<br><br>" + streamStatus.game + "<br>" +
|
||||
(streamStatus.rerun ? "Vod-casting" : "Live") + " for " +
|
||||
@@ -338,7 +338,7 @@ void SplitHeader::updateChannelText()
|
||||
title += " (live)";
|
||||
}
|
||||
} else {
|
||||
this->tooltip = QString();
|
||||
this->tooltip_ = QString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ void SplitHeader::updateChannelText()
|
||||
title = "<empty>";
|
||||
}
|
||||
|
||||
this->isLive = false;
|
||||
this->isLive_ = false;
|
||||
this->titleLabel->setText(title);
|
||||
}
|
||||
|
||||
@@ -354,12 +354,12 @@ void SplitHeader::updateModerationModeIcon()
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
this->moderationButton->setPixmap(this->split->getModerationMode()
|
||||
this->moderationButton_->setPixmap(this->split_->getModerationMode()
|
||||
? *app->resources->moderationmode_enabled->getPixmap()
|
||||
: *app->resources->moderationmode_disabled->getPixmap());
|
||||
|
||||
bool modButtonVisible = false;
|
||||
ChannelPtr channel = this->split->getChannel();
|
||||
ChannelPtr channel = this->split_->getChannel();
|
||||
|
||||
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
@@ -367,7 +367,7 @@ void SplitHeader::updateModerationModeIcon()
|
||||
modButtonVisible = true;
|
||||
}
|
||||
|
||||
this->moderationButton->setVisible(modButtonVisible);
|
||||
this->moderationButton_->setVisible(modButtonVisible);
|
||||
}
|
||||
|
||||
void SplitHeader::paintEvent(QPaintEvent *)
|
||||
@@ -382,26 +382,26 @@ void SplitHeader::paintEvent(QPaintEvent *)
|
||||
void SplitHeader::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
this->dragging = true;
|
||||
this->dragging_ = true;
|
||||
|
||||
this->dragStart = event->pos();
|
||||
this->dragStart_ = event->pos();
|
||||
}
|
||||
|
||||
this->doubleClicked = false;
|
||||
this->doubleClicked_ = false;
|
||||
}
|
||||
|
||||
void SplitHeader::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (this->dragging && event->button() == Qt::LeftButton) {
|
||||
if (this->dragging_ && event->button() == Qt::LeftButton) {
|
||||
QPoint pos = event->globalPos();
|
||||
|
||||
if (!showingHelpTooltip) {
|
||||
this->showingHelpTooltip = true;
|
||||
if (!showingHelpTooltip_) {
|
||||
this->showingHelpTooltip_ = true;
|
||||
|
||||
QTimer::singleShot(400, this, [this, pos] {
|
||||
if (this->doubleClicked) {
|
||||
this->doubleClicked = false;
|
||||
this->showingHelpTooltip = false;
|
||||
if (this->doubleClicked_) {
|
||||
this->doubleClicked_ = false;
|
||||
this->showingHelpTooltip_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -416,22 +416,22 @@ void SplitHeader::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
QTimer::singleShot(3000, widget, [this, widget] {
|
||||
widget->close();
|
||||
this->showingHelpTooltip = false;
|
||||
this->showingHelpTooltip_ = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this->dragging = false;
|
||||
this->dragging_ = false;
|
||||
}
|
||||
|
||||
void SplitHeader::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (this->dragging) {
|
||||
if (std::abs(this->dragStart.x() - event->pos().x()) > int(12 * this->getScale()) ||
|
||||
std::abs(this->dragStart.y() - event->pos().y()) > int(12 * this->getScale())) {
|
||||
this->split->drag();
|
||||
this->dragging = false;
|
||||
if (this->dragging_) {
|
||||
if (std::abs(this->dragStart_.x() - event->pos().x()) > int(12 * this->getScale()) ||
|
||||
std::abs(this->dragStart_.y() - event->pos().y()) > int(12 * this->getScale())) {
|
||||
this->split_->drag();
|
||||
this->dragging_ = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,17 +439,17 @@ void SplitHeader::mouseMoveEvent(QMouseEvent *event)
|
||||
void SplitHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
this->split->doChangeChannel();
|
||||
this->split_->doChangeChannel();
|
||||
}
|
||||
this->doubleClicked = true;
|
||||
this->doubleClicked_ = true;
|
||||
}
|
||||
|
||||
void SplitHeader::enterEvent(QEvent *event)
|
||||
{
|
||||
if (!this->tooltip.isEmpty()) {
|
||||
if (!this->tooltip_.isEmpty()) {
|
||||
auto tooltipWidget = TooltipWidget::getInstance();
|
||||
tooltipWidget->moveTo(this, this->mapToGlobal(this->rect().bottomLeft()), false);
|
||||
tooltipWidget->setText(this->tooltip);
|
||||
tooltipWidget->setText(this->tooltip_);
|
||||
tooltipWidget->show();
|
||||
tooltipWidget->raise();
|
||||
}
|
||||
@@ -472,16 +472,16 @@ void SplitHeader::themeChangedEvent()
|
||||
{
|
||||
QPalette palette;
|
||||
|
||||
if (this->split->hasFocus()) {
|
||||
if (this->split_->hasFocus()) {
|
||||
palette.setColor(QPalette::Foreground, this->theme->splits.header.focusedText);
|
||||
} else {
|
||||
palette.setColor(QPalette::Foreground, this->theme->splits.header.text);
|
||||
}
|
||||
|
||||
if (this->theme->isLightTheme()) {
|
||||
this->dropdownButton->setPixmap(QPixmap(":/images/menu_black.png"));
|
||||
this->dropdownButton_->setPixmap(QPixmap(":/images/menu_black.png"));
|
||||
} else {
|
||||
this->dropdownButton->setPixmap(QPixmap(":/images/menu_white.png"));
|
||||
this->dropdownButton_->setPixmap(QPixmap(":/images/menu_white.png"));
|
||||
}
|
||||
|
||||
this->titleLabel->setPalette(palette);
|
||||
@@ -493,7 +493,7 @@ void SplitHeader::menuMoveSplit()
|
||||
|
||||
void SplitHeader::menuReloadChannelEmotes()
|
||||
{
|
||||
auto channel = this->split->getChannel();
|
||||
auto channel = this->split_->getChannel();
|
||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
if (twitchChannel) {
|
||||
|
||||
@@ -55,33 +55,32 @@ private:
|
||||
void setupModeLabel(RippleEffectLabel &label);
|
||||
void addDropdownItems(RippleEffectButton *label);
|
||||
|
||||
Split *const split;
|
||||
Split *const split_;
|
||||
|
||||
QPoint dragStart;
|
||||
bool dragging = false;
|
||||
bool doubleClicked = false;
|
||||
bool showingHelpTooltip = false;
|
||||
QPoint dragStart_;
|
||||
bool dragging_ = false;
|
||||
bool doubleClicked_ = false;
|
||||
bool showingHelpTooltip_ = false;
|
||||
|
||||
pajlada::Signals::Connection onlineStatusChangedConnection;
|
||||
pajlada::Signals::Connection onlineStatusChangedConnection_;
|
||||
|
||||
RippleEffectButton *dropdownButton = nullptr;
|
||||
RippleEffectButton *dropdownButton_ = nullptr;
|
||||
// Label *titleLabel;
|
||||
Label *titleLabel = nullptr;
|
||||
RippleEffectLabel *modeButton = nullptr;
|
||||
RippleEffectButton *moderationButton = nullptr;
|
||||
RippleEffectLabel *modeButton_ = nullptr;
|
||||
RippleEffectButton *moderationButton_ = nullptr;
|
||||
|
||||
QMenu dropdownMenu;
|
||||
QMenu modeMenu;
|
||||
QMenu dropdownMenu_;
|
||||
QMenu modeMenu_;
|
||||
|
||||
pajlada::Signals::NoArgSignal modeUpdateRequested_;
|
||||
|
||||
QString tooltip;
|
||||
bool isLive;
|
||||
QString tooltip_;
|
||||
bool isLive_;
|
||||
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||
|
||||
public slots:
|
||||
|
||||
void menuMoveSplit();
|
||||
void menuReloadChannelEmotes();
|
||||
void menuManualReconnect();
|
||||
|
||||
@@ -91,7 +91,7 @@ void SplitInput::initLayout()
|
||||
// clear channelview selection when selecting in the input
|
||||
QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable, [this](bool available) {
|
||||
if (available) {
|
||||
this->split_->view.clearSelection();
|
||||
this->split_->view_.clearSelection();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -254,7 +254,7 @@ void SplitInput::installKeyPressedEvent()
|
||||
notebook->selectPreviousTab();
|
||||
}
|
||||
} else if (event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier) {
|
||||
if (this->split_->view.hasSelection()) {
|
||||
if (this->split_->view_.hasSelection()) {
|
||||
this->split_->doCopy();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
void initLayout();
|
||||
void installKeyPressedEvent();
|
||||
void updateEmoteButton();
|
||||
|
||||
Split *const split_;
|
||||
std::unique_ptr<EmotePopup> emotePopup_;
|
||||
|
||||
@@ -56,11 +60,6 @@ private:
|
||||
QString currMsg_;
|
||||
int prevIndex_ = 0;
|
||||
|
||||
void initLayout();
|
||||
void installKeyPressedEvent();
|
||||
|
||||
void updateEmoteButton();
|
||||
|
||||
private slots:
|
||||
void editTextChanged();
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ namespace chatterino {
|
||||
|
||||
SplitOverlay::SplitOverlay(Split *parent)
|
||||
: BaseWidget(parent)
|
||||
, split(parent)
|
||||
, split_(parent)
|
||||
{
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
this->_layout = layout;
|
||||
this->layout_ = layout;
|
||||
layout->setMargin(1);
|
||||
layout->setSpacing(1);
|
||||
|
||||
@@ -30,11 +30,11 @@ SplitOverlay::SplitOverlay(Split *parent)
|
||||
layout->setColumnStretch(3, 1);
|
||||
|
||||
QPushButton *move = new QPushButton(getApp()->resources->split.move, QString());
|
||||
QPushButton *left = this->_left = new QPushButton(getApp()->resources->split.left, QString());
|
||||
QPushButton *right = this->_right =
|
||||
QPushButton *left = this->left_ = new QPushButton(getApp()->resources->split.left, QString());
|
||||
QPushButton *right = this->right_ =
|
||||
new QPushButton(getApp()->resources->split.right, QString());
|
||||
QPushButton *up = this->_up = new QPushButton(getApp()->resources->split.up, QString());
|
||||
QPushButton *down = this->_down = new QPushButton(getApp()->resources->split.down, QString());
|
||||
QPushButton *up = this->up_ = new QPushButton(getApp()->resources->split.up, QString());
|
||||
QPushButton *down = this->down_ = new QPushButton(getApp()->resources->split.down, QString());
|
||||
|
||||
move->setGraphicsEffect(new QGraphicsOpacityEffect(this));
|
||||
left->setGraphicsEffect(new QGraphicsOpacityEffect(this));
|
||||
@@ -98,7 +98,7 @@ void SplitOverlay::paintEvent(QPaintEvent *)
|
||||
}
|
||||
|
||||
QRect rect;
|
||||
switch (this->hoveredElement) {
|
||||
switch (this->hoveredElement_) {
|
||||
case SplitLeft: {
|
||||
rect = QRect(0, 0, this->width() / 2, this->height());
|
||||
} break;
|
||||
@@ -134,10 +134,10 @@ void SplitOverlay::resizeEvent(QResizeEvent *event)
|
||||
bool wideEnough = event->size().width() > 150 * _scale;
|
||||
bool highEnough = event->size().height() > 150 * _scale;
|
||||
|
||||
this->_left->setVisible(wideEnough);
|
||||
this->_right->setVisible(wideEnough);
|
||||
this->_up->setVisible(highEnough);
|
||||
this->_down->setVisible(highEnough);
|
||||
this->left_->setVisible(wideEnough);
|
||||
this->right_->setVisible(wideEnough);
|
||||
this->up_->setVisible(highEnough);
|
||||
this->down_->setVisible(highEnough);
|
||||
}
|
||||
|
||||
void SplitOverlay::mouseMoveEvent(QMouseEvent *event)
|
||||
@@ -169,7 +169,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched, QEvent *even
|
||||
effect->setOpacity(0.99);
|
||||
}
|
||||
|
||||
this->parent->hoveredElement = this->hoveredElement;
|
||||
this->parent->hoveredElement_ = this->hoveredElement;
|
||||
this->parent->update();
|
||||
} break;
|
||||
case QEvent::Leave: {
|
||||
@@ -180,27 +180,27 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched, QEvent *even
|
||||
effect->setOpacity(0.7);
|
||||
}
|
||||
|
||||
this->parent->hoveredElement = HoveredElement::None;
|
||||
this->parent->hoveredElement_ = HoveredElement::None;
|
||||
this->parent->update();
|
||||
} break;
|
||||
case QEvent::MouseButtonPress: {
|
||||
if (this->hoveredElement == HoveredElement::SplitMove) {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::LeftButton) {
|
||||
this->parent->split->drag();
|
||||
this->parent->split_->drag();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
case QEvent::MouseButtonRelease: {
|
||||
if (this->hoveredElement != HoveredElement::SplitMove) {
|
||||
SplitContainer *container = this->parent->split->getContainer();
|
||||
SplitContainer *container = this->parent->split_->getContainer();
|
||||
|
||||
if (container != nullptr) {
|
||||
auto *_split = new Split(container);
|
||||
auto dir = SplitContainer::Direction(this->hoveredElement +
|
||||
SplitContainer::Left - SplitLeft);
|
||||
container->insertSplit(_split, dir, this->parent->split);
|
||||
container->insertSplit(_split, dir, this->parent->split_);
|
||||
this->parent->hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,6 @@ protected:
|
||||
private:
|
||||
// fourtf: !!! preserve the order of left, up, right and down
|
||||
enum HoveredElement { None, SplitMove, SplitLeft, SplitUp, SplitRight, SplitDown };
|
||||
HoveredElement hoveredElement = None;
|
||||
Split *split;
|
||||
QGridLayout *_layout;
|
||||
QPushButton *_left;
|
||||
QPushButton *_up;
|
||||
QPushButton *_right;
|
||||
QPushButton *_down;
|
||||
|
||||
class ButtonEventFilter : public QObject
|
||||
{
|
||||
@@ -44,6 +37,14 @@ private:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
};
|
||||
|
||||
HoveredElement hoveredElement_ = None;
|
||||
Split *split_;
|
||||
QGridLayout *layout_;
|
||||
QPushButton *left_;
|
||||
QPushButton *up_;
|
||||
QPushButton *right_;
|
||||
QPushButton *down_;
|
||||
|
||||
friend class ButtonEventFilter;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user