mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Resize icon with dock-mode
This commit is contained in:
parent
13a2fb8ec5
commit
ac306fb40b
@ -28,12 +28,6 @@ void AppManager::slotEntryAdded(const QDBusObjectPath &path)
|
|||||||
DBusEntryProxyer *entryProxyer = new DBusEntryProxyer(path.path());
|
DBusEntryProxyer *entryProxyer = new DBusEntryProxyer(path.path());
|
||||||
if (entryProxyer->isValid())
|
if (entryProxyer->isValid())
|
||||||
{
|
{
|
||||||
// qWarning() << "app-status" << entryProxyer->data().value("app-status");
|
|
||||||
// qWarning() << "app-xids" << entryProxyer->data().value("app-xids");
|
|
||||||
// qWarning() << "icon" << entryProxyer->data().value("icon");
|
|
||||||
// qWarning() << "menu" << entryProxyer->data().value("menu");
|
|
||||||
// qWarning() << "title" << entryProxyer->data().value("title");
|
|
||||||
|
|
||||||
AppItem *item = new AppItem();
|
AppItem *item = new AppItem();
|
||||||
item->setEntryProxyer(entryProxyer);
|
item->setEntryProxyer(entryProxyer);
|
||||||
emit entryAdded(item);
|
emit entryAdded(item);
|
||||||
|
@ -104,18 +104,17 @@ int DockModeData::getAppItemSpacing()
|
|||||||
|
|
||||||
int DockModeData::getAppIconSize()
|
int DockModeData::getAppIconSize()
|
||||||
{
|
{
|
||||||
// switch (m_currentMode)
|
switch (m_currentMode)
|
||||||
// {
|
{
|
||||||
// case DockConstants::FashionMode:
|
case DockConstants::FashionMode:
|
||||||
// return 48;
|
return 48;
|
||||||
// case DockConstants::EfficientMode:
|
case DockConstants::EfficientMode:
|
||||||
// return 48;
|
return 48;
|
||||||
// case DockConstants::ClassicMode:
|
case DockConstants::ClassicMode:
|
||||||
// return 24;
|
return 32;
|
||||||
// default:
|
default:
|
||||||
// return 32;
|
return 32;
|
||||||
// }
|
}
|
||||||
return 48;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DockModeData::getAppletsItemHeight()
|
int DockModeData::getAppletsItemHeight()
|
||||||
|
@ -15,32 +15,10 @@ AppIcon::AppIcon(QWidget *parent,Qt::WindowFlags f) :
|
|||||||
this->setAlignment(Qt::AlignCenter);
|
this->setAlignment(Qt::AlignCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppIcon::AppIcon(QString iconPath, QWidget *parent, Qt::WindowFlags f) :
|
void AppIcon::setIcon(const QString &iconPath)
|
||||||
QLabel(parent)
|
|
||||||
{
|
{
|
||||||
this->setParent(parent);
|
QString sysIconPath = getSysIcon(iconPath,m_modeData->getAppIconSize());
|
||||||
this->setWindowFlags(f);
|
QPixmap iconPixmap(m_modeData->getAppIconSize(),m_modeData->getAppIconSize());
|
||||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
this->setAlignment(Qt::AlignCenter);
|
|
||||||
|
|
||||||
QString sysIconPath = getSysIcon(iconPath);
|
|
||||||
QPixmap iconPixmap;
|
|
||||||
if (sysIconPath != "")
|
|
||||||
{
|
|
||||||
iconPixmap.load(sysIconPath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iconPixmap.load(iconPath);
|
|
||||||
}
|
|
||||||
this->setPixmap(iconPixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppIcon::setIcon(const QString &iconPath, int size)
|
|
||||||
{
|
|
||||||
QString sysIconPath = getSysIcon(iconPath,size);
|
|
||||||
// qWarning() << "--" << iconPath;
|
|
||||||
QPixmap iconPixmap(this->width(),this->height());
|
|
||||||
if (sysIconPath != "")
|
if (sysIconPath != "")
|
||||||
{
|
{
|
||||||
iconPixmap.load(sysIconPath);
|
iconPixmap.load(sysIconPath);
|
||||||
@ -50,6 +28,8 @@ void AppIcon::setIcon(const QString &iconPath, int size)
|
|||||||
iconPixmap.load(iconPath);
|
iconPixmap.load(iconPath);
|
||||||
}
|
}
|
||||||
this->setPixmap(iconPixmap);
|
this->setPixmap(iconPixmap);
|
||||||
|
QLabel::setPixmap(this->pixmap()->scaled(m_modeData->getAppIconSize(),m_modeData->getAppIconSize(),
|
||||||
|
Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppIcon::getSysIcon(const QString &iconName, int size)
|
QString AppIcon::getSysIcon(const QString &iconName, int size)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <Controller/dockmodedata.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
class AppIcon : public QLabel
|
class AppIcon : public QLabel
|
||||||
@ -12,14 +13,16 @@ class AppIcon : public QLabel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AppIcon(QWidget *parent = 0,Qt::WindowFlags f = 0);
|
explicit AppIcon(QWidget *parent = 0,Qt::WindowFlags f = 0);
|
||||||
explicit AppIcon(QString iconPath, QWidget *parent = 0,Qt::WindowFlags f = 0);//default search system icon path
|
|
||||||
|
|
||||||
void setIcon(const QString &iconPath, int size = 42);
|
void setIcon(const QString &iconPath);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
QString getSysIcon(const QString &iconName, int size = 42);
|
QString getSysIcon(const QString &iconName, int size = 48);
|
||||||
|
private:
|
||||||
|
DockModeData *m_modeData = DockModeData::getInstants();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPICON_H
|
#endif // APPICON_H
|
||||||
|
@ -103,7 +103,7 @@ void AppItem::resizeResources()
|
|||||||
if (m_appIcon != NULL)
|
if (m_appIcon != NULL)
|
||||||
{
|
{
|
||||||
m_appIcon->resize(dockCons->getAppIconSize(),dockCons->getAppIconSize());
|
m_appIcon->resize(dockCons->getAppIconSize(),dockCons->getAppIconSize());
|
||||||
reanchorIcon();
|
updateIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appBackground != NULL)
|
if (appBackground != NULL)
|
||||||
@ -158,9 +158,9 @@ void AppItem::updateIcon()
|
|||||||
if (m_appIcon == NULL)
|
if (m_appIcon == NULL)
|
||||||
{
|
{
|
||||||
m_appIcon = new AppIcon(this);
|
m_appIcon = new AppIcon(this);
|
||||||
m_appIcon->resize(height(), height());
|
|
||||||
m_appIcon->setIcon(m_itemData.iconPath,dockCons->getAppIconSize());
|
|
||||||
}
|
}
|
||||||
|
m_appIcon->resize(height(), height());
|
||||||
|
m_appIcon->setIcon(m_itemData.iconPath);
|
||||||
|
|
||||||
reanchorIcon();
|
reanchorIcon();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user