1 /*
2  * synergy -- mouse and keyboard sharing utility
3  * Copyright (C) 2012-2016 Symless Ltd.
4  * Copyright (C) 2008 Volker Lanz (vl@fidra.de)
5  *
6  * This package is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * found in the file LICENSE that should have accompanied this file.
9  *
10  * This package is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #if !defined(SCREEN__H)
20 
21 #define SCREEN__H
22 
23 #include <QPixmap>
24 #include <QString>
25 #include <QList>
26 #include <QStringList>
27 
28 #include "BaseConfig.h"
29 
30 class QSettings;
31 class QTextStream;
32 
33 class ScreenSettingsDialog;
34 
35 class Screen : public BaseConfig
36 {
37     friend QDataStream& operator<<(QDataStream& outStream, const Screen& screen);
38     friend QDataStream& operator>>(QDataStream& inStream, Screen& screen);
39     friend class ScreenSettingsDialog;
40     friend class ScreenSetupModel;
41     friend class ScreenSetupView;
42 
43     public:
44         Screen();
45         Screen(const QString& name);
46 
47     public:
pixmap()48         const QPixmap* pixmap() const { return &m_Pixmap; }
name()49         const QString& name() const { return m_Name; }
aliases()50         const QStringList& aliases() const { return m_Aliases; }
51 
isNull()52         bool isNull() const { return m_Name.isEmpty(); }
modifier(int m)53         int modifier(int m) const { return m_Modifiers[m] == DefaultMod ? m : m_Modifiers[m]; }
modifiers()54         const QList<int>& modifiers() const { return m_Modifiers; }
switchCorner(int c)55         bool switchCorner(int c) const { return m_SwitchCorners[c]; }
switchCorners()56         const QList<bool>& switchCorners() const { return m_SwitchCorners; }
switchCornerSize()57         int switchCornerSize() const { return m_SwitchCornerSize; }
fix(Fix f)58         bool fix(Fix f) const { return m_Fixes[f]; }
fixes()59         const QList<bool>& fixes() const { return m_Fixes; }
60 
61         void loadSettings(QSettings& settings);
62         void saveSettings(QSettings& settings) const;
63         QTextStream& writeScreensSection(QTextStream& outStream) const;
64         QTextStream& writeAliasesSection(QTextStream& outStream) const;
65 
swapped()66         bool swapped() const { return m_Swapped; }
name()67         QString& name() { return m_Name; }
setName(const QString & name)68         void setName(const QString& name) { m_Name = name; }
isServer()69         bool isServer() const { return m_isServer;}
markAsServer()70         void markAsServer() { m_isServer = true; }
71 
72     protected:
73         void init();
pixmap()74         QPixmap* pixmap() { return &m_Pixmap; }
75 
setPixmap(const QPixmap & pixmap)76         void setPixmap(const QPixmap& pixmap) { m_Pixmap = pixmap; }
aliases()77         QStringList& aliases() { return m_Aliases; }
setModifier(int m,int n)78         void setModifier(int m, int n) { m_Modifiers[m] = n; }
modifiers()79         QList<int>& modifiers() { return m_Modifiers; }
addAlias(const QString & alias)80         void addAlias(const QString& alias) { m_Aliases.append(alias); }
setSwitchCorner(int c,bool on)81         void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
switchCorners()82         QList<bool>& switchCorners() { return m_SwitchCorners; }
setSwitchCornerSize(int val)83         void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
setFix(int f,bool on)84         void setFix(int f, bool on) { m_Fixes[f] = on; }
fixes()85         QList<bool>& fixes() { return m_Fixes; }
setSwapped(bool on)86         void setSwapped(bool on) { m_Swapped = on; }
87 
88     private:
89         QPixmap m_Pixmap;
90         QString m_Name;
91 
92         QStringList m_Aliases;
93         QList<int> m_Modifiers;
94         QList<bool> m_SwitchCorners;
95         int m_SwitchCornerSize;
96         QList<bool> m_Fixes;
97 
98         bool m_Swapped;
99         bool m_isServer = false;
100 };
101 
102 QDataStream& operator<<(QDataStream& outStream, const Screen& screen);
103 QDataStream& operator>>(QDataStream& inStream, Screen& screen);
104 
105 #endif
106 
107