| 1 | // Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "qwaylandoutputmode.h" |
| 5 | #include "qwaylandoutputmode_p.h" |
| 6 | |
| 7 | /*! |
| 8 | \class QWaylandOutputMode |
| 9 | \inmodule QtWaylandCompositor |
| 10 | \since 5.8 |
| 11 | \brief The QWaylandOutputMode class holds the resolution and refresh rate of an output. |
| 12 | |
| 13 | QWaylandOutputMode holds the resolution and refresh rate of an output. |
| 14 | Resolution is expressed in pixels and refresh rate is measured in mHz. |
| 15 | |
| 16 | \sa QWaylandOutput |
| 17 | */ |
| 18 | |
| 19 | QWaylandOutputMode::QWaylandOutputMode() |
| 20 | : d(new QWaylandOutputModePrivate) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | QWaylandOutputMode::QWaylandOutputMode(const QSize &size, int refreshRate) |
| 25 | : d(new QWaylandOutputModePrivate) |
| 26 | { |
| 27 | d->size = size; |
| 28 | d->refreshRate = refreshRate; |
| 29 | } |
| 30 | |
| 31 | QWaylandOutputMode::QWaylandOutputMode(const QWaylandOutputMode &other) |
| 32 | : d(new QWaylandOutputModePrivate) |
| 33 | { |
| 34 | d->size = other.size(); |
| 35 | d->refreshRate = other.refreshRate(); |
| 36 | } |
| 37 | |
| 38 | QWaylandOutputMode::~QWaylandOutputMode() |
| 39 | { |
| 40 | delete d; |
| 41 | } |
| 42 | |
| 43 | QWaylandOutputMode &QWaylandOutputMode::operator=(const QWaylandOutputMode &other) |
| 44 | { |
| 45 | d->size = other.size(); |
| 46 | d->refreshRate = other.refreshRate(); |
| 47 | return *this; |
| 48 | } |
| 49 | |
| 50 | /*! |
| 51 | Returns \c true if this mode is equal to \a other, |
| 52 | otherwise returns \c false. |
| 53 | */ |
| 54 | bool QWaylandOutputMode::operator==(const QWaylandOutputMode &other) const |
| 55 | { |
| 56 | return size() == other.size() && refreshRate() == other.refreshRate(); |
| 57 | } |
| 58 | |
| 59 | /*! |
| 60 | Returns \c true if this mode is not equal to \a other, |
| 61 | otherwise returns \c false. |
| 62 | */ |
| 63 | bool QWaylandOutputMode::operator!=(const QWaylandOutputMode &other) const |
| 64 | { |
| 65 | return size() != other.size() || refreshRate() != other.refreshRate(); |
| 66 | } |
| 67 | |
| 68 | /*! |
| 69 | Returns whether this mode contains a valid resolution and refresh rate. |
| 70 | */ |
| 71 | bool QWaylandOutputMode::isValid() const |
| 72 | { |
| 73 | return !d->size.isEmpty() && d->refreshRate > 0; |
| 74 | } |
| 75 | |
| 76 | /*! |
| 77 | Returns the resolution in pixels. |
| 78 | */ |
| 79 | QSize QWaylandOutputMode::size() const |
| 80 | { |
| 81 | return d->size; |
| 82 | } |
| 83 | |
| 84 | /*! |
| 85 | Returns the refresh rate in mHz. |
| 86 | */ |
| 87 | int QWaylandOutputMode::refreshRate() const |
| 88 | { |
| 89 | return d->refreshRate; |
| 90 | } |
| 91 | |
| 92 | /*! |
| 93 | * \internal |
| 94 | */ |
| 95 | void QWaylandOutputMode::setSize(const QSize &size) |
| 96 | { |
| 97 | d->size = size; |
| 98 | } |
| 99 |
