diff --git a/app/layouts/manager.cpp b/app/layouts/manager.cpp index 332bc88fe..535c2206c 100644 --- a/app/layouts/manager.cpp +++ b/app/layouts/manager.cpp @@ -195,6 +195,37 @@ QStringList Manager::viewTemplateIds() const return ids; } +Latte::Data::LayoutIcon Manager::iconForLayout(const Data::Layout &layout) const +{ + Latte::Data::LayoutIcon _icon; + + if (!layout.icon.isEmpty()) { + //! if there is specific icon set from the user for this layout we draw only that icon + _icon.name = layout.icon; + _icon.isBackgroundFile = false; + return _icon; + } + + //! fallback icon: background image + if (_icon.isEmpty()) { + QString colorPath = m_corona->kPackage().path() + "../../shells/org.kde.latte.shell/contents/images/canvas/"; + + if (layout.backgroundStyle == Layout::PatternBackgroundStyle && layout.background.isEmpty()) { + colorPath += "defaultcustomprint.jpg"; + } else { + colorPath = layout.background.startsWith("/") ? layout.background : colorPath + layout.color + "print.jpg"; + } + + if (QFileInfo(colorPath).exists()) { + _icon.isBackgroundFile = true; + _icon.name = colorPath; + return _icon; + } + } + + return Latte::Data::LayoutIcon(); +} + QList Manager::currentLayouts() const { return m_synchronizer->currentLayouts(); diff --git a/app/layouts/manager.h b/app/layouts/manager.h index 707a8a55f..6f2e5c70c 100644 --- a/app/layouts/manager.h +++ b/app/layouts/manager.h @@ -25,6 +25,8 @@ #include "syncedlaunchers.h" #include "synchronizer.h" #include "../apptypes.h" +#include "../data/layoutdata.h" +#include "../data/layouticondata.h" #include "../settings/settingsdialog/settingsdialog.h" // Qt @@ -87,6 +89,8 @@ public: QStringList currentLayoutsNames() const; + Latte::Data::LayoutIcon iconForLayout(const Data::Layout &layout) const; + MemoryUsage::LayoutsMemory memoryUsage() const; void setMemoryUsage(MemoryUsage::LayoutsMemory memoryUsage); diff --git a/app/settings/settingsdialog/layoutscontroller.cpp b/app/settings/settingsdialog/layoutscontroller.cpp index 13411596d..6ac4cb315 100644 --- a/app/settings/settingsdialog/layoutscontroller.cpp +++ b/app/settings/settingsdialog/layoutscontroller.cpp @@ -145,7 +145,6 @@ void Layouts::initView() //!find the available colors m_iconsPath = m_handler->corona()->kPackage().path() + "../../shells/org.kde.latte.shell/contents/images/canvas/"; - m_model->setIconsPath(m_iconsPath); QDir layoutDir(m_iconsPath); QStringList filter; diff --git a/app/settings/settingsdialog/layoutsmodel.cpp b/app/settings/settingsdialog/layoutsmodel.cpp index e27975ddf..d4aa3ae86 100644 --- a/app/settings/settingsdialog/layoutsmodel.cpp +++ b/app/settings/settingsdialog/layoutsmodel.cpp @@ -404,45 +404,9 @@ Qt::ItemFlags Layouts::flags(const QModelIndex &index) const return flags; } -void Layouts::setIconsPath(QString iconsPath) -{ - m_iconsPath = iconsPath; -} - -Latte::Data::LayoutIcon Layouts::iconForCentralLayout(const int &row) const -{ - Latte::Data::LayoutIcon _icon; - - if (!m_layoutsTable[row].icon.isEmpty()) { - //! if there is specific icon set from the user for this layout we draw only that icon - _icon.name = m_layoutsTable[row].icon; - _icon.isBackgroundFile = false; - return _icon; - } - - //! fallback icon: background image - if (_icon.isEmpty()) { - 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()) { - _icon.isBackgroundFile = true; - _icon.name = colorPath; - return _icon; - } - } - - return Latte::Data::LayoutIcon(); -} - Latte::Data::LayoutIcon Layouts::icon(const int &row) const { - return iconForCentralLayout(row); + return m_corona->layoutsManager()->iconForLayout(m_layoutsTable[row]); } const Latte::Data::LayoutIcon Layouts::currentLayoutIcon(const QString &id) const diff --git a/app/settings/settingsdialog/layoutsmodel.h b/app/settings/settingsdialog/layoutsmodel.h index 46308bda7..d63a886d3 100644 --- a/app/settings/settingsdialog/layoutsmodel.h +++ b/app/settings/settingsdialog/layoutsmodel.h @@ -137,8 +137,6 @@ public: void setCurrentLayoutForFreeActivities(const QString &id); void setOriginalLayoutForFreeActivities(const QString &id); - void setIconsPath(QString iconsPath); - QList alteredLayouts() const; const Latte::Data::LayoutsTable ¤tLayoutsData(); @@ -180,11 +178,8 @@ private: QStringList cleanStrings(const QStringList &original, const QStringList &occupied); Latte::Data::LayoutIcon icon(const int &row) const; - Latte::Data::LayoutIcon iconForCentralLayout(const int &row) const; private: - QString m_iconsPath; - Latte::Data::ActivitiesTable m_activitiesTable; QHash m_activitiesInfo;