diff --git a/app/layout/abstractlayout.cpp b/app/layout/abstractlayout.cpp index 95ee5e87d..943d4f262 100644 --- a/app/layout/abstractlayout.cpp +++ b/app/layout/abstractlayout.cpp @@ -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 diff --git a/app/layout/abstractlayout.h b/app/layout/abstractlayout.h index 80f5b294a..e1a4a35b3 100644 --- a/app/layout/abstractlayout.h +++ b/app/layout/abstractlayout.h @@ -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 combinedFreeEdges(const QList &edges1, diff --git a/app/layout/genericlayout.cpp b/app/layout/genericlayout.cpp index 55840e6a3..8ed9e9d1e 100644 --- a/app/layout/genericlayout.cpp +++ b/app/layout/genericlayout.cpp @@ -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) { diff --git a/app/layout/genericlayout.h b/app/layout/genericlayout.h index 62e8ed290..efe5d3b13 100644 --- a/app/layout/genericlayout.h +++ b/app/layout/genericlayout.h @@ -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(); diff --git a/app/settings/controllers/layoutscontroller.cpp b/app/settings/controllers/layoutscontroller.cpp index bfadc74e7..f62618648 100644 --- a/app/settings/controllers/layoutscontroller.cpp +++ b/app/settings/controllers/layoutscontroller.cpp @@ -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); diff --git a/app/settings/handlers/detailshandler.cpp b/app/settings/handlers/detailshandler.cpp index ebe3b96fe..b7103ed0d 100644 --- a/app/settings/handlers/detailshandler.cpp +++ b/app/settings/handlers/detailshandler.cpp @@ -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); diff --git a/app/settings/models/layoutsmodel.cpp b/app/settings/models/layoutsmodel.cpp index 04f716d5b..cb21052af 100644 --- a/app/settings/models/layoutsmodel.cpp +++ b/app/settings/models/layoutsmodel.cpp @@ -408,7 +408,13 @@ QList 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; diff --git a/shell/package/contents/configuration/CanvasConfiguration.qml b/shell/package/contents/configuration/CanvasConfiguration.qml index 97132edb3..5d46a6bac 100644 --- a/shell/package/contents/configuration/CanvasConfiguration.qml +++ b/shell/package/contents/configuration/CanvasConfiguration.qml @@ -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 {