mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +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());
|
||||
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();
|
||||
item->setEntryProxyer(entryProxyer);
|
||||
emit entryAdded(item);
|
||||
|
@ -104,18 +104,17 @@ int DockModeData::getAppItemSpacing()
|
||||
|
||||
int DockModeData::getAppIconSize()
|
||||
{
|
||||
// switch (m_currentMode)
|
||||
// {
|
||||
// case DockConstants::FashionMode:
|
||||
// return 48;
|
||||
// case DockConstants::EfficientMode:
|
||||
// return 48;
|
||||
// case DockConstants::ClassicMode:
|
||||
// return 24;
|
||||
// default:
|
||||
// return 32;
|
||||
// }
|
||||
return 48;
|
||||
switch (m_currentMode)
|
||||
{
|
||||
case DockConstants::FashionMode:
|
||||
return 48;
|
||||
case DockConstants::EfficientMode:
|
||||
return 48;
|
||||
case DockConstants::ClassicMode:
|
||||
return 32;
|
||||
default:
|
||||
return 32;
|
||||
}
|
||||
}
|
||||
|
||||
int DockModeData::getAppletsItemHeight()
|
||||
|
@ -15,32 +15,10 @@ AppIcon::AppIcon(QWidget *parent,Qt::WindowFlags f) :
|
||||
this->setAlignment(Qt::AlignCenter);
|
||||
}
|
||||
|
||||
AppIcon::AppIcon(QString iconPath, QWidget *parent, Qt::WindowFlags f) :
|
||||
QLabel(parent)
|
||||
void AppIcon::setIcon(const QString &iconPath)
|
||||
{
|
||||
this->setParent(parent);
|
||||
this->setWindowFlags(f);
|
||||
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());
|
||||
QString sysIconPath = getSysIcon(iconPath,m_modeData->getAppIconSize());
|
||||
QPixmap iconPixmap(m_modeData->getAppIconSize(),m_modeData->getAppIconSize());
|
||||
if (sysIconPath != "")
|
||||
{
|
||||
iconPixmap.load(sysIconPath);
|
||||
@ -50,6 +28,8 @@ void AppIcon::setIcon(const QString &iconPath, int size)
|
||||
iconPixmap.load(iconPath);
|
||||
}
|
||||
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)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <Controller/dockmodedata.h>
|
||||
#include <QDebug>
|
||||
|
||||
class AppIcon : public QLabel
|
||||
@ -12,14 +13,16 @@ class AppIcon : public QLabel
|
||||
Q_OBJECT
|
||||
public:
|
||||
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:
|
||||
|
||||
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
|
||||
|
@ -103,7 +103,7 @@ void AppItem::resizeResources()
|
||||
if (m_appIcon != NULL)
|
||||
{
|
||||
m_appIcon->resize(dockCons->getAppIconSize(),dockCons->getAppIconSize());
|
||||
reanchorIcon();
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
if (appBackground != NULL)
|
||||
@ -158,9 +158,9 @@ void AppItem::updateIcon()
|
||||
if (m_appIcon == NULL)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user