fix opacity issue with devices
This commit is contained in:
parent
984c68ef45
commit
02d6315287
|
@ -2,9 +2,13 @@
|
|||
#include "DaytimeSkin.h"
|
||||
#include "RoundedIcon.h"
|
||||
|
||||
#include <QskGraphic.h>
|
||||
#include <QskGraphicLabel.h>
|
||||
#include <QskGridBox.h>
|
||||
#include <QskTextLabel.h>
|
||||
|
||||
#include <QImage>
|
||||
|
||||
namespace {
|
||||
class Device : public QskLinearBox
|
||||
{
|
||||
|
@ -13,16 +17,38 @@ namespace {
|
|||
: QskLinearBox(Qt::Vertical, parent)
|
||||
, m_name(name)
|
||||
{
|
||||
auto fileName = name.toLower();
|
||||
fileName.replace(' ', '-');
|
||||
auto* icon = new RoundedIcon(fileName, gradient, this);
|
||||
icon->setOpacity(0.15);
|
||||
setAutoAddChildren(false);
|
||||
|
||||
m_icon = new RoundedIcon(QString(), gradient, this);
|
||||
m_icon->setOpacity(0.15);
|
||||
addItem(m_icon);
|
||||
|
||||
auto* textLabel = new QskTextLabel(name, this);
|
||||
textLabel->setAlignment(Qt::AlignHCenter);
|
||||
addItem(textLabel);
|
||||
|
||||
auto fileName = name.toLower();
|
||||
fileName.replace(' ', '-');
|
||||
fileName = ":/images/" + fileName + ".png";
|
||||
QImage image( fileName );
|
||||
auto graphic = QskGraphic::fromImage( image );
|
||||
m_graphicLabel = new QskGraphicLabel( graphic, this );
|
||||
}
|
||||
|
||||
protected:
|
||||
void updateLayout() override
|
||||
{
|
||||
QskLinearBox::updateLayout();
|
||||
|
||||
m_graphicLabel->setSize( {36, 36});
|
||||
m_graphicLabel->setPosition( { ( m_icon->width() - m_graphicLabel->width() ) / 2,
|
||||
( m_icon->height() - m_graphicLabel->height() ) / 2 } );
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
RoundedIcon* m_icon;
|
||||
QskGraphicLabel* m_graphicLabel;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,20 @@ RoundedIcon::RoundedIcon(const QString& iconName, const QskGradient& gradient, Q
|
|||
setBoxShapeHint(Panel, 6 );
|
||||
|
||||
QString fileName = ":/images/" + iconName + ".png";
|
||||
QImage image( fileName );
|
||||
auto graphic = QskGraphic::fromImage( image );
|
||||
m_graphicLabel = new QskGraphicLabel( graphic, this );
|
||||
|
||||
if(QFile::exists(fileName))
|
||||
{
|
||||
QImage image( fileName );
|
||||
auto graphic = QskGraphic::fromImage( image );
|
||||
m_graphicLabel = new QskGraphicLabel( graphic, this );
|
||||
}
|
||||
}
|
||||
|
||||
void RoundedIcon::updateLayout()
|
||||
{
|
||||
m_graphicLabel->setSize( {36, 36});
|
||||
m_graphicLabel->setPosition( { ( width() - m_graphicLabel->width() ) / 2, ( height() - m_graphicLabel->height() ) / 2 } );
|
||||
if(m_graphicLabel)
|
||||
{
|
||||
m_graphicLabel->setSize( {36, 36});
|
||||
m_graphicLabel->setPosition( { ( width() - m_graphicLabel->width() ) / 2, ( height() - m_graphicLabel->height() ) / 2 } );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ protected:
|
|||
private:
|
||||
QString m_iconName;
|
||||
QskGradient m_gradient;
|
||||
QskGraphicLabel* m_graphicLabel;
|
||||
QskGraphicLabel* m_graphicLabel = nullptr;
|
||||
};
|
||||
|
||||
#endif // ROUNDEDICON_H
|
||||
|
|
Loading…
Reference in New Issue