Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+12
-21
@@ -1,44 +1,35 @@
|
||||
#include "lts_dummy_widget.h"
|
||||
|
||||
#include <LtsUtilsGui/LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/dds_vector_to_pixmap.h>
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QIcon>
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
|
||||
FullscreenVideoDummyWidget::FullscreenVideoDummyWidget()
|
||||
{
|
||||
setWindowIcon(LtsUtils::iconFromSvg(QStringLiteral(":/style/mobile_video.svg")));
|
||||
setWindowTitle(tr("Fullscreen Video Helper"));
|
||||
|
||||
|
||||
|
||||
|
||||
setWindowIcon(LtsUtils::iconFromSvg(QStringLiteral(":/style/mobile_video.svg")));
|
||||
setWindowTitle(tr("Fullscreen Video Helper"));
|
||||
}
|
||||
|
||||
|
||||
void FullscreenVideoDummyWidget::hideVideo()
|
||||
{
|
||||
qWarning() << "FullscreenVideoDummyWidget::hideVideo()";
|
||||
emit signalHideVideo();
|
||||
qWarning() << "FullscreenVideoDummyWidget::hideVideo()";
|
||||
emit signalHideVideo();
|
||||
}
|
||||
|
||||
void FullscreenVideoDummyWidget::showVideo()
|
||||
{
|
||||
emit signalShowVideo();
|
||||
emit signalShowVideo();
|
||||
}
|
||||
|
||||
|
||||
bool FullscreenVideoDummyWidget::event(QEvent *event)
|
||||
bool FullscreenVideoDummyWidget::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Type::Show)
|
||||
assert(false);
|
||||
return QWidget::event(event);
|
||||
if (event->type() == QEvent::Type::Show)
|
||||
assert(false);
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+17
-22
@@ -1,44 +1,39 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include "ltsmultimonitor_export.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class QEvent;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
|
||||
class LTSMULTIMONITOR_EXPORT SecondaryWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SecondaryWidget() = default;
|
||||
virtual ~SecondaryWidget() = default;
|
||||
Q_OBJECT
|
||||
public:
|
||||
SecondaryWidget() = default;
|
||||
virtual ~SecondaryWidget() = default;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LTSMULTIMONITOR_EXPORT FullscreenVideoDummyWidget : public SecondaryWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FullscreenVideoDummyWidget();
|
||||
public:
|
||||
FullscreenVideoDummyWidget();
|
||||
|
||||
void hideVideo();
|
||||
void showVideo();
|
||||
void hideVideo();
|
||||
void showVideo();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *);
|
||||
protected:
|
||||
bool event(QEvent*);
|
||||
|
||||
signals:
|
||||
void signalWidgetPlaced(const QRect &globalGeometry);
|
||||
void signalHideVideo();
|
||||
void signalShowVideo();
|
||||
signals:
|
||||
void signalWidgetPlaced(const QRect& globalGeometry);
|
||||
void signalHideVideo();
|
||||
void signalShowVideo();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+70
-154
@@ -1,88 +1,63 @@
|
||||
#include "lts_magic_corner.h"
|
||||
|
||||
#include <LtsUtilsGui/LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/dds_vector_to_pixmap.h>
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include <QMouseEvent>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
|
||||
#define SMOL 48
|
||||
#define SMOL 48
|
||||
#define SWOLE 100
|
||||
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
LtsMagicCorner::LtsMagicCorner(const QRect &neogeo)
|
||||
: m_neogeo(neogeo)
|
||||
, m_shrinkTimer(new QTimer(this))
|
||||
, m_label(new QLabel(this))
|
||||
LtsMagicCorner::LtsMagicCorner(const QRect& neogeo)
|
||||
: m_neogeo(neogeo), m_shrinkTimer(new QTimer(this)), m_label(new QLabel(this))
|
||||
{
|
||||
|
||||
|
||||
m_shrinkTimer->setInterval(1500ms);
|
||||
m_shrinkTimer->setSingleShot(true);
|
||||
m_shrinkTimer->setInterval(1500ms);
|
||||
m_shrinkTimer->setSingleShot(true);
|
||||
|
||||
connect(m_shrinkTimer, &QTimer::timeout,
|
||||
this, &LtsMagicCorner::makeSmol);
|
||||
connect(m_shrinkTimer, &QTimer::timeout, this, &LtsMagicCorner::makeSmol);
|
||||
|
||||
makeSmol();
|
||||
makeSmol();
|
||||
|
||||
|
||||
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||
setMouseTracking(true);
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
setWindowFlag(Qt::WindowType::WindowStaysOnTopHint);
|
||||
setWindowFlag(Qt::WindowType::X11BypassWindowManagerHint);
|
||||
activateWindow();
|
||||
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||
setMouseTracking(true);
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
setWindowFlag(Qt::WindowType::WindowStaysOnTopHint);
|
||||
setWindowFlag(Qt::WindowType::X11BypassWindowManagerHint);
|
||||
activateWindow();
|
||||
|
||||
auto* t = new QTimer(this);
|
||||
connect(t, &QTimer::timeout, this, [this]() {
|
||||
if (!isVisible())
|
||||
return;
|
||||
|
||||
|
||||
auto *t = new QTimer(this);
|
||||
connect(t, &QTimer::timeout,
|
||||
this, [this]()
|
||||
{
|
||||
if (!isVisible())
|
||||
return;
|
||||
raise();
|
||||
});
|
||||
t->setInterval(750ms);
|
||||
t->start();
|
||||
|
||||
raise();
|
||||
|
||||
|
||||
|
||||
});
|
||||
t->setInterval(750ms);
|
||||
t->start();
|
||||
|
||||
|
||||
m_label->setMinimumSize(SWOLE, SWOLE);
|
||||
m_label->setMaximumSize(SWOLE, SWOLE);
|
||||
m_label->setGeometry(0, 0, SWOLE, SWOLE);
|
||||
m_label->setText(QStringLiteral("<unknown>"));
|
||||
m_label->setAlignment(Qt::AlignmentFlag::AlignCenter);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_label->setMinimumSize(SWOLE, SWOLE);
|
||||
m_label->setMaximumSize(SWOLE, SWOLE);
|
||||
m_label->setGeometry(0, 0, SWOLE, SWOLE);
|
||||
m_label->setText(QStringLiteral("<unknown>"));
|
||||
m_label->setAlignment(Qt::AlignmentFlag::AlignCenter);
|
||||
}
|
||||
|
||||
|
||||
void LtsMagicCorner::setActiveWidgetType(LtsScreenBase::WidgetType widgetType)
|
||||
{
|
||||
m_activeWidgetType = widgetType;
|
||||
if (widgetType == LtsScreenBase::WidgetType::MainWidget)
|
||||
m_label->setPixmap(m_mainPixmap);
|
||||
else
|
||||
m_label->setPixmap(m_secondaryPixmap);
|
||||
m_activeWidgetType = widgetType;
|
||||
if (widgetType == LtsScreenBase::WidgetType::MainWidget)
|
||||
m_label->setPixmap(m_mainPixmap);
|
||||
else
|
||||
m_label->setPixmap(m_secondaryPixmap);
|
||||
}
|
||||
|
||||
void LtsMagicCorner::setFreezed(bool freezed)
|
||||
@@ -90,125 +65,66 @@ void LtsMagicCorner::setFreezed(bool freezed)
|
||||
setVisible(!freezed);
|
||||
}
|
||||
|
||||
|
||||
void LtsMagicCorner::setIcon(const QIcon &icon, LtsScreenBase::WidgetType widgetType)
|
||||
void LtsMagicCorner::setIcon(const QIcon& icon, LtsScreenBase::WidgetType widgetType)
|
||||
{
|
||||
QPixmap p(LtsUtils::pixmapFromIcon(icon));
|
||||
QPixmap p(LtsUtils::pixmapFromIcon(icon));
|
||||
|
||||
if (widgetType == LtsScreenBase::WidgetType::MainWidget)
|
||||
m_mainPixmap = p;
|
||||
else
|
||||
m_secondaryPixmap = p;
|
||||
if (widgetType == LtsScreenBase::WidgetType::MainWidget)
|
||||
m_mainPixmap = p;
|
||||
else
|
||||
m_secondaryPixmap = p;
|
||||
|
||||
if (widgetType != m_activeWidgetType)
|
||||
m_label->setPixmap(p);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (widgetType != m_activeWidgetType)
|
||||
m_label->setPixmap(p);
|
||||
}
|
||||
|
||||
|
||||
void LtsMagicCorner::mousePressEvent(QMouseEvent *event)
|
||||
void LtsMagicCorner::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
m_mousePressed = (event->button() == Qt::MouseButton::LeftButton);
|
||||
m_mousePressed = (event->button() == Qt::MouseButton::LeftButton);
|
||||
}
|
||||
|
||||
|
||||
void LtsMagicCorner::mouseReleaseEvent(QMouseEvent *event)
|
||||
void LtsMagicCorner::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (!m_mousePressed)
|
||||
return;
|
||||
if (!m_mousePressed)
|
||||
return;
|
||||
|
||||
m_mousePressed = false;
|
||||
m_mousePressed = false;
|
||||
|
||||
if (event->button() != Qt::MouseButton::LeftButton)
|
||||
return;
|
||||
if (event->button() != Qt::MouseButton::LeftButton)
|
||||
return;
|
||||
|
||||
m_shrinkTimer->start();
|
||||
emit toggle();
|
||||
m_shrinkTimer->start();
|
||||
emit toggle();
|
||||
}
|
||||
|
||||
|
||||
void LtsMagicCorner::makeSmol()
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setGeometry(m_neogeo.x(), m_neogeo.y(), SMOL, SMOL);
|
||||
setMinimumSize(SMOL, SMOL);
|
||||
setMaximumSize(SMOL, SMOL);
|
||||
m_label->hide();
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setGeometry(m_neogeo.x(), m_neogeo.y(), SMOL, SMOL);
|
||||
setMinimumSize(SMOL, SMOL);
|
||||
setMaximumSize(SMOL, SMOL);
|
||||
m_label->hide();
|
||||
}
|
||||
|
||||
|
||||
void LtsMagicCorner::makeSwole()
|
||||
{
|
||||
if (!isVisible())
|
||||
return;
|
||||
if (!isVisible())
|
||||
return;
|
||||
|
||||
setAttribute(Qt::WA_TranslucentBackground, false);
|
||||
setAttribute(Qt::WA_NoSystemBackground, false);
|
||||
setGeometry(m_neogeo.x(), m_neogeo.y(), SWOLE, SWOLE);
|
||||
setMinimumSize(SWOLE, SWOLE);
|
||||
setMaximumSize(SWOLE, SWOLE);
|
||||
m_label->show();
|
||||
m_shrinkTimer->start();
|
||||
update();
|
||||
setAttribute(Qt::WA_TranslucentBackground, false);
|
||||
setAttribute(Qt::WA_NoSystemBackground, false);
|
||||
setGeometry(m_neogeo.x(), m_neogeo.y(), SWOLE, SWOLE);
|
||||
setMinimumSize(SWOLE, SWOLE);
|
||||
setMaximumSize(SWOLE, SWOLE);
|
||||
m_label->show();
|
||||
m_shrinkTimer->start();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void LtsMagicCorner::mouseMoveEvent(QMouseEvent *)
|
||||
void LtsMagicCorner::mouseMoveEvent(QMouseEvent*)
|
||||
{
|
||||
|
||||
emit signalMakeAllSwole();
|
||||
|
||||
emit signalMakeAllSwole();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+29
-33
@@ -1,56 +1,52 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include "lts_screen_base.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
class QMouseEvent;
|
||||
class QPaintEvent;
|
||||
class QLabel;
|
||||
class QTimer;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
class LtsMagicCorner : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LtsMagicCorner(const QRect &neogeo);
|
||||
public:
|
||||
explicit LtsMagicCorner(const QRect& neogeo);
|
||||
|
||||
void setIcon(const QIcon &icon, LtsScreenBase::WidgetType widgetType);
|
||||
void setActiveWidgetType(LtsScreenBase::WidgetType widgetType);
|
||||
|
||||
|
||||
void setFreezed(bool freezed);
|
||||
void setIcon(const QIcon& icon, LtsScreenBase::WidgetType widgetType);
|
||||
void setActiveWidgetType(LtsScreenBase::WidgetType widgetType);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void setFreezed(bool freezed);
|
||||
|
||||
signals:
|
||||
void toggle();
|
||||
void signalMakeAllSwole();
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void makeSmol();
|
||||
signals:
|
||||
void toggle();
|
||||
void signalMakeAllSwole();
|
||||
|
||||
public slots:
|
||||
void makeSwole();
|
||||
private slots:
|
||||
void makeSmol();
|
||||
|
||||
private:
|
||||
QRect m_neogeo;
|
||||
QTimer *m_shrinkTimer;
|
||||
bool m_mousePressed { false };
|
||||
bool m_freezed = false;
|
||||
QLabel *m_label;
|
||||
QPixmap m_mainPixmap;
|
||||
QPixmap m_secondaryPixmap;
|
||||
LtsScreenBase::WidgetType m_activeWidgetType;
|
||||
public slots:
|
||||
void makeSwole();
|
||||
|
||||
private:
|
||||
QRect m_neogeo;
|
||||
QTimer* m_shrinkTimer;
|
||||
bool m_mousePressed{false};
|
||||
bool m_freezed = false;
|
||||
QLabel* m_label;
|
||||
QPixmap m_mainPixmap;
|
||||
QPixmap m_secondaryPixmap;
|
||||
LtsScreenBase::WidgetType m_activeWidgetType;
|
||||
};
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+457
-552
File diff suppressed because it is too large.
Load diff
Executable → Regular
+60
-50
@@ -4,82 +4,92 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
class LtsScreenBase;
|
||||
class MultiMonitorSelectorBase;
|
||||
class LtsScreenContainer;
|
||||
|
||||
|
||||
class LTSMULTIMONITOR_EXPORT LtsMultiMonitor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static LtsMultiMonitor *getInstance();
|
||||
public:
|
||||
static LtsMultiMonitor* getInstance();
|
||||
|
||||
|
||||
bool selectScreen(QWidget* widget, LtsScreenContainer* swap = nullptr, bool putOnMainIfFree = true,
|
||||
bool ltsScreenNormalOnly = false, const QVector<QWidget*>& irreplacableWidgets = {});
|
||||
bool selectAndSwap(QWidget* widget);
|
||||
|
||||
bool selectScreen(QWidget *widget, LtsScreenContainer *swap = nullptr, bool putOnMainIfFree = true, bool ltsScreenNormalOnly = false, const QVector<QWidget *> &irreplacableWidgets = {});
|
||||
bool selectAndSwap(QWidget *widget);
|
||||
void setEnableMultiMonitorMode()
|
||||
{
|
||||
m_active = true;
|
||||
}
|
||||
|
||||
void setDebugMultiMonitorMode()
|
||||
{
|
||||
m_debugMargins = true;
|
||||
}
|
||||
|
||||
void setEnableMultiMonitorMode() { m_active = true; }
|
||||
void setDebugMultiMonitorMode() { m_debugMargins = true; }
|
||||
bool isActive() const { return m_active; }
|
||||
bool isActive() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
LtsScreenBase *widgetsScreen(QWidget *widget);
|
||||
LtsScreenBase* widgetsScreen(QWidget* widget);
|
||||
|
||||
|
||||
void freezeMagicCorner(int screenId);
|
||||
void unfreezeMagicCorner(int screenId);
|
||||
|
||||
bool putScreen(QWidget* widget, int screenId, int screenPart);
|
||||
bool putScreenAutomatically(QWidget* widget);
|
||||
static void place(QWidget* widget);
|
||||
|
||||
void freezeMagicCorner(int screenId);
|
||||
void unfreezeMagicCorner(int screenId);
|
||||
void setSkipScreen(int screenId, int subScreenId = -1)
|
||||
{
|
||||
m_skipScreenId = screenId;
|
||||
m_subSkipScreenId = subScreenId;
|
||||
}
|
||||
|
||||
bool putScreen(QWidget *widget, int screenId, int screenPart);
|
||||
bool putScreenAutomatically(QWidget *widget);
|
||||
static void place(QWidget *widget);
|
||||
void setSkipScreen(int screenId, int subScreenId = -1) { m_skipScreenId = screenId; m_subSkipScreenId = subScreenId; }
|
||||
LtsScreenBase *mainScreen() const { return m_mainScreen; }
|
||||
int screenCount() const;
|
||||
LtsScreenBase* mainScreen() const
|
||||
{
|
||||
return m_mainScreen;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void screenDied();
|
||||
int screenCount() const;
|
||||
|
||||
private:
|
||||
LtsMultiMonitor();
|
||||
~LtsMultiMonitor();
|
||||
static void cleanupLtsMultiMonitor();
|
||||
void init();
|
||||
bool cancelAndProcessIfInactive(QWidget *widget) const;
|
||||
static bool isWidgetSecondary(QWidget *widget) ;
|
||||
private slots:
|
||||
void screenDied();
|
||||
|
||||
|
||||
private:
|
||||
LtsMultiMonitor();
|
||||
~LtsMultiMonitor();
|
||||
static void cleanupLtsMultiMonitor();
|
||||
void init();
|
||||
bool cancelAndProcessIfInactive(QWidget* widget) const;
|
||||
static bool isWidgetSecondary(QWidget* widget);
|
||||
|
||||
bool overlapBaseLayouts(QWidget *widget);
|
||||
bool isOverlapBaseLayouts() const;
|
||||
bool overlapBaseLayouts(QWidget* widget);
|
||||
bool isOverlapBaseLayouts() const;
|
||||
|
||||
QVector<LtsScreenBase *> m_screens;
|
||||
int m_nextScreenId { 0 };
|
||||
LtsScreenBase *m_mainScreen;
|
||||
bool m_active;
|
||||
bool m_initialized;
|
||||
int m_skipScreenId;
|
||||
int m_subSkipScreenId;
|
||||
|
||||
bool m_overlapBaseLayouts;
|
||||
bool m_debugMargins;
|
||||
QVector<LtsScreenBase*> m_screens;
|
||||
int m_nextScreenId{0};
|
||||
LtsScreenBase* m_mainScreen;
|
||||
bool m_active;
|
||||
bool m_initialized;
|
||||
int m_skipScreenId;
|
||||
int m_subSkipScreenId;
|
||||
|
||||
signals:
|
||||
void signalQuitLoop();
|
||||
void signalSelected();
|
||||
void signalScreenCountChanged(int);
|
||||
void signalMakeAllSwole();
|
||||
bool m_overlapBaseLayouts;
|
||||
bool m_debugMargins;
|
||||
|
||||
signals:
|
||||
void signalQuitLoop();
|
||||
void signalSelected();
|
||||
void signalScreenCountChanged(int);
|
||||
void signalMakeAllSwole();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+9
-9
@@ -5,13 +5,13 @@
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef LTSMULTIMONITOR_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define LTSMULTIMONITOR_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_LTSMULTIMONITOR_LIB)
|
||||
# define LTSMULTIMONITOR_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define LTSMULTIMONITOR_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#ifdef BUILD_STATIC_LIBRARIES
|
||||
#define LTSMULTIMONITOR_EXPORT
|
||||
#else
|
||||
#if defined(MAKE_LTSMULTIMONITOR_LIB)
|
||||
#define LTSMULTIMONITOR_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define LTSMULTIMONITOR_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
Executable → Regular
+242
-317
@@ -1,24 +1,22 @@
|
||||
|
||||
|
||||
#include "lts_multi_monitor_selector_base.h"
|
||||
|
||||
#include "lts_multi_monitor.h"
|
||||
#include "lts_screen_base.h"
|
||||
#include "lts_screen_container.h"
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <LtsUtilsCore/promise.h>
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <QCloseEvent>
|
||||
#include <QStyle>
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QColor>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
#include <QStyle>
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
@@ -26,393 +24,320 @@ int MultiMonitorSelectorBase::s_margin = 10;
|
||||
int MultiMonitorSelectorBase::s_offset = 6;
|
||||
int MultiMonitorSelectorBase::s_buttonSize = 20;
|
||||
|
||||
|
||||
MultiMonitorSelectorBase::MultiMonitorSelectorBase(LtsScreenBase *screen, const QVector<QWidget *> &irreplacableWidgets, QWidget *)
|
||||
: QDialog(nullptr)
|
||||
, m_irreplacableWidgets(irreplacableWidgets)
|
||||
, m_screen(screen)
|
||||
, m_screenIsIrreplaceable(screen->isIrreplaceable())
|
||||
MultiMonitorSelectorBase::MultiMonitorSelectorBase(LtsScreenBase* screen, const QVector<QWidget*>& irreplacableWidgets,
|
||||
QWidget*)
|
||||
: QDialog(nullptr), m_irreplacableWidgets(irreplacableWidgets), m_screen(screen),
|
||||
m_screenIsIrreplaceable(screen->isIrreplaceable())
|
||||
{
|
||||
setGeometry(screen->screenRect());
|
||||
setMouseTracking(true);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint );
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setGeometry(screen->screenRect());
|
||||
setMouseTracking(true);
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
||||
|
||||
bool MultiMonitorSelectorBase::isNullSwap(LtsScreenContainer *container)
|
||||
bool MultiMonitorSelectorBase::isNullSwap(LtsScreenContainer* container)
|
||||
{
|
||||
if (container == m_swap)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
if (container == m_swap)
|
||||
{
|
||||
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorBase::closeEvent(QCloseEvent *event)
|
||||
void MultiMonitorSelectorBase::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
|
||||
|
||||
qWarning() << "closeEvent";
|
||||
qWarning() << "closeEvent";
|
||||
|
||||
if (!m_selected && !m_reverted)
|
||||
{
|
||||
qWarning() << "closeEvent: not selected and not reverted! reverting!";
|
||||
m_screen->revertSwitch();
|
||||
}
|
||||
|
||||
if (!m_selected && !m_reverted)
|
||||
{
|
||||
qWarning() << "closeEvent: not selected and not reverted! reverting!";
|
||||
m_screen->revertSwitch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
event->accept();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
||||
bool MultiMonitorSelectorBase::killOrSwapOldBLW(LtsScreenContainer *container ) noexcept(false)
|
||||
bool MultiMonitorSelectorBase::killOrSwapOldBLW(LtsScreenContainer* container) noexcept(false)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (isNullSwap(container))
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
if (isNullSwap(container))
|
||||
return true;
|
||||
|
||||
if (m_swap != nullptr)
|
||||
{
|
||||
QWidget* oldSwapWidget;
|
||||
try
|
||||
{
|
||||
|
||||
oldSwapWidget = m_swap->stealWidget();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
|
||||
if (m_swap != nullptr)
|
||||
{
|
||||
QWidget *oldSwapWidget;
|
||||
throw;
|
||||
}
|
||||
|
||||
if (!container->isEmpty())
|
||||
{
|
||||
|
||||
QWidget* oldContainerWidget;
|
||||
try
|
||||
{
|
||||
|
||||
oldContainerWidget = container->stealWidget();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
m_swap->setWidget(oldContainerWidget);
|
||||
}
|
||||
|
||||
container->setWidget(oldSwapWidget);
|
||||
|
||||
if (m_swap->activeWidgetType() == LtsScreenBase::WidgetType::SecondaryWidget && !m_swap->hasSecondaryWidget() &&
|
||||
m_swap->hasMainWidget())
|
||||
m_swap->toggle();
|
||||
else if (m_swap->activeWidgetType() == LtsScreenBase::WidgetType::MainWidget && !m_swap->hasMainWidget() &&
|
||||
m_swap->hasSecondaryWidget())
|
||||
m_swap->toggle();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QWidget* oldWidget;
|
||||
try
|
||||
{
|
||||
|
||||
oldSwapWidget = m_swap->stealWidget();
|
||||
|
||||
|
||||
oldWidget = container->widget();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
throw;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
auto* oldBLW = qobject_cast<LtsWidgets::LtsBaseLayoutWidget*>(oldWidget);
|
||||
|
||||
|
||||
|
||||
if (!container->isEmpty())
|
||||
if (oldBLW == nullptr)
|
||||
{
|
||||
|
||||
QWidget *oldContainerWidget;
|
||||
try
|
||||
{
|
||||
|
||||
oldContainerWidget = container->stealWidget();
|
||||
container->stealWidget()->deleteLater();
|
||||
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
m_swap->setWidget(oldContainerWidget);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!oldBLW->slotClose())
|
||||
{
|
||||
|
||||
|
||||
container->setWidget(oldSwapWidget);
|
||||
throw "MultiMonitorSelectorBase::killOrSwapOldBLW: failed to close old blw";
|
||||
}
|
||||
|
||||
|
||||
if(m_swap->activeWidgetType() == LtsScreenBase::WidgetType::SecondaryWidget && !m_swap->hasSecondaryWidget() && m_swap->hasMainWidget())
|
||||
m_swap->toggle();
|
||||
else if(m_swap->activeWidgetType() == LtsScreenBase::WidgetType::MainWidget && !m_swap->hasMainWidget() && m_swap->hasSecondaryWidget())
|
||||
m_swap->toggle();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QWidget *oldWidget;
|
||||
try
|
||||
{
|
||||
|
||||
oldWidget = container->widget();
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto *oldBLW = qobject_cast<LtsWidgets::LtsBaseLayoutWidget *>(oldWidget);
|
||||
|
||||
if (oldBLW == nullptr)
|
||||
{
|
||||
container->stealWidget()->deleteLater();
|
||||
|
||||
container->stealWidget();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!oldBLW->slotClose())
|
||||
{
|
||||
|
||||
throw "MultiMonitorSelectorBase::killOrSwapOldBLW: failed to close old blw";
|
||||
}
|
||||
|
||||
container->stealWidget();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorBase::setWidget(QWidget *widget)
|
||||
void MultiMonitorSelectorBase::setWidget(QWidget* widget)
|
||||
{
|
||||
m_widget = widget;
|
||||
m_widget = widget;
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorBase::mouseMoveEvent(QMouseEvent *event)
|
||||
void MultiMonitorSelectorBase::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
m_cursorPos = event->pos();
|
||||
update();
|
||||
m_cursorPos = event->pos();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorBase::mousePressEvent(QMouseEvent *event)
|
||||
void MultiMonitorSelectorBase::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
const QRect abortButtonRect(QRect(centeredRect().topRight() + QPoint(s_buttonSize, s_buttonSize), QSize(s_buttonSize, s_buttonSize)));
|
||||
auto pos = event->pos();
|
||||
const QRect abortButtonRect(
|
||||
QRect(centeredRect().topRight() + QPoint(s_buttonSize, s_buttonSize), QSize(s_buttonSize, s_buttonSize)));
|
||||
auto pos = event->pos();
|
||||
|
||||
Q_ASSERT(m_widget != nullptr);
|
||||
Q_ASSERT(m_widget != nullptr);
|
||||
|
||||
if (abortButtonRect.contains(pos) || m_widget == nullptr)
|
||||
{
|
||||
qWarning() << "X pressed!";
|
||||
m_reverted = true;
|
||||
m_screen->revertSwitch();
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
if (abortButtonRect.contains(pos) || m_widget == nullptr)
|
||||
{
|
||||
qWarning() << "X pressed!";
|
||||
m_reverted = true;
|
||||
m_screen->revertSwitch();
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
if (processSelection(pos))
|
||||
{
|
||||
qWarning() << "process!";
|
||||
m_screen->finalizeSwitch();
|
||||
selected();
|
||||
return;
|
||||
}
|
||||
if (processSelection(pos))
|
||||
{
|
||||
qWarning() << "process!";
|
||||
m_screen->finalizeSwitch();
|
||||
selected();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorBase::selected()
|
||||
{
|
||||
m_widget = nullptr;
|
||||
m_selected = true;
|
||||
emit signalSelected();
|
||||
m_widget = nullptr;
|
||||
m_selected = true;
|
||||
emit signalSelected();
|
||||
}
|
||||
|
||||
|
||||
QRect MultiMonitorSelectorBase::centeredRect() const
|
||||
{
|
||||
|
||||
if (m_cachedCenteredRect.isValid())
|
||||
|
||||
if (m_cachedCenteredRect.isValid())
|
||||
return m_cachedCenteredRect;
|
||||
|
||||
const QSize thisSize(size());
|
||||
const QSize newSize(thisSize.width() * 0.20, thisSize.height() * 0.20);
|
||||
m_cachedCenteredRect = QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, newSize, rect());
|
||||
|
||||
return m_cachedCenteredRect;
|
||||
|
||||
|
||||
const QSize thisSize(size());
|
||||
const QSize newSize(thisSize.width() * 0.20, thisSize.height() * 0.20);
|
||||
m_cachedCenteredRect = QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, newSize, rect());
|
||||
|
||||
return m_cachedCenteredRect;
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorBase::setColors(QPainter &p, const QRect checkSelection, bool occupied, bool countEdge)
|
||||
void MultiMonitorSelectorBase::setColors(QPainter& p, const QRect checkSelection, bool occupied, bool countEdge)
|
||||
{
|
||||
if (occupied)
|
||||
{
|
||||
p.setBrush(QColor("silver"));
|
||||
p.setPen(QPen(QColor("white"), 2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (checkSelection.contains(m_cursorPos, countEdge))
|
||||
{
|
||||
|
||||
p.setBrush(QColor("grey"));
|
||||
p.setPen(QPen(QColor("white"), 2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
p.setBrush(QColor("black"));
|
||||
p.setPen(QPen(p.brush(), 1));
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorBase::drawBase(QPainter &p, bool drawSelector, bool occupied, bool isSecondary, bool isInactiveWidgetOccupied)
|
||||
{
|
||||
bool showReplacementIndicator = true;
|
||||
#ifndef GUEZ_MODE
|
||||
isSecondary = false;
|
||||
showReplacementIndicator = false;
|
||||
#endif
|
||||
|
||||
|
||||
p.save();
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
|
||||
|
||||
p.setBrush(QColor(53, 53, 53, 150));
|
||||
p.drawRect(geometry());
|
||||
|
||||
|
||||
|
||||
const QRect centered(centeredRect());
|
||||
p.setBrush(QColor("silver"));
|
||||
p.setPen(QPen(QColor("black"), 0.5));
|
||||
|
||||
|
||||
|
||||
if (isSecondary && isInactiveWidgetOccupied)
|
||||
{
|
||||
const QRect r(centered.adjusted(12, 12, 12, 12));
|
||||
setColors(p, r, true);
|
||||
p.drawRoundedRect(r, 7, 7);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (drawSelector)
|
||||
{
|
||||
if (!m_screenIsIrreplaceable)
|
||||
if (occupied)
|
||||
{
|
||||
|
||||
setColors(p, centered, occupied);
|
||||
p.setBrush(QColor("silver"));
|
||||
p.setPen(QPen(QColor("white"), 2));
|
||||
return;
|
||||
}
|
||||
|
||||
p.drawRoundedRect(centered, 7, 7);
|
||||
}
|
||||
if (checkSelection.contains(m_cursorPos, countEdge))
|
||||
{
|
||||
|
||||
p.setBrush(QColor("grey"));
|
||||
p.setPen(QPen(QColor("white"), 2));
|
||||
return;
|
||||
}
|
||||
|
||||
const int cX = centered.x();
|
||||
const int cW = centered.width();
|
||||
const int cY = centered.y();
|
||||
const int cH = centered.height();
|
||||
p.setBrush(QColor("black"));
|
||||
p.setPen(QPen(p.brush(), 1));
|
||||
}
|
||||
|
||||
void MultiMonitorSelectorBase::drawBase(QPainter& p, bool drawSelector, bool occupied, bool isSecondary,
|
||||
bool isInactiveWidgetOccupied)
|
||||
{
|
||||
bool showReplacementIndicator = true;
|
||||
#ifndef GUEZ_MODE
|
||||
isSecondary = false;
|
||||
showReplacementIndicator = false;
|
||||
#endif
|
||||
|
||||
p.save();
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
p.setBrush(QColor(53, 53, 53, 150));
|
||||
p.drawRect(geometry());
|
||||
|
||||
const QRect centered(centeredRect());
|
||||
p.setBrush(QColor("silver"));
|
||||
p.setPen(QPen(QColor("black"), 0.5));
|
||||
|
||||
if (isSecondary && isInactiveWidgetOccupied)
|
||||
{
|
||||
const QRect r(centered.adjusted(12, 12, 12, 12));
|
||||
setColors(p, r, true);
|
||||
p.drawRoundedRect(r, 7, 7);
|
||||
}
|
||||
|
||||
if (drawSelector)
|
||||
{
|
||||
if (!m_screenIsIrreplaceable)
|
||||
{
|
||||
|
||||
setColors(p, centered, occupied);
|
||||
}
|
||||
|
||||
p.drawRoundedRect(centered, 7, 7);
|
||||
}
|
||||
|
||||
const int cX = centered.x();
|
||||
const int cW = centered.width();
|
||||
const int cY = centered.y();
|
||||
const int cH = centered.height();
|
||||
|
||||
if (isSecondary)
|
||||
{
|
||||
QPen pen(p.pen());
|
||||
QColor pc(pen.color());
|
||||
const QColor c(255 - pc.red(), 255 - pc.green(), 255 - pc.blue());
|
||||
pen.setColor(c);
|
||||
p.setPen(pen);
|
||||
|
||||
QFont f(p.font());
|
||||
f.setBold(true);
|
||||
f.setPixelSize(cH / 2);
|
||||
p.setFont(f);
|
||||
|
||||
const QString text(tr("S", "Secondary (German: 'H' for 'Hilfsansicht')"));
|
||||
|
||||
p.drawText(centered, Qt::AlignCenter, text);
|
||||
}
|
||||
|
||||
const QRect abortButtonRect(
|
||||
QRect(centered.topRight() + QPoint(s_buttonSize, s_buttonSize), QSize(s_buttonSize, s_buttonSize)));
|
||||
const QPoint topRight(abortButtonRect.topLeft());
|
||||
setColors(p, abortButtonRect, false, false);
|
||||
|
||||
|
||||
if (isSecondary)
|
||||
{
|
||||
QPen pen(p.pen());
|
||||
QColor pc(pen.color());
|
||||
const QColor c(255 - pc.red(), 255 - pc.green(), 255 - pc.blue());
|
||||
pen.setColor(c);
|
||||
pen.setWidth(5.0);
|
||||
p.setPen(pen);
|
||||
|
||||
QFont f(p.font());
|
||||
f.setBold(true);
|
||||
f.setPixelSize(cH / 2);
|
||||
p.setFont(f);
|
||||
p.drawLines(QVector<QLine>() << QLine(topRight, topRight + QPoint(s_buttonSize, s_buttonSize))
|
||||
<< QLine(topRight + QPoint(0, s_buttonSize), topRight + QPoint(s_buttonSize, 0)));
|
||||
|
||||
const QString text(tr("S", "Secondary (German: 'H' for 'Hilfsansicht')"));
|
||||
if (showReplacementIndicator && occupied)
|
||||
{
|
||||
p.setBrush(QColor("silver"));
|
||||
p.setPen(QPen(QColor("white"), 2));
|
||||
|
||||
p.drawText(centered, Qt::AlignCenter, text);
|
||||
}
|
||||
const QRect secondRect(centered.adjusted(cW + 70, 0, cW + 70, 0));
|
||||
p.drawRoundedRect(secondRect, 7, 7);
|
||||
|
||||
p.drawLine(cX + cW + 15, cY + (cH / 2), cX + cW + 55, cY + (cH / 2));
|
||||
|
||||
|
||||
const QRect abortButtonRect(QRect(centered.topRight() + QPoint(s_buttonSize, s_buttonSize), QSize(s_buttonSize, s_buttonSize)));
|
||||
const QPoint topRight(abortButtonRect.topLeft() );
|
||||
setColors(p, abortButtonRect, false, false);
|
||||
|
||||
QPen pen(p.pen());
|
||||
pen.setWidth(5.0);
|
||||
p.setPen(pen);
|
||||
|
||||
p.drawLines(QVector<QLine>()
|
||||
<< QLine(topRight , topRight + QPoint(s_buttonSize, s_buttonSize))
|
||||
<< QLine(topRight + QPoint(0, s_buttonSize), topRight + QPoint(s_buttonSize, 0))
|
||||
);
|
||||
|
||||
|
||||
|
||||
if (showReplacementIndicator && occupied)
|
||||
{
|
||||
p.setBrush(QColor("silver"));
|
||||
p.setPen(QPen(QColor("white"), 2));
|
||||
|
||||
const QRect secondRect(centered.adjusted(cW + 70, 0, cW + 70, 0));
|
||||
p.drawRoundedRect(secondRect, 7, 7);
|
||||
|
||||
|
||||
p.drawLine(cX + cW + 15, cY + (cH / 2),
|
||||
cX + cW + 55, cY + (cH / 2));
|
||||
|
||||
|
||||
p.drawPolygon(QPolygon(
|
||||
{
|
||||
QPoint(cX + cW + 56, cY + (cH / 2)),
|
||||
p.drawPolygon(QPolygon({
|
||||
QPoint(cX + cW + 56, cY + (cH / 2)),
|
||||
QPoint(cX + cW + 46, cY + (cH / 2) - 10),
|
||||
QPoint(cX + cW + 46, cY + (cH / 2) + 10),
|
||||
}));
|
||||
|
||||
const int srX = secondRect.x();
|
||||
const int srY = secondRect.y();
|
||||
const int srH = secondRect.height();
|
||||
const int diameter = srH - 50;
|
||||
const int widthByTwo = (secondRect.width() / 2);
|
||||
const int diameterByTwo = (diameter / 2);
|
||||
const int lineX1 = srX + widthByTwo - diameterByTwo;
|
||||
const int lineY1 = srY + 25;
|
||||
|
||||
p.drawEllipse(lineX1, lineY1, diameter, diameter);
|
||||
const int srX = secondRect.x();
|
||||
const int srY = secondRect.y();
|
||||
const int srH = secondRect.height();
|
||||
const int diameter = srH - 50;
|
||||
const int widthByTwo = (secondRect.width() / 2);
|
||||
const int diameterByTwo = (diameter / 2);
|
||||
const int lineX1 = srX + widthByTwo - diameterByTwo;
|
||||
const int lineY1 = srY + 25;
|
||||
|
||||
|
||||
if (isSecondary)
|
||||
{
|
||||
QFont f(p.font());
|
||||
f.setBold(true);
|
||||
f.setPixelSize(srH / 2);
|
||||
p.setFont(f);
|
||||
p.drawEllipse(lineX1, lineY1, diameter, diameter);
|
||||
|
||||
const QString text(tr("S", "Secondary (German: 'H' for 'Hilfsansicht')"));
|
||||
if (isSecondary)
|
||||
{
|
||||
QFont f(p.font());
|
||||
f.setBold(true);
|
||||
f.setPixelSize(srH / 2);
|
||||
p.setFont(f);
|
||||
|
||||
p.drawText(secondRect, Qt::AlignCenter, text);
|
||||
const QString text(tr("S", "Secondary (German: 'H' for 'Hilfsansicht')"));
|
||||
|
||||
p.drawText(secondRect, Qt::AlignCenter, text);
|
||||
}
|
||||
|
||||
const int lineX2 = lineX1 + diameter;
|
||||
const int lineY2 = lineY1 + diameter;
|
||||
p.drawLine(lineX1, lineY1, lineX2, lineY2);
|
||||
p.drawLine(lineX2, lineY1, lineX1, lineY2);
|
||||
}
|
||||
|
||||
|
||||
const int lineX2 = lineX1 + diameter;
|
||||
const int lineY2 = lineY1 + diameter;
|
||||
p.drawLine(lineX1, lineY1, lineX2, lineY2);
|
||||
p.drawLine(lineX2, lineY1, lineX1, lineY2);
|
||||
}
|
||||
|
||||
|
||||
p.restore();
|
||||
p.restore();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+45
-38
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QScreen;
|
||||
class QPainter;
|
||||
@@ -11,7 +9,6 @@ class QPaintEvent;
|
||||
class QMouseEvent;
|
||||
class QCloseEvent;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
class LtsScreenBase;
|
||||
@@ -19,47 +16,57 @@ class LtsScreenContainer;
|
||||
|
||||
class MultiMonitorSelectorBase : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MultiMonitorSelectorBase(LtsScreenBase *screen, const QVector<QWidget *> &irreplacableWidgets, QWidget *);
|
||||
virtual ~MultiMonitorSelectorBase() {}
|
||||
public:
|
||||
explicit MultiMonitorSelectorBase(LtsScreenBase* screen, const QVector<QWidget*>& irreplacableWidgets, QWidget*);
|
||||
|
||||
void setSwap(LtsScreenContainer *swap) { m_swap = swap; }
|
||||
void setWidget(QWidget *widget);
|
||||
LtsScreenBase *screen() const { return m_screen; }
|
||||
virtual ~MultiMonitorSelectorBase() {}
|
||||
|
||||
signals:
|
||||
void signalSelected();
|
||||
void setSwap(LtsScreenContainer* swap)
|
||||
{
|
||||
m_swap = swap;
|
||||
}
|
||||
|
||||
protected:
|
||||
static int s_offset;
|
||||
static int s_margin;
|
||||
static int s_buttonSize;
|
||||
void setWidget(QWidget* widget);
|
||||
|
||||
LtsScreenContainer *m_swap { nullptr };
|
||||
QWidget *m_widget { nullptr };
|
||||
mutable QRect m_cachedCenteredRect;
|
||||
QVector<QWidget *> m_irreplacableWidgets;
|
||||
LtsScreenBase* screen() const
|
||||
{
|
||||
return m_screen;
|
||||
}
|
||||
|
||||
void drawBase(QPainter &p, bool drawSelector = true, bool occupied = false, bool isSecondary = false, bool isInactiveWidgetOccupied = false);
|
||||
bool killOrSwapOldBLW(LtsScreenContainer *container) noexcept(false);
|
||||
bool isNullSwap(LtsScreenContainer *container);
|
||||
QRect centeredRect() const;
|
||||
void setColors(QPainter &p, const QRect checkSelection, bool occupied = false, bool countEdge = false);
|
||||
void selected();
|
||||
virtual bool processSelection(const QPoint &selection) = 0;
|
||||
signals:
|
||||
void signalSelected();
|
||||
|
||||
private:
|
||||
QPoint m_cursorPos;
|
||||
bool m_selected { false };
|
||||
LtsScreenBase *m_screen;
|
||||
bool m_screenIsIrreplaceable;
|
||||
bool m_reverted { false };
|
||||
protected:
|
||||
static int s_offset;
|
||||
static int s_margin;
|
||||
static int s_buttonSize;
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
LtsScreenContainer* m_swap{nullptr};
|
||||
QWidget* m_widget{nullptr};
|
||||
mutable QRect m_cachedCenteredRect;
|
||||
QVector<QWidget*> m_irreplacableWidgets;
|
||||
|
||||
void drawBase(QPainter& p, bool drawSelector = true, bool occupied = false, bool isSecondary = false,
|
||||
bool isInactiveWidgetOccupied = false);
|
||||
bool killOrSwapOldBLW(LtsScreenContainer* container) noexcept(false);
|
||||
bool isNullSwap(LtsScreenContainer* container);
|
||||
QRect centeredRect() const;
|
||||
void setColors(QPainter& p, const QRect checkSelection, bool occupied = false, bool countEdge = false);
|
||||
void selected();
|
||||
virtual bool processSelection(const QPoint& selection) = 0;
|
||||
|
||||
private:
|
||||
QPoint m_cursorPos;
|
||||
bool m_selected{false};
|
||||
LtsScreenBase* m_screen;
|
||||
bool m_screenIsIrreplaceable;
|
||||
bool m_reverted{false};
|
||||
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+51
-70
@@ -1,100 +1,81 @@
|
||||
|
||||
|
||||
#include "lts_multi_monitor.h"
|
||||
#include "lts_multi_monitor_selector_normal.h"
|
||||
|
||||
#include "lts_dummy_widget.h"
|
||||
#include "lts_multi_monitor.h"
|
||||
#include "lts_screen_container.h"
|
||||
#include "lts_screen_normal.h"
|
||||
#include "lts_dummy_widget.h"
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QPaintEvent>
|
||||
#include <QStyle>
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QColor>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
#include <QStyle>
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
|
||||
MultiMonitorSelectorNormal::MultiMonitorSelectorNormal(LtsScreenNormal *screen, bool isSecondary, const QVector<QWidget *> &irreplacableWidgets)
|
||||
: MultiMonitorSelectorBase(screen, irreplacableWidgets, nullptr)
|
||||
, m_screen(screen)
|
||||
, m_screenIsEmpty(screen->isEmpty())
|
||||
, m_isSecondary(isSecondary)
|
||||
, m_isInactiveWidgetOccupied(screen->child()->isInactiveWidgetOccupied())
|
||||
MultiMonitorSelectorNormal::MultiMonitorSelectorNormal(LtsScreenNormal* screen, bool isSecondary,
|
||||
const QVector<QWidget*>& irreplacableWidgets)
|
||||
: MultiMonitorSelectorBase(screen, irreplacableWidgets, nullptr), m_screen(screen),
|
||||
m_screenIsEmpty(screen->isEmpty()), m_isSecondary(isSecondary),
|
||||
m_isInactiveWidgetOccupied(screen->child()->isInactiveWidgetOccupied())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MultiMonitorSelectorNormal::~MultiMonitorSelectorNormal() {}
|
||||
|
||||
MultiMonitorSelectorNormal::~MultiMonitorSelectorNormal()
|
||||
bool MultiMonitorSelectorNormal::processSelection(const QPoint& selection)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool MultiMonitorSelectorNormal::processSelection(const QPoint &selection)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (!centeredRect().contains(selection))
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_screen->isIrreplaceable())
|
||||
{
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_irreplacableWidgets.contains(m_screen->child()->widget()))
|
||||
return false;
|
||||
}
|
||||
catch(...){}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (killOrSwapOldBLW(m_screen->child()))
|
||||
if (!centeredRect().contains(selection))
|
||||
{
|
||||
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (m_screen->isIrreplaceable())
|
||||
{
|
||||
|
||||
|
||||
m_screen->putWidgetUnmanaged(m_widget);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
try
|
||||
{
|
||||
if (m_irreplacableWidgets.contains(m_screen->child()->widget()))
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (killOrSwapOldBLW(m_screen->child()))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_screen->putWidgetUnmanaged(m_widget);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorNormal::paintEvent(QPaintEvent *)
|
||||
void MultiMonitorSelectorNormal::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter p(this);
|
||||
drawBase(p, true, !m_screenIsEmpty, m_isSecondary, m_isInactiveWidgetOccupied);
|
||||
QPainter p(this);
|
||||
drawBase(p, true, !m_screenIsEmpty, m_isSecondary, m_isInactiveWidgetOccupied);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+14
-16
@@ -1,17 +1,14 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include "lts_multi_monitor_selector_base.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QScreen;
|
||||
class QPaintEvent;
|
||||
class QMouseEvent;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
class LtsScreenBase;
|
||||
@@ -19,20 +16,21 @@ class LtsScreenNormal;
|
||||
|
||||
class MultiMonitorSelectorNormal : public MultiMonitorSelectorBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MultiMonitorSelectorNormal(LtsScreenNormal *screen, bool isSecondary, const QVector<QWidget *> &irreplacableWidgets = {});
|
||||
~MultiMonitorSelectorNormal();
|
||||
public:
|
||||
explicit MultiMonitorSelectorNormal(LtsScreenNormal* screen, bool isSecondary,
|
||||
const QVector<QWidget*>& irreplacableWidgets = {});
|
||||
~MultiMonitorSelectorNormal();
|
||||
|
||||
private:
|
||||
LtsScreenNormal *m_screen;
|
||||
bool m_screenIsEmpty;
|
||||
bool m_isSecondary;
|
||||
bool m_isInactiveWidgetOccupied;
|
||||
private:
|
||||
LtsScreenNormal* m_screen;
|
||||
bool m_screenIsEmpty;
|
||||
bool m_isSecondary;
|
||||
bool m_isInactiveWidgetOccupied;
|
||||
|
||||
bool processSelection(const QPoint &selection) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
bool processSelection(const QPoint& selection) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+221
-264
@@ -1,323 +1,280 @@
|
||||
|
||||
|
||||
#include "lts_multi_monitor_selector_wide.h"
|
||||
|
||||
#include "lts_multi_monitor.h"
|
||||
#include "lts_multi_monitor_selector_wide.h"
|
||||
#include "lts_screen_container.h"
|
||||
#include "lts_screen_wide.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QPaintEvent>
|
||||
#include <QStyle>
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
#include <QColor>
|
||||
|
||||
|
||||
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
#include <QStyle>
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
|
||||
MultiMonitorSelectorWide::MultiMonitorSelectorWide(LtsScreenWide *screen, QWidget *, const QVector<QWidget *> &irreplacableWidgets)
|
||||
: MultiMonitorSelectorBase(screen, irreplacableWidgets, nullptr )
|
||||
, m_screen(screen)
|
||||
{}
|
||||
|
||||
MultiMonitorSelectorWide::MultiMonitorSelectorWide(LtsScreenWide* screen, QWidget*,
|
||||
const QVector<QWidget*>& irreplacableWidgets)
|
||||
: MultiMonitorSelectorBase(screen, irreplacableWidgets, nullptr), m_screen(screen)
|
||||
{
|
||||
}
|
||||
|
||||
bool MultiMonitorSelectorWide::isDrawOnlyOneSelector()
|
||||
{
|
||||
|
||||
|
||||
bool res =
|
||||
((m_screen->childMain()->isEmpty() && m_screen->childLeft()->isEmpty() && m_screen->childRight()->isEmpty()) ||
|
||||
(!m_screen->childMain()->isEmpty() && m_swap != nullptr && m_screen->childMain() == m_swap));
|
||||
|
||||
bool res = ((m_screen->childMain()->isEmpty() && m_screen->childLeft()->isEmpty() && m_screen->childRight()->isEmpty())
|
||||
|| (!m_screen->childMain()->isEmpty() && m_swap != nullptr && m_screen->childMain() == m_swap));
|
||||
|
||||
|
||||
|
||||
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool MultiMonitorSelectorWide::processSelection(const QPoint &selection)
|
||||
bool MultiMonitorSelectorWide::processSelection(const QPoint& selection)
|
||||
{
|
||||
|
||||
|
||||
|
||||
LtsScreenContainer* main = m_screen->childMain();
|
||||
LtsScreenContainer* left = m_screen->childLeft();
|
||||
LtsScreenContainer* right = m_screen->childRight();
|
||||
|
||||
bool singleSelector = isDrawOnlyOneSelector();
|
||||
|
||||
LtsScreenContainer *main = m_screen->childMain();
|
||||
LtsScreenContainer *left = m_screen->childLeft();
|
||||
LtsScreenContainer *right = m_screen->childRight();
|
||||
|
||||
bool singleSelector = isDrawOnlyOneSelector();
|
||||
|
||||
if (singleSelector)
|
||||
{
|
||||
if (main->isIrreplaceable())
|
||||
if (singleSelector)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_irreplacableWidgets.contains(main->widget()))
|
||||
return false;
|
||||
}
|
||||
catch(...){}
|
||||
|
||||
|
||||
|
||||
if (isNullSwap(m_screen->childMain()))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (centeredRect().contains(selection))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (killOrSwapOldBLW(m_screen->childMain()))
|
||||
if (main->isIrreplaceable())
|
||||
{
|
||||
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
m_screen->putWidgetUnmanagedMain(m_widget);
|
||||
|
||||
return true;
|
||||
try
|
||||
{
|
||||
if (m_irreplacableWidgets.contains(main->widget()))
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
if (isNullSwap(m_screen->childMain()))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (centeredRect().contains(selection))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (killOrSwapOldBLW(m_screen->childMain()))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_screen->putWidgetUnmanagedMain(m_widget);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool leftContains = leftSide().contains(selection);
|
||||
bool rightContains = rightSide().contains(selection);
|
||||
|
||||
if (leftContains)
|
||||
{
|
||||
if (left->isIrreplaceable())
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_irreplacableWidgets.contains(left->widget()))
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
QWidget* oldWidget = main->stealWidget();
|
||||
|
||||
m_screen->putWidgetUnmanagedRight(oldWidget);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (killOrSwapOldBLW(left))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_screen->putWidgetUnmanagedLeft(m_widget);
|
||||
return true;
|
||||
}
|
||||
else if (rightContains)
|
||||
{
|
||||
if (right->isIrreplaceable())
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_irreplacableWidgets.contains(right->widget()))
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
QWidget* oldWidget = main->stealWidget();
|
||||
|
||||
m_screen->putWidgetUnmanagedLeft(oldWidget);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (killOrSwapOldBLW(right))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_screen->putWidgetUnmanagedRight(m_widget);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool leftContains = leftSide().contains(selection);
|
||||
bool rightContains = rightSide().contains(selection);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (leftContains)
|
||||
{
|
||||
if (left->isIrreplaceable())
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_irreplacableWidgets.contains(left->widget()))
|
||||
return false;
|
||||
}
|
||||
catch(...){}
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
QWidget *oldWidget = main->stealWidget();
|
||||
|
||||
|
||||
m_screen->putWidgetUnmanagedRight(oldWidget);
|
||||
}
|
||||
catch (...) {}
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (killOrSwapOldBLW(left))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_screen->putWidgetUnmanagedLeft(m_widget);
|
||||
return true;
|
||||
}
|
||||
else if (rightContains)
|
||||
{
|
||||
if (right->isIrreplaceable())
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (m_irreplacableWidgets.contains(right->widget()))
|
||||
return false;
|
||||
}
|
||||
catch(...){}
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
QWidget *oldWidget = main->stealWidget();
|
||||
|
||||
|
||||
m_screen->putWidgetUnmanagedLeft(oldWidget);
|
||||
}
|
||||
catch (...) {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (killOrSwapOldBLW(right))
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
m_screen->putWidgetUnmanagedRight(m_widget);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QRect MultiMonitorSelectorWide::leftSide() const
|
||||
{
|
||||
QRect centered = centeredRect();
|
||||
QRect centered = centeredRect();
|
||||
|
||||
return QRect(centered.x() + s_margin,
|
||||
centered.y() + s_margin,
|
||||
(centered.width() / 2) - (s_margin*2),
|
||||
centered.height() - (s_margin*2));
|
||||
return QRect(centered.x() + s_margin, centered.y() + s_margin, (centered.width() / 2) - (s_margin * 2),
|
||||
centered.height() - (s_margin * 2));
|
||||
}
|
||||
|
||||
|
||||
QRect MultiMonitorSelectorWide::rightSide() const
|
||||
{
|
||||
QRect centered = centeredRect();
|
||||
QRect centered = centeredRect();
|
||||
|
||||
return QRect(centered.x() + (centered.width() / 2) + s_margin,
|
||||
centered.y() + s_margin,
|
||||
(centered.width() / 2) - (s_margin*2),
|
||||
centered.height() - (s_margin*2));
|
||||
return QRect(centered.x() + (centered.width() / 2) + s_margin, centered.y() + s_margin,
|
||||
(centered.width() / 2) - (s_margin * 2), centered.height() - (s_margin * 2));
|
||||
}
|
||||
|
||||
|
||||
void MultiMonitorSelectorWide::paintEvent(QPaintEvent *)
|
||||
void MultiMonitorSelectorWide::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter p(this);
|
||||
p.save();
|
||||
QPainter p(this);
|
||||
p.save();
|
||||
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
const QRect centered(centeredRect());
|
||||
const QRect centered(centeredRect());
|
||||
|
||||
bool drawOnlyOneSelector = isDrawOnlyOneSelector();
|
||||
drawBase(p, drawOnlyOneSelector, false );
|
||||
bool drawOnlyOneSelector = isDrawOnlyOneSelector();
|
||||
drawBase(p, drawOnlyOneSelector, false);
|
||||
|
||||
|
||||
|
||||
if (!drawOnlyOneSelector)
|
||||
{
|
||||
p.setBrush(QColor("silver"));
|
||||
p.setPen(QPen(QColor("black"), 0.5));
|
||||
p.drawRoundedRect(centered, 7, 7);
|
||||
|
||||
|
||||
bool leftIrreplacable = false;
|
||||
try
|
||||
if (!drawOnlyOneSelector)
|
||||
{
|
||||
leftIrreplacable = m_irreplacableWidgets.contains(m_screen->childLeft()->widget());
|
||||
}
|
||||
catch(...){}
|
||||
p.setBrush(QColor("silver"));
|
||||
p.setPen(QPen(QColor("black"), 0.5));
|
||||
p.drawRoundedRect(centered, 7, 7);
|
||||
|
||||
if (!m_screen->childLeft()->isIrreplaceable() && !leftIrreplacable)
|
||||
{
|
||||
|
||||
const QRect leftSide(centered.x() + s_margin,
|
||||
centered.y() + s_margin,
|
||||
(centered.width() / 2) - (s_margin*2),
|
||||
centered.height() - (s_margin*2));
|
||||
bool leftIrreplacable = false;
|
||||
try
|
||||
{
|
||||
leftIrreplacable = m_irreplacableWidgets.contains(m_screen->childLeft()->widget());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
setColors(p, leftSide, !m_screen->childLeft()->isEmpty());
|
||||
if (!m_screen->childLeft()->isIrreplaceable() && !leftIrreplacable)
|
||||
{
|
||||
|
||||
p.drawRoundedRect(leftSide, 6, 6);
|
||||
const QRect leftSide(centered.x() + s_margin, centered.y() + s_margin,
|
||||
(centered.width() / 2) - (s_margin * 2), centered.height() - (s_margin * 2));
|
||||
|
||||
setColors(p, leftSide, !m_screen->childLeft()->isEmpty());
|
||||
|
||||
p.drawRoundedRect(leftSide, 6, 6);
|
||||
}
|
||||
|
||||
bool rightIrreplacable = false;
|
||||
try
|
||||
{
|
||||
rightIrreplacable = m_irreplacableWidgets.contains(m_screen->childRight()->widget());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
if (!m_screen->childRight()->isIrreplaceable() && !rightIrreplacable)
|
||||
{
|
||||
|
||||
const QRect rightSide(centered.x() + (centered.width() / 2) + s_margin, centered.y() + s_margin,
|
||||
(centered.width() / 2) - (s_margin * 2), centered.height() - (s_margin * 2));
|
||||
|
||||
setColors(p, rightSide, !m_screen->childRight()->isEmpty());
|
||||
|
||||
p.drawRoundedRect(rightSide, 6, 6);
|
||||
}
|
||||
}
|
||||
|
||||
static int buttonSize = 20;
|
||||
const QRect abortButtonRect(
|
||||
QRect(centered.topRight() + QPoint(buttonSize, buttonSize), QSize(buttonSize, buttonSize)));
|
||||
const QPoint topRight(abortButtonRect.topLeft());
|
||||
setColors(p, abortButtonRect, false, false);
|
||||
|
||||
bool rightIrreplacable = false;
|
||||
try
|
||||
{
|
||||
rightIrreplacable = m_irreplacableWidgets.contains(m_screen->childRight()->widget());
|
||||
}
|
||||
catch(...){}
|
||||
QPen pen(p.pen());
|
||||
pen.setWidth(5.0);
|
||||
p.setPen(pen);
|
||||
|
||||
if (!m_screen->childRight()->isIrreplaceable() && !rightIrreplacable)
|
||||
{
|
||||
|
||||
const QRect rightSide(centered.x() + (centered.width() / 2) + s_margin,
|
||||
centered.y() + s_margin,
|
||||
(centered.width() / 2) - (s_margin*2),
|
||||
centered.height() - (s_margin*2));
|
||||
p.drawLines(QVector<QLine>() << QLine(topRight, topRight + QPoint(buttonSize, buttonSize))
|
||||
<< QLine(topRight + QPoint(0, buttonSize), topRight + QPoint(buttonSize, 0)));
|
||||
|
||||
setColors(p, rightSide, !m_screen->childRight()->isEmpty());
|
||||
|
||||
p.drawRoundedRect(rightSide, 6, 6);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int buttonSize = 20;
|
||||
const QRect abortButtonRect(QRect(centered.topRight() + QPoint(buttonSize, buttonSize), QSize(buttonSize, buttonSize)));
|
||||
const QPoint topRight(abortButtonRect.topLeft() );
|
||||
setColors(p, abortButtonRect, false, false);
|
||||
|
||||
|
||||
QPen pen(p.pen());
|
||||
pen.setWidth(5.0);
|
||||
p.setPen(pen);
|
||||
|
||||
p.drawLines(QVector<QLine>()
|
||||
<< QLine(topRight , topRight + QPoint(buttonSize, buttonSize))
|
||||
<< QLine(topRight + QPoint(0, buttonSize), topRight + QPoint(buttonSize, 0))
|
||||
);
|
||||
|
||||
|
||||
p.restore();
|
||||
p.restore();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+13
-15
@@ -1,17 +1,14 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include "LtsMultiMonitor/lts_multi_monitor_selector_base.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QScreen;
|
||||
class QPaintEvent;
|
||||
class QMouseEvent;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
class LtsScreenWide;
|
||||
@@ -19,19 +16,20 @@ class LtsScreenBase;
|
||||
|
||||
class MultiMonitorSelectorWide : public MultiMonitorSelectorBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MultiMonitorSelectorWide(LtsScreenWide *screen, QWidget *superParent, const QVector<QWidget *> &irreplacableWidgets);
|
||||
public:
|
||||
explicit MultiMonitorSelectorWide(LtsScreenWide* screen, QWidget* superParent,
|
||||
const QVector<QWidget*>& irreplacableWidgets);
|
||||
|
||||
private:
|
||||
LtsScreenWide *m_screen;
|
||||
private:
|
||||
LtsScreenWide* m_screen;
|
||||
|
||||
bool isDrawOnlyOneSelector();
|
||||
QRect leftSide() const;
|
||||
QRect rightSide() const;
|
||||
bool processSelection(const QPoint &selection) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
bool isDrawOnlyOneSelector();
|
||||
QRect leftSide() const;
|
||||
QRect rightSide() const;
|
||||
bool processSelection(const QPoint& selection) override;
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+28
-46
@@ -1,70 +1,52 @@
|
||||
#include "lts_screen_base.h"
|
||||
|
||||
#include "lts_dummy_widget.h"
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <LtsUtilsCore/promise.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSplitter>
|
||||
#include <QHBoxLayout>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <QCloseEvent>
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSplitter>
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QtPlatformHeaders/qwindowswindowfunctions.h>
|
||||
#endif
|
||||
|
||||
|
||||
class NoCloseWidget : public QWidget
|
||||
{
|
||||
void closeEvent(QCloseEvent *event) override
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
void closeEvent(QCloseEvent* event) override
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
LtsScreenBase::LtsScreenBase(QRect screenGeo, int screenId, bool debugMargins, const QString &serial)
|
||||
: m_screenDialog(new NoCloseWidget())
|
||||
, m_screenId(screenId)
|
||||
, m_serial(serial)
|
||||
, m_screenRect(screenGeo)
|
||||
LtsScreenBase::LtsScreenBase(QRect screenGeo, int screenId, bool debugMargins, const QString& serial)
|
||||
: m_screenDialog(new NoCloseWidget()), m_screenId(screenId), m_serial(serial), m_screenRect(screenGeo)
|
||||
{
|
||||
connect(this, &LtsScreenBase::destroyed,
|
||||
m_screenDialog, &QWidget::deleteLater);
|
||||
connect(this, &LtsScreenBase::destroyed, m_screenDialog, &QWidget::deleteLater);
|
||||
|
||||
if (debugMargins)
|
||||
{
|
||||
qWarning() << "LtsScreenBase: screen rect adjusted for dev machines!";
|
||||
m_screenRect.adjust(+50, +50, -100, -100);
|
||||
}
|
||||
if (debugMargins)
|
||||
{
|
||||
qWarning() << "LtsScreenBase: screen rect adjusted for dev machines!";
|
||||
m_screenRect.adjust(+50, +50, -100, -100);
|
||||
}
|
||||
|
||||
|
||||
m_screenDialog->setWindowFlags(Qt::FramelessWindowHint);
|
||||
m_screenDialog->setGeometry(m_screenRect);
|
||||
m_screenDialog->setMinimumSize(m_screenRect.width(), m_screenRect.height());
|
||||
m_screenDialog->setMaximumSize(m_screenRect.width(), m_screenRect.height());
|
||||
m_screenDialog->setContentsMargins(0, 0, 0, 0);
|
||||
m_screenDialog->setWindowFlag(Qt::WindowType::WindowStaysOnBottomHint);
|
||||
m_screenDialog->setWindowFlags(Qt::FramelessWindowHint);
|
||||
m_screenDialog->setGeometry(m_screenRect);
|
||||
m_screenDialog->setMinimumSize(m_screenRect.width(), m_screenRect.height());
|
||||
m_screenDialog->setMaximumSize(m_screenRect.width(), m_screenRect.height());
|
||||
m_screenDialog->setContentsMargins(0, 0, 0, 0);
|
||||
m_screenDialog->setWindowFlag(Qt::WindowType::WindowStaysOnBottomHint);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
m_screenDialog->winId();
|
||||
QWindowsWindowFunctions::setHasBorderInFullScreen(m_screenDialog->windowHandle(), true);
|
||||
m_screenDialog->winId();
|
||||
QWindowsWindowFunctions::setHasBorderInFullScreen(m_screenDialog->windowHandle(), true);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_screenDialog->activateWindow();
|
||||
m_screenDialog->show();
|
||||
m_screenDialog->activateWindow();
|
||||
m_screenDialog->show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+56
-37
@@ -1,60 +1,79 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include "ltsmultimonitor_export.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
#include <QWidget>
|
||||
|
||||
class QSplitter;
|
||||
class QHBoxLayout;
|
||||
|
||||
namespace LtsUtils { class Promise; }
|
||||
namespace LtsUtils
|
||||
{
|
||||
class Promise;
|
||||
}
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
class LtsScreenContainer;
|
||||
|
||||
|
||||
|
||||
class LTSMULTIMONITOR_EXPORT LtsScreenBase : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum WidgetType
|
||||
{
|
||||
MainWidget,
|
||||
SecondaryWidget,
|
||||
None,
|
||||
};
|
||||
public:
|
||||
enum WidgetType {
|
||||
MainWidget,
|
||||
SecondaryWidget,
|
||||
None,
|
||||
};
|
||||
|
||||
LtsScreenBase(QRect screenGeo, int screenId, bool debugMargins, const QString &serial);
|
||||
LtsScreenBase(QRect screenGeo, int screenId, bool debugMargins, const QString& serial);
|
||||
|
||||
const QRect &screenRect() const { return m_screenRect; }
|
||||
int screenId() const { return m_screenId; }
|
||||
const QString serialNumber() const { return m_serial; }
|
||||
QWidget *screenDialog() const { return m_screenDialog; }
|
||||
const QRect& screenRect() const
|
||||
{
|
||||
return m_screenRect;
|
||||
}
|
||||
|
||||
virtual int screenType() const = 0;
|
||||
virtual int containerIdOfWidget(QWidget *widget) const noexcept(false) = 0;
|
||||
virtual LtsScreenContainer *putWidget(QWidget *widget, int screenPart = -1 ) noexcept(false) = 0;
|
||||
virtual LtsScreenContainer *containerOfWidget(QWidget *widget) noexcept(false) = 0;
|
||||
virtual bool isEmpty() const = 0;
|
||||
virtual bool isIrreplaceable() const = 0;
|
||||
virtual void check() {}
|
||||
virtual bool hasWidget(QWidget *widget) const = 0;
|
||||
virtual void switchToTemp(WidgetType ) {}
|
||||
virtual void finalizeSwitch() {}
|
||||
virtual void revertSwitch() {}
|
||||
int screenId() const
|
||||
{
|
||||
return m_screenId;
|
||||
}
|
||||
|
||||
protected:
|
||||
QWidget *m_screenDialog;
|
||||
const QString serialNumber() const
|
||||
{
|
||||
return m_serial;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_screenId;
|
||||
QString m_serial;
|
||||
QRect m_screenRect;
|
||||
QWidget* screenDialog() const
|
||||
{
|
||||
return m_screenDialog;
|
||||
}
|
||||
|
||||
virtual int screenType() const = 0;
|
||||
virtual int containerIdOfWidget(QWidget* widget) const noexcept(false) = 0;
|
||||
virtual LtsScreenContainer* putWidget(QWidget* widget, int screenPart = -1) noexcept(false) = 0;
|
||||
virtual LtsScreenContainer* containerOfWidget(QWidget* widget) noexcept(false) = 0;
|
||||
virtual bool isEmpty() const = 0;
|
||||
virtual bool isIrreplaceable() const = 0;
|
||||
|
||||
virtual void check() {}
|
||||
|
||||
virtual bool hasWidget(QWidget* widget) const = 0;
|
||||
|
||||
virtual void switchToTemp(WidgetType) {}
|
||||
|
||||
virtual void finalizeSwitch() {}
|
||||
|
||||
virtual void revertSwitch() {}
|
||||
|
||||
protected:
|
||||
QWidget* m_screenDialog;
|
||||
|
||||
private:
|
||||
int m_screenId;
|
||||
QString m_serial;
|
||||
QRect m_screenRect;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+244
-383
@@ -1,555 +1,416 @@
|
||||
#include "lts_screen_container.h"
|
||||
|
||||
#include "lts_dummy_widget.h"
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QResizeEvent>
|
||||
#include <QRect>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QRect>
|
||||
#include <QResizeEvent>
|
||||
#include <QTimer>
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
QString LtsScreenContainer::geoStr() const
|
||||
{
|
||||
return QStringLiteral("%1:%2:")
|
||||
.arg(QString::number(m_screenGeo.x()).rightJustified(4, QLatin1Char(' ')))
|
||||
.arg(QString::number(m_screenGeo.y()).rightJustified(4, QLatin1Char(' ')))
|
||||
;
|
||||
return QStringLiteral("%1:%2:")
|
||||
.arg(QString::number(m_screenGeo.x()).rightJustified(4, QLatin1Char(' ')))
|
||||
.arg(QString::number(m_screenGeo.y()).rightJustified(4, QLatin1Char(' ')));
|
||||
}
|
||||
|
||||
LtsScreenContainer::LtsScreenContainer(QRect screenGeo)
|
||||
: m_layout(new QHBoxLayout)
|
||||
, m_screenGeo(screenGeo)
|
||||
LtsScreenContainer::LtsScreenContainer(QRect screenGeo) : m_layout(new QHBoxLayout), m_screenGeo(screenGeo)
|
||||
{
|
||||
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setStretch(0, 999);
|
||||
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
vanish();
|
||||
setLayout(m_layout);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setStretch(0, 999);
|
||||
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
vanish();
|
||||
setLayout(m_layout);
|
||||
|
||||
|
||||
QTimer *t = new QTimer(this);
|
||||
t->setInterval(3000);
|
||||
QTimer* t = new QTimer(this);
|
||||
t->setInterval(3000);
|
||||
#ifdef LTS_DEBUG
|
||||
t->start();
|
||||
t->start();
|
||||
#endif
|
||||
connect(t, &QTimer::timeout,
|
||||
this, [this, screenGeo]()
|
||||
{
|
||||
QString old(QStringLiteral("<#!UNKNOWN!#>"));
|
||||
connect(t, &QTimer::timeout, this, [this, screenGeo]() {
|
||||
QString old(QStringLiteral("<#!UNKNOWN!#>"));
|
||||
|
||||
if (m_oldActiveWidget == nullptr)
|
||||
old = QStringLiteral("null");
|
||||
else if (m_oldActiveWidget == &m_mainWidget)
|
||||
old = QStringLiteral("MAIN");
|
||||
else if (m_oldActiveWidget == &m_secondaryWidget)
|
||||
old = QStringLiteral("SECONDARY");
|
||||
|
||||
|
||||
});
|
||||
if (m_oldActiveWidget == nullptr)
|
||||
old = QStringLiteral("null");
|
||||
else if (m_oldActiveWidget == &m_mainWidget)
|
||||
old = QStringLiteral("MAIN");
|
||||
else if (m_oldActiveWidget == &m_secondaryWidget)
|
||||
old = QStringLiteral("SECONDARY");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenContainer::isInactiveWidgetOccupied() const
|
||||
{
|
||||
if (m_activeWidget == &m_mainWidget && m_secondaryWidget != nullptr)
|
||||
return true;
|
||||
if (m_activeWidget == &m_secondaryWidget && m_mainWidget != nullptr)
|
||||
return true;
|
||||
return false;
|
||||
if (m_activeWidget == &m_mainWidget && m_secondaryWidget != nullptr)
|
||||
return true;
|
||||
if (m_activeWidget == &m_secondaryWidget && m_mainWidget != nullptr)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QIcon LtsScreenContainer::mainWindowIcon() const
|
||||
{
|
||||
if (m_mainWidget != nullptr)
|
||||
return m_mainWidget->windowIcon();
|
||||
return {};
|
||||
if (m_mainWidget != nullptr)
|
||||
return m_mainWidget->windowIcon();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
QIcon LtsScreenContainer::secondaryWindowIcon() const
|
||||
{
|
||||
if (m_secondaryWidget != nullptr)
|
||||
return m_secondaryWidget->windowIcon();
|
||||
return {};
|
||||
if (m_secondaryWidget != nullptr)
|
||||
return m_secondaryWidget->windowIcon();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenContainer::mainAndSecondaryOccupied() const
|
||||
{
|
||||
return (m_mainWidget != nullptr && m_secondaryWidget != nullptr);
|
||||
return (m_mainWidget != nullptr && m_secondaryWidget != nullptr);
|
||||
}
|
||||
|
||||
|
||||
LtsScreenBase::WidgetType LtsScreenContainer::activeWidgetType() const
|
||||
{
|
||||
if (m_activeWidget == &m_mainWidget)
|
||||
return LtsScreenBase::WidgetType::MainWidget;
|
||||
if (m_activeWidget == &m_secondaryWidget)
|
||||
return LtsScreenBase::WidgetType::SecondaryWidget;
|
||||
if (m_activeWidget == &m_mainWidget)
|
||||
return LtsScreenBase::WidgetType::MainWidget;
|
||||
if (m_activeWidget == &m_secondaryWidget)
|
||||
return LtsScreenBase::WidgetType::SecondaryWidget;
|
||||
|
||||
assert(false);
|
||||
return LtsScreenBase::WidgetType::None;
|
||||
assert(false);
|
||||
return LtsScreenBase::WidgetType::None;
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenContainer::toggle()
|
||||
{
|
||||
|
||||
switchToTemp((*m_activeWidget == m_mainWidget) ? LtsScreenBase::WidgetType::SecondaryWidget : LtsScreenBase::WidgetType::MainWidget);
|
||||
|
||||
QWidget *w = activeWidget();
|
||||
switchToTemp((*m_activeWidget == m_mainWidget) ? LtsScreenBase::WidgetType::SecondaryWidget
|
||||
: LtsScreenBase::WidgetType::MainWidget);
|
||||
|
||||
assert(w != nullptr);
|
||||
if (w == nullptr)
|
||||
{
|
||||
revertSwitch();
|
||||
return;
|
||||
}
|
||||
QWidget* w = activeWidget();
|
||||
|
||||
if (!tryPutDummyUnmanaged(w))
|
||||
w->show();
|
||||
assert(w != nullptr);
|
||||
if (w == nullptr)
|
||||
{
|
||||
revertSwitch();
|
||||
return;
|
||||
}
|
||||
|
||||
finalizeSwitch();
|
||||
if (!tryPutDummyUnmanaged(w))
|
||||
w->show();
|
||||
|
||||
finalizeSwitch();
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenContainer::isIrreplaceable() const
|
||||
{
|
||||
if (m_activeWidget == nullptr)
|
||||
return false;
|
||||
if (m_activeWidget == nullptr)
|
||||
return false;
|
||||
|
||||
auto *blw = qobject_cast<LtsWidgets::LtsBaseLayoutWidget *>(activeWidget());
|
||||
if (blw == nullptr)
|
||||
return false;
|
||||
auto* blw = qobject_cast<LtsWidgets::LtsBaseLayoutWidget*>(activeWidget());
|
||||
if (blw == nullptr)
|
||||
return false;
|
||||
|
||||
return blw->isIrreplaceable();
|
||||
return blw->isIrreplaceable();
|
||||
}
|
||||
|
||||
|
||||
QWidget *LtsScreenContainer::activeWidget() const
|
||||
QWidget* LtsScreenContainer::activeWidget() const
|
||||
{
|
||||
assert(m_activeWidget != nullptr);
|
||||
assert(m_activeWidget != nullptr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return *m_activeWidget;
|
||||
return *m_activeWidget;
|
||||
}
|
||||
|
||||
|
||||
QWidget **LtsScreenContainer::activeWidgetPtr()
|
||||
QWidget** LtsScreenContainer::activeWidgetPtr()
|
||||
{
|
||||
assert(m_activeWidget != nullptr);
|
||||
assert(m_activeWidget != nullptr);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return m_activeWidget;
|
||||
return m_activeWidget;
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenContainer::vanish()
|
||||
{
|
||||
return;
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_layout->setParent(nullptr);
|
||||
m_layout->setParent(nullptr);
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenContainer::reappear()
|
||||
{
|
||||
return;
|
||||
return;
|
||||
|
||||
setAttribute(Qt::WA_TranslucentBackground, false);
|
||||
|
||||
|
||||
|
||||
setAttribute(Qt::WA_TranslucentBackground, false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_layout->parent() == nullptr)
|
||||
setLayout(m_layout);
|
||||
if (m_layout->parent() == nullptr)
|
||||
setLayout(m_layout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QWidget *LtsScreenContainer::stealWidget() noexcept(false)
|
||||
QWidget* LtsScreenContainer::stealWidget() noexcept(false)
|
||||
{
|
||||
|
||||
|
||||
QWidget **widgetPtr = activeWidgetPtr();
|
||||
QWidget *widget = *widgetPtr;
|
||||
QWidget** widgetPtr = activeWidgetPtr();
|
||||
QWidget* widget = *widgetPtr;
|
||||
|
||||
if (widget == nullptr)
|
||||
{
|
||||
|
||||
throw "stealWidget: no widget to steal";
|
||||
}
|
||||
if (widget == nullptr)
|
||||
{
|
||||
|
||||
|
||||
throw "stealWidget: no widget to steal";
|
||||
}
|
||||
|
||||
|
||||
widget->setParent(nullptr);
|
||||
vanish();
|
||||
widget->setParent(nullptr);
|
||||
vanish();
|
||||
|
||||
|
||||
disconnect(widget, &QWidget::destroyed,
|
||||
this, &LtsScreenContainer::slotChildDestroyed);
|
||||
disconnect(widget, &QWidget::destroyed, this, &LtsScreenContainer::slotChildDestroyed);
|
||||
|
||||
QWidget* oldWidget = widget;
|
||||
*widgetPtr = nullptr;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QWidget *oldWidget = widget;
|
||||
*widgetPtr = nullptr;
|
||||
|
||||
return oldWidget;
|
||||
return oldWidget;
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenContainer::hasWidget(QWidget *widget) const
|
||||
bool LtsScreenContainer::hasWidget(QWidget* widget) const
|
||||
{
|
||||
if (m_mainWidget != nullptr && m_mainWidget == widget)
|
||||
return true;
|
||||
if (m_secondaryWidget != nullptr && m_secondaryWidget == widget)
|
||||
return true;
|
||||
return false;
|
||||
if (m_mainWidget != nullptr && m_mainWidget == widget)
|
||||
return true;
|
||||
if (m_secondaryWidget != nullptr && m_secondaryWidget == widget)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenContainer::isEmpty() const
|
||||
{
|
||||
QWidget **currentWidgetPtr = m_activeWidget;
|
||||
if (currentWidgetPtr == nullptr)
|
||||
return true;
|
||||
return (*currentWidgetPtr == nullptr);
|
||||
QWidget** currentWidgetPtr = m_activeWidget;
|
||||
if (currentWidgetPtr == nullptr)
|
||||
return true;
|
||||
return (*currentWidgetPtr == nullptr);
|
||||
}
|
||||
|
||||
bool LtsScreenContainer::hasMainWidget()
|
||||
{
|
||||
return m_mainWidget != nullptr;
|
||||
return m_mainWidget != nullptr;
|
||||
}
|
||||
|
||||
bool LtsScreenContainer::hasSecondaryWidget()
|
||||
{
|
||||
return m_secondaryWidget != nullptr;
|
||||
return m_secondaryWidget != nullptr;
|
||||
}
|
||||
|
||||
bool LtsScreenContainer::tryPutDummyUnmanaged(QWidget *widget)
|
||||
bool LtsScreenContainer::tryPutDummyUnmanaged(QWidget* widget)
|
||||
{
|
||||
auto *dummy = qobject_cast<FullscreenVideoDummyWidget *>(widget);
|
||||
auto* dummy = qobject_cast<FullscreenVideoDummyWidget*>(widget);
|
||||
|
||||
if (dummy == nullptr)
|
||||
return false;
|
||||
if (dummy == nullptr)
|
||||
return false;
|
||||
|
||||
QRect r(mapToGlobal(rect().topLeft()), rect().size());
|
||||
|
||||
emit dummy->signalWidgetPlaced(r);
|
||||
|
||||
emit signalSetCornerIcons();
|
||||
|
||||
|
||||
|
||||
QRect r(mapToGlobal(rect().topLeft()), rect().size());
|
||||
|
||||
emit dummy->signalWidgetPlaced(r);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
emit signalSetCornerIcons();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenContainer::switchToTemp(LtsScreenBase::WidgetType widgetType)
|
||||
{
|
||||
|
||||
Q_ASSERT(widgetType != LtsScreenBase::WidgetType::None);
|
||||
|
||||
Q_ASSERT(widgetType != LtsScreenBase::WidgetType::None);
|
||||
if ((m_activeWidget == &m_mainWidget && widgetType == LtsScreenBase::WidgetType::MainWidget) ||
|
||||
(m_activeWidget == &m_secondaryWidget && widgetType == LtsScreenBase::WidgetType::SecondaryWidget))
|
||||
{
|
||||
|
||||
if ((m_activeWidget == &m_mainWidget && widgetType == LtsScreenBase::WidgetType::MainWidget) ||
|
||||
(m_activeWidget == &m_secondaryWidget && widgetType == LtsScreenBase::WidgetType::SecondaryWidget))
|
||||
{
|
||||
m_nullSwitchActive = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_nullSwitchActive = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (widgetType == LtsScreenBase::WidgetType::MainWidget)
|
||||
m_oldActiveWidget = &m_secondaryWidget;
|
||||
else if (widgetType == LtsScreenBase::WidgetType::SecondaryWidget)
|
||||
m_oldActiveWidget = &m_mainWidget;
|
||||
else
|
||||
Q_ASSERT(false);
|
||||
|
||||
|
||||
|
||||
|
||||
m_activeWidget = (widgetType == LtsScreenBase::WidgetType::SecondaryWidget ? &m_secondaryWidget : &m_mainWidget);
|
||||
|
||||
if (widgetType == LtsScreenBase::WidgetType::MainWidget)
|
||||
m_oldActiveWidget = &m_secondaryWidget;
|
||||
else if (widgetType == LtsScreenBase::WidgetType::SecondaryWidget)
|
||||
m_oldActiveWidget = &m_mainWidget;
|
||||
else
|
||||
Q_ASSERT(false);
|
||||
|
||||
m_activeWidget = (widgetType == LtsScreenBase::WidgetType::SecondaryWidget ? &m_secondaryWidget : &m_mainWidget);
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenContainer::finalizeSwitch()
|
||||
{
|
||||
|
||||
QWidget** oldActiveWidget = m_oldActiveWidget;
|
||||
m_oldActiveWidget = nullptr;
|
||||
|
||||
QWidget **oldActiveWidget = m_oldActiveWidget;
|
||||
m_oldActiveWidget = nullptr;
|
||||
|
||||
if (m_nullSwitchActive)
|
||||
{
|
||||
|
||||
if (m_nullSwitchActive)
|
||||
{
|
||||
|
||||
m_nullSwitchActive = false;
|
||||
return;
|
||||
}
|
||||
m_nullSwitchActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldActiveWidget == nullptr)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
if (oldActiveWidget == nullptr)
|
||||
{
|
||||
|
||||
if (*oldActiveWidget == nullptr)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (*oldActiveWidget == nullptr)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget* widget = *oldActiveWidget;
|
||||
auto* dummy = qobject_cast<FullscreenVideoDummyWidget*>(widget);
|
||||
if (dummy != nullptr)
|
||||
{
|
||||
|
||||
dummy->hideVideo();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
widget->hide();
|
||||
}
|
||||
|
||||
QWidget* widget2 = *m_activeWidget;
|
||||
auto* dummy2 = qobject_cast<FullscreenVideoDummyWidget*>(widget2);
|
||||
if (dummy2 != nullptr)
|
||||
{
|
||||
dummy2->showVideo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QWidget *widget = *oldActiveWidget;
|
||||
auto *dummy = qobject_cast<FullscreenVideoDummyWidget *>(widget);
|
||||
if (dummy != nullptr)
|
||||
{
|
||||
|
||||
dummy->hideVideo();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
widget->hide();
|
||||
}
|
||||
|
||||
QWidget *widget2 = *m_activeWidget;
|
||||
auto *dummy2 = qobject_cast<FullscreenVideoDummyWidget *>(widget2);
|
||||
if (dummy2 != nullptr)
|
||||
{
|
||||
dummy2->showVideo();
|
||||
}
|
||||
|
||||
emit signalSetCornerIcons();
|
||||
emit signalSetCornerIcons();
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenContainer::revertSwitch()
|
||||
{
|
||||
|
||||
QWidget** oldActiveWidgetBackup = m_oldActiveWidget;
|
||||
m_oldActiveWidget = nullptr;
|
||||
|
||||
QWidget **oldActiveWidgetBackup = m_oldActiveWidget;
|
||||
m_oldActiveWidget = nullptr;
|
||||
|
||||
if (m_nullSwitchActive)
|
||||
{
|
||||
|
||||
if (m_nullSwitchActive)
|
||||
{
|
||||
|
||||
m_nullSwitchActive = false;
|
||||
return;
|
||||
}
|
||||
m_nullSwitchActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (oldActiveWidgetBackup == nullptr)
|
||||
return;
|
||||
|
||||
m_activeWidget = oldActiveWidgetBackup;
|
||||
|
||||
if (oldActiveWidgetBackup == nullptr)
|
||||
return;
|
||||
|
||||
m_activeWidget = oldActiveWidgetBackup;
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenContainer::setWidget(QWidget *widget)
|
||||
void LtsScreenContainer::setWidget(QWidget* widget)
|
||||
{
|
||||
|
||||
QWidget** widgetPtr = activeWidgetPtr();
|
||||
|
||||
|
||||
qWarning() << geoStr() << "setWidget: m_activeWidget" << m_activeWidget;
|
||||
|
||||
QWidget **widgetPtr = activeWidgetPtr();
|
||||
QWidget* currentWidget = *widgetPtr;
|
||||
|
||||
qWarning() << geoStr() << "setWidget: m_activeWidget" << m_activeWidget;
|
||||
Q_ASSERT(currentWidget == nullptr);
|
||||
|
||||
QWidget *currentWidget = *widgetPtr;
|
||||
*widgetPtr = widget;
|
||||
reappear();
|
||||
|
||||
Q_ASSERT(currentWidget == nullptr);
|
||||
connect(widget, &QWidget::destroyed, this, &LtsScreenContainer::slotChildDestroyed, Qt::UniqueConnection);
|
||||
|
||||
if (tryPutDummyUnmanaged(widget))
|
||||
return;
|
||||
|
||||
m_layout->addWidget(widget);
|
||||
|
||||
|
||||
widget->show();
|
||||
|
||||
*widgetPtr = widget;
|
||||
reappear();
|
||||
|
||||
connect(widget, &QWidget::destroyed,
|
||||
this, &LtsScreenContainer::slotChildDestroyed,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
if (tryPutDummyUnmanaged(widget))
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_layout->addWidget(widget);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
widget->show();
|
||||
|
||||
emit signalSetCornerIcons();
|
||||
emit signalSetCornerIcons();
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenContainer::slotChildDestroyed()
|
||||
{
|
||||
if (sender() == static_cast<QObject *>(m_mainWidget))
|
||||
{
|
||||
m_mainWidget = nullptr;
|
||||
qWarning() << geoStr() << "m_mainWidget set to nullptr!";
|
||||
|
||||
if (*m_activeWidget == m_mainWidget)
|
||||
if (sender() == static_cast<QObject*>(m_mainWidget))
|
||||
{
|
||||
qWarning() << "slotChildDestroyed: switching to sec";
|
||||
switchToTemp(LtsScreenBase::WidgetType::SecondaryWidget);
|
||||
m_mainWidget = nullptr;
|
||||
qWarning() << geoStr() << "m_mainWidget set to nullptr!";
|
||||
|
||||
QWidget *widget = activeWidget();
|
||||
|
||||
if (widget != nullptr)
|
||||
{
|
||||
auto *dummy = qobject_cast<FullscreenVideoDummyWidget *>(widget);
|
||||
if (dummy != nullptr)
|
||||
if (*m_activeWidget == m_mainWidget)
|
||||
{
|
||||
QRect r(mapToGlobal(rect().topLeft()), rect().size());
|
||||
qWarning() << geoStr() << "LtsScreenContainer::slotChildDestroyed => (main) dummy->signalWidgetPlaced";
|
||||
emit dummy->signalWidgetPlaced(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
widget->show();
|
||||
}
|
||||
}
|
||||
qWarning() << "slotChildDestroyed: switching to sec";
|
||||
switchToTemp(LtsScreenBase::WidgetType::SecondaryWidget);
|
||||
|
||||
finalizeSwitch();
|
||||
QWidget* widget = activeWidget();
|
||||
|
||||
if (widget != nullptr)
|
||||
{
|
||||
auto* dummy = qobject_cast<FullscreenVideoDummyWidget*>(widget);
|
||||
if (dummy != nullptr)
|
||||
{
|
||||
QRect r(mapToGlobal(rect().topLeft()), rect().size());
|
||||
qWarning() << geoStr()
|
||||
<< "LtsScreenContainer::slotChildDestroyed => (main) dummy->signalWidgetPlaced";
|
||||
emit dummy->signalWidgetPlaced(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
widget->show();
|
||||
}
|
||||
}
|
||||
|
||||
finalizeSwitch();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sender() == static_cast<QObject *>(m_secondaryWidget))
|
||||
{
|
||||
m_secondaryWidget = nullptr;
|
||||
qWarning() << geoStr() << "m_secondaryWidget set to nullptr!";
|
||||
|
||||
if (*m_activeWidget == m_secondaryWidget)
|
||||
else if (sender() == static_cast<QObject*>(m_secondaryWidget))
|
||||
{
|
||||
qWarning() << "slotChildDestroyed: switching to main";
|
||||
switchToTemp(LtsScreenBase::WidgetType::MainWidget);
|
||||
m_secondaryWidget = nullptr;
|
||||
qWarning() << geoStr() << "m_secondaryWidget set to nullptr!";
|
||||
|
||||
QWidget *widget = activeWidget();
|
||||
|
||||
if (widget != nullptr)
|
||||
{
|
||||
auto *dummy = qobject_cast<FullscreenVideoDummyWidget *>(widget);
|
||||
if (dummy != nullptr)
|
||||
if (*m_activeWidget == m_secondaryWidget)
|
||||
{
|
||||
QRect r(mapToGlobal(rect().topLeft()), rect().size());
|
||||
qWarning() << geoStr() << "LtsScreenContainer::slotChildDestroyed => (sec) dummy->signalWidgetPlaced";
|
||||
emit dummy->signalWidgetPlaced(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
widget->show();
|
||||
}
|
||||
}
|
||||
qWarning() << "slotChildDestroyed: switching to main";
|
||||
switchToTemp(LtsScreenBase::WidgetType::MainWidget);
|
||||
|
||||
finalizeSwitch();
|
||||
QWidget* widget = activeWidget();
|
||||
|
||||
if (widget != nullptr)
|
||||
{
|
||||
auto* dummy = qobject_cast<FullscreenVideoDummyWidget*>(widget);
|
||||
if (dummy != nullptr)
|
||||
{
|
||||
QRect r(mapToGlobal(rect().topLeft()), rect().size());
|
||||
qWarning() << geoStr()
|
||||
<< "LtsScreenContainer::slotChildDestroyed => (sec) dummy->signalWidgetPlaced";
|
||||
emit dummy->signalWidgetPlaced(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
widget->show();
|
||||
}
|
||||
}
|
||||
|
||||
finalizeSwitch();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << geoStr() << "slotChildDestroyed NOT received from any known widget !!";
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << geoStr() << "slotChildDestroyed NOT received from any known widget !!";
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
vanish();
|
||||
emit check();
|
||||
vanish();
|
||||
emit check();
|
||||
}
|
||||
|
||||
|
||||
QWidget *LtsScreenContainer::widget() noexcept(false)
|
||||
QWidget* LtsScreenContainer::widget() noexcept(false)
|
||||
{
|
||||
QWidget **widgetPtr = m_activeWidget;
|
||||
if (widgetPtr != nullptr && *widgetPtr != nullptr)
|
||||
return *widgetPtr;
|
||||
throw "no widget in container";
|
||||
QWidget** widgetPtr = m_activeWidget;
|
||||
if (widgetPtr != nullptr && *widgetPtr != nullptr)
|
||||
return *widgetPtr;
|
||||
throw "no widget in container";
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+46
-50
@@ -1,69 +1,65 @@
|
||||
#pragma once
|
||||
#include "lts_screen_base.h"
|
||||
#include "ltsmultimonitor_export.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "lts_screen_base.h"
|
||||
|
||||
#include "ltsmultimonitor_export.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QRect>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QHBoxLayout;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
class LTSMULTIMONITOR_EXPORT LtsScreenContainer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LtsScreenContainer(QRect screenGeo);
|
||||
public:
|
||||
LtsScreenContainer(QRect screenGeo);
|
||||
|
||||
bool isIrreplaceable() const;
|
||||
bool isEmpty() const;
|
||||
bool hasMainWidget();
|
||||
bool hasSecondaryWidget();
|
||||
void setWidget(QWidget *widget);
|
||||
bool hasWidget(QWidget *widget) const;
|
||||
QWidget *widget() noexcept(false);
|
||||
QWidget *stealWidget() noexcept(false);
|
||||
void switchToTemp(LtsScreenBase::WidgetType widgetType);
|
||||
void finalizeSwitch();
|
||||
void revertSwitch();
|
||||
bool mainAndSecondaryOccupied() const;
|
||||
QIcon mainWindowIcon() const;
|
||||
QIcon secondaryWindowIcon() const;
|
||||
LtsScreenBase::WidgetType activeWidgetType() const;
|
||||
bool isInactiveWidgetOccupied() const;
|
||||
bool isIrreplaceable() const;
|
||||
bool isEmpty() const;
|
||||
bool hasMainWidget();
|
||||
bool hasSecondaryWidget();
|
||||
void setWidget(QWidget* widget);
|
||||
bool hasWidget(QWidget* widget) const;
|
||||
QWidget* widget() noexcept(false);
|
||||
QWidget* stealWidget() noexcept(false);
|
||||
void switchToTemp(LtsScreenBase::WidgetType widgetType);
|
||||
void finalizeSwitch();
|
||||
void revertSwitch();
|
||||
bool mainAndSecondaryOccupied() const;
|
||||
QIcon mainWindowIcon() const;
|
||||
QIcon secondaryWindowIcon() const;
|
||||
LtsScreenBase::WidgetType activeWidgetType() const;
|
||||
bool isInactiveWidgetOccupied() const;
|
||||
|
||||
signals:
|
||||
void check();
|
||||
void signalSetCornerIcons();
|
||||
signals:
|
||||
void check();
|
||||
void signalSetCornerIcons();
|
||||
|
||||
private:
|
||||
QHBoxLayout *m_layout { nullptr };
|
||||
QWidget *m_mainWidget { nullptr };
|
||||
QWidget *m_secondaryWidget { nullptr };
|
||||
QWidget **m_activeWidget { nullptr };
|
||||
QWidget **m_oldActiveWidget { nullptr };
|
||||
bool m_nullSwitchActive { false };
|
||||
QRect m_screenGeo;
|
||||
private:
|
||||
QHBoxLayout* m_layout{nullptr};
|
||||
QWidget* m_mainWidget{nullptr};
|
||||
QWidget* m_secondaryWidget{nullptr};
|
||||
QWidget** m_activeWidget{nullptr};
|
||||
QWidget** m_oldActiveWidget{nullptr};
|
||||
bool m_nullSwitchActive{false};
|
||||
QRect m_screenGeo;
|
||||
|
||||
QString geoStr() const;
|
||||
bool tryPutDummyUnmanaged(QWidget *widget);
|
||||
void vanish();
|
||||
void reappear();
|
||||
QWidget *activeWidget() const;
|
||||
QWidget **activeWidgetPtr();
|
||||
QString geoStr() const;
|
||||
bool tryPutDummyUnmanaged(QWidget* widget);
|
||||
void vanish();
|
||||
void reappear();
|
||||
QWidget* activeWidget() const;
|
||||
QWidget** activeWidgetPtr();
|
||||
|
||||
public slots:
|
||||
void toggle();
|
||||
public slots:
|
||||
void toggle();
|
||||
|
||||
private slots:
|
||||
|
||||
void slotChildDestroyed();
|
||||
private slots:
|
||||
|
||||
void slotChildDestroyed();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+54
-119
@@ -1,200 +1,135 @@
|
||||
#include "lts_screen_normal.h"
|
||||
|
||||
#include "lts_dummy_widget.h"
|
||||
#include "lts_screen_container.h"
|
||||
#include "lts_magic_corner.h"
|
||||
#include "lts_screen_container.h"
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSplitter>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <QSplitter>
|
||||
|
||||
#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))
|
||||
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;
|
||||
connect(m_childContainer, &LtsScreenContainer::check, this, &LtsScreenNormal::check);
|
||||
|
||||
theLayout->setContentsMargins(0, 0, 0, 0);
|
||||
theLayout->setSpacing(0);
|
||||
theLayout->setStretch(0, 999);
|
||||
theLayout->addWidget(m_childContainer);
|
||||
auto* theLayout = new QHBoxLayout;
|
||||
|
||||
m_screenDialog->setLayout(theLayout);
|
||||
theLayout->setContentsMargins(0, 0, 0, 0);
|
||||
theLayout->setSpacing(0);
|
||||
theLayout->setStretch(0, 999);
|
||||
theLayout->addWidget(m_childContainer);
|
||||
|
||||
m_corner->hide();
|
||||
connect(m_corner, &LtsMagicCorner::toggle,
|
||||
this, [this]()
|
||||
{
|
||||
m_childContainer->toggle();
|
||||
m_corner->setActiveWidgetType(m_childContainer->activeWidgetType());
|
||||
setCornerIcons();
|
||||
});
|
||||
m_screenDialog->setLayout(theLayout);
|
||||
|
||||
connect(m_corner, &LtsMagicCorner::signalMakeAllSwole,
|
||||
this, &LtsScreenNormal::signalMakeAllSwole);
|
||||
connect(this, &LtsScreenNormal::signalMakeSwole,
|
||||
m_corner, &LtsMagicCorner::makeSwole);
|
||||
m_corner->hide();
|
||||
connect(m_corner, &LtsMagicCorner::toggle, this, [this]() {
|
||||
m_childContainer->toggle();
|
||||
m_corner->setActiveWidgetType(m_childContainer->activeWidgetType());
|
||||
setCornerIcons();
|
||||
});
|
||||
|
||||
connect(m_childContainer, &LtsScreenContainer::signalSetCornerIcons,
|
||||
this, &LtsScreenNormal::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();
|
||||
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);
|
||||
|
||||
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();
|
||||
m_childContainer->mainAndSecondaryOccupied() ? m_corner->show() : m_corner->hide();
|
||||
}
|
||||
|
||||
|
||||
LtsScreenContainer *LtsScreenNormal::containerOfWidget(QWidget *widget)
|
||||
LtsScreenContainer* LtsScreenNormal::containerOfWidget(QWidget* widget)
|
||||
{
|
||||
if (m_childContainer->hasWidget(widget))
|
||||
return m_childContainer;
|
||||
throw "widget is not present on this container";
|
||||
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);
|
||||
m_corner->setFreezed(hide);
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenNormal::isIrreplaceable() const
|
||||
{
|
||||
return m_childContainer->isIrreplaceable();
|
||||
return m_childContainer->isIrreplaceable();
|
||||
}
|
||||
|
||||
|
||||
int LtsScreenNormal::containerIdOfWidget(QWidget *widget) const noexcept(false)
|
||||
int LtsScreenNormal::containerIdOfWidget(QWidget* widget) const noexcept(false)
|
||||
{
|
||||
if (m_childContainer->hasWidget(widget))
|
||||
return 0;
|
||||
throw "widget not on this screen";
|
||||
if (m_childContainer->hasWidget(widget))
|
||||
return 0;
|
||||
throw "widget not on this screen";
|
||||
}
|
||||
|
||||
|
||||
LtsScreenContainer *LtsScreenNormal::putWidget(QWidget *widget, int ) noexcept(false)
|
||||
LtsScreenContainer* LtsScreenNormal::putWidget(QWidget* widget, int) noexcept(false)
|
||||
{
|
||||
if (!isEmpty())
|
||||
throw "cannot put widget as container is non-empty";
|
||||
putWidgetUnmanaged(widget);
|
||||
return m_childContainer;
|
||||
if (!isEmpty())
|
||||
throw "cannot put widget as container is non-empty";
|
||||
putWidgetUnmanaged(widget);
|
||||
return m_childContainer;
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenNormal::hasWidget(QWidget *widget) const
|
||||
bool LtsScreenNormal::hasWidget(QWidget* widget) const
|
||||
{
|
||||
return (m_childContainer->hasWidget(widget));
|
||||
return (m_childContainer->hasWidget(widget));
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenNormal::putWidgetUnmanaged(QWidget *widget)
|
||||
void LtsScreenNormal::putWidgetUnmanaged(QWidget* widget)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_childContainer->setWidget(widget);
|
||||
|
||||
|
||||
|
||||
|
||||
setCornerIcons();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_childContainer->setWidget(widget);
|
||||
|
||||
setCornerIcons();
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenNormal::slotOverlayDestroyed()
|
||||
{
|
||||
m_screenDialog->show();
|
||||
m_screenDialog->show();
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenNormal::isEmpty() const
|
||||
{
|
||||
return m_childContainer->isEmpty();
|
||||
return m_childContainer->isEmpty();
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenNormal::switchToTemp(LtsScreenBase::WidgetType widgetType)
|
||||
{
|
||||
m_childContainer->switchToTemp(widgetType);
|
||||
m_childContainer->switchToTemp(widgetType);
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenNormal::finalizeSwitch()
|
||||
{
|
||||
m_childContainer->finalizeSwitch();
|
||||
m_childContainer->finalizeSwitch();
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenNormal::revertSwitch()
|
||||
{
|
||||
m_childContainer->revertSwitch();
|
||||
m_childContainer->revertSwitch();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+42
-38
@@ -1,59 +1,63 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include "lts_screen_base.h"
|
||||
|
||||
#include "ltsmultimonitor_export.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QSplitter;
|
||||
class QHBoxLayout;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
class LtsMagicCorner;
|
||||
|
||||
|
||||
class LTSMULTIMONITOR_EXPORT LtsScreenNormal : public LtsScreenBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LtsScreenNormal(QRect screenGeo, int screenId, bool debugMargins, const QString &serial);
|
||||
~LtsScreenNormal();
|
||||
int screenType() const override { return 0; }
|
||||
int containerIdOfWidget(QWidget *widget) const noexcept(false) override;
|
||||
LtsScreenContainer *child() const { return m_childContainer; }
|
||||
LtsScreenContainer *putWidget(QWidget *widget, int) noexcept(false) override;
|
||||
LtsScreenContainer *containerOfWidget(QWidget *widget) noexcept(false) override;
|
||||
void hideMagicCorner(bool hide);
|
||||
bool isEmpty() const override;
|
||||
bool isIrreplaceable() const override;
|
||||
void putWidgetUnmanaged(QWidget *widget);
|
||||
bool hasWidget(QWidget *widget) const override;
|
||||
void switchToTemp(WidgetType widgetType) override;
|
||||
void finalizeSwitch() override;
|
||||
void revertSwitch() override;
|
||||
void check() override;
|
||||
public:
|
||||
LtsScreenNormal(QRect screenGeo, int screenId, bool debugMargins, const QString& serial);
|
||||
~LtsScreenNormal();
|
||||
|
||||
private:
|
||||
LtsScreenContainer *m_childContainer { nullptr };
|
||||
LtsMagicCorner *m_corner;
|
||||
|
||||
int screenType() const override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void swapLeftRight();
|
||||
bool tryPutDummyUnmanaged(QWidget *widget);
|
||||
int containerIdOfWidget(QWidget* widget) const noexcept(false) override;
|
||||
|
||||
signals:
|
||||
void signalMakeAllSwole();
|
||||
void signalMakeSwole();
|
||||
LtsScreenContainer* child() const
|
||||
{
|
||||
return m_childContainer;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void slotOverlayDestroyed();
|
||||
void setCornerIcons();
|
||||
LtsScreenContainer* putWidget(QWidget* widget, int) noexcept(false) override;
|
||||
LtsScreenContainer* containerOfWidget(QWidget* widget) noexcept(false) override;
|
||||
void hideMagicCorner(bool hide);
|
||||
bool isEmpty() const override;
|
||||
bool isIrreplaceable() const override;
|
||||
void putWidgetUnmanaged(QWidget* widget);
|
||||
bool hasWidget(QWidget* widget) const override;
|
||||
void switchToTemp(WidgetType widgetType) override;
|
||||
void finalizeSwitch() override;
|
||||
void revertSwitch() override;
|
||||
void check() override;
|
||||
|
||||
private:
|
||||
LtsScreenContainer* m_childContainer{nullptr};
|
||||
LtsMagicCorner* m_corner;
|
||||
|
||||
void swapLeftRight();
|
||||
bool tryPutDummyUnmanaged(QWidget* widget);
|
||||
|
||||
signals:
|
||||
void signalMakeAllSwole();
|
||||
void signalMakeSwole();
|
||||
|
||||
private slots:
|
||||
void slotOverlayDestroyed();
|
||||
void setCornerIcons();
|
||||
};
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+125
-161
@@ -1,12 +1,12 @@
|
||||
#include "lts_screen_wide.h"
|
||||
|
||||
#include "lts_dummy_widget.h"
|
||||
#include "lts_screen_container.h"
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSplitter>
|
||||
#include <QHBoxLayout>
|
||||
#include <QSplitter>
|
||||
#include <QTimer>
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QtPlatformHeaders/qwindowswindowfunctions.h>
|
||||
@@ -15,221 +15,185 @@
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
|
||||
LtsScreenWide::LtsScreenWide(const QRect &screenGeo, int screenId, bool debugMargins, const QString &serial)
|
||||
: LtsScreenBase(screenGeo, screenId, debugMargins, serial)
|
||||
, m_childContainerMain(new LtsScreenContainer(screenGeo))
|
||||
, m_childContainerLeft(new LtsScreenContainer(screenGeo))
|
||||
, m_childContainerRight(new LtsScreenContainer(screenGeo))
|
||||
LtsScreenWide::LtsScreenWide(const QRect& screenGeo, int screenId, bool debugMargins, const QString& serial)
|
||||
: LtsScreenBase(screenGeo, screenId, debugMargins, serial), m_childContainerMain(new LtsScreenContainer(screenGeo)),
|
||||
m_childContainerLeft(new LtsScreenContainer(screenGeo)), m_childContainerRight(new LtsScreenContainer(screenGeo))
|
||||
{
|
||||
|
||||
connect(m_childContainerMain, &LtsScreenContainer::check,
|
||||
this, &LtsScreenWide::check);
|
||||
connect(m_childContainerLeft, &LtsScreenContainer::check,
|
||||
this, &LtsScreenWide::check);
|
||||
connect(m_childContainerRight, &LtsScreenContainer::check,
|
||||
this, &LtsScreenWide::check);
|
||||
|
||||
auto *theLayout = new QHBoxLayout;
|
||||
connect(m_childContainerMain, &LtsScreenContainer::check, this, &LtsScreenWide::check);
|
||||
connect(m_childContainerLeft, &LtsScreenContainer::check, this, &LtsScreenWide::check);
|
||||
connect(m_childContainerRight, &LtsScreenContainer::check, this, &LtsScreenWide::check);
|
||||
|
||||
theLayout->setContentsMargins(0, 0, 0, 0);
|
||||
theLayout->setSpacing(0);
|
||||
theLayout->setStretch(0, 9999);
|
||||
auto* theLayout = new QHBoxLayout;
|
||||
|
||||
m_splitter = new QSplitter;
|
||||
m_splitter->setContentsMargins(0, 0, 0, 0);
|
||||
theLayout->setContentsMargins(0, 0, 0, 0);
|
||||
theLayout->setSpacing(0);
|
||||
theLayout->setStretch(0, 9999);
|
||||
|
||||
m_splitter->addWidget(m_childContainerLeft);
|
||||
m_splitter->addWidget(m_childContainerRight);
|
||||
m_splitter = new QSplitter;
|
||||
m_splitter->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
theLayout->addWidget(m_splitter);
|
||||
theLayout->addWidget(m_childContainerMain);
|
||||
m_splitter->addWidget(m_childContainerLeft);
|
||||
m_splitter->addWidget(m_childContainerRight);
|
||||
|
||||
m_screenDialog->setLayout(theLayout);
|
||||
theLayout->addWidget(m_splitter);
|
||||
theLayout->addWidget(m_childContainerMain);
|
||||
|
||||
m_splitter->hide();
|
||||
m_screenDialog->setLayout(theLayout);
|
||||
|
||||
m_splitter->hide();
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenWide::putWidgetUnmanagedMain(QWidget *widget)
|
||||
void LtsScreenWide::putWidgetUnmanagedMain(QWidget* widget)
|
||||
{
|
||||
|
||||
m_childContainerMain->setWidget(widget);
|
||||
|
||||
m_childContainerMain->setWidget(widget);
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenWide::putWidgetUnmanagedRight(QWidget *widget)
|
||||
void LtsScreenWide::putWidgetUnmanagedRight(QWidget* widget)
|
||||
{
|
||||
|
||||
m_childContainerRight->setWidget(widget);
|
||||
|
||||
m_childContainerRight->setWidget(widget);
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenWide::putWidgetUnmanagedLeft(QWidget *widget)
|
||||
void LtsScreenWide::putWidgetUnmanagedLeft(QWidget* widget)
|
||||
{
|
||||
|
||||
m_childContainerLeft->setWidget(widget);
|
||||
|
||||
m_childContainerLeft->setWidget(widget);
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenWide::hasWidget(QWidget *widget) const
|
||||
bool LtsScreenWide::hasWidget(QWidget* widget) const
|
||||
{
|
||||
return (m_childContainerMain->hasWidget(widget) ||
|
||||
m_childContainerLeft->hasWidget(widget) ||
|
||||
m_childContainerRight->hasWidget(widget));
|
||||
return (m_childContainerMain->hasWidget(widget) || m_childContainerLeft->hasWidget(widget) ||
|
||||
m_childContainerRight->hasWidget(widget));
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenWide::isIrreplaceable() const
|
||||
{
|
||||
return (childLeft()->isIrreplaceable() && childRight()->isIrreplaceable() && childMain()->isIrreplaceable());
|
||||
return (childLeft()->isIrreplaceable() && childRight()->isIrreplaceable() && childMain()->isIrreplaceable());
|
||||
}
|
||||
|
||||
|
||||
bool LtsScreenWide::isEmpty() const
|
||||
{
|
||||
return (m_childContainerLeft->isEmpty() && m_childContainerRight->isEmpty() && m_childContainerMain->isEmpty());
|
||||
return (m_childContainerLeft->isEmpty() && m_childContainerRight->isEmpty() && m_childContainerMain->isEmpty());
|
||||
}
|
||||
|
||||
|
||||
int LtsScreenWide::containerIdOfWidget(QWidget *widget) const noexcept(false)
|
||||
int LtsScreenWide::containerIdOfWidget(QWidget* widget) const noexcept(false)
|
||||
{
|
||||
if (m_childContainerMain->hasWidget(widget))
|
||||
return 0;
|
||||
if (m_childContainerLeft->hasWidget(widget))
|
||||
return 1;
|
||||
if (m_childContainerRight->hasWidget(widget))
|
||||
return 2;
|
||||
throw "widget not on this screen";
|
||||
if (m_childContainerMain->hasWidget(widget))
|
||||
return 0;
|
||||
if (m_childContainerLeft->hasWidget(widget))
|
||||
return 1;
|
||||
if (m_childContainerRight->hasWidget(widget))
|
||||
return 2;
|
||||
throw "widget not on this screen";
|
||||
}
|
||||
|
||||
|
||||
LtsScreenContainer *LtsScreenWide::containerOfWidget(QWidget *widget) noexcept(false)
|
||||
LtsScreenContainer* LtsScreenWide::containerOfWidget(QWidget* widget) noexcept(false)
|
||||
{
|
||||
if (m_childContainerMain->hasWidget(widget))
|
||||
return m_childContainerMain;
|
||||
if (m_childContainerLeft->hasWidget(widget))
|
||||
return m_childContainerLeft;
|
||||
if (m_childContainerRight->hasWidget(widget))
|
||||
return m_childContainerRight;
|
||||
throw "widget is not present on this container";
|
||||
if (m_childContainerMain->hasWidget(widget))
|
||||
return m_childContainerMain;
|
||||
if (m_childContainerLeft->hasWidget(widget))
|
||||
return m_childContainerLeft;
|
||||
if (m_childContainerRight->hasWidget(widget))
|
||||
return m_childContainerRight;
|
||||
throw "widget is not present on this container";
|
||||
}
|
||||
|
||||
|
||||
LtsScreenContainer *LtsScreenWide::putWidget(QWidget *widget, int screenPart) noexcept(false)
|
||||
LtsScreenContainer* LtsScreenWide::putWidget(QWidget* widget, int screenPart) noexcept(false)
|
||||
{
|
||||
if (screenPart == -1)
|
||||
{
|
||||
if (!isEmpty())
|
||||
throw "cannot put widget as at least one container is occupied and screen part was not specified";
|
||||
|
||||
putWidgetUnmanagedMain(widget);
|
||||
return m_childContainerMain;
|
||||
}
|
||||
|
||||
switch (screenPart)
|
||||
{
|
||||
case 0:
|
||||
if (screenPart == -1)
|
||||
{
|
||||
if (!m_childContainerMain->isEmpty())
|
||||
throw "cannot put widget as main container is already occupied";
|
||||
if (!isEmpty())
|
||||
throw "cannot put widget as at least one container is occupied and screen part was not specified";
|
||||
|
||||
putWidgetUnmanagedMain(widget);
|
||||
return m_childContainerMain;
|
||||
putWidgetUnmanagedMain(widget);
|
||||
return m_childContainerMain;
|
||||
}
|
||||
|
||||
case 1:
|
||||
switch (screenPart)
|
||||
{
|
||||
if (!m_childContainerLeft->isEmpty())
|
||||
throw "cannot put widget as left container is already occupied";
|
||||
case 0: {
|
||||
if (!m_childContainerMain->isEmpty())
|
||||
throw "cannot put widget as main container is already occupied";
|
||||
|
||||
|
||||
putWidgetUnmanagedMain(widget);
|
||||
return m_childContainerMain;
|
||||
}
|
||||
|
||||
if (!m_childContainerMain->isEmpty())
|
||||
putWidgetUnmanagedRight(m_childContainerMain->stealWidget());
|
||||
case 1: {
|
||||
if (!m_childContainerLeft->isEmpty())
|
||||
throw "cannot put widget as left container is already occupied";
|
||||
|
||||
putWidgetUnmanagedLeft(widget);
|
||||
return m_childContainerLeft;
|
||||
if (!m_childContainerMain->isEmpty())
|
||||
putWidgetUnmanagedRight(m_childContainerMain->stealWidget());
|
||||
|
||||
putWidgetUnmanagedLeft(widget);
|
||||
return m_childContainerLeft;
|
||||
}
|
||||
|
||||
case 2: {
|
||||
if (!m_childContainerRight->isEmpty())
|
||||
throw "cannot put widget as right container is already occupied";
|
||||
|
||||
if (!m_childContainerMain->isEmpty())
|
||||
putWidgetUnmanagedLeft(m_childContainerMain->stealWidget());
|
||||
|
||||
putWidgetUnmanagedRight(widget);
|
||||
return m_childContainerRight;
|
||||
}
|
||||
|
||||
default: {
|
||||
throw "unknown screen part id";
|
||||
}
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if (!m_childContainerRight->isEmpty())
|
||||
throw "cannot put widget as right container is already occupied";
|
||||
|
||||
|
||||
|
||||
if (!m_childContainerMain->isEmpty())
|
||||
putWidgetUnmanagedLeft(m_childContainerMain->stealWidget());
|
||||
|
||||
putWidgetUnmanagedRight(widget);
|
||||
return m_childContainerRight;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
throw "unknown screen part id";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LtsScreenWide::check()
|
||||
{
|
||||
|
||||
|
||||
Q_ASSERT(
|
||||
(!m_childContainerMain->isEmpty() && m_childContainerLeft->isEmpty() && m_childContainerRight->isEmpty()) ||
|
||||
m_childContainerMain->isEmpty());
|
||||
|
||||
|
||||
|
||||
Q_ASSERT( (!m_childContainerMain->isEmpty() && m_childContainerLeft->isEmpty() && m_childContainerRight->isEmpty()) || m_childContainerMain->isEmpty() );
|
||||
|
||||
|
||||
|
||||
if (m_childContainerMain->isEmpty())
|
||||
{
|
||||
if (m_childContainerLeft->isEmpty() && !m_childContainerRight->isEmpty())
|
||||
if (m_childContainerMain->isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
QWidget *widget = m_childContainerRight->stealWidget();
|
||||
m_childContainerMain->setWidget(widget);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
if (m_childContainerLeft->isEmpty() && !m_childContainerRight->isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
QWidget* widget = m_childContainerRight->stealWidget();
|
||||
m_childContainerMain->setWidget(widget);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (!m_childContainerLeft->isEmpty() && m_childContainerRight->isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
QWidget* widget = m_childContainerLeft->stealWidget();
|
||||
m_childContainerMain->setWidget(widget);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!m_childContainerLeft->isEmpty() && m_childContainerRight->isEmpty())
|
||||
|
||||
if (!m_childContainerMain->isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
QWidget *widget = m_childContainerLeft->stealWidget();
|
||||
m_childContainerMain->setWidget(widget);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
m_childContainerMain->show();
|
||||
m_splitter->hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!m_childContainerMain->isEmpty())
|
||||
{
|
||||
|
||||
m_childContainerMain->show();
|
||||
m_splitter->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_childContainerMain->hide();
|
||||
m_splitter->setVisible(!m_childContainerLeft->isEmpty() || !m_childContainerRight->isEmpty());
|
||||
m_childContainerLeft->setVisible(!m_childContainerLeft->isEmpty());
|
||||
m_childContainerRight->setVisible(!m_childContainerRight->isEmpty());
|
||||
m_childContainerMain->hide();
|
||||
m_splitter->setVisible(!m_childContainerLeft->isEmpty() || !m_childContainerRight->isEmpty());
|
||||
m_childContainerLeft->setVisible(!m_childContainerLeft->isEmpty());
|
||||
m_childContainerRight->setVisible(!m_childContainerRight->isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Executable → Regular
+44
-31
@@ -1,52 +1,65 @@
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
#include "lts_screen_base.h"
|
||||
|
||||
#include "ltsmultimonitor_export.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QSplitter;
|
||||
class QHBoxLayout;
|
||||
|
||||
|
||||
namespace LtsMultiMonitor
|
||||
{
|
||||
|
||||
class LTSMULTIMONITOR_EXPORT LtsScreenWide : public LtsScreenBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LtsScreenWide(const QRect &screenGeo, int screenId, bool debugMargins, const QString &serial);
|
||||
public:
|
||||
LtsScreenWide(const QRect& screenGeo, int screenId, bool debugMargins, const QString& serial);
|
||||
|
||||
int screenType() const override { return 1; }
|
||||
LtsScreenContainer *containerOfWidget(QWidget *widget) noexcept(false) override;
|
||||
bool isEmpty() const override;
|
||||
LtsScreenContainer *childLeft() const { return m_childContainerLeft; }
|
||||
LtsScreenContainer *childRight() const { return m_childContainerRight; }
|
||||
LtsScreenContainer *childMain() const { return m_childContainerMain; }
|
||||
void putWidgetUnmanagedMain(QWidget *widget);
|
||||
void putWidgetUnmanagedLeft(QWidget *widget);
|
||||
void putWidgetUnmanagedRight(QWidget *widget);
|
||||
bool isIrreplaceable() const override;
|
||||
bool hasWidget(QWidget *widget) const override;
|
||||
LtsScreenContainer *putWidget(QWidget *widget, int screenPart) noexcept(false) override;
|
||||
int containerIdOfWidget(QWidget *widget) const noexcept(false) override;
|
||||
int screenType() const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void check() override;
|
||||
LtsScreenContainer* containerOfWidget(QWidget* widget) noexcept(false) override;
|
||||
bool isEmpty() const override;
|
||||
|
||||
private:
|
||||
LtsScreenContainer *m_childContainerMain;
|
||||
LtsScreenContainer *m_childContainerLeft;
|
||||
LtsScreenContainer *m_childContainerRight;
|
||||
QSplitter *m_splitter;
|
||||
LtsScreenContainer* childLeft() const
|
||||
{
|
||||
return m_childContainerLeft;
|
||||
}
|
||||
|
||||
void swapLeftRight();
|
||||
LtsScreenContainer* childRight() const
|
||||
{
|
||||
return m_childContainerRight;
|
||||
}
|
||||
|
||||
LtsScreenContainer* childMain() const
|
||||
{
|
||||
return m_childContainerMain;
|
||||
}
|
||||
|
||||
void putWidgetUnmanagedMain(QWidget* widget);
|
||||
void putWidgetUnmanagedLeft(QWidget* widget);
|
||||
void putWidgetUnmanagedRight(QWidget* widget);
|
||||
bool isIrreplaceable() const override;
|
||||
bool hasWidget(QWidget* widget) const override;
|
||||
LtsScreenContainer* putWidget(QWidget* widget, int screenPart) noexcept(false) override;
|
||||
int containerIdOfWidget(QWidget* widget) const noexcept(false) override;
|
||||
|
||||
public slots:
|
||||
void check() override;
|
||||
|
||||
private:
|
||||
LtsScreenContainer* m_childContainerMain;
|
||||
LtsScreenContainer* m_childContainerLeft;
|
||||
LtsScreenContainer* m_childContainerRight;
|
||||
QSplitter* m_splitter;
|
||||
|
||||
void swapLeftRight();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LtsMultiMonitor
|
||||
Reference in new issue
Block a user