Skip to content

Commit

Permalink
fix: adapt new quick pannel plugin interface
Browse files Browse the repository at this point in the history
As title.
Tray icon manager updated from dde-dock to dde-tray-loader,
no longer compatible with previous settings.
This commit updates the interface to PluginsItemInterfaceV2.

Log: Adapt new quick pannel plugin interface.
Bug: https://pms.uniontech.com/bug-view-266839.html
  • Loading branch information
rb-union authored and deepin-bot[bot] committed Oct 25, 2024
1 parent 0ae8018 commit 6201657
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/dde-dock-plugins/shotstart/shotstartplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ void ShotStartPlugin::pluginStateSwitched()
}
}

#if defined(DOCK_API_VERSION) && (DOCK_API_VERSION >= DOCK_API_VERSION_CHECK(2, 0, 0))

/**
* @return The Tray plugin supports the quick panel type
*/
Dock::PluginFlags ShotStartPlugin::flags() const
{
return Dock::Type_Quick | Dock::Quick_Panel_Single | Dock::Attribute_Normal;
}

#endif

QWidget *ShotStartPlugin::itemWidget(const QString &itemKey)
{
if (itemKey == QUICK_ITEM_KEY) {
Expand Down
16 changes: 15 additions & 1 deletion src/dde-dock-plugins/shotstart/shotstartplugin.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// Copyright (C) 2020 ~ 2024 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
Expand All @@ -10,9 +10,19 @@
#include "quickpanelwidget.h"
#include "tipswidget.h"
#include <QtDBus/QtDBus>

#include <dde-dock/constants.h>
#if defined(DOCK_API_VERSION) && (DOCK_API_VERSION >= DOCK_API_VERSION_CHECK(2, 0, 0))
#include <dde-dock/pluginsiteminterface_v2.h>
#else
#include <dde-dock/pluginsiteminterface.h>
#endif

#if defined(DOCK_API_VERSION) && (DOCK_API_VERSION >= DOCK_API_VERSION_CHECK(2, 0, 0))
class ShotStartPlugin : public QObject, PluginsItemInterfaceV2
#else
class ShotStartPlugin : public QObject, PluginsItemInterface
#endif
{
Q_OBJECT
Q_INTERFACES(PluginsItemInterface)
Expand Down Expand Up @@ -46,6 +56,10 @@ class ShotStartPlugin : public QObject, PluginsItemInterface
bool pluginIsDisable() override;
void pluginStateSwitched() override;

#if defined(DOCK_API_VERSION) && (DOCK_API_VERSION >= DOCK_API_VERSION_CHECK(2, 0, 0))
Dock::PluginFlags flags() const override;
#endif

/**
* Dock::Type_Quick=0x02 插件类型-快捷插件区;
* Dock::Quick_Panel_Single=0x40 当插件类型为Common时,快捷插件区域只有一列的那种插件;
Expand Down
12 changes: 12 additions & 0 deletions src/dde-dock-plugins/shotstartrecord/shotstartrecordplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ void ShotStartRecordPlugin::pluginStateSwitched()
}
}

#if defined(DOCK_API_VERSION) && (DOCK_API_VERSION >= DOCK_API_VERSION_CHECK(2, 0, 0))

/**
* @return The Tray plugin supports the quick panel type
*/
Dock::PluginFlags ShotStartRecordPlugin::flags() const
{
return Dock::Type_Quick | Dock::Quick_Panel_Single | Dock::Attribute_Normal;
}

#endif

/**
* @brief itemWidget:返回插件主控件,用于dde-dock面板上显示
* @param itemKey:控件名称
Expand Down
33 changes: 24 additions & 9 deletions src/dde-dock-plugins/shotstartrecord/shotstartrecordplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@
#include "recordiconwidget.h"
#include "quickpanelwidget.h"
#include "tipswidget.h"

#include <QtDBus/QtDBus>

#include <dde-dock/constants.h>
#if defined(DOCK_API_VERSION) && (DOCK_API_VERSION >= DOCK_API_VERSION_CHECK(2, 0, 0))
#include <dde-dock/pluginsiteminterface_v2.h>
#else
#include <dde-dock/pluginsiteminterface.h>
#endif

#if defined(DOCK_API_VERSION) && (DOCK_API_VERSION >= DOCK_API_VERSION_CHECK(2, 0, 0))
class ShotStartRecordPlugin : public QObject, PluginsItemInterfaceV2
#else
class ShotStartRecordPlugin : public QObject, PluginsItemInterface
#endif
{
Q_OBJECT
Q_INTERFACES(PluginsItemInterface)
Expand All @@ -31,6 +42,10 @@ class ShotStartRecordPlugin : public QObject, PluginsItemInterface
bool pluginIsDisable() override;
void pluginStateSwitched() override;

#if defined(DOCK_API_VERSION) && (DOCK_API_VERSION >= DOCK_API_VERSION_CHECK(2, 0, 0))
Dock::PluginFlags flags() const override;
#endif

/**
* Dock::Type_Quick=0x02 插件类型-快捷插件区;
* Dock::Quick_Panel_Single=0x40 当插件类型为Common时,快捷插件区域只有一列的那种插件;
Expand Down Expand Up @@ -66,15 +81,15 @@ public Q_SLOTS:
bool getTrayIconVisible();

private:
QScopedPointer<RecordIconWidget> m_iconWidget; // 任务栏图标
QScopedPointer<QuickPanelWidget> m_quickPanelWidget; // 快捷面板
QScopedPointer<RecordIconWidget> m_iconWidget; // 任务栏图标
QScopedPointer<QuickPanelWidget> m_quickPanelWidget; // 快捷面板
QScopedPointer<TipsWidget> m_tipsWidget;
bool m_isRecording; // true:正在录屏 false:未启动录屏
QTimer *m_checkTimer; // 此定时器的作用为每隔1秒检查下截图录屏是否还在运行中。避免截图录屏崩溃后导致本插件还在执行
int m_nextCount = 0; // 用来判断录屏是否正在进行中
int m_count = 0; // 用来判断录屏是否正在进行中
bool m_bDockQuickPanel; // 兼容性适配,老版的dock不支持快捷面板
bool m_bPreviousIsVisable = false; // 记录前置状态是否为禁止使能状态
bool m_isRecording; // true:正在录屏 false:未启动录屏
QTimer *m_checkTimer; // 此定时器的作用为每隔1秒检查下截图录屏是否还在运行中。避免截图录屏崩溃后导致本插件还在执行
int m_nextCount = 0; // 用来判断录屏是否正在进行中
int m_count = 0; // 用来判断录屏是否正在进行中
bool m_bDockQuickPanel; // 兼容性适配,老版的dock不支持快捷面板
bool m_bPreviousIsVisable = false; // 记录前置状态是否为禁止使能状态
};

#endif // RECORDTIME_H
#endif // RECORDTIME_H

0 comments on commit 6201657

Please sign in to comment.