Commit bede0b95 authored by David Edmundson's avatar David Edmundson

Add setScale option to kscreendoctor

Summary:
Adds set scale option to kscreen doctor.

Test Plan: Ran it, my screen changed awesomely.

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: mart, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D6026
parent a02d9257
......@@ -223,7 +223,17 @@ void Doctor::parsePositionalArgs()
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 @@ bool Doctor::setPosition(int id, const QPoint &pos)
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) {
......
......@@ -51,6 +51,7 @@ public:
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:
......
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