mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat:format code
This commit is contained in:
parent
f7cc0e4625
commit
871b5f0edf
@ -65,41 +65,31 @@ static QGSettings *GSettingsByDockApp()
|
||||
}
|
||||
|
||||
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
: DockItem(parent),
|
||||
m_appNameTips(new TipsWidget(this)),
|
||||
m_appPreviewTips(nullptr),
|
||||
m_itemEntryInter(new DockEntryInter("com.deepin.dde.daemon.Dock", entry.path(), QDBusConnection::sessionBus(), this)),
|
||||
|
||||
m_swingEffectView(nullptr),
|
||||
m_itemAnimation(nullptr),
|
||||
|
||||
m_wmHelper(DWindowManagerHelper::instance()),
|
||||
|
||||
m_drag(nullptr),
|
||||
|
||||
m_dragging(false),
|
||||
|
||||
m_retryTimes(0),
|
||||
m_lastShowDay(0),
|
||||
m_lastclickTimes(0),
|
||||
|
||||
m_appIcon(QPixmap()),
|
||||
|
||||
m_updateIconGeometryTimer(new QTimer(this)),
|
||||
m_retryObtainIconTimer(new QTimer(this)),
|
||||
m_refershIconTimer(new QTimer(this)),
|
||||
|
||||
m_smallWatcher(new QFutureWatcher<QPixmap>(this)),
|
||||
m_largeWatcher(new QFutureWatcher<QPixmap>(this))
|
||||
: DockItem(parent)
|
||||
, m_appNameTips(new TipsWidget(this))
|
||||
, m_appPreviewTips(nullptr)
|
||||
, m_itemEntryInter(new DockEntryInter("com.deepin.dde.daemon.Dock", entry.path(), QDBusConnection::sessionBus(), this))
|
||||
, m_swingEffectView(nullptr)
|
||||
, m_itemAnimation(nullptr)
|
||||
, m_wmHelper(DWindowManagerHelper::instance())
|
||||
, m_drag(nullptr)
|
||||
, m_dragging(false)
|
||||
, m_retryTimes(0)
|
||||
, m_lastShowDay(0)
|
||||
, m_lastclickTimes(0)
|
||||
, m_appIcon(QPixmap())
|
||||
, m_updateIconGeometryTimer(new QTimer(this))
|
||||
, m_retryObtainIconTimer(new QTimer(this))
|
||||
, m_refershIconTimer(new QTimer(this))
|
||||
, m_smallWatcher(new QFutureWatcher<QPixmap>(this))
|
||||
, m_largeWatcher(new QFutureWatcher<QPixmap>(this))
|
||||
{
|
||||
QHBoxLayout *centralLayout = new QHBoxLayout;
|
||||
centralLayout->setMargin(0);
|
||||
centralLayout->setSpacing(0);
|
||||
|
||||
setAccessibleName(m_itemEntryInter->name());
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
setLayout(centralLayout);
|
||||
|
||||
m_id = m_itemEntryInter->id();
|
||||
@ -134,12 +124,12 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
connect(GSettingsByDockApp(), &QGSettings::changed, this, &AppItem::onGSettingsChanged);
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &AppItem::onThemeTypeChanged);
|
||||
|
||||
connect(m_refershIconTimer, &QTimer::timeout, this, [=](){
|
||||
m_curDate = QDate::currentDate();
|
||||
if(m_curDate.day() != m_lastShowDay){
|
||||
m_lastShowDay = m_curDate.day();
|
||||
refershIcon();
|
||||
}
|
||||
connect(m_refershIconTimer, &QTimer::timeout, this, [ = ]() {
|
||||
m_curDate = QDate::currentDate();
|
||||
if (m_curDate.day() != m_lastShowDay) {
|
||||
m_lastShowDay = m_curDate.day();
|
||||
refershIcon();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -155,7 +145,7 @@ const QString AppItem::appId() const
|
||||
return m_id;
|
||||
}
|
||||
|
||||
const bool AppItem::isValid() const
|
||||
bool AppItem::isValid() const
|
||||
{
|
||||
return m_itemEntryInter->isValid() && !m_itemEntryInter->id().isEmpty();
|
||||
}
|
||||
@ -608,7 +598,7 @@ void AppItem::refershIcon()
|
||||
else
|
||||
m_appIcon = ThemeAppIcon::getIcon(icon, iconSize * 0.8, devicePixelRatioF());
|
||||
|
||||
if(!m_refershIconTimer->isActive()&&m_itemEntryInter->icon() == "dde-calendar"){
|
||||
if (!m_refershIconTimer->isActive() && m_itemEntryInter->icon() == "dde-calendar") {
|
||||
m_refershIconTimer->start();
|
||||
}
|
||||
|
||||
@ -663,7 +653,7 @@ void AppItem::playSwingEffect()
|
||||
stopSwingEffect();
|
||||
|
||||
QPair<QGraphicsView *, QGraphicsItemAnimation *> pair = SwingEffect(
|
||||
this, m_appIcon, rect(), devicePixelRatioF());
|
||||
this, m_appIcon, rect(), devicePixelRatioF());
|
||||
|
||||
m_swingEffectView = pair.first;
|
||||
m_itemAnimation = pair.second;
|
||||
@ -710,8 +700,8 @@ void AppItem::onGSettingsChanged(const QString &key)
|
||||
}
|
||||
|
||||
QGSettings *setting = m_itemEntryInter->isDocked()
|
||||
? GSettingsByDockApp()
|
||||
: GSettingsByActiveApp();
|
||||
? GSettingsByDockApp()
|
||||
: GSettingsByActiveApp();
|
||||
|
||||
if (setting->keys().contains("enable")) {
|
||||
const bool isEnable = GSettingsByApp()->keys().contains("enable") && GSettingsByApp()->get("enable").toBool();
|
||||
@ -722,11 +712,11 @@ void AppItem::onGSettingsChanged(const QString &key)
|
||||
bool AppItem::checkGSettingsControl() const
|
||||
{
|
||||
QGSettings *setting = m_itemEntryInter->isDocked()
|
||||
? GSettingsByDockApp()
|
||||
: GSettingsByActiveApp();
|
||||
? GSettingsByDockApp()
|
||||
: GSettingsByActiveApp();
|
||||
|
||||
return (setting->keys().contains("control") && setting->get("control").toBool()) ||
|
||||
(GSettingsByApp()->keys().contains("control") && GSettingsByApp()->get("control").toBool());
|
||||
(GSettingsByApp()->keys().contains("control") && GSettingsByApp()->get("control").toBool());
|
||||
}
|
||||
|
||||
void AppItem::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType)
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
~AppItem();
|
||||
|
||||
const QString appId() const;
|
||||
const bool isValid() const;
|
||||
bool isValid() const;
|
||||
void updateWindowIconGeometries();
|
||||
void undock();
|
||||
QWidget *appDragWidget();
|
||||
@ -113,7 +113,7 @@ private:
|
||||
bool m_dragging;
|
||||
bool m_active;
|
||||
int m_retryTimes;
|
||||
int m_lastShowDay;
|
||||
int m_lastShowDay;
|
||||
unsigned long m_lastclickTimes;
|
||||
|
||||
WindowInfoMap m_windowInfos;
|
||||
|
@ -50,55 +50,54 @@ const QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size, cons
|
||||
QIcon icon;
|
||||
// 把size改为小于size的最大偶数 :)
|
||||
const int s = int(size * ratio) & ~1;
|
||||
const float iconZoom = size /64.0*0.8;
|
||||
const float iconZoom = size / 64.0 * 0.8;
|
||||
|
||||
if(iconName == "dde-calendar"){
|
||||
if (iconName == "dde-calendar") {
|
||||
QDate const date(QDate::currentDate());
|
||||
|
||||
auto pixday = ImageUtil::loadSvg(":/indicator/resources/calendar_bg.svg","",size,ratio);
|
||||
auto pixday = ImageUtil::loadSvg(":/indicator/resources/calendar_bg.svg", "", size, ratio);
|
||||
auto calendar = new QWidget() ;
|
||||
calendar->setFixedSize(s,s);
|
||||
calendar->setFixedSize(s, s);
|
||||
|
||||
calendar->setAutoFillBackground(true);
|
||||
QPalette palette = calendar->palette();
|
||||
palette.setBrush(QPalette::Window,
|
||||
QBrush(QPixmap(":/indicator/resources/calendar_bg.svg").scaled(
|
||||
calendar->size(),
|
||||
Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation)));
|
||||
calendar->setPalette(palette);
|
||||
QPalette palette = calendar->palette();
|
||||
palette.setBrush(QPalette::Window,
|
||||
QBrush(QPixmap(":/indicator/resources/calendar_bg.svg").scaled(
|
||||
calendar->size(),
|
||||
Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation)));
|
||||
calendar->setPalette(palette);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setSpacing(0);
|
||||
auto month = new QLabel();
|
||||
month->setPixmap( ImageUtil::loadSvg(QString(":/icons/resources/month%1.svg").arg(date.month()),QSize(36,16)*iconZoom,ratio));
|
||||
month->setPixmap(ImageUtil::loadSvg(QString(":/icons/resources/month%1.svg").arg(date.month()), QSize(36, 16)*iconZoom, ratio));
|
||||
month->setFixedHeight(month->pixmap()->height());
|
||||
month->setAlignment(Qt::AlignCenter);
|
||||
month->setFixedWidth(s-5*iconZoom);
|
||||
layout->addWidget(month,Qt::AlignVCenter);
|
||||
month->setFixedWidth(s - 5 * iconZoom);
|
||||
layout->addWidget(month, Qt::AlignVCenter);
|
||||
|
||||
auto day = new QLabel();
|
||||
day->setPixmap( ImageUtil::loadSvg(QString(":/icons/resources/day%1.svg").arg(date.day()),QSize(32,30)*iconZoom,ratio));
|
||||
day->setPixmap(ImageUtil::loadSvg(QString(":/icons/resources/day%1.svg").arg(date.day()), QSize(32, 30)*iconZoom, ratio));
|
||||
day->setAlignment(Qt::AlignCenter);
|
||||
day->setFixedHeight(day->pixmap()->height());
|
||||
day->raise();
|
||||
layout->addWidget(day,Qt::AlignVCenter);
|
||||
layout->addWidget(day, Qt::AlignVCenter);
|
||||
|
||||
auto week = new QLabel();
|
||||
week->setPixmap( ImageUtil::loadSvg(QString(":/icons/resources/week%1.svg").arg(date.dayOfWeek()),QSize(26,13)*iconZoom,ratio));
|
||||
week->setPixmap(ImageUtil::loadSvg(QString(":/icons/resources/week%1.svg").arg(date.dayOfWeek()), QSize(26, 13)*iconZoom, ratio));
|
||||
week->setFixedHeight(week->pixmap()->height());
|
||||
week->setAlignment(Qt::AlignCenter);
|
||||
week->setFixedWidth(s+5*iconZoom);
|
||||
layout->addWidget(week,Qt::AlignVCenter);
|
||||
week->setFixedWidth(s + 5 * iconZoom);
|
||||
layout->addWidget(week, Qt::AlignVCenter);
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0,10*iconZoom,0,10*iconZoom);
|
||||
layout->setContentsMargins(0, 10 * iconZoom, 0, 10 * iconZoom);
|
||||
calendar->setLayout(layout);
|
||||
pixmap = calendar->grab(calendar->rect());
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
|
||||
// load pixmap from our Cache
|
||||
@ -114,8 +113,7 @@ const QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size, cons
|
||||
}
|
||||
|
||||
// load pixmap from Byte-Data
|
||||
if (iconName.startsWith("data:image/"))
|
||||
{
|
||||
if (iconName.startsWith("data:image/")) {
|
||||
const QStringList strs = iconName.split("base64,");
|
||||
if (strs.size() == 2)
|
||||
pixmap.loadFromData(QByteArray::fromBase64(strs.at(1).toLatin1()));
|
||||
@ -125,17 +123,16 @@ const QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size, cons
|
||||
}
|
||||
|
||||
// load pixmap from File
|
||||
if (QFile::exists(iconName))
|
||||
{
|
||||
if (QFile::exists(iconName)) {
|
||||
pixmap = QPixmap(iconName);
|
||||
if (!pixmap.isNull())
|
||||
break;
|
||||
}
|
||||
|
||||
icon = QIcon::fromTheme(iconName);
|
||||
if(icon.isNull()){
|
||||
icon = QIcon::fromTheme("deepinwine-"+iconName);
|
||||
}else{
|
||||
if (icon.isNull()) {
|
||||
icon = QIcon::fromTheme("deepinwine-" + iconName);
|
||||
} else {
|
||||
icon = QIcon::fromTheme(iconName, QIcon::fromTheme("application-x-desktop"));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user