File indexing completed on 2024-04-21 16:17:34

0001 /*
0002  *  SPDX-FileCopyrightText: 2012 Alejandro Fiestas Olivares <afiestas@kde.org>
0003  *  SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com>
0004  *
0005  *  SPDX-License-Identifier: LGPL-2.1-or-later
0006  */
0007 
0008 #include "screen.h"
0009 
0010 using namespace KScreen;
0011 
0012 class Q_DECL_HIDDEN Screen::Private
0013 {
0014 public:
0015     Private()
0016         : id(0)
0017         , maxActiveOutputsCount(0)
0018     {
0019     }
0020 
0021     Private(const Private &other)
0022         : id(other.id)
0023         , maxActiveOutputsCount(other.maxActiveOutputsCount)
0024         , currentSize(other.currentSize)
0025         , minSize(other.minSize)
0026         , maxSize(other.maxSize)
0027     {
0028     }
0029 
0030     int id;
0031     int maxActiveOutputsCount;
0032     QSize currentSize;
0033     QSize minSize;
0034     QSize maxSize;
0035 };
0036 
0037 Screen::Screen()
0038     : QObject(nullptr)
0039     , d(new Private())
0040 {
0041 }
0042 
0043 Screen::Screen(Screen::Private *dd)
0044     : QObject()
0045     , d(dd)
0046 {
0047 }
0048 
0049 Screen::~Screen()
0050 {
0051     delete d;
0052 }
0053 
0054 ScreenPtr Screen::clone() const
0055 {
0056     return ScreenPtr(new Screen(new Private(*d)));
0057 }
0058 
0059 int Screen::id() const
0060 {
0061     return d->id;
0062 }
0063 
0064 void Screen::setId(int id)
0065 {
0066     d->id = id;
0067 }
0068 
0069 QSize Screen::currentSize() const
0070 {
0071     return d->currentSize;
0072 }
0073 
0074 void Screen::setCurrentSize(const QSize &currentSize)
0075 {
0076     if (d->currentSize == currentSize) {
0077         return;
0078     }
0079 
0080     d->currentSize = currentSize;
0081 
0082     Q_EMIT currentSizeChanged();
0083 }
0084 
0085 QSize Screen::maxSize() const
0086 {
0087     return d->maxSize;
0088 }
0089 
0090 void Screen::setMaxSize(const QSize &maxSize)
0091 {
0092     d->maxSize = maxSize;
0093 }
0094 
0095 QSize Screen::minSize() const
0096 {
0097     return d->minSize;
0098 }
0099 
0100 void Screen::setMinSize(const QSize &minSize)
0101 {
0102     d->minSize = minSize;
0103 }
0104 
0105 int Screen::maxActiveOutputsCount() const
0106 {
0107     return d->maxActiveOutputsCount;
0108 }
0109 
0110 void Screen::setMaxActiveOutputsCount(int maxActiveOutputsCount)
0111 {
0112     d->maxActiveOutputsCount = maxActiveOutputsCount;
0113 }
0114 
0115 void Screen::apply(const ScreenPtr &other)
0116 {
0117     // Only set values that can change
0118     setMaxActiveOutputsCount(other->d->maxActiveOutputsCount);
0119     setCurrentSize(other->d->currentSize);
0120 }