fix: properly handle CLI arguments (#2368)

Fix CLI arguments not being respected. This happened due to the addition of category-based logging (--help, --version) and changes to the window loading ( --channels), respectively.

When handling --channels, I took the liberty to refactor the previous version of window description (which relied on generating JSON) to directly building the WindowLayout.
This commit is contained in:
Leon Richardt
2021-01-23 16:26:42 +01:00
committed by GitHub
parent 55dd09a9f0
commit 1b75dc1e2c
6 changed files with 140 additions and 81 deletions
+18 -8
View File
@@ -37,8 +37,6 @@
namespace chatterino {
namespace {
const QString WINDOW_LAYOUT_FILENAME(QStringLiteral("window-layout.json"));
boost::optional<bool> &shouldMoveOutOfBoundsWindow()
{
static boost::optional<bool> x;
@@ -47,6 +45,9 @@ namespace {
} // namespace
const QString WindowManager::WINDOW_LAYOUT_FILENAME(
QStringLiteral("window-layout.json"));
using SplitNode = SplitContainer::Node;
using SplitDirection = SplitContainer::Direction;
@@ -83,8 +84,8 @@ void WindowManager::showAccountSelectPopup(QPoint point)
}
WindowManager::WindowManager()
: windowLayoutFilePath(
combinePath(getPaths()->settingsDirectory, WINDOW_LAYOUT_FILENAME))
: windowLayoutFilePath(combinePath(getPaths()->settingsDirectory,
WindowManager::WINDOW_LAYOUT_FILENAME))
{
qCDebug(chatterinoWindowmanager) << "init WindowManager";
@@ -297,7 +298,16 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
assert(!this->initialized_);
{
auto windowLayout = this->loadWindowLayoutFromFile();
WindowLayout windowLayout;
if (getArgs().customChannelLayout)
{
windowLayout = getArgs().customChannelLayout.value();
}
else
{
windowLayout = this->loadWindowLayoutFromFile();
}
this->emotePopupPos_ = windowLayout.emotePopupPos_;
@@ -305,10 +315,10 @@ void WindowManager::initialize(Settings &settings, Paths &paths)
}
// No main window has been created from loading, create an empty one
if (mainWindow_ == nullptr)
if (this->mainWindow_ == nullptr)
{
mainWindow_ = &this->createWindow(WindowType::Main);
mainWindow_->getNotebook().addPage(true);
this->mainWindow_ = &this->createWindow(WindowType::Main);
this->mainWindow_->getNotebook().addPage(true);
}
settings.timestampFormat.connect([this](auto, auto) {