Commit ec0e1847 authored by Méven Car's avatar Méven Car
Browse files

[KCM/Datetime] Convert a foreach, port away from KStandardDirs

Reviewers: ervin, #plasma

Reviewed By: ervin

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26295
parent 83b42833
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QDebug> #include <QDebug>
#include <kprocess.h> #include <kprocess.h>
#include <kstandarddirs.h>
#include <kmessagebox.h> #include <kmessagebox.h>
#include <kdialog.h> #include <kdialog.h>
#include <kconfig.h> #include <kconfig.h>
...@@ -154,15 +153,17 @@ void Dtime::findNTPutility(){ ...@@ -154,15 +153,17 @@ void Dtime::findNTPutility(){
envpath.remove(0, 1); envpath.remove(0, 1);
} }
QString path = QStringLiteral("/sbin:/usr/sbin:"); QStringList path = {"/sbin", "/usr/sbin"};
if (!envpath.isEmpty()) { if (!envpath.isEmpty()) {
path += QFile::decodeName(envpath); path += QFile::decodeName(envpath).split(QLatin1Char(':'));
} else { } else {
path += QLatin1String("/bin:/usr/bin"); path += {"/bin", "/usr/bin"};
} }
foreach(const QString &possible_ntputility, QStringList() << "ntpdate" << "rdate" ) { const auto possible_ntputilities = {"ntpdate", "rdate"};
if( !((ntpUtility = KStandardDirs::findExe(possible_ntputility, path)).isEmpty()) ) { for (const QString &possible_ntputility : possible_ntputilities) {
auto ntpUtility = QStandardPaths::findExecutable(possible_ntputility, path);
if (!ntpUtility.isEmpty()) {
qDebug() << "ntpUtility = " << ntpUtility; qDebug() << "ntpUtility = " << ntpUtility;
return; return;
} }
......
...@@ -227,7 +227,7 @@ int ClockHelper::tzreset() ...@@ -227,7 +227,7 @@ int ClockHelper::tzreset()
void ClockHelper::toHwclock() void ClockHelper::toHwclock()
{ {
QString hwclock = KStandardDirs::findExe(QStringLiteral("hwclock"), exePath); QString hwclock = QStandardPaths::findExecutable(QStringLiteral("hwclock"), exePath.split(QLatin1Char(':')));
if (!hwclock.isEmpty()) { if (!hwclock.isEmpty()) {
KProcess::execute(hwclock, QStringList() << QStringLiteral("--systohc")); KProcess::execute(hwclock, QStringList() << QStringLiteral("--systohc"));
} }
......
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