mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: 修复控制中心中调整任务栏高度反应慢的问题
之前是因为任务栏在每次调整后都会计算,导致反应慢 在调整期间屏蔽计算过程,调整结束后再设置相关接口的值 Log: Bug: https://pms.uniontech.com/zentao/bug-view-101271.html Influence: 控制中心-个性化-任务栏设置,调整任务栏高度 Change-Id: I611a305727d1916db4ed836253a1ac9966e523a9
This commit is contained in:
parent
fe42f84253
commit
c650d12860
@ -118,9 +118,9 @@ QStringList DBusDockAdaptors::GetLoadedPlugins()
|
||||
return newList;
|
||||
}
|
||||
|
||||
void DBusDockAdaptors::resizeDock(int offset)
|
||||
void DBusDockAdaptors::resizeDock(int offset, bool dragging)
|
||||
{
|
||||
parent()->resizeDock(offset);
|
||||
parent()->resizeDock(offset, dragging);
|
||||
}
|
||||
|
||||
// 返回每个插件的识别Key(所以此值应始终不变),供个性化插件根据key去匹配每个插件对应的图标
|
||||
|
@ -45,6 +45,7 @@ class DBusDockAdaptors: public QDBusAbstractAdaptor
|
||||
" </method>"
|
||||
" <method name=\"resizeDock\">"
|
||||
" <arg name=\"offset\" type=\"i\" direction=\"in\"/>"
|
||||
" <arg name=\"dragging\" type=\"b\" direction=\"in\"/>"
|
||||
" </method>"
|
||||
" <method name=\"getPluginKey\">"
|
||||
" <arg name=\"pluginName\" type=\"s\" direction=\"in\"/>"
|
||||
@ -79,7 +80,7 @@ public Q_SLOTS: // METHODS
|
||||
|
||||
QStringList GetLoadedPlugins();
|
||||
|
||||
void resizeDock(int offset);
|
||||
void resizeDock(int offset, bool dragging);
|
||||
|
||||
QString getPluginKey(const QString &pluginName);
|
||||
|
||||
|
@ -469,8 +469,10 @@ void MainWindow::resetDragWindow()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::resizeDock(int offset)
|
||||
void MainWindow::resizeDock(int offset, bool dragging)
|
||||
{
|
||||
qApp->setProperty(DRAG_STATE_PROP, dragging);
|
||||
|
||||
const QRect &rect = m_multiScreenWorker->getDockShowMinGeometry(m_multiScreenWorker->deskScreen());
|
||||
QRect newRect;
|
||||
switch (m_multiScreenWorker->position()) {
|
||||
@ -506,15 +508,11 @@ void MainWindow::resizeDock(int offset)
|
||||
|
||||
// 更新界面大小
|
||||
m_mainPanel->setFixedSize(newRect.size());
|
||||
QEvent event(QEvent::LayoutRequest);
|
||||
qApp->sendEvent(m_mainPanel, &event);
|
||||
m_mainPanel->repaint();
|
||||
setFixedSize(newRect.size());
|
||||
qApp->sendEvent(this, &event);
|
||||
this->repaint();
|
||||
move(newRect.topLeft());
|
||||
|
||||
m_multiScreenWorker->updateDaemonDockSize(offset);
|
||||
if (!dragging)
|
||||
resetDragWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,7 +198,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
void RegisterDdeSession();
|
||||
void resizeDock(int offset);
|
||||
void resizeDock(int offset, bool dragging);
|
||||
void resetDragWindow(); // 任务栏调整高度或宽度后需调用此函数
|
||||
|
||||
private slots:
|
||||
|
@ -99,17 +99,17 @@ public Q_SLOTS: // METHODS
|
||||
|
||||
|
||||
|
||||
inline QDBusPendingReply<> resizeDock(int offset)
|
||||
inline QDBusPendingReply<> resizeDock(int offset, bool dragging)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(offset);
|
||||
argumentList << QVariant::fromValue(offset) << QVariant::fromValue(dragging);
|
||||
return asyncCallWithArgumentList(QStringLiteral("resizeDock"), argumentList);
|
||||
}
|
||||
|
||||
inline void resizeDockQueued(int offset)
|
||||
inline void resizeDockQueued(int offset, bool dragging)
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << QVariant::fromValue(offset);
|
||||
argumentList << QVariant::fromValue(offset) << QVariant::fromValue(dragging);
|
||||
|
||||
CallQueued(QStringLiteral("resizeDock"), argumentList);
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ ModuleWidget::ModuleWidget(QWidget *parent)
|
||||
, m_modeComboxWidget(new ComboxWidget(this))
|
||||
, m_positionComboxWidget(new ComboxWidget(this))
|
||||
, m_stateComboxWidget(new ComboxWidget(this))
|
||||
, m_delayTimer(new QTimer(this))
|
||||
, m_sizeSlider(new TitledSliderItem(tr("Size"), this))
|
||||
, m_screenSettingTitle(new TitleLabel(tr("Multiple Displays"), this))
|
||||
, m_screenSettingComboxWidget(new ComboxWidget(this))
|
||||
@ -76,16 +75,13 @@ ModuleWidget::ModuleWidget(QWidget *parent)
|
||||
, m_daemonDockInter(new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this))
|
||||
, m_dockInter(new DBusInter("com.deepin.dde.Dock", "/com/deepin/dde/Dock", QDBusConnection::sessionBus(), this))
|
||||
, m_gsettingsWatcher(new GSettingWatcher("com.deepin.dde.control-center", "personalization", this))
|
||||
, m_sliderPressed(false)
|
||||
{
|
||||
// 异步,否则频繁调用可能会导致卡顿
|
||||
m_daemonDockInter->setSync(false);
|
||||
initUI();
|
||||
|
||||
m_delayTimer->setInterval(100);
|
||||
m_delayTimer->setSingleShot(true);
|
||||
|
||||
connect(m_dockInter, &DBusInter::pluginVisibleChanged, this, &ModuleWidget::updateItemCheckStatus);
|
||||
connect(m_delayTimer, &QTimer::timeout, this, &ModuleWidget::onResizeDock);
|
||||
}
|
||||
|
||||
ModuleWidget::~ModuleWidget()
|
||||
@ -175,12 +171,22 @@ void ModuleWidget::initUI()
|
||||
connect(m_daemonDockInter, &DBusDock::WindowSizeFashionChanged, this, &ModuleWidget::updateSliderValue);
|
||||
connect(m_daemonDockInter, &DBusDock::WindowSizeEfficientChanged, this, &ModuleWidget::updateSliderValue);
|
||||
connect(m_sizeSlider->slider(), &DSlider::sliderMoved, m_sizeSlider->slider(), &DSlider::valueChanged);
|
||||
connect(m_sizeSlider->slider(), &DSlider::valueChanged, m_delayTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||
connect(m_sizeSlider->slider(), &DSlider::valueChanged, this, [ = ] (int value) {
|
||||
m_dockInter->resizeDock(value, true);
|
||||
});
|
||||
connect(m_sizeSlider->slider(), &DSlider::sliderPressed, m_dockInter, [ = ] {
|
||||
m_daemonDockInter->blockSignals(true);
|
||||
m_sliderPressed = true;
|
||||
});
|
||||
connect(m_sizeSlider->slider(), &DSlider::sliderReleased, m_dockInter, [ = ] {
|
||||
m_daemonDockInter->blockSignals(false);
|
||||
m_sliderPressed = false;
|
||||
|
||||
// 松开手后通知dock拖拽状态接触
|
||||
QTimer::singleShot(0, this, [ = ] {
|
||||
int offset = m_sizeSlider->slider()->value();
|
||||
m_dockInter->resizeDock(offset, false);
|
||||
});
|
||||
});
|
||||
|
||||
updateSliderValue();
|
||||
@ -338,9 +344,3 @@ void ModuleWidget::updateItemCheckStatus(const QString &name, bool visible)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleWidget::onResizeDock()
|
||||
{
|
||||
int offset = m_sizeSlider->slider()->value();
|
||||
m_dockInter->resizeDock(offset);
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ DWIDGET_END_NAMESPACE
|
||||
|
||||
class TitleLabel;
|
||||
class QStandardItemModel;
|
||||
class QTimer;
|
||||
|
||||
using namespace dcc::widgets;
|
||||
using namespace dcc_dock_plugin;
|
||||
@ -64,14 +63,12 @@ private:
|
||||
private Q_SLOTS:
|
||||
void updateSliderValue();
|
||||
void updateItemCheckStatus(const QString &name, bool visible);
|
||||
void onResizeDock();
|
||||
|
||||
private:
|
||||
ComboxWidget *m_modeComboxWidget;
|
||||
ComboxWidget *m_positionComboxWidget;
|
||||
ComboxWidget *m_stateComboxWidget;
|
||||
|
||||
QTimer *m_delayTimer;
|
||||
TitledSliderItem *m_sizeSlider;
|
||||
|
||||
TitleLabel *m_screenSettingTitle;
|
||||
@ -85,6 +82,8 @@ private:
|
||||
DBusDock *m_daemonDockInter;
|
||||
DBusInter *m_dockInter;
|
||||
GSettingWatcher *m_gsettingsWatcher;
|
||||
|
||||
bool m_sliderPressed;
|
||||
};
|
||||
|
||||
#endif // MODULE_WIDGET_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user