KScreen::ConfigPtr Generator::idealConfig(const KScreen::ConfigPtr ¤tConfig) { Q_ASSERT(currentConfig); // KDebug::Block idealBlock("Ideal Config"); KScreen::ConfigPtr config = currentConfig->clone(); disableAllDisconnectedOutputs(config->outputs()); KScreen::OutputList connectedOutputs = config->connectedOutputs(); qCDebug(KSCREEN_KDED) << "Connected outputs: " << connectedOutputs.count(); if (connectedOutputs.isEmpty()) { return config; } if (connectedOutputs.count() == 1) { singleOutput(connectedOutputs); return config; } if (isLaptop()) { laptop(connectedOutputs); return fallbackIfNeeded(config); } qCDebug(KSCREEN_KDED) << "Extend to Right"; extendToRight(connectedOutputs); return fallbackIfNeeded(config); }
void LoadSettings::loadConfiguration(KScreen::ConfigPtr config) { QSettings settings("LXQt", "lxqt-config-monitor"); QJsonDocument document = QJsonDocument::fromJson( settings.value("currentConfig").toByteArray() ); QJsonObject json = document.object(); QJsonArray array = json["outputs"].toArray(); KScreen::OutputList outputs = config->outputs(); for (const KScreen::OutputPtr &output : outputs) { qDebug() << "Output: " << output->name(); for(int i=0;i<array.size();i++) { QJsonObject monitorSettings = array[i].toObject(); if( monitorSettings["name"] == output->name() ) { KScreen::Edid* edid = output->edid(); if (edid && edid->isValid()) if( monitorSettings["hash"].toString() != edid->hash() ) { qDebug() << "Hash: " << monitorSettings["hash"].toString() << "==" << edid->hash(); return exit(1); // Saved settings are from other monitor } if( monitorSettings["connected"].toBool() != output->isConnected() ) return exit(2); // Saved settings are from other monitor if( !output->isConnected() ) continue; output->setEnabled( monitorSettings["enabled"].toBool() ); output->setPrimary( monitorSettings["primary"].toBool() ); output->setPos( QPoint(monitorSettings["xPos"].toInt(),monitorSettings["yPos"].toInt()) ); output->setCurrentModeId( monitorSettings["currentMode"].toString() ); output->setRotation( (KScreen::Output::Rotation)(monitorSettings["rotation"].toInt()) ); } } } if (KScreen::Config::canBeApplied(config)) KScreen::SetConfigOperation(config).exec(); exit(0); }