Changeset View
Changeset View
Standalone View
Standalone View
kcms/ksplash/kcm.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 49 | KAboutData* about = new KAboutData(QStringLiteral("kcm_splashscreen"), i18n("Splash Screen"), | |||
---|---|---|---|---|---|
50 | QStringLiteral("0.1"), QString(), KAboutLicense::LGPL); | 50 | QStringLiteral("0.1"), QString(), KAboutLicense::LGPL); | ||
51 | about->addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org")); | 51 | about->addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org")); | ||
52 | setAboutData(about); | 52 | setAboutData(about); | ||
53 | setButtons(Help | Apply | Default); | 53 | setButtons(Help | Apply | Default); | ||
54 | 54 | | |||
55 | m_model = new QStandardItemModel(this); | 55 | m_model = new QStandardItemModel(this); | ||
56 | QHash<int, QByteArray> roles = m_model->roleNames(); | 56 | QHash<int, QByteArray> roles = m_model->roleNames(); | ||
57 | roles[PluginNameRole] = "pluginName"; | 57 | roles[PluginNameRole] = "pluginName"; | ||
58 | roles[ScreenhotRole] = "screenshot"; | 58 | roles[ScreenshotRole] = "screenshot"; | ||
59 | roles[DescriptionRole] = "description"; | 59 | roles[DescriptionRole] = "description"; | ||
60 | m_model->setItemRoleNames(roles); | 60 | m_model->setItemRoleNames(roles); | ||
61 | loadModel(); | 61 | loadModel(); | ||
62 | } | 62 | } | ||
63 | 63 | | |||
64 | QList<Plasma::Package> KCMSplashScreen::availablePackages(const QString &component) | 64 | QList<Plasma::Package> KCMSplashScreen::availablePackages(const QString &component) | ||
65 | { | 65 | { | ||
66 | QList<Plasma::Package> packages; | 66 | QList<Plasma::Package> packages; | ||
Show All 12 Lines | 75 | for (const QString &path : paths) { | |||
79 | if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { | 79 | if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { | ||
80 | packages << pkg; | 80 | packages << pkg; | ||
81 | } | 81 | } | ||
82 | } | 82 | } | ||
83 | 83 | | |||
84 | return packages; | 84 | return packages; | ||
85 | } | 85 | } | ||
86 | 86 | | |||
87 | QStandardItemModel *KCMSplashScreen::splashModel() | 87 | QStandardItemModel *KCMSplashScreen::splashModel() const | ||
88 | { | 88 | { | ||
89 | return m_model; | 89 | return m_model; | ||
90 | } | 90 | } | ||
91 | 91 | | |||
92 | QString KCMSplashScreen::selectedPlugin() const | 92 | QString KCMSplashScreen::selectedPlugin() const | ||
93 | { | 93 | { | ||
94 | return m_selectedPlugin; | 94 | return m_selectedPlugin; | ||
95 | } | 95 | } | ||
Show All 26 Lines | |||||
122 | void KCMSplashScreen::loadModel() | 122 | void KCMSplashScreen::loadModel() | ||
123 | { | 123 | { | ||
124 | m_model->clear(); | 124 | m_model->clear(); | ||
125 | 125 | | |||
126 | const QList<Plasma::Package> pkgs = availablePackages(QStringLiteral("splashmainscript")); | 126 | const QList<Plasma::Package> pkgs = availablePackages(QStringLiteral("splashmainscript")); | ||
127 | for (const Plasma::Package &pkg : pkgs) { | 127 | for (const Plasma::Package &pkg : pkgs) { | ||
128 | QStandardItem* row = new QStandardItem(pkg.metadata().name()); | 128 | QStandardItem* row = new QStandardItem(pkg.metadata().name()); | ||
129 | row->setData(pkg.metadata().pluginName(), PluginNameRole); | 129 | row->setData(pkg.metadata().pluginName(), PluginNameRole); | ||
130 | row->setData(pkg.filePath("previews", QStringLiteral("splash.png")), ScreenhotRole); | 130 | row->setData(pkg.filePath("previews", QStringLiteral("splash.png")), ScreenshotRole); | ||
131 | row->setData(pkg.metadata().comment(), DescriptionRole); | 131 | row->setData(pkg.metadata().comment(), DescriptionRole); | ||
132 | m_model->appendRow(row); | 132 | m_model->appendRow(row); | ||
133 | } | 133 | } | ||
134 | m_model->sort(0 /*column*/); | 134 | m_model->sort(0 /*column*/); | ||
135 | 135 | | |||
136 | QStandardItem* row = new QStandardItem(i18n("None")); | 136 | QStandardItem* row = new QStandardItem(i18n("None")); | ||
137 | row->setData("None", PluginNameRole); | 137 | row->setData("None", PluginNameRole); | ||
138 | row->setData(i18n("No splash screen will be shown"), DescriptionRole); | 138 | row->setData(i18n("No splash screen will be shown"), DescriptionRole); | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
202 | void KCMSplashScreen::test(const QString &plugin) | 202 | void KCMSplashScreen::test(const QString &plugin) | ||
203 | { | 203 | { | ||
204 | if (plugin.isEmpty() || plugin == QLatin1String("None") || m_testProcess) { | 204 | if (plugin.isEmpty() || plugin == QLatin1String("None") || m_testProcess) { | ||
205 | return; | 205 | return; | ||
206 | } | 206 | } | ||
207 | 207 | | |||
208 | m_testProcess = new QProcess(this); | 208 | m_testProcess = new QProcess(this); | ||
209 | connect(m_testProcess, &QProcess::errorOccurred, this, [this](QProcess::ProcessError error) { | 209 | connect(m_testProcess, &QProcess::errorOccurred, this, [this](QProcess::ProcessError error) { | ||
210 | Q_UNUSED(error); | 210 | Q_UNUSED(error) | ||
211 | emit testingFailed(); | 211 | emit testingFailed(); | ||
212 | }); | 212 | }); | ||
213 | connect(m_testProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, | 213 | connect(m_testProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, | ||
214 | [this](int exitCode, QProcess::ExitStatus exitStatus) { | 214 | [this](int exitCode, QProcess::ExitStatus exitStatus) { | ||
215 | Q_UNUSED(exitCode); | 215 | Q_UNUSED(exitCode) | ||
216 | Q_UNUSED(exitStatus); | 216 | Q_UNUSED(exitStatus) | ||
217 | 217 | | |||
218 | m_testProcess->deleteLater(); | 218 | m_testProcess->deleteLater(); | ||
219 | m_testProcess = nullptr; | 219 | m_testProcess = nullptr; | ||
220 | emit testingChanged(); | 220 | emit testingChanged(); | ||
221 | }); | 221 | }); | ||
222 | 222 | | |||
223 | emit testingChanged(); | 223 | emit testingChanged(); | ||
224 | m_testProcess->start(QStringLiteral("ksplashqml"), {plugin, QStringLiteral("--test")}); | 224 | m_testProcess->start(QStringLiteral("ksplashqml"), {plugin, QStringLiteral("--test")}); | ||
225 | } | 225 | } | ||
226 | 226 | | |||
227 | #include "kcm.moc" | 227 | #include "kcm.moc" |