fix: Merge branch 'maintain/5.1' into uos

将maintain/5.1合并到uos

Log: 合并分支代码
Change-Id: I72eb946ceecb80db492e8e582cbb64290dc606d0
This commit is contained in:
chenjun 2020-08-26 18:10:49 +08:00
commit cface16a58
9 changed files with 57 additions and 85 deletions

View File

@ -74,12 +74,8 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
QHBoxLayout *centralLayout = new QHBoxLayout;
centralLayout->addWidget(m_title);
centralLayout->addWidget(m_closeBtn2D);
centralLayout->setSpacing(5);
centralLayout->setMargin(0);
centralLayout->setAlignment(m_closeBtn2D, Qt::AlignRight);
setLayout(centralLayout);
setAcceptDrops(true);
resize(SNAP_WIDTH, SNAP_HEIGHT);
@ -202,6 +198,7 @@ void AppSnapshot::enterEvent(QEvent *e)
QWidget::enterEvent(e);
if (!m_wmHelper->hasComposite()) {
m_closeBtn2D->move(width() - m_closeBtn2D->width() - 5, (height() - m_closeBtn2D->height()) / 2);
m_closeBtn2D->setVisible(true);
} else {
emit entered(wid());

View File

@ -857,6 +857,8 @@ void MainPanelControl::showEvent(QShowEvent *event)
void MainPanelControl::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
QColor color;
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
@ -914,12 +916,10 @@ void MainPanelControl::resizeDockIcon()
int totalLength = ((m_position == Position::Top) || (m_position == Position::Bottom)) ? width() : height();
// 减去托盘间隔区域
totalLength -= (m_tray->trayVisableItemCount() + 1) * 10;
// 减去插件间隔
totalLength -= (m_pluginLayout->count() + 1) * 10;
// 减去3个分割线的宽度
totalLength -= 3 * SPLITER_SIZE;
// 减去所有插件宽度,加上参与计算的3个插件宽度
// 减去所有插件宽度,加上参与计算的4个插件宽度
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
totalLength -= m_pluginAreaWidget->width();
if (trashPlugin) totalLength += trashPlugin->width();
@ -941,32 +941,28 @@ void MainPanelControl::resizeDockIcon()
// 参与计算的插件的个数(包含托盘和插件,垃圾桶,关机,屏幕键盘)
int pluginCount = m_tray->trayVisableItemCount() + (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
// icon个数
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + pluginCount;
int iconSize = 0;
// 余数
int yu = (totalLength % iconCount);
// icon宽度 = (总宽度-余数)/icon个数
iconSize = (totalLength - yu) / iconCount;
if (iconSize < 20 || iconSize > 40) {
// 减去插件和托盘的宽度
if (iconSize < 20)
totalLength -= 20 * pluginCount;
else
totalLength -= 40 * pluginCount;
iconCount -= pluginCount;
// 余数
yu = (totalLength % iconCount);
// icon宽度 = (总宽度-余数)/icon个数
iconSize = (totalLength - yu) / iconCount;
int iconSize = (totalLength - yu) / iconCount;
//计算插件图标的最大或最小值
int tray_item_size = qBound(20, iconSize, 40);
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
tray_item_size = qMin(tray_item_size,height());
tray_item_size = std::min(tray_item_size, height() - 20);
} else {
tray_item_size = qMin(tray_item_size,width());
tray_item_size = std::min(tray_item_size, width() - 20);
}
//减去插件图标的大小后重新计算固定图标和应用图标的平均大小
totalLength -= tray_item_size * pluginCount;
iconCount -= pluginCount;
// 余数
yu = (totalLength % iconCount);
// icon宽度 = (总宽度-余数)/icon个数
iconSize = (totalLength - yu) / iconCount;
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
if (iconSize >= height()) {
@ -985,7 +981,7 @@ void MainPanelControl::resizeDockIcon()
void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin, PluginsItem *notificationPlugin)
{
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);
}
@ -993,31 +989,15 @@ void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin,
m_fixedSpliter->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));
// 垃圾桶
if (trashPlugin)
trashPlugin->setFixedSize(std::min(w, h - 20), h - 20);
for (int i = 0; i < m_appAreaSonLayout->count(); ++ i) {
m_appAreaSonLayout->itemAt(i)->widget()->setMaximumWidth(h);
m_appAreaSonLayout->itemAt(i)->widget()->setMaximumHeight(QWIDGETSIZE_MAX);
}
} else {
m_fixedSpliter->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);
// 垃圾桶
if (trashPlugin)
trashPlugin->setFixedSize(w - 20, std::min(w - 20, h));
for (int i = 0; i < m_appAreaSonLayout->count(); ++ i) {
m_appAreaSonLayout->itemAt(i)->widget()->setMaximumHeight(w);
m_appAreaSonLayout->itemAt(i)->widget()->setMaximumWidth(QWIDGETSIZE_MAX);
}
}
// 插件和托盘
for (int i = 0; i < m_appAreaSonLayout->count(); ++i) {
m_appAreaSonLayout->itemAt(i)->widget()->setFixedSize(w, h);
}
// 托盘上每个图标大小
int tray_item_size = 20;
@ -1033,28 +1013,27 @@ void MainPanelControl::calcuDockIconSize(int w, int h, PluginsItem *trashPlugin,
if (tray_item_size < 20)
return;
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
m_tray->centralWidget()->setProperty("iconSize", tray_item_size);
// 插件
// 插件
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {
if (shutdownPlugin)
shutdownPlugin->setFixedSize(tray_item_size, h - 20);
if (keyboardPlugin)
keyboardPlugin->setFixedSize(tray_item_size, h - 20);
if (notificationPlugin) {
if (notificationPlugin)
notificationPlugin->setFixedSize(tray_item_size, h - 20);
}
if (trashPlugin)
trashPlugin->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 (notificationPlugin) {
if (notificationPlugin)
notificationPlugin->setFixedSize(w - 20, tray_item_size);
}
if (trashPlugin)
trashPlugin->setFixedSize(w - 20, tray_item_size);
}
if ((m_position == Position::Top) || (m_position == Position::Bottom)) {

View File

@ -42,7 +42,7 @@ DockPopupWindow::DockPopupWindow(QWidget *parent)
compositeChanged();
setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint);
setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus);
setAttribute(Qt::WA_InputMethodEnabled, false);
connect(m_acceptDelayTimer, &QTimer::timeout, this, &DockPopupWindow::accept);

View File

@ -431,5 +431,4 @@ void MainWindow::themeTypeChanged(DGuiApplicationHelper::ColorType themeType)
}
}
#include "mainwindow.moc"

View File

@ -82,7 +82,7 @@ int KeyboardPlugin::itemSortKey(const QString &itemKey)
{
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
return m_proxyInter->getValue(this, key, 2).toInt();
return m_proxyInter->getValue(this, key, 1).toInt();
}
void KeyboardPlugin::setSortKey(const QString &itemKey, const int order)

View File

@ -314,15 +314,7 @@ void NetworkItem::refreshIcon()
case Connected:
case Aconnected:
strength = getStrongestAp();
if (strength < 0)
strength = 100;
if (strength == 100) {
stateString = "80";
} else if (strength < 20) {
stateString = "0";
} else {
stateString = QString::number(strength / 10 & ~0x1) + "0";
}
stateString = getStrengthStateString(strength);
iconString = QString("wireless-%1-symbolic").arg(stateString);
break;
case Bconnected:
@ -342,13 +334,7 @@ void NetworkItem::refreshIcon()
m_timer->start();
if (m_switchWire) {
strength = QTime::currentTime().msec() / 10 % 100;
if (strength == 100) {
stateString = "80";
} else if (strength < 20) {
stateString = "0";
} else {
stateString = QString::number(strength / 10 & ~0x1) + "0";
}
stateString = getStrengthStateString(strength);
iconString = QString("wireless-%1-symbolic").arg(stateString);
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE
&& DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType)
@ -372,13 +358,7 @@ void NetworkItem::refreshIcon()
case Aconnecting: {
m_timer->start();
strength = QTime::currentTime().msec() / 10 % 100;
if (strength == 100) {
stateString = "80";
} else if (strength < 20) {
stateString = "0";
} else {
stateString = QString::number(strength / 10 & ~0x1) + "0";
}
stateString = getStrengthStateString(strength);
iconString = QString("wireless-%1-symbolic").arg(stateString);
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE
&& DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType)
@ -476,6 +456,22 @@ bool NetworkItem::eventFilter(QObject *obj, QEvent *event)
return false;
}
QString NetworkItem::getStrengthStateString(int strength)
{
if (5 >= strength)
return "0";
else if (5 < strength && 30 >= strength)
return "20";
else if (30 < strength && 55 >= strength)
return "40";
else if (55 < strength && 65 >= strength)
return "60";
else if (65 < strength)
return "80";
else
return "0";
}
void NetworkItem::wiredsEnable(bool enable)
{
for (auto wiredItem : m_wiredItems) {

View File

@ -73,6 +73,7 @@ protected:
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
bool eventFilter(QObject *obj,QEvent *event) override;
QString getStrengthStateString(int strength = 0);
private slots:
void wiredsEnable(bool enable);

View File

@ -141,7 +141,7 @@ int NetworkPlugin::itemSortKey(const QString &itemKey)
{
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
return m_proxyInter->getValue(this, key, 2).toInt();
return m_proxyInter->getValue(this, key, 3).toInt();
}
void NetworkPlugin::setSortKey(const QString &itemKey, const int order)

View File

@ -113,7 +113,7 @@ int SoundPlugin::itemSortKey(const QString &itemKey)
{
const QString key = QString("pos_%1_%2").arg(itemKey).arg(Dock::Efficient);
return m_proxyInter->getValue(this, key, 1).toInt();
return m_proxyInter->getValue(this, key, 2).toInt();
}
void SoundPlugin::setSortKey(const QString &itemKey, const int order)