Commit 6e5421e0 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent cdaade8a
......@@ -17,10 +17,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "control.h"
#include "globals.h"
#include <KDirWatch>
#include <QDir>
#include <QFile>
#include <QJsonDocument>
#include <QDir>
#include <KDirWatch>
#include <kscreen/config.h>
#include <kscreen/output.h>
......@@ -45,7 +45,7 @@ void Control::activateWatcher()
});
}
KDirWatch* Control::watcher() const
KDirWatch *Control::watcher() const
{
return m_watcher;
}
......@@ -69,11 +69,11 @@ bool Control::writeFile()
QFile file(path);
if (!file.open(QIODevice::WriteOnly)) {
// TODO: logging category?
// qCWarning(KSCREEN_COMMON) << "Failed to open config control file for writing! " << file.errorString();
// qCWarning(KSCREEN_COMMON) << "Failed to open config control file for writing! " << file.errorString();
return false;
}
file.write(QJsonDocument::fromVariant(infoMap).toJson());
// qCDebug(KSCREEN_COMMON) << "Control saved on: " << file.fileName();
// qCDebug(KSCREEN_COMMON) << "Control saved on: " << file.fileName();
return true;
}
......@@ -98,12 +98,12 @@ QString Control::filePathFromHash(const QString &hash) const
return dirPath() % hash;
}
QVariantMap& Control::info()
QVariantMap &Control::info()
{
return m_info;
}
const QVariantMap& Control::constInfo() const
const QVariantMap &Control::constInfo() const
{
return m_info;
}
......@@ -126,7 +126,7 @@ ControlConfig::ControlConfig(KScreen::ConfigPtr config, QObject *parent)
: Control(parent)
, m_config(config)
{
// qDebug() << "Looking for control file:" << config->connectedOutputsHash();
// qDebug() << "Looking for control file:" << config->connectedOutputsHash();
readFile();
// TODO: use a file watcher in case of changes to the control file while
......@@ -184,8 +184,7 @@ bool ControlConfig::writeFile()
{
bool success = true;
for (auto *outputControl : m_outputsControls) {
if (getOutputRetention(outputControl->id(), outputControl->name())
== OutputRetention::Individual) {
if (getOutputRetention(outputControl->id(), outputControl->name()) == OutputRetention::Individual) {
continue;
}
success &= outputControl->writeFile();
......@@ -303,8 +302,8 @@ qreal ControlConfig::getScale(const QString &outputId, const QString &outputName
}
// Info for output not found.
return -1;
}
return -1;
}
void ControlConfig::setScale(const KScreen::OutputPtr &output, qreal value)
{
......@@ -321,7 +320,6 @@ void ControlConfig::setScale(const QString &outputId, const QString &outputName,
if (auto *control = getOutputControl(outputId, outputName)) {
control->setScale(value);
}
};
for (it = outputsInfo.begin(); it != outputsInfo.end(); ++it) {
......@@ -387,7 +385,6 @@ void ControlConfig::setAutoRotate(const QString &outputId, const QString &output
if (auto *control = getOutputControl(outputId, outputName)) {
control->setAutoRotate(value);
}
};
for (it = outputsInfo.begin(); it != outputsInfo.end(); ++it) {
......@@ -415,8 +412,7 @@ bool ControlConfig::getAutoRotateOnlyInTabletMode(const KScreen::OutputPtr &outp
return getAutoRotateOnlyInTabletMode(output->hashMd5(), output->name());
}
bool ControlConfig::getAutoRotateOnlyInTabletMode(const QString &outputId,
const QString &outputName) const
bool ControlConfig::getAutoRotateOnlyInTabletMode(const QString &outputId, const QString &outputName) const
{
const auto retention = getOutputRetention(outputId, outputName);
if (retention == OutputRetention::Individual) {
......@@ -445,8 +441,7 @@ void ControlConfig::setAutoRotateOnlyInTabletMode(const KScreen::OutputPtr &outp
}
// TODO: combine methods (templated functions)
void ControlConfig::setAutoRotateOnlyInTabletMode(const QString &outputId,
const QString &outputName, bool value)
void ControlConfig::setAutoRotateOnlyInTabletMode(const QString &outputId, const QString &outputName, bool value)
{
QList<QVariant>::iterator it;
QVariantList outputsInfo = getOutputs();
......@@ -477,14 +472,12 @@ void ControlConfig::setAutoRotateOnlyInTabletMode(const QString &outputId,
setOutputAutoRotateOnlyInTabletMode();
}
KScreen::OutputPtr ControlConfig::getReplicationSource(const KScreen::OutputPtr &output) const
{
return getReplicationSource(output->hashMd5(), output->name());
}
KScreen::OutputPtr ControlConfig::getReplicationSource(const QString &outputId,
const QString &outputName) const
KScreen::OutputPtr ControlConfig::getReplicationSource(const QString &outputId, const QString &outputName) const
{
const QVariantList outputsInfo = getOutputs();
for (const auto &variantInfo : outputsInfo) {
......@@ -512,14 +505,12 @@ KScreen::OutputPtr ControlConfig::getReplicationSource(const QString &outputId,
return nullptr;
}
void ControlConfig::setReplicationSource(const KScreen::OutputPtr &output,
const KScreen::OutputPtr &source)
void ControlConfig::setReplicationSource(const KScreen::OutputPtr &output, const KScreen::OutputPtr &source)
{
setReplicationSource(output->hashMd5(), output->name(), source);
}
void ControlConfig::setReplicationSource(const QString &outputId, const QString &outputName,
const KScreen::OutputPtr &source)
void ControlConfig::setReplicationSource(const QString &outputId, const QString &outputName, const KScreen::OutputPtr &source)
{
QList<QVariant>::iterator it;
QVariantList outputsInfo = getOutputs();
......@@ -558,8 +549,7 @@ void ControlConfig::setOutputs(QVariantList outputsInfo)
auto &infoMap = info();
infoMap[QStringLiteral("outputs")] = outputsInfo;
}
ControlOutput* ControlConfig::getOutputControl(const QString &outputId,
const QString &outputName) const
ControlOutput *ControlConfig::getOutputControl(const QString &outputId, const QString &outputName) const
{
for (auto *control : m_outputsControls) {
if (control->id() == outputId && control->name() == outputName) {
......
......@@ -20,8 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kscreen/types.h>
#include <QObject>
#include <QVector>
#include <QVariantMap>
#include <QVector>
class KDirWatch;
......@@ -38,7 +38,6 @@ public:
explicit Control(QObject *parent = nullptr);
~Control() override = default;
virtual bool writeFile();
......@@ -52,9 +51,9 @@ protected:
virtual QString filePath() const = 0;
QString filePathFromHash(const QString &hash) const;
void readFile();
QVariantMap& info();
const QVariantMap& constInfo() const;
KDirWatch* watcher() const;
QVariantMap &info();
const QVariantMap &constInfo() const;
KDirWatch *watcher() const;
static OutputRetention convertVariantToOutputRetention(QVariant variant);
......@@ -90,15 +89,12 @@ public:
bool getAutoRotateOnlyInTabletMode(const KScreen::OutputPtr &output) const;
bool getAutoRotateOnlyInTabletMode(const QString &outputId, const QString &outputName) const;
void setAutoRotateOnlyInTabletMode(const KScreen::OutputPtr &output, bool value);
void setAutoRotateOnlyInTabletMode(const QString &outputId, const QString &outputName,
bool value);
void setAutoRotateOnlyInTabletMode(const QString &outputId, const QString &outputName, bool value);
KScreen::OutputPtr getReplicationSource(const KScreen::OutputPtr &output) const;
KScreen::OutputPtr getReplicationSource(const QString &outputId,
const QString &outputName) const;
KScreen::OutputPtr getReplicationSource(const QString &outputId, const QString &outputName) const;
void setReplicationSource(const KScreen::OutputPtr &output, const KScreen::OutputPtr &source);
void setReplicationSource(const QString &outputId, const QString &outputName,
const KScreen::OutputPtr &source);
void setReplicationSource(const QString &outputId, const QString &outputName, const KScreen::OutputPtr &source);
QString dirPath() const override;
QString filePath() const override;
......@@ -110,11 +106,11 @@ private:
QVariantList getOutputs() const;
void setOutputs(QVariantList outputsInfo);
bool infoIsOutput(const QVariantMap &info, const QString &outputId, const QString &outputName) const;
ControlOutput* getOutputControl(const QString &outputId, const QString &outputName) const;
ControlOutput *getOutputControl(const QString &outputId, const QString &outputName) const;
KScreen::ConfigPtr m_config;
QStringList m_duplicateOutputIds;
QVector<ControlOutput*> m_outputsControls;
QVector<ControlOutput *> m_outputsControls;
};
class ControlOutput : public Control
......
......@@ -20,11 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace Globals
{
QString s_dirPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) % QStringLiteral("/kscreen/");
QString s_dirPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) %
QStringLiteral("/kscreen/");
QString dirPath() {
QString dirPath()
{
return s_dirPath;
}
......
......@@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace Globals
{
void setDirPath(const QString &path);
QString dirPath();
void setDirPath(const QString &path);
QString dirPath();
}
#endif
......@@ -55,7 +55,7 @@ QOrientationReading::Orientation OrientationSensor::value() const
bool OrientationSensor::available() const
{
return m_sensor->connectToBackend();
return m_sensor->connectToBackend();
}
bool OrientationSensor::enabled() const
......@@ -71,12 +71,10 @@ void OrientationSensor::setEnabled(bool enable)
m_enabled = enable;
if (enable) {
connect(m_sensor, &QOrientationSensor::readingChanged,
this, &OrientationSensor::updateState);
connect(m_sensor, &QOrientationSensor::readingChanged, this, &OrientationSensor::updateState);
m_sensor->start();
} else {
disconnect(m_sensor, &QOrientationSensor::readingChanged,
this, &OrientationSensor::updateState);
disconnect(m_sensor, &QOrientationSensor::readingChanged, this, &OrientationSensor::updateState);
m_value = QOrientationReading::Undefined;
}
Q_EMIT enabledChanged(enable);
......
......@@ -25,7 +25,7 @@
#include <KLocalizedString>
QString Utils::outputName(const KScreen::OutputPtr& output)
QString Utils::outputName(const KScreen::OutputPtr &output)
{
return outputName(output.data());
}
......@@ -57,4 +57,3 @@ QString Utils::sizeToString(const QSize &size)
{
return QStringLiteral("%1x%2").arg(size.width()).arg(size.height());
}
......@@ -22,19 +22,18 @@
#ifndef KSCREEN_KCM_UTILS_H
#define KSCREEN_KCM_UTILS_H
#include <QString>
#include <QSize>
#include <QString>
#include <kscreen/types.h>
#include <kscreen/output.h>
#include <kscreen/types.h>
namespace Utils
{
QString outputName(const KScreen::Output *output);
QString outputName(const KScreen::OutputPtr &output);
QString outputName(const KScreen::Output *output);
QString outputName(const KScreen::OutputPtr &output);
QString sizeToString(const QSize &size);
QString sizeToString(const QSize &size);
}
#endif
......@@ -20,18 +20,17 @@
#include <QDebug>
#include <QDir>
#include <QTextStream>
#include <QStandardPaths>
#include <QJsonDocument>
#include <QJsonObject>
#include <QStandardPaths>
#include <QTextStream>
#include <kscreen/types.h>
#include <kscreen/config.h>
#include <kscreen/mode.h>
#include <kscreen/configmonitor.h>
#include <kscreen/edid.h>
#include <kscreen/getconfigoperation.h>
#include <kscreen/mode.h>
#include <kscreen/types.h>
static QTextStream cout(stdout);
......@@ -54,7 +53,6 @@ Console::Console(const ConfigPtr &config)
Console::~Console()
{
}
void Console::printConfig()
......@@ -68,15 +66,13 @@ void Console::printConfig()
return;
}
connect(m_config.data(), &Config::primaryOutputChanged,
[&](const OutputPtr &output) {
if (output) {
qDebug() << "New primary output: "
<< output->id() << output->name();
} else {
qDebug() << "No primary output.";
}
});
connect(m_config.data(), &Config::primaryOutputChanged, [&](const OutputPtr &output) {
if (output) {
qDebug() << "New primary output: " << output->id() << output->name();
} else {
qDebug() << "No primary output.";
}
});
qDebug() << "Screen:";
qDebug() << "\tmaxSize:" << m_config->screen()->maxSize();
......@@ -84,7 +80,7 @@ void Console::printConfig()
qDebug() << "\tcurrentSize:" << m_config->screen()->currentSize();
OutputList outputs = m_config->outputs();
Q_FOREACH(const OutputPtr &output, outputs) {
Q_FOREACH (const OutputPtr &output, outputs) {
qDebug() << "\n-----------------------------------------------------\n";
qDebug() << "Id: " << output->id();
qDebug() << "Name: " << output->name();
......@@ -104,7 +100,8 @@ void Console::printConfig()
}
qDebug() << "Scale: " << output->scale();
if (output->clones().isEmpty()) {
qDebug() << "Clones: " << "None";
qDebug() << "Clones: "
<< "None";
} else {
qDebug() << "Clones: " << output->clones().count();
}
......@@ -114,11 +111,11 @@ void Console::printConfig()
qDebug() << "Modes: ";
ModeList modes = output->modes();
Q_FOREACH(const ModePtr &mode, modes) {
Q_FOREACH (const ModePtr &mode, modes) {
qDebug() << "\t" << mode->id() << " " << mode->name() << " " << mode->size() << " " << mode->refreshRate();
}
Edid* edid = output->edid();
Edid *edid = output->edid();
qDebug() << "EDID Info: ";
if (edid && edid->isValid()) {
qDebug() << "\tDevice ID: " << edid->deviceId();
......@@ -140,40 +137,39 @@ void Console::printConfig()
}
}
QString Console::typetoString(const Output::Type& type) const
QString Console::typetoString(const Output::Type &type) const
{
switch (type) {
case Output::Unknown:
return QStringLiteral("Unknown");
case Output::Panel:
return QStringLiteral("Panel (Laptop)");
case Output::VGA:
return QStringLiteral("VGA");
case Output::DVI:
return QStringLiteral("DVI");
case Output::DVII:
return QStringLiteral("DVI-I");
case Output::DVIA:
return QStringLiteral("DVI-A");
case Output::DVID:
return QStringLiteral("DVI-D");
case Output::HDMI:
return QStringLiteral("HDMI");
case Output::TV:
return QStringLiteral("TV");
case Output::TVComposite:
return QStringLiteral("TV-Composite");
case Output::TVSVideo:
return QStringLiteral("TV-SVideo");
case Output::TVComponent:
return QStringLiteral("TV-Component");
case Output::TVSCART:
return QStringLiteral("TV-SCART");
case Output::TVC4:
return QStringLiteral("TV-C4");
case Output::DisplayPort:
return QStringLiteral("DisplayPort");
case Output::Unknown:
return QStringLiteral("Unknown");
case Output::Panel:
return QStringLiteral("Panel (Laptop)");
case Output::VGA:
return QStringLiteral("VGA");
case Output::DVI:
return QStringLiteral("DVI");
case Output::DVII:
return QStringLiteral("DVI-I");
case Output::DVIA:
return QStringLiteral("DVI-A");
case Output::DVID:
return QStringLiteral("DVI-D");
case Output::HDMI:
return QStringLiteral("HDMI");
case Output::TV:
return QStringLiteral("TV");
case Output::TVComposite:
return QStringLiteral("TV-Composite");
case Output::TVSVideo:
return QStringLiteral("TV-SVideo");
case Output::TVComponent:
return QStringLiteral("TV-Component");
case Output::TVSCART:
return QStringLiteral("TV-SCART");
case Output::TVC4:
return QStringLiteral("TV-C4");
case Output::DisplayPort:
return QStringLiteral("DisplayPort");
};
return QStringLiteral("Invalid Type") + QString::number(type);
}
......@@ -194,14 +190,15 @@ void Console::printSerializations()
qDebug() << "Number of files: " << files.count() << endl;
QJsonDocument parser;
Q_FOREACH(const QString fileName, files) {
Q_FOREACH (const QString fileName, files) {
QJsonParseError error;
qDebug() << fileName;
QFile file(path + QLatin1Char('/') + fileName);
file.open(QFile::ReadOnly);
QVariant data = parser.fromJson(file.readAll(), &error);
if (error.error != QJsonParseError::NoError) {
qDebug() << " " << "can't parse file";
qDebug() << " "
<< "can't parse file";
qDebug() << " " << error.errorString();
continue;
}
......
......@@ -30,20 +30,20 @@ class Config;
class Console : public QObject
{
Q_OBJECT
public:
explicit Console(const KScreen::ConfigPtr &config);
~Console() override;
public:
explicit Console(const KScreen::ConfigPtr &config);
~Console() override;
public Q_SLOTS:
void printConfig();
void printJSONConfig();
QString typetoString(const KScreen::Output::Type &type) const;
void printSerializations();
void monitor();
void monitorAndPrint();
public Q_SLOTS:
void printConfig();
void printJSONConfig();
QString typetoString(const KScreen::Output::Type &type) const;
void printSerializations();
void monitor();
void monitorAndPrint();
private:
KScreen::ConfigPtr m_config;
private:
KScreen::ConfigPtr m_config;
};
#endif
......@@ -18,15 +18,15 @@
#include <unistd.h>
#include <QProcess>
#include <QCommandLineParser>
#include <QGuiApplication>
#include <QDateTime>
#include <KAboutData>
#include <KLocalizedString>
#include <QCommandLineParser>
#include <QDateTime>
#include <QGuiApplication>
#include <QProcess>
#include <kscreen/getconfigoperation.h>
#include <kscreen/config.h>
#include <kscreen/getconfigoperation.h>
#include "console.h"
......@@ -34,8 +34,7 @@ using namespace std;
void configReceived(KScreen::ConfigOperation *op)
{
const KScreen::ConfigPtr config = qobject_cast<KScreen::GetConfigOperation*>(op)->config();
const KScreen::ConfigPtr config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
const QString command = op->property("command").toString();
const qint64 msecs = QDateTime::currentMSecsSinceEpoch() - op->property("start").toLongLong();
......@@ -48,10 +47,10 @@ void configReceived(KScreen::ConfigOperation *op)
console->monitorAndPrint();
} else if (command == QLatin1String("monitor")) {
QTextStream(stdout) << "Remember to enable KSRandR or KSRandR11 in kdebugdialog" << endl;
//Print config so that we have some pivot data
// Print config so that we have some pivot data
console->printConfig();
console->monitor();
//Do nothing, enable backend output to see debug
// Do nothing, enable backend output to see debug
} else if (command == QLatin1String("outputs")) {
console->printConfig();
qApp->quit();
......@@ -74,23 +73,24 @@ void configReceived(KScreen::ConfigOperation *op)
console->printJSONConfig();
qApp->quit();
} else {
qApp->quit();
}
}
int main (int argc, char *argv[])
int main(int argc, char *argv[])
{
dup2(1, 2);
QGuiApplication app(argc, argv);
KAboutData aboutData(QStringLiteral("kscreen-console"), i18n("KScreen Console"), QStringLiteral("1.0"), i18n("KScreen Console"),
KAboutLicense::GPL, i18n("(c) 2012 KScreen Team"));
KAboutData aboutData(QStringLiteral("kscreen-console"),
i18n("KScreen Console"),
QStringLiteral("1.0"),
i18n("KScreen Console"),
KAboutLicense::GPL,
i18n("(c) 2012 KScreen Team"));
KAboutData::setApplicationData(aboutData);
aboutData.addAuthor(i18n("Alejandro Fiestas Olivares"), i18n("Maintainer"), QStringLiteral("afiestas@kde.org"),
QStringLiteral("http://www.afiestas.org/"));
aboutData.addAuthor(i18n("Alejandro Fiestas Olivares"), i18n("Maintainer"), QStringLiteral("afiestas@kde.org"), QStringLiteral("http://www.afiestas.org/"));
QCommandLineParser parser;
parser.setApplicationDescription(
......@@ -102,8 +102,7 @@ int main (int argc, char *argv[])
" monitor Monitor for changes\n"
" json Show current KScreen config"));
parser.addHelpOption();
parser.addPositionalArgument(QStringLiteral("command"), i18n("Command to execute"),
QStringLiteral("bug|config|outputs|monitor|json"));
parser.addPositionalArgument(QStringLiteral("command"), i18n("Command to execute"), QStringLiteral("bug|config|outputs|monitor|json"));
parser.addPositionalArgument(QStringLiteral("[args...]"), i18n("Arguments for the specified command"));
parser.process(app);
......@@ -118,10 +117,9 @@ int main (int argc, char *argv[])
KScreen::GetConfigOperation *op = new KScreen::GetConfigOperation();
op->setProperty("command", command);
op->setProperty("start", QDateTime::currentMSecsSinceEpoch());
QObject::connect(op, &KScreen::GetConfigOperation::finished,
[&](KScreen::ConfigOperation *op) {
configReceived(op);
});
QObject::connect(op, &KScreen::GetConfigOperation::finished, [&](KScreen::ConfigOperation *op) {
configReceived(op);
});
app.exec();
}
......@@ -42,10 +42,8 @@ void ConfigHandler::setConfig(KScreen::ConfigPtr config)
m_control.reset(new ControlConfig(config));
m_outputs = new OutputModel(this);
connect(m_outputs, &OutputModel::positionChanged,
this, &ConfigHandler::checkScreenNormalization);
connect(m_outputs, &OutputModel::sizeChanged,
this, &ConfigHandler::checkScreenNormalization);