mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
chore: 整理代码
删除用不到的内容 Log: Task: https://pms.uniontech.com/zentao/task-view-86488.html Change-Id: I5eb0b09cef1d504640cc676d2059cd2dfacaafaa
This commit is contained in:
parent
916ab6482b
commit
14d1f5d52a
@ -61,6 +61,7 @@ include_directories(
|
||||
frame/item/resources
|
||||
frame/util
|
||||
frame/window
|
||||
frame/window/components
|
||||
frame/xcb
|
||||
../widgets
|
||||
../interfaces
|
||||
@ -71,10 +72,11 @@ aux_source_directory(frame/dbus DBUS)
|
||||
aux_source_directory(frame/dbus/sni SNI)
|
||||
aux_source_directory(frame/display DISPLAY)
|
||||
aux_source_directory(frame/item ITEM)
|
||||
aux_source_directory(frame/item/components COMPONENTS)
|
||||
aux_source_directory(frame/item/components ITEMCOMPONENTS)
|
||||
aux_source_directory(frame/item/resources RESOURCES)
|
||||
aux_source_directory(frame/util UTIL)
|
||||
aux_source_directory(frame/window WINDOW)
|
||||
aux_source_directory(frame/window/components WINDOWCOMPONENTS)
|
||||
aux_source_directory(frame/xcb XCB)
|
||||
|
||||
file(GLOB SRC_PATH
|
||||
@ -84,9 +86,10 @@ file(GLOB SRC_PATH
|
||||
${SNI}
|
||||
${DISPLAY}
|
||||
${ITEM}
|
||||
${COMPONENTS}
|
||||
${ITEMCOMPONENTS}
|
||||
${UTIL}
|
||||
${WINDOW}
|
||||
${WINDOWCOMPONENTS}
|
||||
${XCB}
|
||||
)
|
||||
|
||||
|
@ -28,7 +28,11 @@ pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||
pkg_check_modules(DtkGUI REQUIRED dtkgui)
|
||||
|
||||
# driver-manager
|
||||
add_executable(${BIN_NAME} ${SRCS} ${INTERFACES} ${SRC_PATH} item/item.qrc)
|
||||
add_executable(${BIN_NAME}
|
||||
${SRCS}
|
||||
${INTERFACES}
|
||||
${SRC_PATH}
|
||||
item/item.qrc)
|
||||
|
||||
target_include_directories(${BIN_NAME} PUBLIC
|
||||
${DtkWidget_INCLUDE_DIRS}
|
||||
@ -49,6 +53,7 @@ target_include_directories(${BIN_NAME} PUBLIC
|
||||
item/components
|
||||
util
|
||||
window
|
||||
window/components
|
||||
xcb
|
||||
../plugins/tray
|
||||
../plugins/show-desktop
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "mainpanelcontrol.h"
|
||||
#include "desktop_widget.h"
|
||||
#include "tipswidget.h"
|
||||
#include "dockpopupwindow.h"
|
||||
#include "statebutton.h"
|
||||
|
||||
#include "launcheritem.h"
|
||||
#include "appitem.h"
|
||||
@ -113,7 +113,6 @@ SET_FORM_ACCESSIBLE(QScrollArea, "QScrollArea")
|
||||
SET_FORM_ACCESSIBLE(QFrame, "QFrame")
|
||||
SET_FORM_ACCESSIBLE(QGraphicsView, "QGraphicsView")
|
||||
SET_FORM_ACCESSIBLE(DragWidget, "DragWidget")
|
||||
SET_FORM_ACCESSIBLE(StateButton, "StateButton")
|
||||
|
||||
QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object)
|
||||
{
|
||||
@ -178,7 +177,6 @@ QAccessibleInterface *accessibleFactory(const QString &classname, QObject *objec
|
||||
ELSE_USE_ACCESSIBLE(classname, QFrame)
|
||||
ELSE_USE_ACCESSIBLE(classname, QGraphicsView)
|
||||
ELSE_USE_ACCESSIBLE(classname, DragWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, StateButton)
|
||||
ELSE_USE_ACCESSIBLE(classname, HorizontalSeperator);
|
||||
|
||||
if (!interface && object->inherits("QWidget") && !ignoreLst.contains(classname)) {
|
||||
|
@ -42,7 +42,7 @@ void TrayPluginItem::setRightSplitVisible(const bool visible)
|
||||
QMetaObject::invokeMethod(centralWidget(), "setRightSplitVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
|
||||
}
|
||||
|
||||
int TrayPluginItem::trayVisableItemCount()
|
||||
int TrayPluginItem::trayVisibleItemCount()
|
||||
{
|
||||
return m_trayVisableItemCount;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
void setSuggestIconSize(QSize size);
|
||||
void setRightSplitVisible(const bool visible);
|
||||
int trayVisableItemCount();
|
||||
int trayVisibleItemCount();
|
||||
|
||||
Q_SIGNALS:
|
||||
void trayVisableCountChanged(const int &count) const;
|
||||
|
@ -1,87 +0,0 @@
|
||||
#include "statebutton.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPainter>
|
||||
#include <QtMath>
|
||||
|
||||
StateButton::StateButton(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_type(Check)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
}
|
||||
|
||||
void StateButton::setType(StateButton::Type type)
|
||||
{
|
||||
m_type = type;
|
||||
update();
|
||||
}
|
||||
|
||||
void StateButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
int radius = qMin(width(), height());
|
||||
painter.setPen(QPen(Qt::NoPen));
|
||||
painter.setBrush(palette().color(QPalette::Highlight));
|
||||
painter.drawPie(rect(), 0, 360 * 16);
|
||||
|
||||
QPen pen(Qt::white, radius / 100.0 * 6.20, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
|
||||
switch (m_type) {
|
||||
case Check: drawCheck(painter, pen, radius); break;
|
||||
case Fork: drawFork(painter, pen, radius); break;
|
||||
}
|
||||
}
|
||||
|
||||
void StateButton::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QWidget::mousePressEvent(event);
|
||||
emit click();
|
||||
}
|
||||
|
||||
void StateButton::enterEvent(QEvent *event)
|
||||
{
|
||||
QWidget::enterEvent(event);
|
||||
setType(Fork);
|
||||
}
|
||||
|
||||
void StateButton::leaveEvent(QEvent *event)
|
||||
{
|
||||
QWidget::leaveEvent(event);
|
||||
setType(Check);
|
||||
}
|
||||
|
||||
void StateButton::drawCheck(QPainter &painter, QPen &pen, int radius)
|
||||
{
|
||||
painter.setPen(pen);
|
||||
|
||||
QPointF points[3] = {
|
||||
QPointF(radius / 100.0 * 32, radius / 100.0 * 57),
|
||||
QPointF(radius / 100.0 * 45, radius / 100.0 * 70),
|
||||
QPointF(radius / 100.0 * 75, radius / 100.0 * 35)
|
||||
};
|
||||
|
||||
painter.drawPolyline(points, 3);
|
||||
}
|
||||
|
||||
void StateButton::drawFork(QPainter &painter, QPen &pen, int radius)
|
||||
{
|
||||
pen.setCapStyle(Qt::RoundCap);
|
||||
painter.setPen(pen);
|
||||
|
||||
QPointF pointsl[2] = {
|
||||
QPointF(radius / 100.0 * 35, radius / 100.0 * 35),
|
||||
QPointF(radius / 100.0 * 65, radius / 100.0 * 65)
|
||||
};
|
||||
|
||||
painter.drawPolyline(pointsl, 2);
|
||||
|
||||
QPointF pointsr[2] = {
|
||||
QPointF(radius / 100.0 * 65, radius / 100.0 * 35),
|
||||
QPointF(radius / 100.0 * 35, radius / 100.0 * 65)
|
||||
};
|
||||
|
||||
painter.drawPolyline(pointsr, 2);
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
#ifndef STATEBUTTON_H
|
||||
#define STATEBUTTON_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class StateButton : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
Check,
|
||||
Fork
|
||||
};
|
||||
|
||||
public:
|
||||
explicit StateButton(QWidget *parent = nullptr);
|
||||
void setType(Type type);
|
||||
|
||||
signals:
|
||||
void click();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
|
||||
private:
|
||||
void drawCheck(QPainter &painter, QPen &pen, int radius);
|
||||
void drawFork(QPainter &painter, QPen &pen, int radius);
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
};
|
||||
|
||||
#endif // STATEBUTTON_H
|
91
frame/window/components/desktop_widget.cpp
Normal file
91
frame/window/components/desktop_widget.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include "desktop_widget.h"
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QProcess>
|
||||
|
||||
DesktopWidget::DesktopWidget(QWidget *parent)
|
||||
: QWidget (parent)
|
||||
, m_isHover(false)
|
||||
, m_needRecoveryWin(false)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
void DesktopWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
//描绘桌面区域的颜色
|
||||
painter.setOpacity(1);
|
||||
QPen pen;
|
||||
QColor penColor(0, 0, 0, 25);
|
||||
pen.setWidth(2);
|
||||
pen.setColor(penColor);
|
||||
painter.setPen(pen);
|
||||
painter.drawRect(rect());
|
||||
if (m_isHover) {
|
||||
painter.fillRect(rect(), QColor(255, 255, 255, 51));
|
||||
} else {
|
||||
painter.fillRect(rect(), QColor(255, 255, 255, 25));
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopWidget::enterEvent(QEvent *event)
|
||||
{
|
||||
if (checkNeedShowDesktop()) {
|
||||
m_needRecoveryWin = true;
|
||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
||||
}
|
||||
|
||||
m_isHover = true;
|
||||
update();
|
||||
|
||||
return QWidget::enterEvent(event);
|
||||
}
|
||||
|
||||
void DesktopWidget::leaveEvent(QEvent *event)
|
||||
{
|
||||
// 鼠标移入时隐藏了窗口,移出时恢复
|
||||
if (m_needRecoveryWin) {
|
||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
||||
}
|
||||
|
||||
m_isHover = false;
|
||||
update();
|
||||
|
||||
return QWidget::leaveEvent(event);
|
||||
}
|
||||
|
||||
void DesktopWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (m_needRecoveryWin) {
|
||||
// 手动点击 显示桌面窗口 后,鼠标移出时不再调用显/隐窗口进程,以手动点击设置为准
|
||||
m_needRecoveryWin = false;
|
||||
} else {
|
||||
// 需求调整,鼠标移入,预览桌面时再点击显示桌面保持显示桌面状态,再点击才切换桌面显、隐状态
|
||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
||||
}
|
||||
}
|
||||
|
||||
QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ShowDesktopWidget::checkNeedShowDesktop 根据窗管提供接口(当前是否显示的桌面),提供鼠标
|
||||
* 移入 显示桌面窗口 区域时,是否需要显示桌面判断依据
|
||||
* @return 窗管返回 当前是桌面 或 窗管接口查询失败 返回false,否则true
|
||||
*/
|
||||
bool DesktopWidget::checkNeedShowDesktop()
|
||||
{
|
||||
QDBusInterface wmInter("com.deepin.wm", "/com/deepin/wm", "com.deepin.wm");
|
||||
QList<QVariant> argumentList;
|
||||
QDBusMessage reply = wmInter.callWithArgumentList(QDBus::Block, QStringLiteral("GetIsShowDesktop"), argumentList);
|
||||
if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 1) {
|
||||
return !reply.arguments().at(0).toBool();
|
||||
}
|
||||
|
||||
qDebug() << "wm call GetIsShowDesktop fail, res:" << reply.type();
|
||||
return false;
|
||||
}
|
27
frame/window/components/desktop_widget.h
Normal file
27
frame/window/components/desktop_widget.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef DESKTOP_WIDGET_H
|
||||
#define DESKTOP_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPaintEvent>
|
||||
#include <QEnterEvent>
|
||||
|
||||
class DesktopWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit DesktopWidget(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
bool checkNeedShowDesktop();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
bool m_isHover; // 判断鼠标是否移到desktop区域
|
||||
bool m_needRecoveryWin;
|
||||
};
|
||||
|
||||
#endif // DESKTOP_WIDGET_H
|
@ -29,6 +29,7 @@
|
||||
#include "dockitemmanager.h"
|
||||
#include "touchsignalmanager.h"
|
||||
#include "utils.h"
|
||||
#include "desktop_widget.h"
|
||||
|
||||
#include <QDrag>
|
||||
#include <QTimer>
|
||||
@ -36,6 +37,8 @@
|
||||
#include <QString>
|
||||
#include <QApplication>
|
||||
#include <QPointer>
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
#include <DWindowManagerHelper>
|
||||
@ -68,23 +71,17 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
, m_placeholderItem(nullptr)
|
||||
, m_appDragWidget(nullptr)
|
||||
, m_dislayMode(Efficient)
|
||||
, m_trayIconCount(0)
|
||||
, m_tray(nullptr)
|
||||
, m_isHover(false)
|
||||
, m_needRecoveryWin(false)
|
||||
, m_trashItem(nullptr)
|
||||
{
|
||||
initUi();
|
||||
initUI();
|
||||
updateMainPanelLayout();
|
||||
setAcceptDrops(true);
|
||||
setMouseTracking(true);
|
||||
m_desktopWidget->setMouseTracking(true);
|
||||
m_desktopWidget->setObjectName("showdesktoparea");
|
||||
|
||||
m_appAreaWidget->installEventFilter(this);
|
||||
m_appAreaSonWidget->installEventFilter(this);
|
||||
m_trayAreaWidget->installEventFilter(this);
|
||||
m_desktopWidget->installEventFilter(this);
|
||||
m_pluginAreaWidget->installEventFilter(this);
|
||||
|
||||
//在设置每条线大小前,应该设置fixedsize(0,0)
|
||||
@ -94,7 +91,7 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
m_traySpliter->setFixedSize(0,0);
|
||||
}
|
||||
|
||||
void MainPanelControl::initUi()
|
||||
void MainPanelControl::initUI()
|
||||
{
|
||||
/* 固定区域 */
|
||||
m_fixedAreaWidget->setObjectName("fixedarea");
|
||||
@ -644,25 +641,6 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
// 高效模式下,鼠标移入移出'显示桌面'区域的处理
|
||||
if (watched == m_desktopWidget) {
|
||||
if (event->type() == QEvent::Enter) {
|
||||
if (checkNeedShowDesktop()) {
|
||||
m_needRecoveryWin = true;
|
||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
||||
}
|
||||
m_isHover = true;
|
||||
update();
|
||||
} else if (event->type() == QEvent::Leave) {
|
||||
// 鼠标移入时隐藏了窗口,移出时恢复
|
||||
if (m_needRecoveryWin) {
|
||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
||||
}
|
||||
m_isHover = false;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
// 更新应用区域子控件大小以及位置
|
||||
if (watched == m_appAreaWidget) {
|
||||
if (event->type() == QEvent::Resize)
|
||||
@ -721,17 +699,6 @@ void MainPanelControl::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
m_mousePressPos = e->globalPos();
|
||||
|
||||
QRect rect(m_desktopWidget->pos(), m_desktopWidget->size());
|
||||
if (rect.contains(e->pos())) {
|
||||
if (m_needRecoveryWin) {
|
||||
// 手动点击 显示桌面窗口 后,鼠标移出时不再调用显/隐窗口进程,以手动点击设置为准
|
||||
m_needRecoveryWin = false;
|
||||
} else {
|
||||
// 需求调整,鼠标移入,预览桌面时再点击显示桌面保持显示桌面状态,再点击才切换桌面显、隐状态
|
||||
QProcess::startDetached("/usr/lib/deepin-daemon/desktop-toggle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget::mousePressEvent(e);
|
||||
@ -984,20 +951,6 @@ void MainPanelControl::paintEvent(QPaintEvent *event)
|
||||
painter.fillRect(m_fixedSpliter->geometry(), color);
|
||||
painter.fillRect(m_appSpliter->geometry(), color);
|
||||
painter.fillRect(m_traySpliter->geometry(), color);
|
||||
|
||||
//描绘桌面区域的颜色
|
||||
painter.setOpacity(1);
|
||||
QPen pen;
|
||||
QColor penColor(0, 0, 0, 25);
|
||||
pen.setWidth(2);
|
||||
pen.setColor(penColor);
|
||||
painter.setPen(pen);
|
||||
painter.drawRect(m_desktopWidget->geometry());
|
||||
if (m_isHover) {
|
||||
painter.fillRect(m_desktopWidget->geometry(), QColor(255, 255, 255, 51));
|
||||
return;
|
||||
}
|
||||
painter.fillRect(m_desktopWidget->geometry(), QColor(255, 255, 255, 25));
|
||||
}
|
||||
|
||||
/**重新计算任务栏上应用图标、插件图标的大小,并设置
|
||||
@ -1036,7 +989,7 @@ void MainPanelControl::resizeDockIcon()
|
||||
int totalLength = ((m_position == Position::Top) || (m_position == Position::Bottom)) ? width() : height();
|
||||
// 减去托盘间隔区域
|
||||
if (m_tray) {
|
||||
totalLength -= (m_tray->trayVisableItemCount() + 1) * 10;
|
||||
totalLength -= (m_tray->trayVisibleItemCount() + 1) * 10;
|
||||
}
|
||||
// 减去3个分割线的宽度
|
||||
totalLength -= 3 * SPLITER_SIZE;
|
||||
@ -1064,7 +1017,7 @@ void MainPanelControl::resizeDockIcon()
|
||||
// 参与计算的插件的个数(包含托盘和插件,垃圾桶,关机,屏幕键盘)
|
||||
int pluginCount = 0;
|
||||
if (m_tray) {
|
||||
pluginCount = m_tray->trayVisableItemCount() + (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
|
||||
pluginCount = m_tray->trayVisibleItemCount() + (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
|
||||
} else {
|
||||
pluginCount = (trashPlugin ? 1 : 0) + (shutdownPlugin ? 1 : 0) + (keyboardPlugin ? 1 : 0) + (notificationPlugin ? 1 : 0);
|
||||
}
|
||||
@ -1205,21 +1158,6 @@ void MainPanelControl::calcuDockIconSize(int w, int h, int traySize, PluginsItem
|
||||
}
|
||||
}
|
||||
|
||||
/**获取托盘插件的个数并更新任务栏图标大小
|
||||
* @brief MainPanelControl::getTrayVisableItemCount
|
||||
*/
|
||||
void MainPanelControl::getTrayVisableItemCount()
|
||||
{
|
||||
if (m_trayAreaLayout->count() > 0) {
|
||||
TrayPluginItem *w = static_cast<TrayPluginItem *>(m_trayAreaLayout->itemAt(0)->widget());
|
||||
m_trayIconCount = w->trayVisableItemCount();
|
||||
} else {
|
||||
m_trayIconCount = 0;
|
||||
}
|
||||
|
||||
resizeDockIcon();
|
||||
}
|
||||
|
||||
/**时尚模式没有‘显示桌面’区域
|
||||
* @brief MainPanelControl::resizeDesktopWidget
|
||||
*/
|
||||
|
@ -25,30 +25,20 @@
|
||||
#include "constants.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include <com_deepin_daemon_gesture.h>
|
||||
|
||||
using namespace Dock;
|
||||
using Gesture = com::deepin::daemon::Gesture;
|
||||
|
||||
class QBoxLayout;
|
||||
class QLabel;
|
||||
class TrayPluginItem;
|
||||
class PluginsItem;
|
||||
|
||||
class DesktopWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DesktopWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class DockItem;
|
||||
class PlaceholderItem;
|
||||
class AppDragWidget;
|
||||
class DesktopWidget;
|
||||
class MainPanelControl : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -57,7 +47,7 @@ public:
|
||||
|
||||
void setPositonValue(Position position);
|
||||
void setDisplayMode(DisplayMode dislayMode);
|
||||
void getTrayVisableItemCount();
|
||||
void resizeDockIcon();
|
||||
void updatePluginsLayout();
|
||||
|
||||
public slots:
|
||||
@ -69,17 +59,8 @@ signals:
|
||||
void itemMoved(DockItem *sourceItem, DockItem *targetItem);
|
||||
void itemAdded(const QString &appDesktop, int idx);
|
||||
|
||||
protected:
|
||||
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 initUI();
|
||||
void updateAppAreaSonWidgetSize();
|
||||
void updateMainPanelLayout();
|
||||
void updateDisplayMode();
|
||||
@ -94,17 +75,27 @@ private:
|
||||
void addPluginAreaItem(int index, QWidget *wdg);
|
||||
void removePluginAreaItem(QWidget *wdg);
|
||||
|
||||
// 拖拽相关
|
||||
void startDrag(DockItem *);
|
||||
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
||||
void moveItem(DockItem *sourceItem, DockItem *targetItem);
|
||||
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeDockIcon();
|
||||
|
||||
void calcuDockIconSize(int w, int h, int traySize, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin, PluginsItem *notificationPlugin);
|
||||
void resizeDesktopWidget();
|
||||
bool checkNeedShowDesktop();
|
||||
bool appIsOnDock(const QString &appDesktop);
|
||||
|
||||
protected:
|
||||
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;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
QBoxLayout *m_mainPanelLayout;
|
||||
|
||||
@ -128,10 +119,7 @@ private:
|
||||
AppDragWidget *m_appDragWidget;
|
||||
DisplayMode m_dislayMode;
|
||||
QPoint m_mousePressPos;
|
||||
int m_trayIconCount;
|
||||
TrayPluginItem *m_tray;
|
||||
bool m_isHover; // 判断鼠标是否移到desktop区域
|
||||
bool m_needRecoveryWin; // 判断鼠标移出desktop区域是否恢复之前窗口
|
||||
int m_dragIndex = -1; // 记录应用区域被拖拽图标的位置
|
||||
|
||||
PluginsItem *m_trashItem; // 垃圾箱插件(需要特殊处理一下)
|
||||
|
@ -314,7 +314,7 @@ void MainWindow::initConnections()
|
||||
connect(DockItemManager::instance(), &DockItemManager::itemInserted, m_mainPanel, &MainPanelControl::insertItem, Qt::DirectConnection);
|
||||
connect(DockItemManager::instance(), &DockItemManager::itemRemoved, m_mainPanel, &MainPanelControl::removeItem, Qt::DirectConnection);
|
||||
connect(DockItemManager::instance(), &DockItemManager::itemUpdated, m_mainPanel, &MainPanelControl::itemUpdated, Qt::DirectConnection);
|
||||
connect(DockItemManager::instance(), &DockItemManager::trayVisableCountChanged, this, &MainWindow::getTrayVisableItemCount, Qt::QueuedConnection);
|
||||
connect(DockItemManager::instance(), &DockItemManager::trayVisableCountChanged, this, &MainWindow::resizeDockIcon, Qt::QueuedConnection);
|
||||
connect(DockItemManager::instance(), &DockItemManager::requestWindowAutoHide, m_menuWorker, &MenuWorker::setAutoHide);
|
||||
connect(m_mainPanel, &MainPanelControl::itemMoved, DockItemManager::instance(), &DockItemManager::itemMoved, Qt::DirectConnection);
|
||||
connect(m_mainPanel, &MainPanelControl::itemAdded, DockItemManager::instance(), &DockItemManager::itemAdded, Qt::DirectConnection);
|
||||
@ -349,9 +349,9 @@ void MainWindow::initConnections()
|
||||
* @brief MainWindow::getTrayVisableItemCount
|
||||
* 重新获取以下当前托盘区域有多少个可见的图标,并更新图标的大小
|
||||
*/
|
||||
void MainWindow::getTrayVisableItemCount()
|
||||
void MainWindow::resizeDockIcon()
|
||||
{
|
||||
m_mainPanel->getTrayVisableItemCount();
|
||||
m_mainPanel->resizeDockIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,7 +159,7 @@ private:
|
||||
void initComponents();
|
||||
void initConnections();
|
||||
|
||||
void getTrayVisableItemCount();
|
||||
void resizeDockIcon();
|
||||
|
||||
signals:
|
||||
void panelGeometryChanged();
|
||||
|
@ -33,7 +33,7 @@ TEST_F(Ut_TrayPluginItem, coverage_test)
|
||||
item.setSuggestIconSize(QSize());
|
||||
item.setRightSplitVisible(true);
|
||||
|
||||
ASSERT_EQ(item.trayVisableItemCount(), 0);
|
||||
ASSERT_EQ(item.trayVisibleItemCount(), 0);
|
||||
|
||||
QMouseEvent event(QEvent::MouseButtonPress, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
|
||||
qApp->sendEvent(item.centralWidget(), &event);
|
||||
|
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2020 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* Maintainer: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "statebutton.h"
|
||||
|
||||
class Test_StateButton : public QObject, public ::testing::Test
|
||||
{};
|
||||
|
||||
TEST_F(Test_StateButton, statebutton_clicked_test)
|
||||
{
|
||||
StateButton button;
|
||||
QSignalSpy spy(&button, SIGNAL(click()));
|
||||
QTest::mousePress(&button, Qt::LeftButton, Qt::NoModifier);
|
||||
ASSERT_EQ(spy.count(), 1);
|
||||
}
|
||||
|
||||
TEST_F(Test_StateButton, event_test)
|
||||
{
|
||||
StateButton button;
|
||||
|
||||
QEvent event(QEvent::Enter);
|
||||
button.enterEvent(&event);
|
||||
|
||||
QEvent event2(QEvent::Leave);
|
||||
button.leaveEvent(&event2);
|
||||
|
||||
ASSERT_TRUE(true);
|
||||
}
|
||||
|
||||
TEST_F(Test_StateButton, paintEvent)
|
||||
{
|
||||
StateButton button;
|
||||
|
||||
QRect rect(0, 0, 10, 10);
|
||||
QPaintEvent e(rect);
|
||||
button.setType(StateButton::Check);
|
||||
button.paintEvent(&e);
|
||||
|
||||
button.setType(StateButton::Fork);
|
||||
button.paintEvent(&e);
|
||||
|
||||
QTest::qWait(10);
|
||||
button.setType(StateButton::Fork);
|
||||
ASSERT_EQ(button.m_type, StateButton::Fork);
|
||||
|
||||
QTest::qWait(10);
|
||||
button.setType(StateButton::Check);
|
||||
ASSERT_EQ(button.m_type, StateButton::Check);
|
||||
}
|
@ -61,30 +61,12 @@ void Test_MainPanelControl::TearDown()
|
||||
mainPanel = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_MainPanelControl, getTrayVisableItemCount)
|
||||
{
|
||||
MainPanelControl panel;
|
||||
TestPlugin plugin;
|
||||
|
||||
ASSERT_EQ(panel.m_trayIconCount, 0);
|
||||
panel.getTrayVisableItemCount();
|
||||
ASSERT_EQ(panel.m_trayIconCount, 0);
|
||||
|
||||
TrayPluginItem trayPluginItem(&plugin, "tray", "1.2.0");
|
||||
panel.addTrayAreaItem(0, &trayPluginItem);
|
||||
panel.getTrayVisableItemCount();
|
||||
}
|
||||
|
||||
TEST_F(Test_MainPanelControl, paintEvent)
|
||||
{
|
||||
MainPanelControl panel;
|
||||
QRect paintRect(0, 0, 10, 10);
|
||||
QPaintEvent event(paintRect);
|
||||
|
||||
panel.m_isHover = true;
|
||||
panel.paintEvent(&event);
|
||||
|
||||
panel.m_isHover = false;
|
||||
panel.paintEvent(&event);
|
||||
|
||||
ASSERT_TRUE(true);
|
||||
@ -147,12 +129,6 @@ TEST_F(Test_MainPanelControl, eventFilter)
|
||||
panel.eventFilter(mainPanel->m_appAreaSonWidget, &event);
|
||||
panel.eventFilter(mainPanel->m_appAreaWidget, &event);
|
||||
|
||||
QEvent enterEvent(QEvent::Enter);
|
||||
panel.eventFilter(mainPanel->m_desktopWidget, &enterEvent);
|
||||
|
||||
QEvent leaveEvent(QEvent::Leave);
|
||||
panel.eventFilter(mainPanel->m_desktopWidget, &leaveEvent);
|
||||
|
||||
QEvent moveEvent(QEvent::Move);
|
||||
panel.eventFilter(mainPanel->m_appAreaWidget, &moveEvent);
|
||||
|
||||
|
@ -137,7 +137,7 @@ TEST_F(Test_MainWindow, coverage_test)
|
||||
{
|
||||
MainWindow *window = new MainWindow;
|
||||
|
||||
window->getTrayVisableItemCount();
|
||||
window->resizeDockIcon();
|
||||
window->adjustShadowMask();
|
||||
window->resetDragWindow();
|
||||
window->onMainWindowSizeChanged(QPoint(10, 10));
|
||||
|
Loading…
x
Reference in New Issue
Block a user