Changeset View
Changeset View
Standalone View
Standalone View
kded/output.cpp
Show All 10 Lines | |||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | *********************************************************************/ | 16 | *********************************************************************/ | ||
17 | #include "output.h" | 17 | #include "output.h" | ||
18 | #include "config.h" | 18 | #include "config.h" | ||
19 | #include "../common/globals.h" | | |||
20 | 19 | | |||
21 | #include "kscreen_daemon_debug.h" | 20 | #include "kscreen_daemon_debug.h" | ||
22 | #include "generator.h" | 21 | #include "generator.h" | ||
23 | 22 | | |||
24 | #include <QStringList> | 23 | #include <QStringList> | ||
25 | #include <QFile> | 24 | #include <QFile> | ||
26 | #include <QJsonDocument> | 25 | #include <QJsonDocument> | ||
27 | #include <QDir> | 26 | #include <QDir> | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 111 | { | |||
114 | if (info.empty()) { | 113 | if (info.empty()) { | ||
115 | // if info is empty, the global file does not exists, or is in an unreadable state | 114 | // if info is empty, the global file does not exists, or is in an unreadable state | ||
116 | return false; | 115 | return false; | ||
117 | } | 116 | } | ||
118 | readInGlobalPartFromInfo(output, info); | 117 | readInGlobalPartFromInfo(output, info); | ||
119 | return true; | 118 | return true; | ||
120 | } | 119 | } | ||
121 | 120 | | |||
121 | KScreen::Output::Rotation orientationToRotation(QOrientationReading::Orientation orientation, | ||||
122 | KScreen::Output::Rotation fallback) | ||||
123 | { | ||||
124 | using Orientation = QOrientationReading::Orientation; | ||||
125 | | ||||
126 | switch (orientation) { | ||||
127 | case Orientation::TopUp: | ||||
128 | return KScreen::Output::Rotation::None; | ||||
129 | case Orientation::TopDown: | ||||
130 | return KScreen::Output::Rotation::Inverted; | ||||
131 | case Orientation::LeftUp: | ||||
132 | return KScreen::Output::Rotation::Right; | ||||
133 | case Orientation::RightUp: | ||||
134 | return KScreen::Output::Rotation::Left; | ||||
135 | case Orientation::Undefined: | ||||
136 | case Orientation::FaceUp: | ||||
137 | case Orientation::FaceDown: | ||||
138 | return fallback; | ||||
139 | default: | ||||
140 | Q_UNREACHABLE(); | ||||
141 | } | ||||
142 | } | ||||
143 | | ||||
144 | bool Output::updateOrientation(KScreen::OutputPtr &output, | ||||
145 | QOrientationReading::Orientation orientation) | ||||
146 | { | ||||
147 | if (output->type() != KScreen::Output::Type::Panel) { | ||||
148 | return false; | ||||
149 | } | ||||
150 | const auto currentRotation = output->rotation(); | ||||
151 | const auto rotation = orientationToRotation(orientation, currentRotation); | ||||
152 | if (rotation == currentRotation) { | ||||
153 | return true; | ||||
154 | } | ||||
155 | output->setRotation(rotation); | ||||
156 | return true; | ||||
157 | } | ||||
158 | | ||||
159 | // TODO: move this into the Layouter class. | ||||
122 | void Output::adjustPositions(KScreen::ConfigPtr config, const QVariantList &outputsInfo) | 160 | void Output::adjustPositions(KScreen::ConfigPtr config, const QVariantList &outputsInfo) | ||
123 | { | 161 | { | ||
124 | typedef QPair<int, QPoint> Out; | 162 | typedef QPair<int, QPoint> Out; | ||
125 | 163 | | |||
126 | KScreen::OutputList outputs = config->outputs(); | 164 | KScreen::OutputList outputs = config->outputs(); | ||
127 | QVector<Out> sortedOutputs; // <id, pos> | 165 | QVector<Out> sortedOutputs; // <id, pos> | ||
128 | for (const KScreen::OutputPtr output : outputs) { | 166 | for (const KScreen::OutputPtr output : outputs) { | ||
129 | sortedOutputs.append(Out(output->id(), output->pos())); | 167 | sortedOutputs.append(Out(output->id(), output->pos())); | ||
▲ Show 20 Lines • Show All 298 Lines • Show Last 20 Lines |