mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat: Optimize code structure
调整任务栏布局的代码结构,删除无用代码。 Log: 调整任务栏布局的代码结构。 Change-Id: Ic2f2fba9567580fd3852b892ce714c190d3b5a02
This commit is contained in:
parent
d7a2f1577c
commit
ea2ec0396a
@ -58,27 +58,27 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_mainPanelLayout(new QBoxLayout(QBoxLayout::LeftToRight, this))
|
||||
, m_fixedAreaWidget(new QWidget(this))
|
||||
, m_appAreaWidget(new QWidget(this))
|
||||
, m_trayAreaWidget(new QWidget(this))
|
||||
, m_pluginAreaWidget(new QWidget(this))
|
||||
, m_desktopWidget(new DesktopWidget(this))
|
||||
, m_fixedAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
, m_trayAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
, m_pluginLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
, m_fixedSpliter(new QLabel(this))
|
||||
, m_appAreaWidget(new QWidget(this))
|
||||
, m_appAreaSonWidget(new QWidget(this))
|
||||
, m_appAreaSonLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
, m_appSpliter(new QLabel(this))
|
||||
, m_trayAreaWidget(new QWidget(this))
|
||||
, m_trayAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
, m_traySpliter(new QLabel(this))
|
||||
, m_pluginAreaWidget(new QWidget(this))
|
||||
, m_pluginLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
, m_desktopWidget(new DesktopWidget(this))
|
||||
, m_position(Position::Bottom)
|
||||
, m_placeholderItem(nullptr)
|
||||
, m_appDragWidget(nullptr)
|
||||
, m_dislayMode(Efficient)
|
||||
, m_fixedSpliter(new QLabel(this))
|
||||
, m_appSpliter(new QLabel(this))
|
||||
, m_traySpliter(new QLabel(this))
|
||||
, m_isHover(false)
|
||||
, m_needRecoveryWin(false)
|
||||
, m_isEnableLaunch(true)
|
||||
{
|
||||
init();
|
||||
initUi();
|
||||
updateMainPanelLayout();
|
||||
setAcceptDrops(true);
|
||||
setMouseTracking(true);
|
||||
@ -101,60 +101,54 @@ MainPanelControl::~MainPanelControl()
|
||||
{
|
||||
}
|
||||
|
||||
void MainPanelControl::init()
|
||||
void MainPanelControl::initUi()
|
||||
{
|
||||
// 主窗口
|
||||
m_fixedSpliter->setObjectName("spliter_fix");
|
||||
m_appSpliter->setObjectName("spliter_app");
|
||||
m_traySpliter->setObjectName("spliter_tray");
|
||||
|
||||
m_appAreaWidget->setAccessibleName("AppFullArea");
|
||||
|
||||
/* 固定区域 */
|
||||
m_fixedAreaWidget->setObjectName("fixedarea");
|
||||
m_fixedAreaWidget->setLayout(m_fixedAreaLayout);
|
||||
m_fixedAreaLayout->setSpacing(0);
|
||||
m_fixedAreaLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_mainPanelLayout->addWidget(m_fixedAreaWidget);
|
||||
m_mainPanelLayout->addWidget(m_fixedSpliter);
|
||||
|
||||
m_fixedSpliter->setObjectName("spliter_fix");
|
||||
m_mainPanelLayout->addWidget(m_fixedSpliter, Qt::AlignCenter);
|
||||
|
||||
/* 应用程序区域 */
|
||||
m_appAreaWidget->setAccessibleName("AppFullArea");
|
||||
m_mainPanelLayout->addWidget(m_appAreaWidget);
|
||||
m_mainPanelLayout->addWidget(m_appSpliter);
|
||||
m_appAreaSonLayout->setSpacing(0);
|
||||
m_appAreaSonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_appAreaSonWidget->setObjectName("apparea");
|
||||
m_appAreaSonWidget->setLayout(m_appAreaSonLayout);
|
||||
m_appAreaSonLayout->setSpacing(0);
|
||||
m_appAreaSonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_appSpliter->setObjectName("spliter_app");
|
||||
m_mainPanelLayout->addWidget(m_appSpliter, Qt::AlignCenter);
|
||||
|
||||
/* 托盘区域 */
|
||||
m_trayAreaWidget->setObjectName("trayarea");
|
||||
m_trayAreaWidget->setLayout(m_trayAreaLayout);
|
||||
m_trayAreaLayout->setSpacing(0);
|
||||
m_trayAreaLayout->setContentsMargins(0, 10, 0, 10);
|
||||
m_mainPanelLayout->addWidget(m_trayAreaWidget);
|
||||
m_mainPanelLayout->addWidget(m_traySpliter);
|
||||
|
||||
m_traySpliter->setObjectName("spliter_tray");
|
||||
m_mainPanelLayout->addWidget(m_traySpliter, Qt::AlignCenter);
|
||||
|
||||
/* 插件区域 */
|
||||
m_pluginAreaWidget->setObjectName("pluginarea");
|
||||
m_pluginAreaWidget->setLayout(m_pluginLayout);
|
||||
m_pluginLayout->setSpacing(10);
|
||||
m_pluginLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_mainPanelLayout->addWidget(m_pluginAreaWidget);
|
||||
|
||||
m_mainPanelLayout->setMargin(0);
|
||||
m_mainPanelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_mainPanelLayout->setSpacing(0);
|
||||
m_mainPanelLayout->setAlignment(m_fixedSpliter, Qt::AlignCenter);
|
||||
m_mainPanelLayout->setAlignment(m_appSpliter, Qt::AlignCenter);
|
||||
m_mainPanelLayout->setAlignment(m_traySpliter, Qt::AlignCenter);
|
||||
|
||||
// 固定区域
|
||||
m_fixedAreaWidget->setLayout(m_fixedAreaLayout);
|
||||
m_fixedAreaWidget->setObjectName("fixedarea");
|
||||
m_fixedAreaLayout->setMargin(0);
|
||||
m_fixedAreaLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_fixedAreaLayout->setSpacing(0);
|
||||
|
||||
// 应用程序
|
||||
m_appAreaSonWidget->setLayout(m_appAreaSonLayout);
|
||||
m_appAreaSonWidget->setObjectName("apparea");
|
||||
m_appAreaSonLayout->setMargin(0);
|
||||
m_appAreaSonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_appAreaSonLayout->setSpacing(0);
|
||||
|
||||
// 托盘
|
||||
m_trayAreaWidget->setLayout(m_trayAreaLayout);
|
||||
m_trayAreaWidget->setObjectName("trayarea");
|
||||
m_trayAreaLayout->setMargin(0);
|
||||
m_trayAreaLayout->setContentsMargins(0, 10, 0, 10);
|
||||
m_trayAreaLayout->setSpacing(0);
|
||||
|
||||
// 插件
|
||||
m_pluginAreaWidget->setLayout(m_pluginLayout);
|
||||
m_pluginAreaWidget->setObjectName("pluginarea");
|
||||
m_pluginLayout->setMargin(0);
|
||||
m_pluginLayout->setSpacing(10);
|
||||
|
||||
//桌面
|
||||
/* 桌面预览 */
|
||||
m_mainPanelLayout->addWidget(m_desktopWidget);
|
||||
|
||||
m_mainPanelLayout->setSpacing(0);
|
||||
m_mainPanelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
connect(GSettingsByLaunch(), &QGSettings::changed, this, &MainPanelControl::onGSettingsChanged);
|
||||
}
|
||||
|
||||
@ -180,11 +174,11 @@ void MainPanelControl::onGSettingsChanged(const QString &key)
|
||||
}
|
||||
}
|
||||
|
||||
void MainPanelControl::setDisplayMode(DisplayMode mode)
|
||||
void MainPanelControl::setDisplayMode(DisplayMode dislayMode)
|
||||
{
|
||||
if (mode == m_dislayMode)
|
||||
if (dislayMode == m_dislayMode)
|
||||
return;
|
||||
m_dislayMode = mode;
|
||||
m_dislayMode = dislayMode;
|
||||
updateDisplayMode();
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,8 @@ class DesktopWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DesktopWidget(QWidget *parent) : QWidget(parent){
|
||||
explicit DesktopWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@ -61,40 +62,49 @@ public:
|
||||
explicit MainPanelControl(QWidget *parent = nullptr);
|
||||
~MainPanelControl() override;
|
||||
|
||||
void addFixedAreaItem(int index, QWidget *wdg);
|
||||
void addAppAreaItem(int index, QWidget *wdg);
|
||||
void addTrayAreaItem(int index, QWidget *wdg);
|
||||
void addPluginAreaItem(int index, QWidget *wdg);
|
||||
void removeFixedAreaItem(QWidget *wdg);
|
||||
void removeAppAreaItem(QWidget *wdg);
|
||||
void removeTrayAreaItem(QWidget *wdg);
|
||||
void removePluginAreaItem(QWidget *wdg);
|
||||
void setPositonValue(Position position);
|
||||
void setDisplayMode(DisplayMode m_displayMode);
|
||||
void setDisplayMode(DisplayMode dislayMode);
|
||||
void getTrayVisableItemCount();
|
||||
|
||||
MainPanelDelegate *delegate() const;
|
||||
void setDelegate(MainPanelDelegate *delegate);
|
||||
|
||||
public slots:
|
||||
void insertItem(const int index, DockItem *item);
|
||||
void removeItem(DockItem *item);
|
||||
void itemUpdated(DockItem *item);
|
||||
|
||||
void onGSettingsChanged(const QString &key);
|
||||
|
||||
signals:
|
||||
void itemMoved(DockItem *sourceItem, DockItem *targetItem);
|
||||
void itemAdded(const QString &appDesktop, int idx);
|
||||
|
||||
private:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
void init();
|
||||
void updateAppAreaSonWidgetSize();
|
||||
void updateMainPanelLayout();
|
||||
void updateDisplayMode();
|
||||
void moveAppSonWidget();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||
void dragEnterEvent(QDragEnterEvent *e) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
||||
void dropEvent(QDropEvent *) override;
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
void initUi();
|
||||
void updateAppAreaSonWidgetSize();
|
||||
void updateMainPanelLayout();
|
||||
void updateDisplayMode();
|
||||
void moveAppSonWidget();
|
||||
|
||||
void addFixedAreaItem(int index, QWidget *wdg);
|
||||
void removeFixedAreaItem(QWidget *wdg);
|
||||
void addAppAreaItem(int index, QWidget *wdg);
|
||||
void removeAppAreaItem(QWidget *wdg);
|
||||
void addTrayAreaItem(int index, QWidget *wdg);
|
||||
void removeTrayAreaItem(QWidget *wdg);
|
||||
void addPluginAreaItem(int index, QWidget *wdg);
|
||||
void removePluginAreaItem(QWidget *wdg);
|
||||
|
||||
void startDrag(DockItem *);
|
||||
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
||||
@ -106,44 +116,35 @@ private:
|
||||
void resizeDesktopWidget();
|
||||
bool checkNeedShowDesktop();
|
||||
|
||||
public slots:
|
||||
void insertItem(const int index, DockItem *item);
|
||||
void removeItem(DockItem *item);
|
||||
void itemUpdated(DockItem *item);
|
||||
|
||||
// void
|
||||
void onGSettingsChanged(const QString &key);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
private:
|
||||
QBoxLayout *m_mainPanelLayout;
|
||||
QWidget *m_fixedAreaWidget;
|
||||
QWidget *m_appAreaWidget;
|
||||
QWidget *m_trayAreaWidget;
|
||||
QWidget *m_pluginAreaWidget;
|
||||
DesktopWidget *m_desktopWidget;
|
||||
QBoxLayout *m_fixedAreaLayout;
|
||||
QBoxLayout *m_trayAreaLayout;
|
||||
QBoxLayout *m_pluginLayout;
|
||||
QWidget *m_appAreaSonWidget;
|
||||
QBoxLayout *m_appAreaSonLayout;
|
||||
// QBoxLayout *m_appAreaLayout;
|
||||
|
||||
QWidget *m_fixedAreaWidget; // 固定区域
|
||||
QBoxLayout *m_fixedAreaLayout; //
|
||||
QLabel *m_fixedSpliter; // 固定区域与应用区域间的分割线
|
||||
QWidget *m_appAreaWidget; // 应用区域
|
||||
QWidget *m_appAreaSonWidget; // 子应用区域
|
||||
QBoxLayout *m_appAreaSonLayout; //
|
||||
QLabel *m_appSpliter; // 应用区域与托盘区域间的分割线
|
||||
QWidget *m_trayAreaWidget; // 托盘区域
|
||||
QBoxLayout *m_trayAreaLayout; //
|
||||
QLabel *m_traySpliter; // 托盘区域与插件区域间的分割线
|
||||
QWidget *m_pluginAreaWidget; // 插件区域
|
||||
QBoxLayout *m_pluginLayout; //
|
||||
DesktopWidget *m_desktopWidget; // 桌面预览区域
|
||||
|
||||
Position m_position;
|
||||
QPointer<PlaceholderItem> m_placeholderItem;
|
||||
MainPanelDelegate *m_delegate;
|
||||
QString m_draggingMimeKey;
|
||||
AppDragWidget *m_appDragWidget;
|
||||
DisplayMode m_dislayMode;
|
||||
QLabel *m_fixedSpliter;
|
||||
QLabel *m_appSpliter;
|
||||
QLabel *m_traySpliter;
|
||||
QPoint m_mousePressPos;
|
||||
int m_trayIconCount;
|
||||
TrayPluginItem *m_tray = nullptr;
|
||||
bool m_isHover;//判断鼠标是否移到desktop区域
|
||||
bool m_isHover; // 判断鼠标是否移到desktop区域
|
||||
bool m_needRecoveryWin; // 判断鼠标移出desktop区域是否恢复之前窗口
|
||||
bool m_isEnableLaunch;//判断是否使能了com.deepin.dde.dock.module.launcher
|
||||
bool m_isEnableLaunch; // 判断是否使能了com.deepin.dde.dock.module.launcher
|
||||
};
|
||||
|
||||
#endif // MAINPANELCONTROL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user