1 /*
2     Copyright (C) 2016  P.L. Lucas <selairi@gmail.com>
3 
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) any later version.
8 
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Lesser General Public License for more details.
13 
14     You should have received a copy of the GNU Lesser General Public
15     License along with this library; if not, write to the Free Software
16     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18 
19 #include "monitorinfo.h"
20 
MonitorInfo(int id,QString name,long backlightMax)21 MonitorInfo::MonitorInfo(int id, QString name, long backlightMax)
22     : mBacklightMax(backlightMax),
23       mBacklight(-1),
24       mBrightness(-1.0f),
25       mName(name),
26       mId(id)
27 {
28 }
29 
MonitorInfo(const MonitorInfo & monitor)30 MonitorInfo::MonitorInfo(const MonitorInfo &monitor)
31 {
32     mId = monitor.mId;
33     mName = monitor.mName;
34     mBacklightMax = monitor.mBacklightMax;
35     mBacklight = monitor.mBacklight;
36     mBrightness = monitor.mBrightness;
37 }
38 
isBacklightSupported() const39 bool MonitorInfo::isBacklightSupported() const
40 {
41     return mBacklightMax > 0;
42 }
43 
backlightMax() const44 long MonitorInfo::backlightMax() const
45 {
46     return mBacklightMax;
47 }
48 
backlight() const49 long MonitorInfo::backlight() const
50 {
51     return mBacklight;
52 }
53 
setBacklight(const long value)54 void MonitorInfo::setBacklight(const long value)
55 {
56     mBacklight = value;
57 }
58 
brightness() const59 float MonitorInfo::brightness() const
60 {
61     return mBrightness;
62 }
63 
setBrightness(const float percent)64 void MonitorInfo::setBrightness(const float percent)
65 {
66     mBrightness = qMax(qMin((float)2.0, percent), (float)0.0);
67 }
68 
id() const69 int MonitorInfo::id() const
70 {
71     return mId;
72 }
73 
name() const74 QString MonitorInfo::name() const
75 {
76     return mName;
77 }
78 
79