Skip to content

Commit

Permalink
fix: Keep tray icon previous state
Browse files Browse the repository at this point in the history
保持托盘图标之前的状态,在录屏结束后
不一定需要显示托盘图标。

Log: 修复部分显示问题
  • Loading branch information
rb-union authored and deepin-bot[bot] committed Apr 10, 2024
1 parent 804f13a commit 9aaeb1a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 22 additions & 4 deletions src/dde-dock-plugins/shotstartrecord/shotstartrecordplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ void ShotStartRecordPlugin::invokedMenuItem(const QString &, const QString &, co
*/
bool ShotStartRecordPlugin::onStart()
{
// 仅隐藏任务栏图标
setTrayIconVisible(false);
m_bPreviousIsVisable = getTrayIconVisible();
if (m_bPreviousIsVisable) {
// 仅隐藏任务栏图标
setTrayIconVisible(false);
}

qCDebug(RECORD_LOG) << "Start The Clock!";
m_isRecording = true;
Expand All @@ -225,8 +228,10 @@ bool ShotStartRecordPlugin::onStart()
*/
void ShotStartRecordPlugin::onStop()
{
// 恢复显示任务栏图标
setTrayIconVisible(true);
if (m_bPreviousIsVisable) {
// 恢复显示任务栏图标
setTrayIconVisible(true);
}

m_isRecording = false;
m_quickPanelWidget->stop();
Expand Down Expand Up @@ -300,6 +305,19 @@ void ShotStartRecordPlugin::setTrayIconVisible(bool visible)
interface.call("setPluginVisible", pluginDisplayName(), visible);
}

/**
@return 当前图标在任务栏是否可见
*/
bool ShotStartRecordPlugin::getTrayIconVisible()
{
QDBusInterface interface("com.deepin.dde.Dock", "/com/deepin/dde/Dock", "com.deepin.dde.Dock", QDBusConnection::sessionBus());
auto msg = interface.call("getPluginVisible", pluginDisplayName());
if (QDBusMessage::ReplyMessage == msg.type()) {
return msg.arguments().takeFirst().toBool();
}
return false;
}

ShotStartRecordPlugin::~ShotStartRecordPlugin()
{
if (nullptr != m_iconWidget)
Expand Down
4 changes: 3 additions & 1 deletion src/dde-dock-plugins/shotstartrecord/shotstartrecordplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public Q_SLOTS:
private:
void onClickQuickPanel();
void setTrayIconVisible(bool visible);
bool getTrayIconVisible();

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

#endif // RECORDTIME_H

0 comments on commit 9aaeb1a

Please sign in to comment.