Changeset View
Changeset View
Standalone View
Standalone View
kcms/dateandtime/dtime.cpp
Show All 37 Lines | |||||
38 | 38 | | |||
39 | #include <QCheckBox> | 39 | #include <QCheckBox> | ||
40 | #include <QPaintEvent> | 40 | #include <QPaintEvent> | ||
41 | #include <QGridLayout> | 41 | #include <QGridLayout> | ||
42 | #include <QHBoxLayout> | 42 | #include <QHBoxLayout> | ||
43 | #include <QVBoxLayout> | 43 | #include <QVBoxLayout> | ||
44 | #include <QDebug> | 44 | #include <QDebug> | ||
45 | #include <kprocess.h> | 45 | #include <kprocess.h> | ||
46 | #include <kstandarddirs.h> | | |||
47 | #include <kmessagebox.h> | 46 | #include <kmessagebox.h> | ||
48 | #include <kdialog.h> | 47 | #include <kdialog.h> | ||
49 | #include <kconfig.h> | 48 | #include <kconfig.h> | ||
50 | #include <kcolorscheme.h> | 49 | #include <kcolorscheme.h> | ||
51 | #include <ksystemtimezone.h> | 50 | #include <ksystemtimezone.h> | ||
52 | #include <KTreeWidgetSearchLine> | 51 | #include <KTreeWidgetSearchLine> | ||
53 | #include <KGlobal> | 52 | #include <KGlobal> | ||
54 | 53 | | |||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | |||||
149 | } | 148 | } | ||
150 | 149 | | |||
151 | void Dtime::findNTPutility(){ | 150 | void Dtime::findNTPutility(){ | ||
152 | QByteArray envpath = qgetenv("PATH"); | 151 | QByteArray envpath = qgetenv("PATH"); | ||
153 | if (!envpath.isEmpty() && envpath.startsWith(':')) { | 152 | if (!envpath.isEmpty() && envpath.startsWith(':')) { | ||
154 | envpath.remove(0, 1); | 153 | envpath.remove(0, 1); | ||
155 | } | 154 | } | ||
156 | 155 | | |||
157 | QString path = QStringLiteral("/sbin:/usr/sbin:"); | 156 | QStringList path = {"/sbin", "/usr/sbin"}; | ||
158 | if (!envpath.isEmpty()) { | 157 | if (!envpath.isEmpty()) { | ||
159 | path += QFile::decodeName(envpath); | 158 | path += QFile::decodeName(envpath).split(QLatin1Char(':')); | ||
160 | } else { | 159 | } else { | ||
161 | path += QLatin1String("/bin:/usr/bin"); | 160 | path += {"/bin", "/usr/bin"}; | ||
162 | } | 161 | } | ||
163 | 162 | | |||
164 | foreach(const QString &possible_ntputility, QStringList() << "ntpdate" << "rdate" ) { | 163 | const auto possible_ntputilities = {"ntpdate", "rdate"}; | ||
165 | if( !((ntpUtility = KStandardDirs::findExe(possible_ntputility, path)).isEmpty()) ) { | 164 | for (const QString &possible_ntputility : possible_ntputilities) { | ||
165 | auto ntpUtility = QStandardPaths::findExecutable(possible_ntputility, path); | ||||
ervin: nitpick again, feel free to fix or not before pushing: ntpUtility could be declared const | |||||
166 | if (!ntpUtility.isEmpty()) { | ||||
166 | qDebug() << "ntpUtility = " << ntpUtility; | 167 | qDebug() << "ntpUtility = " << ntpUtility; | ||
I'd use the opportunity to split that into two statements, I find the assign + test in if rather heavy to read. ervin: I'd use the opportunity to split that into two statements, I find the assign + test in if… | |||||
167 | return; | 168 | return; | ||
168 | } | 169 | } | ||
169 | } | 170 | } | ||
170 | 171 | | |||
171 | qDebug() << "ntpUtility not found!"; | 172 | qDebug() << "ntpUtility not found!"; | ||
172 | } | 173 | } | ||
173 | 174 | | |||
174 | void Dtime::set_time() | 175 | void Dtime::set_time() | ||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |
nitpick again, feel free to fix or not before pushing: ntpUtility could be declared const