Files
qt6-migration-pipeline/Lts/Common/LtsMultiMonitor/lts_screen_normal.cpp
T

202 lines
3.5 KiB
C++
Executable File

#include "lts_screen_normal.h"
#include "lts_dummy_widget.h"
#include "lts_screen_container.h"
#include "lts_magic_corner.h"
#include <LtsWidgets/lts_base_layout_widget.h>
#include <QDebug>
#include <QSplitter>
#include <QHBoxLayout>
#ifdef Q_OS_WIN
#include <QtPlatformHeaders/qwindowswindowfunctions.h>
#endif
namespace LtsMultiMonitor
{
LtsScreenNormal::LtsScreenNormal(QRect screenGeo, int screenId, bool debugMargins, const QString &serial)
: LtsScreenBase(screenGeo, screenId, debugMargins, serial)
, m_childContainer(new LtsScreenContainer(screenGeo))
, m_corner(new LtsMagicCorner(screenGeo))
{
connect(m_childContainer, &LtsScreenContainer::check,
this, &LtsScreenNormal::check);
auto *theLayout = new QHBoxLayout;
theLayout->setContentsMargins(0, 0, 0, 0);
theLayout->setMargin(0);
theLayout->setSpacing(0);
theLayout->setStretch(0, 999);
theLayout->addWidget(m_childContainer);
m_screenDialog->setLayout(theLayout);
m_corner->hide();
connect(m_corner, &LtsMagicCorner::toggle,
this, [this]()
{
m_childContainer->toggle();
m_corner->setActiveWidgetType(m_childContainer->activeWidgetType());
setCornerIcons();
});
connect(m_corner, &LtsMagicCorner::signalMakeAllSwole,
this, &LtsScreenNormal::signalMakeAllSwole);
connect(this, &LtsScreenNormal::signalMakeSwole,
m_corner, &LtsMagicCorner::makeSwole);
connect(m_childContainer, &LtsScreenContainer::signalSetCornerIcons,
this, &LtsScreenNormal::setCornerIcons);
}
LtsScreenNormal::~LtsScreenNormal()
{
m_corner->deleteLater();
}
void LtsScreenNormal::setCornerIcons()
{
m_corner->setActiveWidgetType(m_childContainer->activeWidgetType());
m_corner->setIcon(m_childContainer->mainWindowIcon(), LtsScreenBase::WidgetType::MainWidget);
m_corner->setIcon(m_childContainer->secondaryWindowIcon(), LtsScreenBase::WidgetType::SecondaryWidget);
}
void LtsScreenNormal::check()
{
m_childContainer->mainAndSecondaryOccupied() ? m_corner->show() : m_corner->hide();
}
LtsScreenContainer *LtsScreenNormal::containerOfWidget(QWidget *widget)
{
if (m_childContainer->hasWidget(widget))
return m_childContainer;
throw "widget is not present on this container";
}
void LtsScreenNormal::hideMagicCorner(bool hide)
{
m_corner->setFreezed(hide);
}
bool LtsScreenNormal::isIrreplaceable() const
{
return m_childContainer->isIrreplaceable();
}
int LtsScreenNormal::containerIdOfWidget(QWidget *widget) const noexcept(false)
{
if (m_childContainer->hasWidget(widget))
return 0;
throw "widget not on this screen";
}
LtsScreenContainer *LtsScreenNormal::putWidget(QWidget *widget, int ) noexcept(false)
{
if (!isEmpty())
throw "cannot put widget as container is non-empty";
putWidgetUnmanaged(widget);
return m_childContainer;
}
bool LtsScreenNormal::hasWidget(QWidget *widget) const
{
return (m_childContainer->hasWidget(widget));
}
void LtsScreenNormal::putWidgetUnmanaged(QWidget *widget)
{
m_childContainer->setWidget(widget);
setCornerIcons();
}
void LtsScreenNormal::slotOverlayDestroyed()
{
m_screenDialog->show();
}
bool LtsScreenNormal::isEmpty() const
{
return m_childContainer->isEmpty();
}
void LtsScreenNormal::switchToTemp(LtsScreenBase::WidgetType widgetType)
{
m_childContainer->switchToTemp(widgetType);
}
void LtsScreenNormal::finalizeSwitch()
{
m_childContainer->finalizeSwitch();
}
void LtsScreenNormal::revertSwitch()
{
m_childContainer->revertSwitch();
}
}