Improve wallpaper rendering

Update the targetSize when it changes to ensure we update the image when
resolution changes. Also, since the view has an initial size of 1024x768, it would
just load that image and never use the full resolution leaving you with an ugly
blurry image. Additionally, don't bother looking up the image until everything has
settled, potentially improving startup performance slightly by saving a bit of IO.

REVIEW: 124311
wilder-5.14
Kai Uwe Broulik 11 years ago
parent 56d2c15b9a
commit 29e39fe58a
  1. 31
      wallpapers/image/image.cpp
  2. 10
      wallpapers/image/image.h

@ -4,6 +4,7 @@
* Copyright 2008 Petri Damsten <damu@iki.fi> *
* Copyright 2008 Alexis Ménard <darktears31@gmail.com> *
* Copyright 2014 Sebastian Kügler <sebas@kde.org> *
* Copyright 2015 Kai Uwe Broulik <kde@privat.broulik.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -54,6 +55,7 @@
Image::Image(QObject *parent)
: QObject(parent),
m_ready(false),
m_delay(10),
m_dirWatch(new KDirWatch(this)),
m_mode(SingleImage),
@ -83,6 +85,22 @@ Image::~Image()
delete m_dialog;
}
void Image::classBegin()
{
}
void Image::componentComplete()
{
// don't bother loading single image until all properties have settled
// otherwise we would load a too small image (initial view size) just
// to load the proper one afterwards etc etc
m_ready = true;
if (m_mode == SingleImage) {
setSingleImage();
}
}
QString Image::wallpaperPath() const
{
return m_wallpaperPath;
@ -196,6 +214,10 @@ QSize Image::targetSize() const
void Image::setTargetSize(const QSize &size)
{
m_targetSize = size;
if (m_mode == SingleImage) {
setSingleImage();
}
}
int Image::height() const
@ -393,6 +415,15 @@ void Image::syncWallpaperPackage()
void Image::setSingleImage()
{
if (!m_ready) {
return;
}
// supposedly QSize::isEmpty() is true if "either width or height are >= 0"
if (!m_targetSize.width() || !m_targetSize.height()) {
return;
}
const QString oldPath = m_wallpaperPath;
if (m_wallpaper.isEmpty()) {
useSingleImageDefaults();

@ -2,6 +2,7 @@
* Copyright 2007 Paolo Capriotti <p.capriotti@gmail.com> *
* Copyright 2008 by Petri Damsten <damu@iki.fi> *
* Copyright 2014 Sebastian Kügler <sebas@kde.org> *
* Copyright 2015 Kai Uwe Broulik <kde@privat.broulik.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -29,6 +30,7 @@
#include <QObject>
#include <QPersistentModelIndex>
#include <QDateTime>
#include <QQmlParserStatus>
#include <KPackage/Package>
@ -45,9 +47,11 @@ namespace KNS3 {
class BackgroundListModel;
class Image : public QObject
class Image : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(RenderingMode renderingMode READ renderingMode WRITE setRenderingMode NOTIFY renderingModeChanged)
Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY wallpaperPathChanged)
Q_PROPERTY(QAbstractItemModel *wallpaperModel READ wallpaperModel CONSTANT)
@ -109,6 +113,9 @@ class Image : public QObject
void findPreferedImageInPackage(KPackage::Package &package);
void classBegin() override;
void componentComplete() override;
public Q_SLOTS:
void nextSlide();
void removeWallpaper(QString name);
@ -153,6 +160,7 @@ class Image : public QObject
private:
bool m_ready;
int m_delay;
QStringList m_dirs;
QString m_wallpaper;

Loading…
Cancel
Save