Added x-attach-split-to-window command line arg (#2411)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include "widgets/helper/NotebookTab.hpp"
|
||||
#include "widgets/helper/ResizingTextEdit.hpp"
|
||||
#include "widgets/helper/SearchPopup.hpp"
|
||||
#include "widgets/splits/ClosedSplits.hpp"
|
||||
#include "widgets/splits/SplitContainer.hpp"
|
||||
#include "widgets/splits/SplitHeader.hpp"
|
||||
#include "widgets/splits/SplitInput.hpp"
|
||||
@@ -78,15 +77,8 @@ namespace {
|
||||
pajlada::Signals::Signal<Qt::KeyboardModifiers> Split::modifierStatusChanged;
|
||||
Qt::KeyboardModifiers Split::modifierStatus = Qt::NoModifier;
|
||||
|
||||
Split::Split(SplitContainer *parent)
|
||||
: Split(static_cast<QWidget *>(parent))
|
||||
{
|
||||
this->container_ = parent;
|
||||
}
|
||||
|
||||
Split::Split(QWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
, container_(nullptr)
|
||||
, channel_(Channel::getEmpty())
|
||||
, vbox_(new QVBoxLayout(this))
|
||||
, header_(new SplitHeader(this))
|
||||
@@ -173,7 +165,7 @@ Split::Split(QWidget *parent)
|
||||
});
|
||||
|
||||
this->view_->joinToChannel.connect([this](QString twitchChannel) {
|
||||
this->container_->appendNewSplit(false)->setChannel(
|
||||
this->openSplitRequested.invoke(
|
||||
getApp()->twitch.server->getOrAddChannel(twitchChannel));
|
||||
});
|
||||
|
||||
@@ -294,21 +286,6 @@ ChannelView &Split::getChannelView()
|
||||
return *this->view_;
|
||||
}
|
||||
|
||||
SplitContainer *Split::getContainer()
|
||||
{
|
||||
return this->container_;
|
||||
}
|
||||
|
||||
bool Split::isInContainer() const
|
||||
{
|
||||
return this->container_ != nullptr;
|
||||
}
|
||||
|
||||
void Split::setContainer(SplitContainer *container)
|
||||
{
|
||||
this->container_ = container;
|
||||
}
|
||||
|
||||
void Split::updateInputPlaceholder()
|
||||
{
|
||||
if (!this->getChannel()->isTwitchChannel())
|
||||
@@ -388,7 +365,7 @@ void Split::setChannel(IndirectChannel newChannel)
|
||||
}
|
||||
|
||||
this->channel_.get()->displayNameChanged.connect([this] {
|
||||
this->container_->refreshTab();
|
||||
this->actionRequested.invoke(Action::RefreshTab);
|
||||
});
|
||||
|
||||
this->channelChanged.invoke();
|
||||
@@ -435,10 +412,7 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
||||
if (dialog->hasSeletedChannel())
|
||||
{
|
||||
this->setChannel(dialog->getSelectedChannel());
|
||||
if (this->isInContainer())
|
||||
{
|
||||
this->container_->refreshTab();
|
||||
}
|
||||
this->actionRequested.invoke(Action::RefreshTab);
|
||||
}
|
||||
|
||||
callback(dialog->hasSeletedChannel());
|
||||
@@ -514,10 +488,7 @@ void Split::enterEvent(QEvent *event)
|
||||
this->overlay_->show();
|
||||
}
|
||||
|
||||
if (this->container_ != nullptr)
|
||||
{
|
||||
this->container_->resetMouseStatus();
|
||||
}
|
||||
this->actionRequested.invoke(Action::ResetMouseStatus);
|
||||
}
|
||||
|
||||
void Split::leaveEvent(QEvent *event)
|
||||
@@ -554,23 +525,12 @@ void Split::setIsTopRightSplit(bool value)
|
||||
/// Slots
|
||||
void Split::addSibling()
|
||||
{
|
||||
if (this->container_)
|
||||
{
|
||||
this->container_->appendNewSplit(true);
|
||||
}
|
||||
this->actionRequested.invoke(Action::AppendNewSplit);
|
||||
}
|
||||
|
||||
void Split::deleteFromContainer()
|
||||
{
|
||||
if (this->container_)
|
||||
{
|
||||
this->container_->deleteSplit(this);
|
||||
auto *tab = this->getContainer()->getTab();
|
||||
tab->connect(tab, &QWidget::destroyed, [tab]() mutable {
|
||||
ClosedSplits::invalidateTab(tab);
|
||||
});
|
||||
ClosedSplits::push({this->getChannel()->getName(), tab});
|
||||
}
|
||||
this->actionRequested.invoke(Action::Delete);
|
||||
}
|
||||
|
||||
void Split::changeChannel()
|
||||
|
||||
@@ -38,7 +38,6 @@ class Split : public BaseWidget, pajlada::Signals::SignalHolder
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Split(SplitContainer *parent);
|
||||
explicit Split(QWidget *parent);
|
||||
|
||||
~Split() override;
|
||||
@@ -48,7 +47,6 @@ public:
|
||||
pajlada::Signals::NoArgSignal focusLost;
|
||||
|
||||
ChannelView &getChannelView();
|
||||
SplitContainer *getContainer();
|
||||
|
||||
IndirectChannel getIndirectChannel();
|
||||
ChannelPtr getChannel();
|
||||
@@ -80,6 +78,24 @@ public:
|
||||
modifierStatusChanged;
|
||||
static Qt::KeyboardModifiers modifierStatus;
|
||||
|
||||
enum class Action {
|
||||
RefreshTab,
|
||||
ResetMouseStatus,
|
||||
AppendNewSplit,
|
||||
Delete,
|
||||
|
||||
SelectSplitLeft,
|
||||
SelectSplitRight,
|
||||
SelectSplitAbove,
|
||||
SelectSplitBelow,
|
||||
};
|
||||
|
||||
pajlada::Signals::Signal<Action> actionRequested;
|
||||
pajlada::Signals::Signal<ChannelPtr> openSplitRequested;
|
||||
|
||||
// args: (SplitContainer::Direction dir, Split* parent)
|
||||
pajlada::Signals::Signal<int, Split *> insertSplitRequested;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
@@ -98,7 +114,6 @@ private:
|
||||
void handleModifiers(Qt::KeyboardModifiers modifiers);
|
||||
void updateInputPlaceholder();
|
||||
|
||||
SplitContainer *container_;
|
||||
IndirectChannel channel_;
|
||||
|
||||
bool moderationMode_{};
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/helper/ChannelView.hpp"
|
||||
#include "widgets/helper/NotebookTab.hpp"
|
||||
#include "widgets/splits/ClosedSplits.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
@@ -160,8 +161,6 @@ void SplitContainer::insertSplit(Split *split, Direction direction,
|
||||
|
||||
assertInGuiThread();
|
||||
|
||||
split->setContainer(this);
|
||||
|
||||
if (relativeTo == nullptr)
|
||||
{
|
||||
if (this->baseNode_.type_ == Node::EmptyRoot)
|
||||
@@ -211,7 +210,9 @@ void SplitContainer::addSplit(Split *split)
|
||||
|
||||
this->refreshTab();
|
||||
|
||||
this->managedConnect(split->getChannelView().tabHighlightRequested,
|
||||
auto &&conns = this->connectionsPerSplit_[split];
|
||||
|
||||
conns.managedConnect(split->getChannelView().tabHighlightRequested,
|
||||
[this](HighlightState state) {
|
||||
if (this->tab_ != nullptr)
|
||||
{
|
||||
@@ -219,14 +220,64 @@ void SplitContainer::addSplit(Split *split)
|
||||
}
|
||||
});
|
||||
|
||||
this->managedConnect(split->getChannelView().liveStatusChanged, [this]() {
|
||||
conns.managedConnect(split->getChannelView().liveStatusChanged, [this]() {
|
||||
this->refreshTabLiveStatus();
|
||||
});
|
||||
|
||||
this->managedConnect(split->focused, [this, split] {
|
||||
conns.managedConnect(split->focused, [this, split] {
|
||||
this->setSelected(split);
|
||||
});
|
||||
|
||||
conns.managedConnect(split->openSplitRequested, [this](auto channel) {
|
||||
this->appendNewSplit(false)->setChannel(channel);
|
||||
});
|
||||
|
||||
conns.managedConnect(
|
||||
split->actionRequested, [this, split](Split::Action action) {
|
||||
switch (action)
|
||||
{
|
||||
case Split::Action::RefreshTab:
|
||||
this->refreshTab();
|
||||
break;
|
||||
|
||||
case Split::Action::ResetMouseStatus:
|
||||
this->resetMouseStatus();
|
||||
break;
|
||||
|
||||
case Split::Action::AppendNewSplit:
|
||||
this->appendNewSplit(true);
|
||||
break;
|
||||
|
||||
case Split::Action::Delete: {
|
||||
this->deleteSplit(split);
|
||||
auto *tab = this->getTab();
|
||||
tab->connect(tab, &QWidget::destroyed, [tab]() mutable {
|
||||
ClosedSplits::invalidateTab(tab);
|
||||
});
|
||||
ClosedSplits::push({split->getChannel()->getName(), tab});
|
||||
}
|
||||
break;
|
||||
|
||||
case Split::Action::SelectSplitLeft:
|
||||
this->selectNextSplit(SplitContainer::Left);
|
||||
break;
|
||||
case Split::Action::SelectSplitRight:
|
||||
this->selectNextSplit(SplitContainer::Right);
|
||||
break;
|
||||
case Split::Action::SelectSplitAbove:
|
||||
this->selectNextSplit(SplitContainer::Above);
|
||||
break;
|
||||
case Split::Action::SelectSplitBelow:
|
||||
this->selectNextSplit(SplitContainer::Below);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
conns.managedConnect(split->insertSplitRequested, [this](int dir,
|
||||
Split *parent) {
|
||||
this->insertSplit(new Split(this), static_cast<Direction>(dir), parent);
|
||||
});
|
||||
|
||||
this->layout();
|
||||
}
|
||||
|
||||
@@ -282,10 +333,7 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split)
|
||||
|
||||
this->refreshTab();
|
||||
|
||||
// fourtf: really bad
|
||||
split->getChannelView().tabHighlightRequested.disconnectAll();
|
||||
|
||||
split->getChannelView().tabHighlightRequested.disconnectAll();
|
||||
this->connectionsPerSplit_.erase(this->connectionsPerSplit_.find(split));
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
@@ -255,6 +255,9 @@ private:
|
||||
NotebookTab *tab_;
|
||||
std::vector<Split *> splits_;
|
||||
|
||||
std::unordered_map<Split *, pajlada::Signals::SignalHolder>
|
||||
connectionsPerSplit_;
|
||||
|
||||
bool isDragging_ = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -247,12 +247,8 @@ void SplitInput::installKeyPressedEvent()
|
||||
}
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Above);
|
||||
}
|
||||
this->split_->actionRequested.invoke(
|
||||
Split::Action::SelectSplitAbove);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -312,49 +308,37 @@ void SplitInput::installKeyPressedEvent()
|
||||
event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
// h: vim binding for left
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
event->accept();
|
||||
this->split_->actionRequested.invoke(
|
||||
Split::Action::SelectSplitLeft);
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Left);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
else if (event->key() == Qt::Key_J &&
|
||||
event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
// j: vim binding for down
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
event->accept();
|
||||
this->split_->actionRequested.invoke(
|
||||
Split::Action::SelectSplitBelow);
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Below);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
else if (event->key() == Qt::Key_K &&
|
||||
event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
// k: vim binding for up
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
event->accept();
|
||||
this->split_->actionRequested.invoke(
|
||||
Split::Action::SelectSplitAbove);
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Above);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
else if (event->key() == Qt::Key_L &&
|
||||
event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
// l: vim binding for right
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
event->accept();
|
||||
this->split_->actionRequested.invoke(
|
||||
Split::Action::SelectSplitRight);
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Right);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Down)
|
||||
{
|
||||
@@ -364,12 +348,8 @@ void SplitInput::installKeyPressedEvent()
|
||||
}
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Below);
|
||||
}
|
||||
this->split_->actionRequested.invoke(
|
||||
Split::Action::SelectSplitBelow);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -422,24 +402,16 @@ void SplitInput::installKeyPressedEvent()
|
||||
{
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Left);
|
||||
}
|
||||
this->split_->actionRequested.invoke(
|
||||
Split::Action::SelectSplitLeft);
|
||||
}
|
||||
}
|
||||
else if (event->key() == Qt::Key_Right)
|
||||
{
|
||||
if (event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
SplitContainer *page = this->split_->getContainer();
|
||||
|
||||
if (page != nullptr)
|
||||
{
|
||||
page->selectNextSplit(SplitContainer::Right);
|
||||
}
|
||||
this->split_->actionRequested.invoke(
|
||||
Split::Action::SelectSplitRight);
|
||||
}
|
||||
}
|
||||
else if ((event->key() == Qt::Key_C ||
|
||||
|
||||
@@ -220,18 +220,13 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched,
|
||||
case QEvent::MouseButtonRelease: {
|
||||
if (this->hoveredElement != HoveredElement::SplitMove)
|
||||
{
|
||||
SplitContainer *container =
|
||||
this->parent->split_->getContainer();
|
||||
auto dir = SplitContainer::Direction(
|
||||
this->hoveredElement + SplitContainer::Left - SplitLeft);
|
||||
|
||||
if (container != nullptr)
|
||||
{
|
||||
auto *_split = new Split(container);
|
||||
auto dir = SplitContainer::Direction(this->hoveredElement +
|
||||
SplitContainer::Left -
|
||||
SplitLeft);
|
||||
container->insertSplit(_split, dir, this->parent->split_);
|
||||
this->parent->hide();
|
||||
}
|
||||
this->parent->split_->insertSplitRequested.invoke(
|
||||
static_cast<int>(dir), this->parent->split_);
|
||||
|
||||
this->parent->hide();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user