Commit e4a44363 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

clang-tidy: Force braces around statements

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent 402cf1d2
......@@ -40,8 +40,9 @@ void DisplayNumber::setWidth(int digits)
QString s(QStringLiteral("0123456789.+-"));
int width = 0, charWidth = 0;
for (int i = 0; i < 11; i++, width = fm.boundingRect(s[i]).width())
for (int i = 0; i < 11; i++, width = fm.boundingRect(s[i]).width()) {
charWidth = (width > charWidth) ? width : charWidth;
}
dg = digits;
setMinimumWidth(dg * charWidth + charWidth / 2);
......
......@@ -105,15 +105,16 @@ KGamma::~KGamma()
if (GammaCorrection) {
// Do not emit signals during destruction (bug 221611)
bool blocked = blockSignals(true);
if (loadUserSettings())
if (loadUserSettings()) {
load();
else if (!saved)
} else if (!saved) {
for (int i = 0; i < ScreenCount; i++) {
xv->setScreen(i);
xv->setGamma(XVidExtWrap::Red, rbak[i]);
xv->setGamma(XVidExtWrap::Green, gbak[i]);
xv->setGamma(XVidExtWrap::Blue, bbak[i]);
}
}
delete rootProcess;
blockSignals(blocked);
}
......@@ -244,13 +245,15 @@ void KGamma::setupUI()
screenselect = new QComboBox(options);
optionsHBoxLayout->addWidget(screenselect);
for (int i = 0; i < ScreenCount; i++)
for (int i = 0; i < ScreenCount; i++) {
screenselect->addItem(i18n("Screen %1", i + 1));
}
screenselect->setCurrentIndex(currentScreen);
if (ScreenCount <= 1) {
screenselect->setEnabled(false);
} else
} else {
connect(screenselect, QOverload<int>::of(&QComboBox::activated), this, &KGamma::changeScreen);
}
optionsHBoxLayout->setSpacing(10);
optionsHBoxLayout->setStretchFactor(xf86cfgbox, 10);
......@@ -276,29 +279,32 @@ void KGamma::load()
KConfigGroup group = config->group("ConfigFile");
// save checkbox status
if (xf86cfgbox->isChecked())
if (xf86cfgbox->isChecked()) {
group.writeEntry("use", "XF86Config");
else
} else {
group.writeEntry("use", "kgammarc");
}
// load syncbox status
group = config->group("SyncBox");
if (group.readEntry("sync") == QLatin1String("yes"))
if (group.readEntry("sync") == QLatin1String("yes")) {
syncbox->setChecked(true);
else
} else {
syncbox->setChecked(false);
}
config->sync();
delete config;
for (int i = 0; i < ScreenCount; i++) {
xv->setScreen(i);
if (rgamma[i] == ggamma[i] && rgamma[i] == bgamma[i])
if (i == currentScreen)
if (rgamma[i] == ggamma[i] && rgamma[i] == bgamma[i]) {
if (i == currentScreen) {
gctrl->setGamma(rgamma[i]);
else
} else {
xv->setGamma(XVidExtWrap::Value, rgamma[i].toFloat());
else {
}
} else {
if (i == currentScreen) {
rgctrl->setGamma(rgamma[i]);
ggctrl->setGamma(ggamma[i]);
......@@ -330,10 +336,11 @@ void KGamma::save()
KConfig *config = new KConfig(QStringLiteral("kgammarc"));
KConfigGroup group = config->group("SyncBox");
if (syncbox->isChecked())
if (syncbox->isChecked()) {
group.writeEntry("sync", "yes");
else
} else {
group.writeEntry("sync", "no");
}
if (!xf86cfgbox->isChecked()) { // write gamma settings to the users config
for (int i = 0; i < ScreenCount; i++) {
......@@ -350,8 +357,9 @@ void KGamma::save()
if (!(rootProcess->state() == QProcess::Running)) {
QString Arguments = QStringLiteral("xf86gammacfg ");
for (int i = 0; i < ScreenCount; i++)
for (int i = 0; i < ScreenCount; i++) {
Arguments += rgamma[assign[i]] + QLatin1Char(' ') + ggamma[assign[i]] + QLatin1Char(' ') + bgamma[assign[i]] + QLatin1Char(' ');
}
rootProcess->setProgram(QStandardPaths::findExecutable(QStringLiteral("kdesu")));
rootProcess->setArguments(Arguments.split(QLatin1Char(' ')));
rootProcess->start();
......@@ -383,8 +391,9 @@ bool KGamma::loadSettings()
KConfigGroup grp = config->group("ConfigFile");
QString ConfigFile(grp.readEntry("use"));
KConfigGroup syncGroup = config->group("SyncBox");
if (syncGroup.readEntry("sync") == QLatin1String("yes"))
if (syncGroup.readEntry("sync") == QLatin1String("yes")) {
syncbox->setChecked(true);
}
delete config;
if (ConfigFile == QLatin1String("XF86Config")) { // parse XF86Config
......@@ -430,8 +439,9 @@ bool KGamma::loadSystemSettings()
QStringList words = s.split(QLatin1Char(' '));
if (!words.empty()) {
if (words[0] == QLatin1String("Section") && words.size() > 1) {
if ((Section = words[1]) == QLatin1String("\"Monitor\""))
if ((Section = words[1]) == QLatin1String("\"Monitor\"")) {
gm = false;
}
} else if (words[0] == QLatin1String("EndSection")) {
if (Section == QLatin1String("\"Monitor\"") && !gm) {
Gamma << QString();
......@@ -439,10 +449,11 @@ bool KGamma::loadSystemSettings()
}
Section = QString();
} else if (words[0] == QLatin1String("Identifier") && words.size() > 1) {
if (Section == QLatin1String("\"Monitor\""))
if (Section == QLatin1String("\"Monitor\"")) {
Monitor << words[1];
else if (Section == QLatin1String("\"Screen\""))
} else if (Section == QLatin1String("\"Screen\"")) {
Screen << words[1];
}
} else if (words[0] == QLatin1String("Screen") && words.size() > 1) {
if (Section == QLatin1String("\"ServerLayout\"")) {
bool ok;
......@@ -456,8 +467,9 @@ bool KGamma::loadSystemSettings()
}
}
} else if (words[0] == QLatin1String("Monitor") && words.size() > 1) {
if (Section == QLatin1String("\"Screen\""))
if (Section == QLatin1String("\"Screen\"")) {
ScreenMonitor << words[1];
}
} else if (words[0] == QLatin1String("Gamma")) {
if (Section == QLatin1String("\"Monitor\"")) {
Gamma << s;
......@@ -486,9 +498,9 @@ bool KGamma::loadSystemSettings()
QStringList words = Gamma[assign[i]].split(QLatin1Char(' '));
QStringList::ConstIterator it = words.constBegin();
if (words.size() < 4)
if (words.size() < 4) {
rgamma[i] = ggamma[i] = bgamma[i] = *(++it); // single gamma value
else {
} else {
rgamma[i] = *(++it); // eventually rgb gamma values
ggamma[i] = *(++it);
bgamma[i] = *(++it);
......@@ -511,10 +523,11 @@ bool KGamma::validateGammaValues()
bgamma[i].toFloat(&bOk);
if (!(rOk && gOk && bOk)) {
if (rOk)
if (rOk) {
ggamma[i] = bgamma[i] = rgamma[i];
else
} else {
result = false;
}
}
}
return (result);
......@@ -524,10 +537,11 @@ void KGamma::changeConfig()
{
bool Ok = false;
if (xf86cfgbox->isChecked())
if (xf86cfgbox->isChecked()) {
Ok = loadSystemSettings();
else
} else {
Ok = loadUserSettings();
}
if (!Ok) {
for (int i = 0; i < ScreenCount; i++) {
......@@ -575,8 +589,9 @@ void KGamma::changeScreen(int sn)
rgctrl->setControl(red);
ggctrl->setControl(green);
bgctrl->setControl(blue);
if (red != green || red != blue)
if (red != green || red != blue) {
gctrl->suspend();
}
}
int KGamma::buttons()
......@@ -615,12 +630,15 @@ Q_DECL_EXPORT void kcminit_kgamma()
xv.setScreen(i);
KConfigGroup screenGroup = config->group(QStringLiteral("Screen %1").arg(i));
if ((rgamma = screenGroup.readEntry("rgamma").toFloat()))
if ((rgamma = screenGroup.readEntry("rgamma").toFloat())) {
xv.setGamma(XVidExtWrap::Red, rgamma);
if ((ggamma = screenGroup.readEntry("ggamma").toFloat()))
}
if ((ggamma = screenGroup.readEntry("ggamma").toFloat())) {
xv.setGamma(XVidExtWrap::Green, ggamma);
if ((bgamma = screenGroup.readEntry("bgamma").toFloat()))
}
if ((bgamma = screenGroup.readEntry("bgamma").toFloat())) {
xv.setGamma(XVidExtWrap::Blue, bgamma);
}
}
delete config;
}
......
......@@ -33,9 +33,11 @@ XF86ConfigPath::XF86ConfigPath()
searchPaths.push_back("/usr/X11R6/lib/X11/xorg.conf");
vector<string>::iterator it = searchPaths.begin();
for (; it != searchPaths.end(); ++it)
if (!access((Path = *it).c_str(), F_OK))
for (; it != searchPaths.end(); ++it) {
if (!access((Path = *it).c_str(), F_OK)) {
break;
}
}
}
XF86ConfigPath::~XF86ConfigPath()
......
......@@ -47,8 +47,9 @@ XVidExtWrap::XVidExtWrap(bool *OK, const char *displayname)
XVidExtWrap::~XVidExtWrap()
{
if (dpy)
if (dpy) {
XCloseDisplay(dpy);
}
}
int XVidExtWrap::_DefaultScreen()
......@@ -73,24 +74,29 @@ int XVidExtWrap::_ScreenCount()
while (getline(in, s, '\n')) {
words.clear();
istringstream ss(s.c_str());
while (ss >> buf)
while (ss >> buf) {
words.push_back(buf); // Split "s" into words
}
if (!words.empty()) {
if (words[0] == "Section" && words.size() > 1) {
if (words[1] == "\"ServerLayout\"")
if (words[1] == "\"ServerLayout\"") {
section = true;
} else if (words[0] == "EndSection")
}
} else if (words[0] == "EndSection") {
section = false;
if (section && words[0] == "Screen")
}
if (section && words[0] == "Screen") {
++count;
}
}
} // end while
in.close();
}
if (!count)
if (!count) {
count = 1; // If failed,fill count with a valid value;
}
return (count);
}
......@@ -107,8 +113,9 @@ void XVidExtWrap::setGamma(int channel, float gam, bool *OK)
if (gam >= mingamma && gam <= maxgamma) {
if (!XF86VidModeGetGamma(dpy, screen, &gamma)) {
qDebug() << "KGamma: Unable to query gamma correction";
if (OK)
if (OK) {
*OK = false;
}
} else {
switch (channel) {
case Value:
......@@ -127,12 +134,14 @@ void XVidExtWrap::setGamma(int channel, float gam, bool *OK)
};
if (!XF86VidModeSetGamma(dpy, screen, &gamma)) {
qDebug() << "KGamma: Unable to set gamma correction";
if (OK)
if (OK) {
*OK = false;
}
} else {
XFlush(dpy);
if (OK)
if (OK) {
*OK = true;
}
}
}
}
......@@ -145,8 +154,9 @@ float XVidExtWrap::getGamma(int channel, bool *OK)
if (!XF86VidModeGetGamma(dpy, screen, &gamma)) {
qDebug() << "KGamma: Unable to query gamma correction";
if (OK)
if (OK) {
*OK = false;
}
} else {
switch (channel) {
case Value:
......@@ -161,8 +171,9 @@ float XVidExtWrap::getGamma(int channel, bool *OK)
case Blue:
gam = gamma.blue;
};
if (OK)
if (OK) {
*OK = true;
}
}
return (gam);
}
......
......@@ -69,8 +69,9 @@ int main(int argc, char *argv[])
if (!cpyonly) {
words.clear();
std::istringstream ss(s.c_str());
while (ss >> buf)
while (ss >> buf) {
words.push_back(buf);
}
if (!words.empty()) {
if (words[0] == "Section" && words.size() > 1) {
......@@ -108,17 +109,19 @@ int main(int argc, char *argv[])
if (success) {
rename((*it).c_str(), (*it + ".kgammaorig").c_str());
rename((*it + ".tmp").c_str(), (*it).c_str());
} else
} else {
remove((*it + ".tmp").c_str());
}
break;
}
}
}
}
if (!success)
if (!success) {
cerr << "Usage: xf86gammacfg RGAMMA GGAMMA "
"BGAMMA [RGAMMA GGAMMA BGAMMA [...]]"
<< endl;
}
return !success;
}
......
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