perf: 启动速度优化

任务栏插件加载的配置改成只在用到的时候创建一次,加速启动的时间,同时也减小了内存;启动器部分的提示框延迟创建。

Log: 优化启动速度
Influence: 任务栏启动时间
Task: https://pms.uniontech.com/zentao/task-view-95700.html
Change-Id: I187100f24cf9ac932b1e143c7671beb0841b3fce
This commit is contained in:
donghualin 2021-12-31 17:27:09 +08:00
parent a8becc02df
commit f830885be5
5 changed files with 31 additions and 38 deletions

View File

@ -54,7 +54,6 @@ AppItem::AppItem(const QGSettings *appSettings, const QGSettings *activeAppSetti
, m_appSettings(appSettings)
, m_activeAppSettings(activeAppSettings)
, m_dockedAppSettings(dockedAppSettings)
, 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)
@ -70,7 +69,6 @@ AppItem::AppItem(const QGSettings *appSettings, const QGSettings *activeAppSetti
, m_retryObtainIconTimer(new QTimer(this))
, m_refershIconTimer(new QTimer(this))
, m_themeType(DGuiApplicationHelper::instance()->themeType())
, m_config(new DConfig(QString("com.deepin.dde.dock.dconfig"), QString(), this))
{
QHBoxLayout *centralLayout = new QHBoxLayout;
centralLayout->setMargin(0);
@ -83,10 +81,6 @@ AppItem::AppItem(const QGSettings *appSettings, const QGSettings *activeAppSetti
m_id = m_itemEntryInter->id();
m_active = m_itemEntryInter->isActive();
m_appNameTips->setObjectName(m_itemEntryInter->name());
m_appNameTips->setVisible(false);
m_appNameTips->installEventFilter(this);
m_updateIconGeometryTimer->setInterval(500);
m_updateIconGeometryTimer->setSingleShot(true);
@ -476,22 +470,24 @@ const QString AppItem::contextMenu() const
QWidget *AppItem::popupTips()
{
if (checkGSettingsControl()) {
if (checkGSettingsControl())
return nullptr;
}
if (m_dragging)
return nullptr;
static TipsWidget appNameTips(topLevelWidget());
appNameTips.setVisible(false);
if (!m_windowInfos.isEmpty()) {
const quint32 currentWindow = m_itemEntryInter->currentWindow();
Q_ASSERT(m_windowInfos.contains(currentWindow));
m_appNameTips->setText(m_windowInfos[currentWindow].title.simplified());
appNameTips.setText(m_windowInfos[currentWindow].title.simplified());
} else {
m_appNameTips->setText(m_itemEntryInter->name().simplified());
appNameTips.setText(m_itemEntryInter->name().simplified());
}
return m_appNameTips;
return &appNameTips;
}
void AppItem::startDrag()
@ -672,8 +668,9 @@ void AppItem::showPreview()
connect(m_appPreviewTips, &PreviewContainer::requestHidePopup, this, &AppItem::onResetPreview);
// 预览标题显示方式的配置
if (m_config->isValid() && m_config->keyList().contains("Dock_Show_Window_name"))
m_appPreviewTips->setTitleDisplayMode(m_config->value("Dock_Show_Window_name").toInt());
DConfig config(QString("com.deepin.dde.dock.dconfig"), QString());
if (config.isValid() && config.keyList().contains("Dock_Show_Window_name"))
m_appPreviewTips->setTitleDisplayMode(config.value("Dock_Show_Window_name").toInt());
showPopupWindow(m_appPreviewTips, true);
}
@ -766,7 +763,6 @@ void AppItem::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType)
AppItem::~AppItem()
{
stopSwingEffect();
m_appNameTips->deleteLater();
}
void AppItem::showEvent(QShowEvent *e)

View File

@ -39,10 +39,6 @@
using DockEntryInter = com::deepin::dde::daemon::dock::Entry;
class QGSettings;
DCORE_BEGIN_NAMESPACE
class DConfig;
DCORE_END_NAMESPACE
class AppItem : public DockItem
{
Q_OBJECT
@ -114,7 +110,6 @@ private:
const QGSettings *m_activeAppSettings;
const QGSettings *m_dockedAppSettings;
TipsWidget *m_appNameTips;
PreviewContainer *m_appPreviewTips;
DockEntryInter *m_itemEntryInter;
@ -148,7 +143,6 @@ private:
DGuiApplicationHelper::ColorType m_themeType;
static QPoint MousePressPos;
DTK_CORE_NAMESPACE::DConfig *m_config;
};
#endif // APPITEM_H

View File

@ -22,26 +22,24 @@
#include "launcheritem.h"
#include "themeappicon.h"
#include "utils.h"
#include "../widgets/tipswidget.h"
#include <QPainter>
#include <QProcess>
#include <QMouseEvent>
#include <QApplication>
#include <QGSettings>
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <DDBusSender>
#include <QDBusPendingReply>
DCORE_USE_NAMESPACE
LauncherItem::LauncherItem(QWidget *parent)
: DockItem(parent)
, m_launcherInter(new LauncherInter("com.deepin.dde.Launcher", "/com/deepin/dde/Launcher", QDBusConnection::sessionBus(), this))
, m_tips(new TipsWidget(this))
, m_gsettings(Utils::ModuleSettingsPtr("launcher", QByteArray(), this))
{
m_launcherInter->setSync(true, false);
m_tips->setVisible(false);
m_tips->setObjectName("launcher");
if (m_gsettings) {
connect(m_gsettings, &QGSettings::changed, this, &LauncherItem::onGSettingsChanged);
}
@ -102,9 +100,14 @@ void LauncherItem::mouseReleaseEvent(QMouseEvent *e)
if (e->button() != Qt::LeftButton)
return;
if (!m_launcherInter->IsVisible()) {
m_launcherInter->Show();
}
DDBusSender dbusSender = DDBusSender()
.service("com.deepin.dde.Launcher")
.path("/com/deepin/dde/Launcher")
.interface("com.deepin.dde.Launcher");
QDBusPendingReply<bool> visibleReply = dbusSender.property("Visible").get();
if (!visibleReply.value())
dbusSender.method("Show").call();
}
QWidget *LauncherItem::popupTips()
@ -113,8 +116,10 @@ QWidget *LauncherItem::popupTips()
return nullptr;
}
m_tips.reset(new TipsWidget(this));
m_tips->setVisible(false);
m_tips->setText(tr("Launcher"));
return m_tips;
return m_tips.get();
}
void LauncherItem::onGSettingsChanged(const QString& key) {

View File

@ -23,11 +23,11 @@
#define LAUNCHERITEM_H
#include "dockitem.h"
#include "../widgets/tipswidget.h"
#include <com_deepin_dde_launcher.h>
namespace Dock {
class TipsWidget;
}
using LauncherInter = com::deepin::dde::Launcher;
class QGSettings;
class LauncherItem : public DockItem
{
@ -57,9 +57,8 @@ private:
private:
QPixmap m_icon;
LauncherInter *m_launcherInter;
TipsWidget *m_tips;
const QGSettings *m_gsettings;
QSharedPointer<TipsWidget> m_tips;
};
#endif // LAUNCHERITEM_H

View File

@ -153,10 +153,9 @@ void MainWindow::launch()
return;
m_launched = true;
qApp->processEvents();
setVisible(true);
m_multiScreenWorker->initShow();
m_shadowMaskOptimizeTimer->start();
QTimer::singleShot(0, this, [ this ] { this->setVisible(true); });
}
/**