2 * Copyright 2008 Aike J Sommer <dev@aikesommer.name>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2,
7 * or (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef KEPHAL_XMLCONFIGURATIONS_H
22 #define KEPHAL_XMLCONFIGURATIONS_H
27 #include "configurations/backendconfigurations.h"
28 #include "configurations/externalconfiguration.h"
29 #include "kephal/configurations.h"
34 class XMLConfigurations
;
35 class ConfigurationsXML
;
36 class ConfigurationXML
;
42 class XMLConfiguration
: public BackendConfiguration
{
45 XMLConfiguration(XMLConfigurations
* parent
, ConfigurationXML
* configuration
);
51 QMap
<int, QPoint
> layout();
54 ConfigurationXML
* configuration();
55 void setLayout(const QMap
<int, QPoint
> & layout
);
58 void activate(XMLConfiguration
* configuration
);
61 ConfigurationXML
* m_configuration
;
62 XMLConfigurations
* m_parent
;
63 QMap
<int, QPoint
> m_layout
;
67 class XMLConfigurations
: public BackendConfigurations
{
70 XMLConfigurations(QObject
* parent
);
72 QMap
<QString
, Configuration
*> configurations();
73 Configuration
* findConfiguration();
74 Configuration
* activeConfiguration();
75 QList
<Configuration
*> alternateConfigurations();
76 QList
<QPoint
> possiblePositions(Output
* output
);
77 bool move(Output
* output
, const QPoint
& position
);
78 bool resize(Output
* output
, const QSize
& size
);
79 bool rotate(Output
* output
, Rotation rotation
);
80 bool changeRate(Output
* output
, float rate
);
81 bool reflectX(Output
* output
, bool reflect
);
82 bool reflectY(Output
* output
, bool reflect
);
83 int screen(Output
* output
);
84 void applyOutputSettings();
85 void setPolling(bool polling
);
91 void confirmTimerTimeout();
92 bool activate(XMLConfiguration
* configuration
);
93 void activateExternal();
98 OutputsXML
* findKnownOutputs();
99 OutputsXML
* findBestOutputs();
100 qreal
match(QString known
, QString current
);
101 qreal
match(int known
, int current
);
102 QMap
<int, int> matchLayouts(const QMap
<int, QPoint
> & currentLayout
, const QMap
<int, QPoint
> & layout
);
103 QMap
<int, QRect
> calcMatchingLayout(const QMap
<int, QPoint
> & currentLayout
, XMLConfiguration
* configuration
, QMap
<int, QPoint
> layout
, Output
* output
= 0, int * outputScreen
= 0);
104 void translateToOther(QMap
<int, QRect
> & layout
, Output
* base
, QMap
<int, int> match
= (QMap
<int, int>()));
105 QList
<XMLConfiguration
*> equivalentConfigurations(int numScreens
);
106 QMap
<XMLConfiguration
*, QPoint
> equivalentConfigurationsPositions(Output
* output
);
107 QMap
<XMLConfiguration
*, QPoint
> simpleConfigurationsPositions(Output
* output
, bool sameCount
);
108 QMap
<XMLConfiguration
*, QPoint
> sameConfigurationsPositions(Output
* output
, bool sameCount
);
109 QMap
<XMLConfiguration
*, QMap
<int, QPoint
> > matchingConfigurationsLayouts(const QMap
<int, QPoint
> & currentLayout
, int removedOutputs
);
110 XMLConfiguration
* simpleConfiguration(int numScreens
);
113 bool activateLayout(const QMap
<int, QRect
> & layout
, const QMap
<Output
*, int> & outputScreens
);
114 bool activateLayout(const QMap
<int, QRect
> & layout
, const QMap
<Output
*, int> & outputScreens
, const QMap
<Output
*, QSize
> & outputSizes
);
115 QMap
<Output
*, int> currentOutputScreens();
116 void matchOutputScreens(const QMap
<int, QPoint
> & layout
);
117 OutputXML
* outputXml(const QString
& id
);
118 QMap
<int, QRect
> resizeLayout(Output
* output
, const QSize
& size
, QMap
<Output
*, int> & outputScreens
, QMap
<Output
*, QSize
> & outputSizes
);
119 void requireConfirm();
121 QMap
<QString
, XMLConfiguration
*> m_configurations
;
122 XMLConfiguration
* m_activeConfiguration
;
123 XMLConfiguration
* m_markedConfiguration
;
124 ExternalConfiguration
* m_externalConfiguration
;
125 ConfigurationsXML
* m_configXml
;
126 QString m_configPath
;
127 OutputsXML
* m_currentOutputs
;
128 bool m_currentOutputsKnown
;
129 QTimer
* m_confirmTimer
;
131 bool m_awaitingConfirm
;
137 #endif // KEPHAL_XMLCONFIGURATIONS_H