use properly default custom background values

pull/19/head
Michail Vourlakos 5 years ago
parent 1ee03fe92d
commit 0286966cab

@ -222,6 +222,16 @@ void AbstractLayout::clearLastUsedActivity()
emit lastUsedActivityChanged();
}
QString AbstractLayout::defaultCustomTextColor()
{
return "#3C1C00";
}
QString AbstractLayout::defaultCustomBackground()
{
return "defaultcustom";
}
QString AbstractLayout::defaultTextColor(const QString &color)
{
//! the user is in default layout theme

@ -89,7 +89,7 @@ public:
QString name() const;
QString file() const;
QString background() const;
virtual QString background() const;
QString color() const;
void setColor(QString color);
@ -102,7 +102,7 @@ public:
QString predefinedTextColor() const;
QString textColor() const;
virtual QString textColor() const;
void setTextColor(QString color);
BackgroundStyle backgroundStyle() const;
@ -114,6 +114,8 @@ public:
virtual Type type() const;
// STATIC
static QString defaultCustomTextColor();
static QString defaultCustomBackground();
static QString defaultTextColor(const QString &color);
static QString layoutName(const QString &fileName);
static QList<Plasma::Types::Location> combinedFreeEdges(const QList<Plasma::Types::Location> &edges1,

@ -192,6 +192,31 @@ bool GenericLayout::isInternalContainment(Plasma::Applet *applet) const
return false;
}
QString GenericLayout::background() const
{
QString colorsPath = m_corona->kPackage().path() + "../../shells/org.kde.latte.shell/contents/images/canvas/";
if (backgroundStyle() == Layout::PatternBackgroundStyle) {
if (customBackground().isEmpty()) {
return colorsPath + "defaultcustomprint.jpg";
} else {
return AbstractLayout::customBackground();
}
}
return colorsPath + AbstractLayout::color() + "print.jpg";
}
QString GenericLayout::textColor() const
{
if (backgroundStyle() == Layout::PatternBackgroundStyle && customBackground().isEmpty()) {
return AbstractLayout::defaultCustomTextColor();
}
return AbstractLayout::textColor();
}
Plasma::Containment *GenericLayout::internalContainmentOf(Plasma::Applet *applet) const
{
if (!applet) {

@ -77,6 +77,9 @@ public:
GenericLayout(QObject *parent, QString layoutFile, QString assignedName = QString());
~GenericLayout() override;
QString background() const override;
QString textColor() const override;
virtual const QStringList appliedActivities() = 0; // to move at an interface
void importToCorona();

@ -131,7 +131,7 @@ void Layouts::initView()
m_view->sortByColumn(m_viewSortColumn, m_viewSortOrder);
//!find the available colors
m_iconsPath = m_handler->corona()->kPackage().path() + "../../plasmoids/org.kde.latte.containment/contents/icons/";
m_iconsPath = m_handler->corona()->kPackage().path() + "../../shells/org.kde.latte.shell/contents/images/canvas/";
m_model->setIconsPath(m_iconsPath);
QDir layoutDir(m_iconsPath);

@ -152,8 +152,8 @@ void DetailsHandler::loadLayout(const Data::Layout &data)
m_ui->colorsCmb->setCurrentIndex(m_colorsModel->row(data.color));
if (data.background.isEmpty()) {
m_ui->backPatternWidget->setBackground(m_colorsModel->colorPath("defaultcustom"));
m_ui->backPatternWidget->setTextColor("#3C1C00");
m_ui->backPatternWidget->setBackground(m_colorsModel->colorPath(Layout::AbstractLayout::defaultCustomBackground()));
m_ui->backPatternWidget->setTextColor(Layout::AbstractLayout::defaultCustomTextColor());
} else {
m_ui->backPatternWidget->setBackground(data.background);
m_ui->backPatternWidget->setTextColor(data.textColor);

@ -408,7 +408,13 @@ QList<Data::LayoutIcon> Layouts::icons(const int &row) const
//! background image
if (icons.count() == 0) {
QString colorPath = m_layoutsTable[row].background.startsWith("/") ? m_layoutsTable[row].background : m_iconsPath + m_layoutsTable[row].color + "print.jpg";
QString colorPath;
if (m_layoutsTable[row].backgroundStyle == Layout::PatternBackgroundStyle && m_layoutsTable[row].background.isEmpty()) {
colorPath = m_iconsPath + "defaultcustomprint.jpg";
} else {
colorPath = m_layoutsTable[row].background.startsWith("/") ? m_layoutsTable[row].background : m_iconsPath + m_layoutsTable[row].color + "print.jpg";
}
if (QFileInfo(colorPath).exists()) {
Data::LayoutIcon icon;

@ -84,16 +84,7 @@ Item{
anchors.fill: parent
opacity: root.maxOpacity
fillMode: Image.Tile
source: {
if (hasBackground) {
return latteView.layout.background;
}
return latteView.layout ? "../images/canvas/"+latteView.layout.background+"print.jpg" : "../images/canvas/blueprint.jpg"
}
readonly property bool hasBackground: (latteView.layout && latteView.layout.background.startsWith("/")) ? true : false
source: latteView.layout ? latteView.layout.background : "../images/canvas/blueprint.jpg"
Behavior on opacity {
NumberAnimation {

Loading…
Cancel
Save