Commit bf4521e4 authored by Sebastian Kügler's avatar Sebastian Kügler

kscreen-doctor: support setting scale of outputs

Add the option to set the scale of an output in kscreen doctor.

CHANGELOG: kscreen-doctor: support setting scale of outputs
parent 7d30357b
......@@ -245,6 +245,19 @@ void Doctor::parsePositionalArgs()
qApp->exit(1);
return;
}
} else if ((ops.count() == 4 || ops.count() == 5) && ops[2] == QStringLiteral("scale")) {
// be lenient about . vs. comma as separator
qreal scale = ops[3].replace(QStringLiteral(","), QStringLiteral(".")).toDouble(&ok);
if (ops.count() == 5) {
const auto dbl = ops[3] + QStringLiteral(".") + ops[4];
scale = dbl.toDouble(&ok);
};
// set scale
if (!ok || scale == 0 || !setScale(output_id, scale)) {
qCDebug(KSCREEN_DOCTOR) << "Could not set scale " << scale << " to output " << output_id;
qApp->exit(9);
return;
}
} else {
cerr << "Unable to parse arguments" << op << endl;
qApp->exit(2);
......@@ -415,6 +428,24 @@ bool Doctor::setMode(int id, const QString &mode_id)
return false;
}
bool Doctor::setScale(int id, int scale)
{
if (!m_config) {
qCWarning(KSCREEN_DOCTOR) << "Invalid config.";
return false;
}
Q_FOREACH (const auto &output, m_config->outputs()) {
if (output->id() == id) {
output->setScale(scale);
m_changed = true;
return true;
}
}
cout << "Output scale " << id << " invalid." << endl;
return false;
}
void Doctor::applyConfig()
{
if (!m_changed) {
......
......@@ -52,6 +52,7 @@ public:
bool setEnabled(int id, bool enabled);
bool setPosition(int id, const QPoint &pos);
bool setMode(int id, const QString &mode_id);
bool setScale(int id, int scale);
Q_SIGNALS:
void outputsChanged();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment