mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
chore: 添加代码注释
所有的函数和类尽量都添加注释,方便别人维护 Log: Change-Id: If8cb522b78bcfa38f0ab4da8b453045cc917784d
This commit is contained in:
parent
1597fab278
commit
46d5771ff9
@ -33,6 +33,10 @@
|
||||
#include <QObject>
|
||||
|
||||
using DBusDock = com::deepin::dde::daemon::Dock;
|
||||
/**
|
||||
* @brief The DockItemManager class
|
||||
* 管理类,管理所有的应用数据,插件数据
|
||||
*/
|
||||
class DockItemManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -57,6 +57,10 @@ const QString g_cfgPath = QStandardPaths::standardLocations(QStandardPaths::Conf
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @brief IsSaveMode
|
||||
* @return 判断当前是否应该进入安全模式(安全模式下不加载插件)
|
||||
*/
|
||||
bool IsSaveMode()
|
||||
{
|
||||
QSettings settings(g_cfgPath, QSettings::IniFormat);
|
||||
@ -73,6 +77,10 @@ bool IsSaveMode()
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief sig_crash
|
||||
* @return 当应用收到对应的退出信号时,会调用此函数,用于保存一下应用崩溃时间,崩溃次数,用以判断是否应该进入安全模式,见IsSaveMode()
|
||||
*/
|
||||
[[noreturn]] void sig_crash(int sig)
|
||||
{
|
||||
QDir dir(QStandardPaths::standardLocations(QStandardPaths::CacheLocation)[0]);
|
||||
@ -181,6 +189,7 @@ int main(int argc, char *argv[])
|
||||
app.setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps, false);
|
||||
|
||||
// 自动化标记由此开始
|
||||
QAccessible::installFactory(accessibleFactory);
|
||||
|
||||
// load dde-network-utils translator
|
||||
@ -211,6 +220,7 @@ int main(int argc, char *argv[])
|
||||
QDir::setCurrent(QApplication::applicationDirPath());
|
||||
#endif
|
||||
|
||||
// 注册任务栏的DBus服务
|
||||
MainWindow mw;
|
||||
DBusDockAdaptors adaptor(&mw);
|
||||
QDBusConnection::sessionBus().registerService("com.deepin.dde.Dock");
|
||||
|
@ -144,6 +144,10 @@ void MainPanelControl::initUi()
|
||||
m_mainPanelLayout->setAlignment(m_traySpliter, Qt::AlignCenter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainPanelControl::setDisplayMode 根据任务栏显示模式更新界面显示,如果是时尚模式,没有‘显示桌面'区域,否则就有
|
||||
* @param dislayMode 任务栏显示模式
|
||||
*/
|
||||
void MainPanelControl::setDisplayMode(DisplayMode dislayMode)
|
||||
{
|
||||
if (dislayMode == m_dislayMode)
|
||||
@ -275,6 +279,10 @@ void MainPanelControl::updateAppAreaSonWidgetSize()
|
||||
moveAppSonWidget();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setPositonValue 根据传入的位置更新界面布局,比如任务栏在左,布局应该是上下布局,任务栏在下,应该是左右布局
|
||||
* @param position 任务栏的位置
|
||||
*/
|
||||
void MainPanelControl::setPositonValue(Dock::Position position)
|
||||
{
|
||||
if (m_position == position)
|
||||
@ -340,10 +348,10 @@ void MainPanelControl::removeItem(DockItem *item)
|
||||
resizeDockIcon();
|
||||
}
|
||||
|
||||
MainPanelDelegate *MainPanelControl::delegate() const
|
||||
{
|
||||
return m_delegate;
|
||||
}
|
||||
//MainPanelDelegate *MainPanelControl::delegate() const
|
||||
//{
|
||||
// return m_delegate;
|
||||
//}
|
||||
|
||||
void MainPanelControl::setDelegate(MainPanelDelegate *delegate)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
void getTrayVisableItemCount();
|
||||
void updatePluginsLayout();
|
||||
|
||||
MainPanelDelegate *delegate() const;
|
||||
// MainPanelDelegate *delegate() const;
|
||||
void setDelegate(MainPanelDelegate *delegate);
|
||||
|
||||
public slots:
|
||||
|
@ -144,6 +144,10 @@ MainWindow::~MainWindow()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::launch
|
||||
* 任务栏初次启动时调用此方法,里面是做了一些初始化操作
|
||||
*/
|
||||
void MainWindow::launch()
|
||||
{
|
||||
if (!qApp->property("CANSHOW").toBool())
|
||||
@ -156,6 +160,13 @@ void MainWindow::launch()
|
||||
m_shadowMaskOptimizeTimer->start();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::callShow
|
||||
* 此方法是被外部进程通过DBus调用的。
|
||||
* @note 当任务栏以-r参数启动时,其不会显示界面,需要在外部通过DBus调用此接口之后才会显示界面,
|
||||
* 这里是以前为了优化任务栏的启动速度做的处理,当任务栏启动时,此时窗管进程可能还未启动完全,
|
||||
* 部分设置未初始化完等,导致任务栏显示的界面异常,所以留下此接口,被startdde延后调用
|
||||
*/
|
||||
void MainWindow::callShow()
|
||||
{
|
||||
static bool flag = false;
|
||||
@ -175,6 +186,10 @@ void MainWindow::callShow()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::relaodPlugins
|
||||
* 需要重新加载插件时,此接口会被调用,目前是用于任务栏的安全模式退出时调用
|
||||
*/
|
||||
void MainWindow::relaodPlugins()
|
||||
{
|
||||
if (qApp->property("PLUGINSLOADED").toBool()) {
|
||||
@ -362,11 +377,18 @@ void MainWindow::initConnections()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::getTrayVisableItemCount
|
||||
* 重新获取以下当前托盘区域有多少个可见的图标,并更新图标的大小
|
||||
*/
|
||||
void MainWindow::getTrayVisableItemCount()
|
||||
{
|
||||
m_mainPanel->getTrayVisableItemCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::adjustShadowMask 更新任务栏的圆角大小(时尚模式下才有圆角效果)
|
||||
*/
|
||||
void MainWindow::adjustShadowMask()
|
||||
{
|
||||
if (!m_launched || m_shadowMaskOptimizeTimer->isActive())
|
||||
@ -397,6 +419,10 @@ void MainWindow::onDbusNameOwnerChanged(const QString &name, const QString &oldO
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::setEffectEnabled
|
||||
* @param enabled 根据当前系统是否enabled特效来更新任务栏的外观样式
|
||||
*/
|
||||
void MainWindow::setEffectEnabled(const bool enabled)
|
||||
{
|
||||
setMaskColor(AutoColor);
|
||||
@ -406,16 +432,29 @@ void MainWindow::setEffectEnabled(const bool enabled)
|
||||
m_platformWindowHandle.setBorderWidth(enabled ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::setComposite
|
||||
* @param hasComposite 系统是否支持混成(也就是特效)
|
||||
*/
|
||||
void MainWindow::setComposite(const bool hasComposite)
|
||||
{
|
||||
setEffectEnabled(hasComposite);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::appIsOnDock 判断应用是否驻留在任务栏上
|
||||
* @param appDesktop 应用的desktop文件的完整路径
|
||||
* @return true: 驻留;false:未驻留
|
||||
*/
|
||||
bool MainWindow::appIsOnDock(const QString &appDesktop)
|
||||
{
|
||||
return DockItemManager::instance()->appIsOnDock(appDesktop);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::resetDragWindow 更新任务栏的拖拽区域
|
||||
* @note 任务栏远离屏幕的一边是支持拖拽的,由一个不可见的widget提拽支持,当任务栏的geometry发生变化的时候,此拖拽区域也需要更新其自身的geometry
|
||||
*/
|
||||
void MainWindow::resetDragWindow()
|
||||
{
|
||||
switch (m_multiScreenWorker->position()) {
|
||||
@ -468,6 +507,10 @@ void MainWindow::resetDragWindow()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::onMainWindowSizeChanged 任务栏拖拽过程中会不听调用此方法更新自身大小
|
||||
* @param offset 拖拽时的坐标偏移量
|
||||
*/
|
||||
void MainWindow::onMainWindowSizeChanged(QPoint offset)
|
||||
{
|
||||
const QRect &rect = m_multiScreenWorker->dockRect(m_multiScreenWorker->deskScreen()
|
||||
@ -512,6 +555,10 @@ void MainWindow::onMainWindowSizeChanged(QPoint offset)
|
||||
move(newRect.topLeft());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::themeTypeChanged 系统主题发生变化时,此方法被调用
|
||||
* @param themeType 当前系统主题
|
||||
*/
|
||||
void MainWindow::themeTypeChanged(DGuiApplicationHelper::ColorType themeType)
|
||||
{
|
||||
if (m_wmHelper->hasComposite()) {
|
||||
@ -522,6 +569,9 @@ void MainWindow::themeTypeChanged(DGuiApplicationHelper::ColorType themeType)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::touchRequestResizeDock 触屏情况用手指调整任务栏高度或宽度
|
||||
*/
|
||||
void MainWindow::touchRequestResizeDock()
|
||||
{
|
||||
const QPoint touchPos(QCursor::pos());
|
||||
@ -562,6 +612,10 @@ void MainWindow::touchRequestResizeDock()
|
||||
, Qt::NoModifier, Qt::MouseEventSynthesizedByApplication));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::setGeometry
|
||||
* @param rect 设置任务栏的位置和大小,重写此函数时为了及时发出panelGeometryChanged信号,最终供外部DBus调用方使用
|
||||
*/
|
||||
void MainWindow::setGeometry(const QRect &rect)
|
||||
{
|
||||
if (rect == this->geometry()) {
|
||||
|
@ -88,6 +88,6 @@ TEST_F(Test_MainPanelControl, cover_test)
|
||||
mainPanel->removeAppAreaItem(new QWidget);
|
||||
mainPanel->removeTrayAreaItem(new QWidget);
|
||||
mainPanel->updateAppAreaSonWidgetSize();
|
||||
mainPanel->setDelegate(mainPanel->delegate());
|
||||
// mainPanel->setDelegate(mainPanel->delegate());
|
||||
mainPanel->checkNeedShowDesktop();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user