Changeset View
Changeset View
Standalone View
Standalone View
kcm/src/declarative/qmlscreen.cpp
Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | |||||
181 | 181 | | |||
182 | QSize QMLScreen::maxScreenSize() const | 182 | QSize QMLScreen::maxScreenSize() const | ||
183 | { | 183 | { | ||
184 | return m_config->screen()->maxSize(); | 184 | return m_config->screen()->maxSize(); | ||
185 | } | 185 | } | ||
186 | 186 | | |||
187 | float QMLScreen::outputScale() const | 187 | float QMLScreen::outputScale() const | ||
188 | { | 188 | { | ||
189 | return 1.0 / 8.0; | 189 | return 1.0 / 12.0; | ||
190 | } | 190 | } | ||
191 | 191 | | |||
192 | void QMLScreen::outputConnectedChanged() | 192 | void QMLScreen::outputConnectedChanged() | ||
193 | { | 193 | { | ||
194 | int connectedCount = 0; | 194 | int connectedCount = 0; | ||
195 | 195 | | |||
196 | Q_FOREACH (const KScreen::OutputPtr &output, m_outputMap.keys()) { | 196 | Q_FOREACH (const KScreen::OutputPtr &output, m_outputMap.keys()) { | ||
197 | if (output->isConnected()) { | 197 | if (output->isConnected()) { | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 294 | Q_FOREACH (QMLOutput *output, m_outputMap) { | |||
312 | if (!other || output->y() + output->height() > other->y() + other->height()) { | 312 | if (!other || output->y() + output->height() > other->y() + other->height()) { | ||
313 | m_bottommost = output; | 313 | m_bottommost = output; | ||
314 | } | 314 | } | ||
315 | } | 315 | } | ||
316 | } | 316 | } | ||
317 | 317 | | |||
318 | void QMLScreen::updateOutputsPlacement() | 318 | void QMLScreen::updateOutputsPlacement() | ||
319 | { | 319 | { | ||
320 | int disabledOffsetX = width(); | | |||
321 | QSizeF activeScreenSize; | 320 | QSizeF activeScreenSize; | ||
322 | 321 | | |||
323 | Q_FOREACH (QQuickItem *item, childItems()) { | 322 | Q_FOREACH (QQuickItem *item, childItems()) { | ||
324 | QMLOutput *qmlOutput = qobject_cast<QMLOutput*>(item); | 323 | QMLOutput *qmlOutput = qobject_cast<QMLOutput*>(item); | ||
325 | if (!qmlOutput->output()->isConnected()) { | 324 | if (!qmlOutput->output()->isConnected() || !qmlOutput->output()->isEnabled()) { | ||
326 | continue; | | |||
327 | } | | |||
328 | | ||||
329 | if (!qmlOutput->output()->isEnabled()) { | | |||
330 | qmlOutput->blockSignals(true); | | |||
331 | disabledOffsetX -= qmlOutput->width(); | | |||
332 | qmlOutput->setPosition(QPoint(disabledOffsetX, 0)); | | |||
333 | qmlOutput->blockSignals(false); | | |||
334 | continue; | 325 | continue; | ||
335 | } | 326 | } | ||
336 | 327 | | |||
337 | if (qmlOutput->outputX() + qmlOutput->currentOutputWidth() > activeScreenSize.width()) { | 328 | if (qmlOutput->outputX() + qmlOutput->currentOutputWidth() > activeScreenSize.width()) { | ||
338 | activeScreenSize.setWidth(qmlOutput->outputX() + qmlOutput->currentOutputWidth()); | 329 | activeScreenSize.setWidth(qmlOutput->outputX() + qmlOutput->currentOutputWidth()); | ||
339 | } | 330 | } | ||
340 | if (qmlOutput->outputY() + qmlOutput->currentOutputHeight() > activeScreenSize.height()) { | 331 | if (qmlOutput->outputY() + qmlOutput->currentOutputHeight() > activeScreenSize.height()) { | ||
341 | activeScreenSize.setHeight(qmlOutput->outputY() + qmlOutput->currentOutputHeight()); | 332 | activeScreenSize.setHeight(qmlOutput->outputY() + qmlOutput->currentOutputHeight()); | ||
342 | } | 333 | } | ||
343 | } | 334 | } | ||
344 | 335 | | |||
345 | activeScreenSize *= outputScale(); | 336 | activeScreenSize *= outputScale(); | ||
346 | 337 | | |||
347 | const QPointF offset((width() - activeScreenSize.width()) / 2.0, | 338 | const QPointF offset((width() - activeScreenSize.width()) / 2.0, | ||
348 | (height() - activeScreenSize.height()) / 2.0); | 339 | (height() - activeScreenSize.height()) / 2.0); | ||
349 | 340 | | |||
341 | qreal lastX = -1.0; | ||||
342 | qreal lastY = -1.0; | ||||
350 | Q_FOREACH (QQuickItem *item, childItems()) { | 343 | Q_FOREACH (QQuickItem *item, childItems()) { | ||
351 | QMLOutput *qmlOutput = qobject_cast<QMLOutput*>(item); | 344 | QMLOutput *qmlOutput = qobject_cast<QMLOutput*>(item); | ||
352 | if (!qmlOutput->output()->isConnected() || !qmlOutput->output()->isEnabled()) { | 345 | if (!qmlOutput->output()->isConnected() || !qmlOutput->output()->isEnabled()) { | ||
353 | continue; | 346 | continue; | ||
354 | } | 347 | } | ||
355 | 348 | | |||
356 | qmlOutput->blockSignals(true); | 349 | qmlOutput->blockSignals(true); | ||
357 | qmlOutput->setPosition(QPointF(offset.x() + (qmlOutput->outputX() * outputScale()), | 350 | qmlOutput->setPosition(QPointF(offset.x() + (qmlOutput->outputX() * outputScale()), | ||
358 | offset.y() + (qmlOutput->outputY() * outputScale()))); | 351 | offset.y() + (qmlOutput->outputY() * outputScale()))); | ||
352 | lastX = qMax(lastX, qmlOutput->position().x() + qmlOutput->size().width()); | ||||
353 | lastY = qMax(lastY, qmlOutput->position().y()); | ||||
359 | qmlOutput->blockSignals(false); | 354 | qmlOutput->blockSignals(false); | ||
360 | } | 355 | } | ||
356 | | ||||
357 | Q_FOREACH (QQuickItem *item, childItems()) { | ||||
358 | QMLOutput *qmlOutput = qobject_cast<QMLOutput*>(item); | ||||
359 | if (qmlOutput->output()->isConnected() && !qmlOutput->output()->isEnabled()) { | ||||
360 | qmlOutput->blockSignals(true); | ||||
361 | qmlOutput->setPosition(QPointF(lastX, lastY)); | ||||
362 | lastX += qmlOutput->size().width(); | ||||
363 | qmlOutput->blockSignals(false); | ||||
364 | } | ||||
365 | } | ||||
361 | } | 366 | } | ||
362 | 367 | | |||
363 | void QMLScreen::setEngine(QQmlEngine* engine) | 368 | void QMLScreen::setEngine(QQmlEngine* engine) | ||
364 | { | 369 | { | ||
365 | m_engine = engine; | 370 | m_engine = engine; | ||
366 | } | 371 | } |