Changeset View
Changeset View
Standalone View
Standalone View
kcms/ksplash/kcm.cpp
Show All 23 Lines | |||||
24 | #include <KAboutData> | 24 | #include <KAboutData> | ||
25 | #include <KSharedConfig> | 25 | #include <KSharedConfig> | ||
26 | #include <QStandardPaths> | 26 | #include <QStandardPaths> | ||
27 | #include <QProcess> | 27 | #include <QProcess> | ||
28 | #include <QQuickView> | 28 | #include <QQuickView> | ||
29 | 29 | | |||
30 | #include <QVBoxLayout> | 30 | #include <QVBoxLayout> | ||
31 | #include <QPushButton> | 31 | #include <QPushButton> | ||
32 | #include <QMessageBox> | | |||
33 | #include <QStandardItemModel> | 32 | #include <QStandardItemModel> | ||
34 | #include <QQmlContext> | 33 | #include <QQmlContext> | ||
35 | #include <QDir> | 34 | #include <QDir> | ||
36 | 35 | | |||
37 | #include <KLocalizedString> | 36 | #include <KLocalizedString> | ||
38 | #include <Plasma/PluginLoader> | 37 | #include <Plasma/PluginLoader> | ||
39 | 38 | | |||
40 | #include <KNewStuff3/KNS3/DownloadDialog> | 39 | #include <KNewStuff3/KNS3/DownloadDialog> | ||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Line(s) | 188 | { | |||
190 | for (int i = 0; i < m_model->rowCount(); ++i) { | 189 | for (int i = 0; i < m_model->rowCount(); ++i) { | ||
191 | if (m_model->data(m_model->index(i, 0), PluginNameRole).toString() == m_selectedPlugin) { | 190 | if (m_model->data(m_model->index(i, 0), PluginNameRole).toString() == m_selectedPlugin) { | ||
192 | return i; | 191 | return i; | ||
193 | } | 192 | } | ||
194 | } | 193 | } | ||
195 | return -1; | 194 | return -1; | ||
196 | } | 195 | } | ||
197 | 196 | | |||
197 | bool KCMSplashScreen::testing() const | ||||
198 | { | ||||
199 | return m_testProcess; | ||||
200 | } | ||||
201 | | ||||
198 | void KCMSplashScreen::test(const QString &plugin) | 202 | void KCMSplashScreen::test(const QString &plugin) | ||
199 | { | 203 | { | ||
200 | if (plugin.isEmpty() || plugin == QLatin1String("None")) { | 204 | if (plugin.isEmpty() || plugin == QLatin1String("None") || m_testProcess) { | ||
201 | return; | 205 | return; | ||
202 | } | 206 | } | ||
203 | 207 | | |||
204 | QProcess proc; | 208 | m_testProcess = new QProcess(this); | ||
205 | QStringList arguments; | 209 | connect(m_testProcess, &QProcess::errorOccurred, this, [this](QProcess::ProcessError error) { | ||
206 | arguments << plugin << QStringLiteral("--test"); | 210 | Q_UNUSED(error); | ||
207 | if (proc.execute(QStringLiteral("ksplashqml"), arguments)) { | 211 | emit testingFailed(); | ||
208 | QMessageBox::critical(nullptr, i18n("Error"), i18n("Failed to successfully test the splash screen.")); | 212 | }); | ||
209 | } | 213 | connect(m_testProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, | ||
214 | [this](int exitCode, QProcess::ExitStatus exitStatus) { | ||||
215 | Q_UNUSED(exitCode); | ||||
216 | Q_UNUSED(exitStatus); | ||||
217 | | ||||
218 | m_testProcess->deleteLater(); | ||||
219 | m_testProcess = nullptr; | ||||
220 | emit testingChanged(); | ||||
221 | }); | ||||
222 | | ||||
223 | emit testingChanged(); | ||||
224 | m_testProcess->start(QStringLiteral("ksplashqml"), {plugin, QStringLiteral("--test")}); | ||||
210 | } | 225 | } | ||
211 | 226 | | |||
212 | #include "kcm.moc" | 227 | #include "kcm.moc" |