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(); emit lastUsedActivityChanged();
} }
QString AbstractLayout::defaultCustomTextColor()
{
return "#3C1C00";
}
QString AbstractLayout::defaultCustomBackground()
{
return "defaultcustom";
}
QString AbstractLayout::defaultTextColor(const QString &color) QString AbstractLayout::defaultTextColor(const QString &color)
{ {
//! the user is in default layout theme //! the user is in default layout theme

@ -89,7 +89,7 @@ public:
QString name() const; QString name() const;
QString file() const; QString file() const;
QString background() const; virtual QString background() const;
QString color() const; QString color() const;
void setColor(QString color); void setColor(QString color);
@ -102,7 +102,7 @@ public:
QString predefinedTextColor() const; QString predefinedTextColor() const;
QString textColor() const; virtual QString textColor() const;
void setTextColor(QString color); void setTextColor(QString color);
BackgroundStyle backgroundStyle() const; BackgroundStyle backgroundStyle() const;
@ -114,6 +114,8 @@ public:
virtual Type type() const; virtual Type type() const;
// STATIC // STATIC
static QString defaultCustomTextColor();
static QString defaultCustomBackground();
static QString defaultTextColor(const QString &color); static QString defaultTextColor(const QString &color);
static QString layoutName(const QString &fileName); static QString layoutName(const QString &fileName);
static QList<Plasma::Types::Location> combinedFreeEdges(const QList<Plasma::Types::Location> &edges1, 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; 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 Plasma::Containment *GenericLayout::internalContainmentOf(Plasma::Applet *applet) const
{ {
if (!applet) { if (!applet) {

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

@ -131,7 +131,7 @@ void Layouts::initView()
m_view->sortByColumn(m_viewSortColumn, m_viewSortOrder); m_view->sortByColumn(m_viewSortColumn, m_viewSortOrder);
//!find the available colors //!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); m_model->setIconsPath(m_iconsPath);
QDir layoutDir(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)); m_ui->colorsCmb->setCurrentIndex(m_colorsModel->row(data.color));
if (data.background.isEmpty()) { if (data.background.isEmpty()) {
m_ui->backPatternWidget->setBackground(m_colorsModel->colorPath("defaultcustom")); m_ui->backPatternWidget->setBackground(m_colorsModel->colorPath(Layout::AbstractLayout::defaultCustomBackground()));
m_ui->backPatternWidget->setTextColor("#3C1C00"); m_ui->backPatternWidget->setTextColor(Layout::AbstractLayout::defaultCustomTextColor());
} else { } else {
m_ui->backPatternWidget->setBackground(data.background); m_ui->backPatternWidget->setBackground(data.background);
m_ui->backPatternWidget->setTextColor(data.textColor); m_ui->backPatternWidget->setTextColor(data.textColor);

@ -408,7 +408,13 @@ QList<Data::LayoutIcon> Layouts::icons(const int &row) const
//! background image //! background image
if (icons.count() == 0) { 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()) { if (QFileInfo(colorPath).exists()) {
Data::LayoutIcon icon; Data::LayoutIcon icon;

@ -84,16 +84,7 @@ Item{
anchors.fill: parent anchors.fill: parent
opacity: root.maxOpacity opacity: root.maxOpacity
fillMode: Image.Tile fillMode: Image.Tile
source: latteView.layout ? latteView.layout.background : "../images/canvas/blueprint.jpg"
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
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {

Loading…
Cancel
Save