Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/image/image.cpp
Show First 20 Lines • Show All 249 Lines • ▼ Show 20 Line(s) | |||||
250 | 250 | | |||
251 | KPackage::Package *Image::package() | 251 | KPackage::Package *Image::package() | ||
252 | { | 252 | { | ||
253 | return &m_wallpaperPackage; | 253 | return &m_wallpaperPackage; | ||
254 | } | 254 | } | ||
255 | 255 | | |||
256 | void Image::useSingleImageDefaults() | 256 | void Image::useSingleImageDefaults() | ||
257 | { | 257 | { | ||
258 | m_wallpaper = QString(); | ||||
259 | | ||||
260 | // Try from the look and feel package first, then from the plasma theme | ||||
261 | KPackage::Package lookAndFeelPackage = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | ||||
262 | KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); | ||||
263 | const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); | ||||
264 | // If empty, it will be the default (currently Breeze) | ||||
265 | if (!packageName.isEmpty()) { | ||||
266 | lookAndFeelPackage.setPath(packageName); | ||||
267 | } | ||||
268 | | ||||
269 | KConfigGroup lnfDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(lookAndFeelPackage.filePath("defaults")), "Wallpaper"); | ||||
270 | | ||||
271 | const QString image = lnfDefaultsConfig.readEntry("Image", ""); | ||||
272 | if (!image.isEmpty()) { | ||||
273 | KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Wallpaper/Images")); | ||||
274 | package.setPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("wallpapers/") + image, QStandardPaths::LocateDirectory)); | ||||
275 | | ||||
276 | if (package.isValid()) { | ||||
277 | m_wallpaper = package.path(); | ||||
278 | } else { | ||||
279 | m_wallpaper = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("wallpapers/") + image); | ||||
280 | } | ||||
281 | } | ||||
282 | | ||||
283 | // Try to get a default from the plasma theme | ||||
284 | if (m_wallpaper.isEmpty()) { | ||||
258 | Plasma::Theme theme; | 285 | Plasma::Theme theme; | ||
259 | m_wallpaper = theme.wallpaperPath(); | 286 | m_wallpaper = theme.wallpaperPath(); | ||
260 | int index = m_wallpaper.indexOf(QString::fromLatin1("/contents/images/")); | 287 | int index = m_wallpaper.indexOf(QString::fromLatin1("/contents/images/")); | ||
261 | if (index > -1) { // We have file from package -> get path to package | 288 | if (index > -1) { // We have file from package -> get path to package | ||
262 | m_wallpaper = m_wallpaper.left(index); | 289 | m_wallpaper = m_wallpaper.left(index); | ||
263 | } | 290 | } | ||
264 | } | 291 | } | ||
292 | } | ||||
265 | 293 | | |||
266 | QAbstractItemModel* Image::wallpaperModel() | 294 | QAbstractItemModel* Image::wallpaperModel() | ||
267 | { | 295 | { | ||
268 | if (!m_model) { | 296 | if (!m_model) { | ||
269 | KConfigGroup cfg = KConfigGroup(KSharedConfig::openConfig(QStringLiteral("plasmarc")), | 297 | KConfigGroup cfg = KConfigGroup(KSharedConfig::openConfig(QStringLiteral("plasmarc")), | ||
270 | QStringLiteral("Wallpapers")); | 298 | QStringLiteral("Wallpapers")); | ||
271 | m_usersWallpapers = cfg.readEntry("usersWallpapers", m_usersWallpapers); | 299 | m_usersWallpapers = cfg.readEntry("usersWallpapers", m_usersWallpapers); | ||
272 | 300 | | |||
▲ Show 20 Lines • Show All 657 Lines • Show Last 20 Lines |