Added x-attach-split-to-window command line arg (#2411)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "util/Clamp.hpp"
|
||||
#include "util/CombinePath.hpp"
|
||||
#include "widgets/AccountSwitchPopup.hpp"
|
||||
#include "widgets/FramelessEmbedWindow.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||
@@ -130,6 +131,8 @@ WindowManager::WindowManager()
|
||||
});
|
||||
}
|
||||
|
||||
WindowManager::~WindowManager() = default;
|
||||
|
||||
MessageElementFlags WindowManager::getWordFlags()
|
||||
{
|
||||
return this->wordFlags_;
|
||||
@@ -269,22 +272,14 @@ Window &WindowManager::createWindow(WindowType type, bool show)
|
||||
return *window;
|
||||
}
|
||||
|
||||
int WindowManager::windowCount()
|
||||
void WindowManager::select(Split *split)
|
||||
{
|
||||
return this->windows_.size();
|
||||
this->selectSplit.invoke(split);
|
||||
}
|
||||
|
||||
Window *WindowManager::windowAt(int index)
|
||||
void WindowManager::select(SplitContainer *container)
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
if (index < 0 || (size_t)index >= this->windows_.size())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
qCDebug(chatterinoWindowmanager) << "getting window at bad index" << index;
|
||||
|
||||
return this->windows_.at(index);
|
||||
this->selectSplitContainer.invoke(container);
|
||||
}
|
||||
|
||||
QPoint WindowManager::emotePopupPos()
|
||||
@@ -324,11 +319,23 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
|
||||
this->applyWindowLayout(windowLayout);
|
||||
}
|
||||
|
||||
if (getArgs().isFramelessEmbed)
|
||||
{
|
||||
this->framelessEmbedWindow_.reset(new FramelessEmbedWindow);
|
||||
this->framelessEmbedWindow_->show();
|
||||
}
|
||||
|
||||
// No main window has been created from loading, create an empty one
|
||||
if (this->mainWindow_ == nullptr)
|
||||
{
|
||||
this->mainWindow_ = &this->createWindow(WindowType::Main);
|
||||
this->mainWindow_->getNotebook().addPage(true);
|
||||
|
||||
// TODO: don't create main window if it's a frameless embed
|
||||
if (getArgs().isFramelessEmbed)
|
||||
{
|
||||
this->mainWindow_->hide();
|
||||
}
|
||||
}
|
||||
|
||||
settings.timestampFormat.connect([this](auto, auto) {
|
||||
@@ -634,6 +641,11 @@ WindowLayout WindowManager::loadWindowLayoutFromFile() const
|
||||
|
||||
void WindowManager::applyWindowLayout(const WindowLayout &layout)
|
||||
{
|
||||
if (getArgs().dontLoadMainWindow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set emote popup position
|
||||
this->emotePopupPos_ = layout.emotePopupPos_;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/FlagsEnum.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
@@ -19,6 +20,7 @@ using MessageElementFlags = FlagsEnum<MessageElementFlag>;
|
||||
enum class WindowType;
|
||||
|
||||
enum class SettingsDialogPreference;
|
||||
class FramelessEmbedWindow;
|
||||
|
||||
class WindowManager final : public Singleton
|
||||
{
|
||||
@@ -26,6 +28,7 @@ public:
|
||||
static const QString WINDOW_LAYOUT_FILENAME;
|
||||
|
||||
WindowManager();
|
||||
~WindowManager() override;
|
||||
|
||||
static void encodeChannel(IndirectChannel channel, QJsonObject &obj);
|
||||
static void encodeFilters(Split *split, QJsonArray &arr);
|
||||
@@ -53,8 +56,8 @@ public:
|
||||
Window &getSelectedWindow();
|
||||
Window &createWindow(WindowType type, bool show = true);
|
||||
|
||||
int windowCount();
|
||||
Window *windowAt(int index);
|
||||
void select(Split *split);
|
||||
void select(SplitContainer *container);
|
||||
|
||||
QPoint emotePopupPos();
|
||||
void setEmotePopupPos(QPoint pos);
|
||||
@@ -92,6 +95,9 @@ public:
|
||||
// It is currently being used by the "Tooltip Preview Image" system to recheck if an image is ready to be rendered.
|
||||
pajlada::Signals::NoArgSignal miscUpdate;
|
||||
|
||||
pajlada::Signals::Signal<Split *> selectSplit;
|
||||
pajlada::Signals::Signal<SplitContainer *> selectSplitContainer;
|
||||
|
||||
private:
|
||||
void encodeNodeRecursively(SplitContainer::Node *node, QJsonObject &obj);
|
||||
|
||||
@@ -112,6 +118,7 @@ private:
|
||||
|
||||
std::vector<Window *> windows_;
|
||||
|
||||
std::unique_ptr<FramelessEmbedWindow> framelessEmbedWindow_;
|
||||
Window *mainWindow_{};
|
||||
Window *selectedWindow_{};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user