mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 01:33:50 +03:00
details:add layout icon property
--expose icon properly at details window
This commit is contained in:
parent
437c04cf92
commit
28bcc973c0
@ -69,6 +69,7 @@ void AbstractLayout::init()
|
||||
connect(this, &AbstractLayout::customTextColorChanged, this, &AbstractLayout::saveConfig);
|
||||
connect(this, &AbstractLayout::colorChanged, this, &AbstractLayout::saveConfig);
|
||||
|
||||
connect(this, &AbstractLayout::iconChanged, this, &AbstractLayout::saveConfig);
|
||||
connect(this, &AbstractLayout::lastUsedActivityChanged, this, &AbstractLayout::saveConfig);
|
||||
connect(this, &AbstractLayout::launchersChanged, this, &AbstractLayout::saveConfig);
|
||||
connect(this, &AbstractLayout::preferredForShortcutsTouchedChanged, this, &AbstractLayout::saveConfig);
|
||||
@ -211,6 +212,21 @@ void AbstractLayout::setColor(QString color)
|
||||
emit colorChanged();
|
||||
}
|
||||
|
||||
QString AbstractLayout::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
void AbstractLayout::setIcon(const QString &icon)
|
||||
{
|
||||
if (m_icon == icon) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_icon = icon;
|
||||
emit iconChanged();
|
||||
}
|
||||
|
||||
QString AbstractLayout::lastUsedActivity()
|
||||
{
|
||||
return m_lastUsedActivity;
|
||||
@ -358,9 +374,11 @@ void AbstractLayout::loadConfig()
|
||||
|
||||
saveConfig();
|
||||
} else {
|
||||
m_customBackground = m_layoutGroup.readEntry("customBackground", QString(""));
|
||||
m_customTextColor = m_layoutGroup.readEntry("customTextColor", QString(""));
|
||||
m_customBackground = m_layoutGroup.readEntry("customBackground", QString());
|
||||
m_customTextColor = m_layoutGroup.readEntry("customTextColor", QString());
|
||||
}
|
||||
|
||||
m_icon = m_layoutGroup.readEntry("icon", QString());
|
||||
}
|
||||
|
||||
void AbstractLayout::saveConfig()
|
||||
@ -372,6 +390,7 @@ void AbstractLayout::saveConfig()
|
||||
m_layoutGroup.writeEntry("backgroundStyle", (int)m_backgroundStyle);
|
||||
m_layoutGroup.writeEntry("customBackground", m_customBackground);
|
||||
m_layoutGroup.writeEntry("customTextColor", m_customTextColor);
|
||||
m_layoutGroup.writeEntry("icon", m_icon);
|
||||
m_layoutGroup.writeEntry("lastUsedActivity", m_lastUsedActivity);
|
||||
m_layoutGroup.writeEntry("preferredForShortcutsTouched", m_preferredForShortcutsTouched);
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ class AbstractLayout : public QObject
|
||||
|
||||
Q_PROPERTY(bool preferredForShortcutsTouched READ preferredForShortcutsTouched WRITE setPreferredForShortcutsTouched NOTIFY preferredForShortcutsTouchedChanged)
|
||||
|
||||
Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
|
||||
Q_PROPERTY(QString background READ background NOTIFY backgroundChanged)
|
||||
Q_PROPERTY(QString textColor READ textColor NOTIFY textColorChanged)
|
||||
|
||||
@ -100,6 +101,9 @@ public:
|
||||
QString customTextColor() const;
|
||||
void setCustomTextColor(const QString &customColor);
|
||||
|
||||
QString icon() const;
|
||||
void setIcon(const QString &icon);
|
||||
|
||||
QString predefinedTextColor() const;
|
||||
|
||||
virtual QString textColor() const;
|
||||
@ -128,6 +132,7 @@ signals:
|
||||
void customTextColorChanged();
|
||||
void colorChanged();
|
||||
void fileChanged();
|
||||
void iconChanged();
|
||||
void lastUsedActivityChanged();
|
||||
void launchersChanged();
|
||||
void nameChanged();
|
||||
@ -155,7 +160,7 @@ protected:
|
||||
QString m_customTextColor;
|
||||
QString m_color;
|
||||
QString m_lastUsedActivity; //the last used activity for this layout
|
||||
|
||||
QString m_icon;
|
||||
|
||||
BackgroundStyle m_backgroundStyle{ColorBackgroundStyle};
|
||||
|
||||
|
@ -406,6 +406,7 @@ void Layouts::loadLayouts()
|
||||
CentralLayout *central = new CentralLayout(this, original.id);
|
||||
|
||||
original.name = central->name();
|
||||
original.icon = central->icon();
|
||||
original.backgroundStyle = central->backgroundStyle();
|
||||
original.color = central->color();
|
||||
original.background = central->customBackground();
|
||||
@ -539,6 +540,7 @@ const Data::Layout Layouts::addLayoutForFile(QString file, QString layoutName, b
|
||||
m_layouts[copied.id] = settings;
|
||||
|
||||
copied.name = uniqueLayoutName(layoutName);
|
||||
copied.icon = settings->icon();
|
||||
copied.backgroundStyle = settings->backgroundStyle();
|
||||
copied.color = settings->color();
|
||||
copied.textColor = settings->customTextColor();
|
||||
@ -723,38 +725,22 @@ void Layouts::save()
|
||||
generic->unlock();
|
||||
}
|
||||
|
||||
//! Icon
|
||||
generic->setIcon(iLayoutCurrentData.icon);
|
||||
|
||||
//! Backgrounds
|
||||
if (generic->backgroundStyle() != iLayoutCurrentData.backgroundStyle) {
|
||||
generic->setBackgroundStyle(iLayoutCurrentData.backgroundStyle);
|
||||
}
|
||||
|
||||
if (generic->color() != iLayoutCurrentData.color) {
|
||||
generic->setColor(iLayoutCurrentData.color);
|
||||
}
|
||||
|
||||
if (generic->customBackground() != iLayoutCurrentData.background) {
|
||||
generic->setCustomBackground(iLayoutCurrentData.background);
|
||||
}
|
||||
|
||||
if (generic->customTextColor() != iLayoutCurrentData.textColor) {
|
||||
generic->setCustomTextColor(iLayoutCurrentData.textColor);
|
||||
}
|
||||
generic->setBackgroundStyle(iLayoutCurrentData.backgroundStyle);
|
||||
generic->setColor(iLayoutCurrentData.color);
|
||||
generic->setCustomBackground(iLayoutCurrentData.background);
|
||||
generic->setCustomTextColor(iLayoutCurrentData.textColor);
|
||||
|
||||
//! update only the Central-specific layout parts
|
||||
CentralLayout *centralActive = isOriginalLayout ? m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(iLayoutOriginalData.name) : nullptr;
|
||||
CentralLayout *central = centralActive ? centralActive : m_layouts[iLayoutCurrentData.id];
|
||||
|
||||
if (central->showInMenu() != iLayoutCurrentData.isShownInMenu) {
|
||||
central->setShowInMenu(iLayoutCurrentData.isShownInMenu);
|
||||
}
|
||||
|
||||
if (central->disableBordersForMaximizedWindows() != iLayoutCurrentData.hasDisabledBorders) {
|
||||
central->setDisableBordersForMaximizedWindows(iLayoutCurrentData.hasDisabledBorders);
|
||||
}
|
||||
|
||||
if (central->activities() != cleanedActivities) {
|
||||
central->setActivities(cleanedActivities);
|
||||
}
|
||||
central->setShowInMenu(iLayoutCurrentData.isShownInMenu);
|
||||
central->setDisableBordersForMaximizedWindows(iLayoutCurrentData.hasDisabledBorders);
|
||||
central->setActivities(cleanedActivities);
|
||||
|
||||
//! If the layout name changed OR the layout path is a temporary one
|
||||
if ((iLayoutCurrentData.name != iLayoutOriginalData.name) || iLayoutCurrentData.isTemporary()) {
|
||||
|
@ -178,11 +178,24 @@
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="add"/>
|
||||
<iconset theme="add">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -33,6 +33,10 @@
|
||||
// Qt
|
||||
#include <QColorDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QIcon>
|
||||
|
||||
// KDE
|
||||
#include <KIconDialog>
|
||||
|
||||
namespace Latte {
|
||||
namespace Settings {
|
||||
@ -83,6 +87,8 @@ void DetailsHandler::init()
|
||||
});
|
||||
|
||||
connect(m_ui->backgroundBtn, &QPushButton::pressed, this, &DetailsHandler::selectBackground);
|
||||
connect(m_ui->iconBtn, &QPushButton::pressed, this, &DetailsHandler::selectIcon);
|
||||
connect(m_ui->iconClearBtn, &QPushButton::pressed, this, &DetailsHandler::on_clearIcon);
|
||||
connect(m_ui->textColorBtn, &QPushButton::pressed, this, &DetailsHandler::selectTextColor);
|
||||
connect(m_ui->patternClearBtn, &QPushButton::pressed, this, &DetailsHandler::on_clearPattern);
|
||||
|
||||
@ -135,8 +141,10 @@ void DetailsHandler::reload()
|
||||
void DetailsHandler::loadLayout(const Data::Layout &data)
|
||||
{
|
||||
if (data.icon.isEmpty()) {
|
||||
m_ui->iconBtn->setIcon(QIcon::fromTheme("add"));
|
||||
m_ui->iconClearBtn->setVisible(false);
|
||||
} else {
|
||||
m_ui->iconBtn->setIcon(QIcon::fromTheme(data.icon));
|
||||
m_ui->iconClearBtn->setVisible(true);
|
||||
}
|
||||
|
||||
@ -213,6 +221,11 @@ void DetailsHandler::save()
|
||||
{
|
||||
}
|
||||
|
||||
void DetailsHandler::on_clearIcon()
|
||||
{
|
||||
setIcon("");
|
||||
}
|
||||
|
||||
void DetailsHandler::on_clearPattern()
|
||||
{
|
||||
setBackground("");
|
||||
@ -254,6 +267,16 @@ void DetailsHandler::setColor(const QString &color)
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
void DetailsHandler::setIcon(const QString &icon)
|
||||
{
|
||||
if (c_data.icon == icon) {
|
||||
return;
|
||||
}
|
||||
|
||||
c_data.icon = icon;
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
void DetailsHandler::setTextColor(const QString &textColor)
|
||||
{
|
||||
if (c_data.textColor == textColor) {
|
||||
@ -319,6 +342,12 @@ void DetailsHandler::selectBackground()
|
||||
}
|
||||
}
|
||||
|
||||
void DetailsHandler::selectIcon()
|
||||
{
|
||||
KIconDialog iconDialog(m_parentDialog);
|
||||
setIcon(iconDialog.openDialog());
|
||||
}
|
||||
|
||||
void DetailsHandler::selectTextColor()
|
||||
{
|
||||
QColorDialog dialog(m_parentDialog);
|
||||
|
@ -81,12 +81,15 @@ signals:
|
||||
private slots:
|
||||
void on_currentLayoutIndexChanged(int row);
|
||||
void on_currentColorIndexChanged(int row);
|
||||
void on_clearIcon();
|
||||
void on_clearPattern();
|
||||
|
||||
void selectBackground();
|
||||
void selectIcon();
|
||||
void selectTextColor();
|
||||
|
||||
private:
|
||||
void init();
|
||||
void selectBackground();
|
||||
void selectTextColor();
|
||||
void reload();
|
||||
|
||||
void setIsShownInMenu(bool inMenu);
|
||||
@ -95,6 +98,7 @@ private:
|
||||
void setBackground(const QString &background);
|
||||
void setTextColor(const QString &textColor);
|
||||
void setColor(const QString &color);
|
||||
void setIcon(const QString &icon);
|
||||
|
||||
void setBackgroundStyle(const Latte::Layout::BackgroundStyle &style);
|
||||
|
||||
|
@ -406,6 +406,18 @@ QList<Data::LayoutIcon> Layouts::icons(const int &row) const
|
||||
icons.prepend(freeActsData);
|
||||
}
|
||||
|
||||
if (!m_layoutsTable[row].icon.isEmpty() && freeActivitiesPos<0) {
|
||||
//! if there is specific icon set from the user for this layout
|
||||
//! we draw only that icon
|
||||
icons.clear();
|
||||
Data::LayoutIcon icon;
|
||||
icon.name = m_layoutsTable[row].icon;
|
||||
icon.isFreeActivities = false;
|
||||
icon.isBackgroundFile = false;
|
||||
icons << icon;
|
||||
return icons;
|
||||
}
|
||||
|
||||
//! background image
|
||||
if (icons.count() == 0) {
|
||||
QString colorPath;
|
||||
|
Loading…
Reference in New Issue
Block a user