add more spacing
[personal-kdebase.git] / workspace / libs / kephal / configurations / xml / xmlconfigurations.h
blob0b7687ef9d2151eea4d705949e957694f4ef0b52
1 /*
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
24 #include <QRect>
25 #include <QTimer>
27 #include "configurations/backendconfigurations.h"
28 #include "configurations/externalconfiguration.h"
29 #include "kephal/configurations.h"
32 namespace Kephal {
34 class XMLConfigurations;
35 class ConfigurationsXML;
36 class ConfigurationXML;
37 class OutputsXML;
38 class OutputXML;
42 class XMLConfiguration : public BackendConfiguration {
43 Q_OBJECT
44 public:
45 XMLConfiguration(XMLConfigurations * parent, ConfigurationXML * configuration);
47 QString name();
48 bool isModifiable();
49 bool isActivated();
50 void activate();
51 QMap<int, QPoint> layout();
52 int primaryScreen();
54 ConfigurationXML * configuration();
55 void setLayout(const QMap<int, QPoint> & layout);
57 Q_SIGNALS:
58 void activate(XMLConfiguration * configuration);
60 private:
61 ConfigurationXML * m_configuration;
62 XMLConfigurations * m_parent;
63 QMap<int, QPoint> m_layout;
67 class XMLConfigurations : public BackendConfigurations {
68 Q_OBJECT
69 public:
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);
86 bool polling();
87 void confirm();
88 void revert();
90 private Q_SLOTS:
91 void confirmTimerTimeout();
92 bool activate(XMLConfiguration * configuration);
93 void activateExternal();
95 private:
96 void init();
97 void findOutputs();
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);
111 void saveXml();
112 void loadXml();
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;
130 int m_confirmLeft;
131 bool m_awaitingConfirm;
137 #endif // KEPHAL_XMLCONFIGURATIONS_H