diff --git a/src/doctor/doctor.h b/src/doctor/doctor.h --- a/src/doctor/doctor.h +++ b/src/doctor/doctor.h @@ -51,6 +51,7 @@ bool setEnabled(int id, bool enabled); bool setPosition(int id, const QPoint &pos); + bool setScale(int id, int scale); bool setMode(int id, const QString &mode_id); Q_SIGNALS: diff --git a/src/doctor/doctor.cpp b/src/doctor/doctor.cpp --- a/src/doctor/doctor.cpp +++ b/src/doctor/doctor.cpp @@ -223,7 +223,17 @@ return; } qCDebug(KSCREEN_DOCTOR) << "Output" << output_id << "set mode" << mode_id; - + } else if (ops.count() == 4 && ops[2] == QStringLiteral("scale")) { + int scale = ops[3].toInt(&ok); + if (!ok || scale < 1) { + cerr << "Unable to parse scale" << ops[3] << endl; + qApp->exit(5); + return; + } + if (!setScale(output_id, scale)) { + qApp->exit(1); + return; + } } else if (ops.count() == 4 && ops[2] == QStringLiteral("position")) { QStringList _pos = ops[3].split(','); if (_pos.count() != 2) { @@ -391,6 +401,25 @@ return false; } +bool Doctor::setScale(int id, const int scale) +{ + if (!m_config) { + qCWarning(KSCREEN_DOCTOR) << "Invalid config."; + return false; + } + + Q_FOREACH (const auto &output, m_config->outputs()) { + if (output->id() == id) { + qCDebug(KSCREEN_DOCTOR) << "Set scale position" << scale; + output->setScale(scale); + m_changed = true; + return true; + } + } + cout << "Output with id " << id << " not found." << endl; + return false; +} + bool Doctor::setMode(int id, const QString &mode_id) { if (!m_config) {