File indexing completed on 2024-06-23 08:47:21

0001 /*
0002     SPDX-FileCopyrightText: 2021 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "screendata.h"
0007 
0008 #include "../tools/commontools.h"
0009 
0010 namespace Latte {
0011 namespace Data {
0012 
0013 Screen::Screen()
0014     : Generic(),
0015       hasExplicitViews(false),
0016       isActive(false),
0017       isRemovable(false),
0018       isSelected(false),
0019       geometry(QRect(0, 0, 1920, 1080))
0020 {
0021 }
0022 
0023 Screen::Screen(Screen &&o)
0024     : Generic(o),
0025       hasExplicitViews(o.hasExplicitViews),
0026       isActive(o.isActive),
0027       isRemovable(o.isRemovable),
0028       isSelected(o.isSelected),
0029       geometry(o.geometry)
0030 {
0031 }
0032 
0033 Screen::Screen(const Screen &o)
0034     : Generic(o),
0035       hasExplicitViews(o.hasExplicitViews),
0036       isActive(o.isActive),
0037       isRemovable(o.isRemovable),
0038       isSelected(o.isSelected),
0039       geometry(o.geometry)
0040 {
0041 }
0042 
0043 Screen::Screen(const QString &screenId, const QString &serialized)
0044     : Screen()
0045 {
0046     init(screenId, serialized);
0047 }
0048 
0049 Screen &Screen::operator=(const Screen &rhs)
0050 {
0051     id = rhs.id;
0052     name = rhs.name;
0053     hasExplicitViews = rhs.hasExplicitViews;
0054     isActive = rhs.isActive;
0055     isSelected = rhs.isSelected;
0056     isRemovable = rhs.isRemovable;
0057     geometry = rhs.geometry;
0058 
0059     return (*this);
0060 }
0061 
0062 Screen &Screen::operator=(Screen &&rhs)
0063 {
0064     id = rhs.id;
0065     name = rhs.name;
0066     hasExplicitViews = rhs.hasExplicitViews;
0067     isActive = rhs.isActive;
0068     isRemovable = rhs.isRemovable;
0069     isSelected = rhs.isSelected;
0070     geometry = rhs.geometry;
0071 
0072     return (*this);
0073 }
0074 
0075 bool Screen::operator==(const Screen &rhs) const
0076 {
0077     return (id == rhs.id)
0078             && (name == rhs.name)
0079             && (hasExplicitViews == rhs.hasExplicitViews)
0080             //&& (isActive == rhs.isActive) /*Disabled because this is not a data but a screen state*/
0081             //&& (isRemovable == rhs.isRemovable) /*Disabled because this is not a data but a screen state*/
0082             && (isSelected == rhs.isSelected)
0083             && (geometry == rhs.geometry);
0084 }
0085 
0086 bool Screen::operator!=(const Screen &rhs) const
0087 {
0088     return !(*this == rhs);
0089 }
0090 
0091 void Screen::init(const QString &screenId, const QString &serialized)
0092 {
0093     QStringList parts = serialized.split(SERIALIZESPLITTER);
0094 
0095     id = screenId;
0096     name = parts[0];
0097     isActive = false;
0098     isRemovable = false;
0099     isSelected = false;
0100 
0101     if (parts.count() > 1) {
0102         geometry = Latte::stringToRect(parts[1]);
0103     }
0104 }
0105 
0106 bool Screen::isScreensGroup() const
0107 {
0108     int sid = id.toInt();
0109     return ((sid == ONALLSCREENSID) || (sid == ONALLSECONDARYSCREENSID));
0110 }
0111 
0112 QString Screen::serialize() const
0113 {
0114     QStringList result;
0115     result << name;
0116     result << Latte::rectToString(geometry);
0117 
0118     return result.join(SERIALIZESPLITTER);
0119 }
0120 
0121 }
0122 }