mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-26 18:03:42 +03:00
layoutsmanager:take responsibility for layout icons
This commit is contained in:
parent
517b423bc6
commit
cbd8d5d88c
@ -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<CentralLayout *> Manager::currentLayouts() const
|
||||
{
|
||||
return m_synchronizer->currentLayouts();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -137,8 +137,6 @@ public:
|
||||
void setCurrentLayoutForFreeActivities(const QString &id);
|
||||
void setOriginalLayoutForFreeActivities(const QString &id);
|
||||
|
||||
void setIconsPath(QString iconsPath);
|
||||
|
||||
QList<Latte::Data::Layout> 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<QString, KActivities::Info *> m_activitiesInfo;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user