Added x-attach-split-to-window command line arg (#2411)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
fourtf
2021-04-17 16:15:23 +02:00
committed by GitHub
parent 58017a7546
commit 2db140d5af
21 changed files with 350 additions and 160 deletions
@@ -94,7 +94,7 @@ void QuickSwitcherPopup::updateSuggestions(const QString &text)
if (split->getChannel()->getName().contains(text,
Qt::CaseInsensitive))
{
auto item = std::make_unique<SwitchSplitItem>(split);
auto item = std::make_unique<SwitchSplitItem>(sc, split);
this->switcherModel_.addItem(std::move(item));
// We want to continue the outer loop so we need a goto
@@ -7,31 +7,23 @@
namespace chatterino {
SwitchSplitItem::SwitchSplitItem(Split *split)
: AbstractSwitcherItem(QIcon(":switcher/switch.svg"))
, split_(split)
, container_(split->getContainer())
{
}
SwitchSplitItem::SwitchSplitItem(SplitContainer *container)
SwitchSplitItem::SwitchSplitItem(SplitContainer *container, Split *split)
: AbstractSwitcherItem(QIcon(":switcher/switch.svg"))
, container_(container)
, split_(split)
{
assert(this->container_ != nullptr);
}
void SwitchSplitItem::action()
{
auto &nb = getApp()->windows->getMainWindow().getNotebook();
nb.select(this->container_);
/*
* If the item is referring to a specific channel, select the
* corresponding split.
*/
if (this->split_)
{
this->container_->setSelected(this->split_);
getApp()->windows->select(this->split_);
}
else if (this->container_)
{
getApp()->windows->select(this->container_);
}
}
@@ -13,8 +13,7 @@ namespace chatterino {
class SwitchSplitItem : public AbstractSwitcherItem
{
public:
SwitchSplitItem(Split *split);
SwitchSplitItem(SplitContainer *container);
SwitchSplitItem(SplitContainer *container, Split *split = nullptr);
virtual void action() override;
@@ -22,8 +21,8 @@ public:
virtual QSize sizeHint(const QRect &rect) const override;
private:
Split *split_{};
SplitContainer *container_{};
Split *split_{};
};
} // namespace chatterino