mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +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)
|
: QWidget(parent)
|
||||||
, m_mainPanelLayout(new QBoxLayout(QBoxLayout::LeftToRight, this))
|
, m_mainPanelLayout(new QBoxLayout(QBoxLayout::LeftToRight, this))
|
||||||
, m_fixedAreaWidget(new QWidget(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_fixedAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||||
, m_trayAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
, m_fixedSpliter(new QLabel(this))
|
||||||
, m_pluginLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
, m_appAreaWidget(new QWidget(this))
|
||||||
, m_appAreaSonWidget(new QWidget(this))
|
, m_appAreaSonWidget(new QWidget(this))
|
||||||
, m_appAreaSonLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
, 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_position(Position::Bottom)
|
||||||
, m_placeholderItem(nullptr)
|
, m_placeholderItem(nullptr)
|
||||||
, m_appDragWidget(nullptr)
|
, m_appDragWidget(nullptr)
|
||||||
, m_dislayMode(Efficient)
|
, m_dislayMode(Efficient)
|
||||||
, m_fixedSpliter(new QLabel(this))
|
|
||||||
, m_appSpliter(new QLabel(this))
|
|
||||||
, m_traySpliter(new QLabel(this))
|
|
||||||
, m_isHover(false)
|
, m_isHover(false)
|
||||||
, m_needRecoveryWin(false)
|
, m_needRecoveryWin(false)
|
||||||
, m_isEnableLaunch(true)
|
, m_isEnableLaunch(true)
|
||||||
{
|
{
|
||||||
init();
|
initUi();
|
||||||
updateMainPanelLayout();
|
updateMainPanelLayout();
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
@ -101,60 +101,54 @@ MainPanelControl::~MainPanelControl()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::init()
|
void MainPanelControl::initUi()
|
||||||
{
|
{
|
||||||
// 主窗口
|
/* 固定区域 */
|
||||||
m_fixedSpliter->setObjectName("spliter_fix");
|
m_fixedAreaWidget->setObjectName("fixedarea");
|
||||||
m_appSpliter->setObjectName("spliter_app");
|
m_fixedAreaWidget->setLayout(m_fixedAreaLayout);
|
||||||
m_traySpliter->setObjectName("spliter_tray");
|
m_fixedAreaLayout->setSpacing(0);
|
||||||
|
m_fixedAreaLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
m_appAreaWidget->setAccessibleName("AppFullArea");
|
|
||||||
|
|
||||||
m_mainPanelLayout->addWidget(m_fixedAreaWidget);
|
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_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_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->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->addWidget(m_desktopWidget);
|
||||||
|
|
||||||
|
m_mainPanelLayout->setSpacing(0);
|
||||||
|
m_mainPanelLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
connect(GSettingsByLaunch(), &QGSettings::changed, this, &MainPanelControl::onGSettingsChanged);
|
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;
|
return;
|
||||||
m_dislayMode = mode;
|
m_dislayMode = dislayMode;
|
||||||
updateDisplayMode();
|
updateDisplayMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,8 @@ class DesktopWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DesktopWidget(QWidget *parent) : QWidget(parent){
|
explicit DesktopWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,40 +62,49 @@ public:
|
|||||||
explicit MainPanelControl(QWidget *parent = nullptr);
|
explicit MainPanelControl(QWidget *parent = nullptr);
|
||||||
~MainPanelControl() override;
|
~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 setPositonValue(Position position);
|
||||||
void setDisplayMode(DisplayMode m_displayMode);
|
void setDisplayMode(DisplayMode dislayMode);
|
||||||
void getTrayVisableItemCount();
|
void getTrayVisableItemCount();
|
||||||
|
|
||||||
MainPanelDelegate *delegate() const;
|
MainPanelDelegate *delegate() const;
|
||||||
void setDelegate(MainPanelDelegate *delegate);
|
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:
|
signals:
|
||||||
void itemMoved(DockItem *sourceItem, DockItem *targetItem);
|
void itemMoved(DockItem *sourceItem, DockItem *targetItem);
|
||||||
void itemAdded(const QString &appDesktop, int idx);
|
void itemAdded(const QString &appDesktop, int idx);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
void init();
|
|
||||||
void updateAppAreaSonWidgetSize();
|
|
||||||
void updateMainPanelLayout();
|
|
||||||
void updateDisplayMode();
|
|
||||||
void moveAppSonWidget();
|
|
||||||
|
|
||||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||||
void dragEnterEvent(QDragEnterEvent *e) override;
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
||||||
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
||||||
void dropEvent(QDropEvent *) override;
|
void dropEvent(QDropEvent *) override;
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
void mousePressEvent(QMouseEvent *e) 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 *);
|
void startDrag(DockItem *);
|
||||||
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
||||||
@ -106,44 +116,35 @@ private:
|
|||||||
void resizeDesktopWidget();
|
void resizeDesktopWidget();
|
||||||
bool checkNeedShowDesktop();
|
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:
|
private:
|
||||||
QBoxLayout *m_mainPanelLayout;
|
QBoxLayout *m_mainPanelLayout;
|
||||||
QWidget *m_fixedAreaWidget;
|
|
||||||
QWidget *m_appAreaWidget;
|
QWidget *m_fixedAreaWidget; // 固定区域
|
||||||
QWidget *m_trayAreaWidget;
|
QBoxLayout *m_fixedAreaLayout; //
|
||||||
QWidget *m_pluginAreaWidget;
|
QLabel *m_fixedSpliter; // 固定区域与应用区域间的分割线
|
||||||
DesktopWidget *m_desktopWidget;
|
QWidget *m_appAreaWidget; // 应用区域
|
||||||
QBoxLayout *m_fixedAreaLayout;
|
QWidget *m_appAreaSonWidget; // 子应用区域
|
||||||
QBoxLayout *m_trayAreaLayout;
|
QBoxLayout *m_appAreaSonLayout; //
|
||||||
QBoxLayout *m_pluginLayout;
|
QLabel *m_appSpliter; // 应用区域与托盘区域间的分割线
|
||||||
QWidget *m_appAreaSonWidget;
|
QWidget *m_trayAreaWidget; // 托盘区域
|
||||||
QBoxLayout *m_appAreaSonLayout;
|
QBoxLayout *m_trayAreaLayout; //
|
||||||
// QBoxLayout *m_appAreaLayout;
|
QLabel *m_traySpliter; // 托盘区域与插件区域间的分割线
|
||||||
|
QWidget *m_pluginAreaWidget; // 插件区域
|
||||||
|
QBoxLayout *m_pluginLayout; //
|
||||||
|
DesktopWidget *m_desktopWidget; // 桌面预览区域
|
||||||
|
|
||||||
Position m_position;
|
Position m_position;
|
||||||
QPointer<PlaceholderItem> m_placeholderItem;
|
QPointer<PlaceholderItem> m_placeholderItem;
|
||||||
MainPanelDelegate *m_delegate;
|
MainPanelDelegate *m_delegate;
|
||||||
QString m_draggingMimeKey;
|
QString m_draggingMimeKey;
|
||||||
AppDragWidget *m_appDragWidget;
|
AppDragWidget *m_appDragWidget;
|
||||||
DisplayMode m_dislayMode;
|
DisplayMode m_dislayMode;
|
||||||
QLabel *m_fixedSpliter;
|
|
||||||
QLabel *m_appSpliter;
|
|
||||||
QLabel *m_traySpliter;
|
|
||||||
QPoint m_mousePressPos;
|
QPoint m_mousePressPos;
|
||||||
int m_trayIconCount;
|
int m_trayIconCount;
|
||||||
TrayPluginItem *m_tray = nullptr;
|
TrayPluginItem *m_tray = nullptr;
|
||||||
bool m_isHover;//判断鼠标是否移到desktop区域
|
bool m_isHover; // 判断鼠标是否移到desktop区域
|
||||||
bool m_needRecoveryWin; // 判断鼠标移出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
|
#endif // MAINPANELCONTROL_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user