Merge branch 'master' of git://anongit.kde.org/plasma-framework

This commit is contained in:
Anthony Fieroni 2016-03-04 21:06:56 +02:00
commit 7c06cd064a
9 changed files with 89 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -127,6 +127,33 @@ void IconItemTest::changeTheme(Plasma::Theme *theme, const QString &themeName)
}
// ------ Tests
void IconItemTest::loadPixmap()
{
QScopedPointer<QQuickItem> item(createIconItem());
QPixmap sourcePixmap(QFINDTESTDATA("data/test_image.png"));
item->setProperty("source", sourcePixmap);
QVERIFY(item->property("valid").toBool());
QImage capture = grabImage(item.data());
QCOMPARE(capture, sourcePixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
//tests setting icon from a QImage
void IconItemTest::loadImage()
{
QScopedPointer<QQuickItem> item(createIconItem());
QImage sourceImage(QFINDTESTDATA("data/test_image.png"));
item->setProperty("source", sourceImage);
QVERIFY(item->property("valid").toBool());
QImage capture = grabImage(item.data());
QCOMPARE(capture, sourceImage.convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
void IconItemTest::invalidIcon()
{
QString name("tst-plasma-framework-invalid-icon-name");

View File

@ -37,6 +37,9 @@ private Q_SLOTS:
void initTestCase();
void cleanup();
void loadPixmap();
void loadImage();
void invalidIcon();
void usesPlasmaTheme();
void animation();

View File

@ -107,7 +107,6 @@ void IconItem::setSource(const QVariant &source)
if (url.isLocalFile()) {
m_icon = QIcon();
m_imageIcon = QImage(url.path());
m_pixmapIcon = QPixmap();
delete m_svgIcon;
m_svgIcon = 0;
} else {
@ -155,7 +154,6 @@ void IconItem::setSource(const QVariant &source)
delete m_svgIcon;
m_svgIcon = 0;
m_imageIcon = QImage();
m_pixmapIcon = QPixmap();
}
}
}
@ -163,28 +161,17 @@ void IconItem::setSource(const QVariant &source)
} else if (source.canConvert<QIcon>()) {
m_icon = source.value<QIcon>();
m_imageIcon = QImage();
m_pixmapIcon = QPixmap();
delete m_svgIcon;
m_svgIcon = 0;
} else if (source.canConvert<QPixmap>()) {
m_icon = QIcon();
m_imageIcon = QImage();
m_pixmapIcon = source.value<QPixmap>();
delete m_svgIcon;
m_svgIcon = 0;
} else if (source.canConvert<QImage>()) {
m_icon = QIcon();
m_imageIcon = source.value<QImage>();
m_pixmapIcon = QPixmap();
delete m_svgIcon;
m_svgIcon = 0;
} else {
m_icon = QIcon();
m_imageIcon = QImage();
m_pixmapIcon = QPixmap();
delete m_svgIcon;
m_svgIcon = 0;
}
@ -295,7 +282,7 @@ void IconItem::setUsesPlasmaTheme(bool usesPlasmaTheme)
bool IconItem::isValid() const
{
return !m_icon.isNull() || m_svgIcon || !m_pixmapIcon.isNull() || !m_imageIcon.isNull();
return !m_icon.isNull() || m_svgIcon || !m_imageIcon.isNull();
}
int IconItem::paintedWidth() const
@ -427,8 +414,6 @@ void IconItem::loadPixmap()
}
} else if (!m_icon.isNull()) {
result = m_icon.pixmap(QSize(size, size) * (window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
} else if (!m_pixmapIcon.isNull()) {
result = m_pixmapIcon;
} else if (!m_imageIcon.isNull()) {
result = QPixmap::fromImage(m_imageIcon);
} else {

View File

@ -39,14 +39,63 @@ class IconItem : public QQuickItem
{
Q_OBJECT
/**
* Sets the icon to be displayed. Source can be one of:
* - iconName (as a string)
* - URL
* - QImage
* - QPixmap
* - QIcon
*
* When passing an icon name (or a QIcon with an icon name set) it will:
* - load the plasma variant if usesPlasmaTheme is set and exists
* - otherwise try to load the icon as an SVG so colorscopes apply
* - load the icon as normal
*/
Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged)
/**
* Specifies the color group to use for this icon
* This only applies to icons loaded from the plasma theme
*/
Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged)
/**
* See QQuickItem::smooth
*/
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
/**
* Apply a visual indication that this icon is active.
* Typically used to indicate that it is hovered
*/
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
/**
* If set, icon will blend when the source is changed or resized
*/
Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated NOTIFY animatedChanged)
/**
* If set, icon will try and use icons from the Plasma theme if possible
*/
Q_PROPERTY(bool usesPlasmaTheme READ usesPlasmaTheme WRITE setUsesPlasmaTheme NOTIFY usesPlasmaThemeChanged)
/**
* True if a valid icon is set. False otherwise.
*/
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
/**
* The width of the icon that is actually painted
* Icons are drawn at standard icon sizes (eg. 16,32,64) centered within the item
*/
Q_PROPERTY(int paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
/**
* The height of the icon actually being drawn.
* Icons are drawn at standard icon sizes (eg. 16,32,64) centered within the item
*/
Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
public:

View File

@ -2,6 +2,8 @@
Name=Breeze Light
Name[ca]=Brisa clara
Name[ca@valencia]=Brisa clara
Name[cs]=Breeze Světlé
Name[da]=Breeze Light
Name[de]=Breeze Light
Name[en_GB]=Breeze Light
Name[es]=Brisa claro

View File

@ -62,6 +62,7 @@ public:
: q(dialog),
location(Plasma::Types::BottomEdge),
frameSvgItem(0),
hasMask(false),
type(Dialog::Normal),
hideOnWindowDeactivate(false),
outputOnly(false),
@ -131,6 +132,7 @@ public:
QTimer hintsCommitTimer;
QRect cachedGeometry;
bool hasMask;
Dialog::WindowType type;
bool hideOnWindowDeactivate;
bool outputOnly;
@ -229,8 +231,12 @@ void DialogPrivate::updateTheme()
frameSvgItem->frameSvg()->mask());
if (KWindowSystem::compositingActive()) {
if (hasMask) {
hasMask = false;
q->setMask(QRegion());
}
} else {
hasMask = true;
q->setMask(frameSvgItem->frameSvg()->mask());
}
if (q->isVisible()) {