mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix(dde-dock):Third party plug-ins are not displayed completely
第三方插件显示不全 (task:13328)
This commit is contained in:
parent
addd30ef4c
commit
6a1a795649
@ -191,9 +191,9 @@ void MainPanelControl::addTrayAreaItem(int index, QWidget *wdg)
|
|||||||
|
|
||||||
void MainPanelControl::addPluginAreaItem(int index, QWidget *wdg)
|
void MainPanelControl::addPluginAreaItem(int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_pluginLayout->insertWidget(index, wdg);
|
m_pluginLayout->insertWidget(index, wdg, 0, Qt::AlignCenter);
|
||||||
resizeDockIcon();
|
resizeDockIcon();
|
||||||
QTimer::singleShot(50, this, [ = ] {m_pluginAreaWidget->adjustSize();});
|
m_pluginAreaWidget->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::removeFixedAreaItem(QWidget *wdg)
|
void MainPanelControl::removeFixedAreaItem(QWidget *wdg)
|
||||||
@ -782,18 +782,16 @@ void MainPanelControl::resizeDockIcon()
|
|||||||
// 插件有点特殊,因为会引入第三方的插件,并不会受dock的缩放影响,我们只能限制我们自己的插件,否则会导致显示错误。
|
// 插件有点特殊,因为会引入第三方的插件,并不会受dock的缩放影响,我们只能限制我们自己的插件,否则会导致显示错误。
|
||||||
// 以下是受控制的插件
|
// 以下是受控制的插件
|
||||||
PluginsItem *trashPlugin = nullptr;
|
PluginsItem *trashPlugin = nullptr;
|
||||||
int pluginTotalWidth = 0;
|
PluginsItem *shutdownPlugin = nullptr;
|
||||||
int pluginTotalHeight = 0;
|
PluginsItem *keyboardPlugin = nullptr;
|
||||||
int count = 0; //计算除时间和垃圾箱之外的插件个数
|
|
||||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
PluginsItem *w = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||||
if (w->pluginName() == "trash") {
|
if (w->pluginName() == "trash") {
|
||||||
trashPlugin = w;
|
trashPlugin = w;
|
||||||
} else if (w->pluginName() == "datetime") {
|
} else if (w->pluginName() == "shutdown") {
|
||||||
} else {
|
shutdownPlugin = w;
|
||||||
pluginTotalWidth += w->width();
|
} else if (w->pluginName() == "onboard") {
|
||||||
pluginTotalHeight += w->height();
|
keyboardPlugin = w;
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,12 +808,14 @@ void MainPanelControl::resizeDockIcon()
|
|||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
||||||
totalLength -= m_pluginAreaWidget->width();
|
totalLength -= m_pluginAreaWidget->width();
|
||||||
if (trashPlugin) totalLength += trashPlugin->width();
|
if (trashPlugin) totalLength += trashPlugin->width();
|
||||||
totalLength += pluginTotalWidth;
|
if (shutdownPlugin) totalLength += shutdownPlugin->width();
|
||||||
|
if (keyboardPlugin) totalLength += keyboardPlugin->width();
|
||||||
totalLength -= m_desktopWidget->width();
|
totalLength -= m_desktopWidget->width();
|
||||||
} else {
|
} else {
|
||||||
totalLength -= m_pluginAreaWidget->height();
|
totalLength -= m_pluginAreaWidget->height();
|
||||||
if (trashPlugin) totalLength += trashPlugin->height();
|
if (trashPlugin) totalLength += trashPlugin->height();
|
||||||
totalLength += pluginTotalHeight;
|
if (shutdownPlugin) totalLength += shutdownPlugin->height();
|
||||||
|
if (keyboardPlugin) totalLength += keyboardPlugin->height();
|
||||||
totalLength -= m_desktopWidget->height();
|
totalLength -= m_desktopWidget->height();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,7 +823,7 @@ void MainPanelControl::resizeDockIcon()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// 参与计算的插件的个数(包含托盘和插件,垃圾桶,关机,屏幕键盘)
|
// 参与计算的插件的个数(包含托盘和插件,垃圾桶,关机,屏幕键盘)
|
||||||
int pluginCount = m_tray->trayVisableItemCount() + (trashPlugin ? 1 : 0) + count;
|
int pluginCount = m_tray->trayVisableItemCount() + (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0);
|
||||||
|
|
||||||
// icon个数
|
// icon个数
|
||||||
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + pluginCount;
|
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + pluginCount;
|
||||||
@ -853,20 +853,20 @@ void MainPanelControl::resizeDockIcon()
|
|||||||
|
|
||||||
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
||||||
if (iconSize >= height()) {
|
if (iconSize >= height()) {
|
||||||
calcuDockIconSize(height(), height());
|
calcuDockIconSize(height(), height(), trashPlugin, shutdownPlugin, keyboardPlugin);
|
||||||
} else {
|
} else {
|
||||||
calcuDockIconSize(iconSize, height());
|
calcuDockIconSize(iconSize, height(), trashPlugin, shutdownPlugin, keyboardPlugin);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (iconSize >= width()) {
|
if (iconSize >= width()) {
|
||||||
calcuDockIconSize(width(), width());
|
calcuDockIconSize(width(), width(), trashPlugin, shutdownPlugin, keyboardPlugin);
|
||||||
} else {
|
} else {
|
||||||
calcuDockIconSize(width(), iconSize);
|
calcuDockIconSize(width(), iconSize, trashPlugin, shutdownPlugin, keyboardPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::calcuDockIconSize(int w, int h)
|
void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_fixedAreaLayout->count(); ++ i) {
|
for (int i = 0; i < m_fixedAreaLayout->count(); ++ i) {
|
||||||
m_fixedAreaLayout->itemAt(i)->widget()->setFixedSize(w, h);
|
m_fixedAreaLayout->itemAt(i)->widget()->setFixedSize(w, h);
|
||||||
@ -876,14 +876,9 @@ void MainPanelControl::calcuDockIconSize(int w, int h)
|
|||||||
m_fixedSpliter->setFixedSize(SPLITER_SIZE, int(w * 0.6));
|
m_fixedSpliter->setFixedSize(SPLITER_SIZE, int(w * 0.6));
|
||||||
m_appSpliter->setFixedSize(SPLITER_SIZE, int(w * 0.6));
|
m_appSpliter->setFixedSize(SPLITER_SIZE, int(w * 0.6));
|
||||||
m_traySpliter->setFixedSize(SPLITER_SIZE, int(w * 0.5));
|
m_traySpliter->setFixedSize(SPLITER_SIZE, int(w * 0.5));
|
||||||
|
|
||||||
// 垃圾桶
|
// 垃圾桶
|
||||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
if (trashPlugin)
|
||||||
PluginsItem *pluginItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
trashPlugin->setFixedSize(std::min(w, h - 20), h - 20);
|
||||||
if (pluginItem->pluginName() == "trash"){
|
|
||||||
pluginItem->setFixedSize(std::min(w, h - 20), h - 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_appAreaSonLayout->count(); ++ i) {
|
for (int i = 0; i < m_appAreaSonLayout->count(); ++ i) {
|
||||||
m_appAreaSonLayout->itemAt(i)->widget()->setMaximumWidth(h);
|
m_appAreaSonLayout->itemAt(i)->widget()->setMaximumWidth(h);
|
||||||
@ -894,14 +889,10 @@ void MainPanelControl::calcuDockIconSize(int w, int h)
|
|||||||
m_fixedSpliter->setFixedSize(int(h * 0.6), SPLITER_SIZE);
|
m_fixedSpliter->setFixedSize(int(h * 0.6), SPLITER_SIZE);
|
||||||
m_appSpliter->setFixedSize(int(h * 0.6), SPLITER_SIZE);
|
m_appSpliter->setFixedSize(int(h * 0.6), SPLITER_SIZE);
|
||||||
m_traySpliter->setFixedSize(int(h * 0.5), SPLITER_SIZE);
|
m_traySpliter->setFixedSize(int(h * 0.5), SPLITER_SIZE);
|
||||||
|
|
||||||
// 垃圾桶
|
// 垃圾桶
|
||||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
if (trashPlugin)
|
||||||
PluginsItem *pluginItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
trashPlugin->setFixedSize(w - 20, std::min(w - 20, h));
|
||||||
if (pluginItem->pluginName() == "trash"){
|
|
||||||
pluginItem->setFixedSize(w - 20, std::min(w - 20, h));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_appAreaSonLayout->count(); ++ i) {
|
for (int i = 0; i < m_appAreaSonLayout->count(); ++ i) {
|
||||||
m_appAreaSonLayout->itemAt(i)->widget()->setMaximumHeight(w);
|
m_appAreaSonLayout->itemAt(i)->widget()->setMaximumHeight(w);
|
||||||
@ -929,18 +920,49 @@ void MainPanelControl::calcuDockIconSize(int w, int h)
|
|||||||
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
|
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
|
||||||
|
|
||||||
// 插件
|
// 插件
|
||||||
|
if (shutdownPlugin)
|
||||||
|
shutdownPlugin->setFixedSize(tray_item_size, h - 20);
|
||||||
|
if (keyboardPlugin)
|
||||||
|
keyboardPlugin->setFixedSize(tray_item_size, h - 20);
|
||||||
|
} else {
|
||||||
|
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
|
||||||
|
|
||||||
|
if (shutdownPlugin)
|
||||||
|
shutdownPlugin->setFixedSize(w - 20, tray_item_size);
|
||||||
|
if (keyboardPlugin)
|
||||||
|
keyboardPlugin->setFixedSize(w - 20, tray_item_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
|
||||||
|
// 三方插件
|
||||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
PluginsItem *pluginItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
PluginsItem *pItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||||
if (pluginItem->pluginName() != "trash" && pluginItem->pluginName() != "datetime"){
|
if (pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin) {
|
||||||
pluginItem->setFixedSize(tray_item_size, h - 20);
|
int width = pItem->sizeHint().width();
|
||||||
|
if(h == 40 && pItem->sizeHint().width() == 40)
|
||||||
|
width = 20;
|
||||||
|
if (width > -1)
|
||||||
|
pItem->setFixedWidth(width);
|
||||||
|
else {
|
||||||
|
pItem->setFixedWidth(h - 20);
|
||||||
|
}
|
||||||
|
pItem->setFixedHeight(h - 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
|
// 三方插件
|
||||||
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
for (int i = 0; i < m_pluginLayout->count(); ++ i) {
|
||||||
PluginsItem *pluginItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
PluginsItem *pItem = static_cast<PluginsItem *>(m_pluginLayout->itemAt(i)->widget());
|
||||||
if (pluginItem->pluginName() != "trash" && pluginItem->pluginName() != "datetime"){
|
if (pItem != trashPlugin && pItem != shutdownPlugin && pItem != keyboardPlugin) {
|
||||||
pluginItem->setFixedSize(w - 20, tray_item_size);
|
int height = pItem->sizeHint().height();
|
||||||
|
if(w == 40 && pItem->sizeHint().height() == 40)
|
||||||
|
height = 20;
|
||||||
|
if (height > -1)
|
||||||
|
pItem->setFixedHeight(height);
|
||||||
|
else {
|
||||||
|
pItem->setFixedHeight(w - 20);
|
||||||
|
}
|
||||||
|
pItem->setFixedWidth(w - 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ private:
|
|||||||
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void resizeDockIcon();
|
void resizeDockIcon();
|
||||||
void calcuDockIconSize(const int w, const int h);
|
void calcuDockIconSize(const int w, const int h, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void insertItem(const int index, DockItem *item);
|
void insertItem(const int index, DockItem *item);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user