mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
chore: 清除编译警告
清除编译警告和cppcheck检查出的警告信息 Log: Influence: 无 Task: https://pms.uniontech.com/zentao/task-view-96546.html Change-Id: I8b32b02c9d3a284029a39826516ab7b41132f236
This commit is contained in:
parent
7429f3ed33
commit
4b0166f59b
@ -309,6 +309,8 @@ void AppSnapshot::leaveEvent(QEvent *e)
|
||||
|
||||
void AppSnapshot::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
if (!m_wmHelper->hasComposite()) {
|
||||
|
@ -215,31 +215,12 @@ void PreviewContainer::appendSnapWidget(const WId wid)
|
||||
snap->fetchSnapshot();
|
||||
}
|
||||
|
||||
void PreviewContainer::updatePreviewCursor()
|
||||
{
|
||||
static QCursor *lastArrowCursor = nullptr;
|
||||
static QString lastCursorTheme;
|
||||
int lastCursorSize = 0;
|
||||
QString theme = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-name", "bloom").toString();
|
||||
int cursorSize = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-size", 24).toInt();
|
||||
if (theme != lastCursorTheme || cursorSize != lastCursorSize) {
|
||||
QCursor *cursor = ImageUtil::loadQCursorFromX11Cursor(theme.toStdString().c_str(), "left_ptr", cursorSize);
|
||||
if (!cursor)
|
||||
return;
|
||||
lastCursorTheme = theme;
|
||||
lastCursorSize = cursorSize;
|
||||
setCursor(*cursor);
|
||||
if (lastArrowCursor)
|
||||
delete lastArrowCursor;
|
||||
|
||||
lastArrowCursor = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewContainer::enterEvent(QEvent *e)
|
||||
{
|
||||
if (Utils::IS_WAYLAND_DISPLAY)
|
||||
updatePreviewCursor();
|
||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||
Utils::updateCursor(this);
|
||||
}
|
||||
|
||||
QWidget::enterEvent(e);
|
||||
|
||||
m_needActivate = false;
|
||||
|
@ -69,7 +69,6 @@ public slots:
|
||||
private:
|
||||
void adjustSize(const bool composite);
|
||||
void appendSnapWidget(const WId wid);
|
||||
void updatePreviewCursor();
|
||||
|
||||
void enterEvent(QEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
|
@ -127,7 +127,7 @@ int main(int argc, char *argv[])
|
||||
setenv("D_DXCB_FORCE_NO_TITLEBAR", "1", 1);
|
||||
}
|
||||
|
||||
DGuiApplicationHelper::setUseInactiveColorGroup(false);
|
||||
DGuiApplicationHelper::setAttribute(DGuiApplicationHelper::UseInactiveColorGroup, false);
|
||||
DockApplication app(argc, argv);
|
||||
|
||||
auto configs = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
|
||||
|
@ -114,8 +114,9 @@ void DockPopupWindow::hide()
|
||||
void DockPopupWindow::showEvent(QShowEvent *e)
|
||||
{
|
||||
DArrowRectangle::showEvent(e);
|
||||
if (Utils::IS_WAYLAND_DISPLAY)
|
||||
updatePopupWindowCursor();
|
||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||
Utils::updateCursor(this);
|
||||
}
|
||||
|
||||
QTimer::singleShot(1, this, &DockPopupWindow::ensureRaised);
|
||||
}
|
||||
@ -123,33 +124,13 @@ void DockPopupWindow::showEvent(QShowEvent *e)
|
||||
void DockPopupWindow::enterEvent(QEvent *e)
|
||||
{
|
||||
DArrowRectangle::enterEvent(e);
|
||||
if (Utils::IS_WAYLAND_DISPLAY)
|
||||
updatePopupWindowCursor();
|
||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||
Utils::updateCursor(this);
|
||||
}
|
||||
|
||||
QTimer::singleShot(1, this, &DockPopupWindow::ensureRaised);
|
||||
}
|
||||
|
||||
void DockPopupWindow::updatePopupWindowCursor()
|
||||
{
|
||||
static QCursor *lastArrowCursor = nullptr;
|
||||
static QString lastCursorTheme;
|
||||
int lastCursorSize = 0;
|
||||
QString theme = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-name", "bloom").toString();
|
||||
int cursorSize = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-size", 24).toInt();
|
||||
if (theme != lastCursorTheme || cursorSize != lastCursorSize) {
|
||||
QCursor *cursor = ImageUtil::loadQCursorFromX11Cursor(theme.toStdString().c_str(), "left_ptr", cursorSize);
|
||||
if (!cursor)
|
||||
return;
|
||||
lastCursorTheme = theme;
|
||||
lastCursorSize = cursorSize;
|
||||
setCursor(*cursor);
|
||||
if (lastArrowCursor)
|
||||
delete lastArrowCursor;
|
||||
|
||||
lastArrowCursor = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
bool DockPopupWindow::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
if (o != getContent() || e->type() != QEvent::Resize)
|
||||
|
@ -63,7 +63,6 @@ private slots:
|
||||
void onGlobMouseRelease(const QPoint &mousePos, const int flag);
|
||||
void compositeChanged();
|
||||
void ensureRaised();
|
||||
void updatePopupWindowCursor();
|
||||
|
||||
private:
|
||||
bool m_model;
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <QGSettings>
|
||||
#include <QDebug>
|
||||
|
||||
#include "imageutil.h"
|
||||
|
||||
namespace Utils {
|
||||
|
||||
#define ICBC_CONF_FILE "/etc/deepin/icbc.conf"
|
||||
@ -215,6 +217,28 @@ inline int comparePluginApi(const QString &pluginApi1, const QString &pluginApi2
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
inline void updateCursor(QWidget *w)
|
||||
{
|
||||
static QString lastCursorTheme;
|
||||
static int lastCursorSize = 0;
|
||||
QString theme = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-name", "bloom").toString();
|
||||
int cursorSize = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-size", 24).toInt();
|
||||
if (theme != lastCursorTheme || cursorSize != lastCursorSize) {
|
||||
QCursor *cursor = ImageUtil::loadQCursorFromX11Cursor(theme.toStdString().c_str(), "left_ptr", cursorSize);
|
||||
if (!cursor)
|
||||
return;
|
||||
lastCursorTheme = theme;
|
||||
lastCursorSize = cursorSize;
|
||||
w->setCursor(*cursor);
|
||||
static QCursor *lastArrowCursor = nullptr;
|
||||
if (lastArrowCursor)
|
||||
delete lastArrowCursor;
|
||||
|
||||
lastArrowCursor = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // UTILS
|
||||
|
@ -15,6 +15,8 @@ DesktopWidget::DesktopWidget(QWidget *parent)
|
||||
|
||||
void DesktopWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QPainter painter(this);
|
||||
//描绘桌面区域的颜色
|
||||
painter.setOpacity(1);
|
||||
|
@ -711,8 +711,9 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
||||
|
||||
void MainPanelControl::enterEvent(QEvent *event)
|
||||
{
|
||||
if (Utils::IS_WAYLAND_DISPLAY)
|
||||
updatePanelCursor();
|
||||
if (Utils::IS_WAYLAND_DISPLAY) {
|
||||
Utils::updateCursor(this);
|
||||
}
|
||||
|
||||
QWidget::enterEvent(event);
|
||||
}
|
||||
@ -802,98 +803,6 @@ void MainPanelControl::startDrag(DockItem *dockItem)
|
||||
}
|
||||
}
|
||||
|
||||
void MainPanelControl::startDragWayland(DockItem *item)
|
||||
{
|
||||
QPixmap pixmap;
|
||||
if (item->itemType() == DockItem::App) {
|
||||
pixmap = qobject_cast<AppItem *>(item)->appIcon();
|
||||
} else {
|
||||
pixmap = item->grab();
|
||||
}
|
||||
/*TODO: pixmap半透明处理
|
||||
QPixmap pixmap1;
|
||||
{
|
||||
QPixmap temp(pixmap.size());
|
||||
temp.fill(Qt::transparent);
|
||||
|
||||
QPainter p1(&temp);
|
||||
p1.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
p1.drawPixmap(0, 0, pixmap);
|
||||
p1.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
|
||||
//根据QColor中第四个参数设置透明度,0~255
|
||||
p1.fillRect(temp.rect(), QColor(0, 0, 0, 125));
|
||||
p1.end();
|
||||
|
||||
pixmap1 = temp;
|
||||
}*/
|
||||
|
||||
item->setDraging(true);
|
||||
item->update();
|
||||
|
||||
QDrag *drag = new QDrag(item);
|
||||
drag->setPixmap(pixmap);
|
||||
|
||||
drag->setHotSpot(pixmap.rect().center() / pixmap.devicePixelRatioF());
|
||||
drag->setMimeData(new QMimeData);
|
||||
|
||||
/*TODO: 开启线程,在移动中设置图片是否为半透明, 当前接口调用QShapedPixmapWindow找不到动态库的实现
|
||||
bool isRun = true;
|
||||
QtConcurrent::run([&isRun, &pixmap, &pixmap1, this]{
|
||||
while (isRun) {
|
||||
QPlatformDrag *platformDrag = QGuiApplicationPrivate::platformIntegration()->drag();
|
||||
QShapedPixmapWindow *dragIconWindow = nullptr;
|
||||
if (platformDrag)
|
||||
dragIconWindow = static_cast<QSimpleDrag *>(platformDrag)->shapedPixmapWindow();
|
||||
|
||||
if (!dragIconWindow)
|
||||
continue;
|
||||
|
||||
if (AppDragWidget::isRemoveable(m_position, QRect(mapToGlobal(pos()), size()))) {
|
||||
// dragIconWindow->setPixmap(pixmap1);
|
||||
} else {
|
||||
// dragIconWindow->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
}
|
||||
});*/
|
||||
|
||||
drag->exec(Qt::MoveAction);
|
||||
|
||||
//isRun = false;
|
||||
|
||||
if (drag->target() == this) {
|
||||
item->setDraging(false);
|
||||
item->update();
|
||||
return;
|
||||
}
|
||||
|
||||
//开启动画效果
|
||||
auto appDragWidget = new AppDragWidget();
|
||||
appDragWidget->setAppPixmap(pixmap);
|
||||
appDragWidget->setItem(item);
|
||||
appDragWidget->setDockInfo(m_position, QRect(mapToGlobal(pos()), size()));
|
||||
appDragWidget->setOriginPos(m_appAreaSonWidget->mapToGlobal(item->pos()));
|
||||
appDragWidget->setPixmapOpacity(0.5);
|
||||
appDragWidget->show();
|
||||
QGuiApplication::platformNativeInterface()->setWindowProperty(appDragWidget->windowHandle()->handle(),
|
||||
"_d_dwayland_window-type" , "menu");
|
||||
|
||||
QTimer::singleShot(10, [item, appDragWidget]{
|
||||
if (appDragWidget->isRemoveAble(QCursor::pos())) {
|
||||
appDragWidget->showRemoveAnimation();
|
||||
AppItem *appItem = static_cast<AppItem *>(item);
|
||||
appItem->undock();
|
||||
item->setDraging(false);
|
||||
item->update();
|
||||
} else {
|
||||
appDragWidget->showGoBackAnimation();
|
||||
item->setDraging(false);
|
||||
item->update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
||||
{
|
||||
QWidget *parentWidget = m_appAreaSonWidget;
|
||||
@ -1303,25 +1212,3 @@ bool MainPanelControl::appIsOnDock(const QString &appDesktop)
|
||||
{
|
||||
return DockItemManager::instance()->appIsOnDock(appDesktop);
|
||||
}
|
||||
|
||||
// TODO: 多处使用类似方法,可尝试提取公共函数
|
||||
void MainPanelControl::updatePanelCursor()
|
||||
{
|
||||
static QCursor *lastArrowCursor = nullptr;
|
||||
static QString lastCursorTheme;
|
||||
int lastCursorSize = 0;
|
||||
QString theme = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-name", "bloom").toString();
|
||||
int cursorSize = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-size", 24).toInt();
|
||||
if (theme != lastCursorTheme || cursorSize != lastCursorSize) {
|
||||
QCursor *cursor = ImageUtil::loadQCursorFromX11Cursor(theme.toStdString().c_str(), "left_ptr", cursorSize);
|
||||
if (!cursor)
|
||||
return;
|
||||
lastCursorTheme = theme;
|
||||
lastCursorSize = cursorSize;
|
||||
setCursor(*cursor);
|
||||
if (lastArrowCursor)
|
||||
delete lastArrowCursor;
|
||||
|
||||
lastArrowCursor = cursor;
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,6 @@ private:
|
||||
|
||||
// 拖拽相关
|
||||
void startDrag(DockItem *);
|
||||
void startDragWayland(DockItem *item);
|
||||
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
||||
void moveItem(DockItem *sourceItem, DockItem *targetItem);
|
||||
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
||||
@ -96,7 +95,6 @@ protected:
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void updatePanelCursor();
|
||||
|
||||
private:
|
||||
QBoxLayout *m_mainPanelLayout;
|
||||
|
@ -133,7 +133,6 @@ private:
|
||||
int cursorSize = Utils::SettingValue("com.deepin.xsettings", "/com/deepin/xsettings/", "gtk-cursor-theme-size", 24).toInt();
|
||||
Position position = static_cast<Dock::Position>(qApp->property("position").toInt());
|
||||
|
||||
static QCursor *lastCursor = nullptr;
|
||||
static QString lastTheme;
|
||||
static int lastPosition = -1;
|
||||
static int lastCursorSize = -1;
|
||||
@ -147,6 +146,7 @@ private:
|
||||
return;
|
||||
|
||||
setCursor(*newCursor);
|
||||
static QCursor *lastCursor = nullptr;
|
||||
if (lastCursor)
|
||||
delete lastCursor;
|
||||
|
||||
|
@ -10,7 +10,7 @@ file(GLOB_RECURSE SRCS
|
||||
"*.h"
|
||||
"*.cpp")
|
||||
|
||||
find_package(Qt5 COMPONENTS Core Widgets DBus LinguistTools REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Core Widgets DBus Svg LinguistTools REQUIRED)
|
||||
find_package(DdeControlCenter REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(DtkWidget REQUIRED)
|
||||
@ -24,6 +24,7 @@ target_include_directories(${PLUGIN_NAME} PUBLIC
|
||||
../src
|
||||
../../frame/util
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
${Qt5Svg_INCLUDE_DIRS}
|
||||
${DtkWidget_INCLUDE_DIRS}
|
||||
${DdeControlCenter_INCLUDE_DIR}
|
||||
${DFrameworkDBus_INCLUDE_DIRS}
|
||||
@ -32,6 +33,7 @@ target_include_directories(${PLUGIN_NAME} PUBLIC
|
||||
)
|
||||
target_link_libraries(${PLUGIN_NAME} PRIVATE
|
||||
${Qt5Widgets_LIBRARIES}
|
||||
${Qt5Svg_LIBRARIES}
|
||||
${DtkWidget_LIBRARIES}
|
||||
${DdeControlCenter_LIBRARIES}
|
||||
${DFrameworkDBus_LIBRARIES}
|
||||
|
@ -94,6 +94,8 @@ const QString OnboardPlugin::itemCommand(const QString &itemKey)
|
||||
|
||||
const QString OnboardPlugin::itemContextMenu(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
QList<QVariant> items;
|
||||
|
||||
QMap<QString, QVariant> onboardSettings;
|
||||
|
@ -116,6 +116,8 @@ const QString ShutdownPlugin::itemCommand(const QString &itemKey)
|
||||
|
||||
const QString ShutdownPlugin::itemContextMenu(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
QList<QVariant> items;
|
||||
items.reserve(6);
|
||||
|
||||
|
@ -17,6 +17,8 @@ FashionTrayWidgetWrapper *AttentionContainer::takeAttentionWrapper()
|
||||
|
||||
bool AttentionContainer::acceptWrapper(FashionTrayWidgetWrapper *wrapper)
|
||||
{
|
||||
Q_UNUSED(wrapper);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,8 @@ void FashionTrayControlWidget::setExpanded(const bool &expanded)
|
||||
|
||||
void FashionTrayControlWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
|
@ -183,6 +183,7 @@ void FashionTrayItem::onExpandChanged(const bool expand)
|
||||
|
||||
void FashionTrayItem::setRightSplitVisible(const bool visible)
|
||||
{
|
||||
Q_UNUSED(visible);
|
||||
}
|
||||
|
||||
void FashionTrayItem::onPluginSettingsChanged()
|
||||
|
@ -134,6 +134,8 @@ bool TrayPlugin::pluginIsDisable()
|
||||
|
||||
void TrayPlugin::displayModeChanged(const Dock::DisplayMode mode)
|
||||
{
|
||||
Q_UNUSED(mode);
|
||||
|
||||
if (pluginIsDisable()) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user