Skip to content

Commit 74de9a6

Browse files
fix: Update save button tooltip and add new save options
- Enhanced the tooltip for the save button to reflect new save options: "Save to Desktop" and "Save to Pictures". - Updated the save button functionality to dynamically change the tooltip based on user settings. - Added translations for the new save options in multiple languages, improving accessibility for international users. This update enriches the user experience by providing clearer save options and enhancing the overall functionality of the save button. bug: https://pms.uniontech.com/bug-view-337125.html https://pms.uniontech.com/bug-view-339555.html
1 parent dc3263c commit 74de9a6

33 files changed

Lines changed: 348 additions & 134 deletions

src/main_window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ void MainWindow::initToolBarShortcut()
10141014
// 截图模式 AI 助手应用内快捷键
10151015
connect(aiAssistantSC, &QShortcut::activated, this, [=] {
10161016
qCWarning(dsrApp) << "shortcut : aiAssistantSC (key: a)";
1017-
if (status::shot == m_functionType && Utils::is3rdInterfaceStart == false) {
1017+
if ((status::shot == m_functionType || status::scrollshot == m_functionType)&& Utils::is3rdInterfaceStart == false) {
10181018
qCWarning(dsrApp) << "shortcut : aiAssistantSC (key: a)";
10191019
m_toolBar->shapeClickedFromMain("aiassistant");
10201020
}

src/pin_screenshots/ui/subtoolwidget.cpp

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ void SubToolWidget::initShotLable()
6363
// 初始化时调用 updateSaveButtonTip 设置初始的 tooltip
6464
m_saveLocalDirButton->setSaveIcon(QIcon::fromTheme("save"));
6565
m_saveLocalDirButton->setListIcon(QIcon::fromTheme("dropdown"));
66-
// 监听保存按钮的悬停提示事件
67-
m_saveLocalDirButton->installEventFilter(this);
6866
m_pinOptionButton->setObjectName(AC_TOOLBARWIDGET_SAVE_LOACL_PIN_BUT);
6967
m_saveLocalDirButton->setAccessibleName(AC_TOOLBARWIDGET_SAVE_LOACL_PIN_BUT);
7068

7169
// 创建并设置保存菜单管理器
7270
PinSaveMenuManager *pinSaveMenuManager = new PinSaveMenuManager(this);
7371
m_saveLocalDirButton->setOptionsMenu(pinSaveMenuManager->getMenu());
72+
// 连接保存选项改变信号,更新tooltip
73+
connect(pinSaveMenuManager, &PinSaveMenuManager::saveOptionChanged, this, &SubToolWidget::updateSaveButtonTip);
74+
updateSaveButtonTip();
7475

7576
connect(m_saveLocalDirButton, &SaveButton::clicked, this, &SubToolWidget::signalSaveToLocalButtonClicked);
7677

@@ -195,22 +196,40 @@ void SubToolWidget::updateSaveButtonTip()
195196
return;
196197
}
197198

198-
// 使用实时配置生成安全的默认提示文案(事件过滤器会覆盖为更细粒度文案)
199+
199200
QPair<int, int> saveInfo = Settings::instance()->getSaveOption();
200201
const int pathType = saveInfo.first;
201202
const QString specialPath = Settings::instance()->getSavePath();
202203
const bool hasHistoryPath = !specialPath.isEmpty() && QFileInfo::exists(specialPath);
203204

204205
QString tipText;
205-
if (pathType == ASK) {
206-
tipText = tr("Save to local");
207-
} else if (pathType == FOLDER_CHANGE) {
208-
tipText = tr("Select a location when saving");
209-
} else if (pathType == FOLDER) {
210-
tipText = hasHistoryPath ? tr("Save to %1").arg(specialPath)
211-
: tr("Save to local");
212-
} else {
213-
tipText = tr("Save to local");
206+
switch (pathType) {
207+
case ASK:
208+
// 每次询问模式
209+
tipText = tr("Save to local");
210+
break;
211+
case DESKTOP:
212+
// 保存到桌面
213+
tipText = tr("Save to Desktop");
214+
break;
215+
case PICTURES:
216+
// 保存到图片
217+
tipText = tr("Save to Pictures");
218+
break;
219+
case FOLDER:
220+
// 保存到指定路径
221+
tipText = hasHistoryPath ? tr("Save to %1").arg(specialPath)
222+
: tr("Save to local");
223+
break;
224+
case FOLDER_CHANGE:
225+
// 保存时选择/更新位置
226+
tipText = hasHistoryPath ? tr("Update the location when saving")
227+
: tr("Select a location when saving");
228+
break;
229+
default:
230+
// 其他情况(CLIPBOARD等)
231+
tipText = tr("Save to local");
232+
break;
214233
}
215234

216235
m_saveLocalDirButton->setToolTip(tipText);
@@ -283,40 +302,6 @@ void SubToolWidget::updateOptionChecked()
283302

284303
bool SubToolWidget::eventFilter(QObject *watched, QEvent *event)
285304
{
286-
if (watched == m_saveLocalDirButton) {
287-
if (event->type() == QEvent::ToolTip) {
288-
QPair<int, int> saveInfo = Settings::instance()->getSaveOption();
289-
const QString specialPath = Settings::instance()->getSavePath();
290-
const bool hasHistoryPath = !specialPath.isEmpty() && QFileInfo::exists(specialPath);
291-
292-
QString tipText;
293-
switch (saveInfo.first) {
294-
case ASK:
295-
tipText = tr("Save to local");
296-
break;
297-
case FOLDER:
298-
if (hasHistoryPath) {
299-
tipText = tr("Save to %1").arg(specialPath);
300-
} else {
301-
tipText = tr("Save to local");
302-
}
303-
break;
304-
case FOLDER_CHANGE:
305-
// 菜单选中"保存时设置位置" → 根据是否有历史路径决定文案
306-
tipText = hasHistoryPath ? tr("Update the location when saving")
307-
: tr("Select a location when saving");
308-
break;
309-
default:
310-
tipText = tr("Save to local");
311-
break;
312-
}
313-
QHelpEvent *he = static_cast<QHelpEvent *>(event);
314-
QToolTip::showText(he->globalPos(), tipText, m_saveLocalDirButton);
315-
316-
return true;
317-
}
318-
}
319-
320305
if (watched == m_optionMenu) {
321306
if (event->type() == QEvent::MouseButtonPress) {
322307
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);

src/widgets/subtoolwidget.cpp

Lines changed: 75 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "subtoolwidget.h"
66
#include "../camera_process.h"
77
#include "../utils/configsettings.h"
8+
#include "../utils/saveutils.h"
89
#include "../settings.h"
910
#include "tooltips.h"
1011
#include "../utils.h"
@@ -718,13 +719,14 @@ void SubToolWidget::initShotLabel()
718719
m_saveLocalDirButton = new SaveButton();
719720
m_saveLocalDirButton->setCheckable(false);
720721
updateSaveButtonTip();
721-
m_saveLocalDirButton->installEventFilter(this);
722722
// m_saveLocalDirButton->setIcon(QIcon::fromTheme("save"));
723723
Utils::setAccessibility(m_saveLocalDirButton, AC_SUBTOOLWIDGET_SAVETOLOCAL_BUTTON);
724724

725725
// 创建并设置保存菜单管理器
726726
SaveMenuManager *saveMenuManager = new SaveMenuManager(this);
727727
m_saveLocalDirButton->setOptionsMenu(saveMenuManager->getMenu());
728+
// 连接保存选项改变信号,更新tooltip
729+
connect(saveMenuManager, &SaveMenuManager::saveOptionChanged, this, &SubToolWidget::updateSaveButtonTip);
728730

729731
m_shotBtnGroup->addButton(m_saveLocalDirButton);
730732
// m_saveLocalDirButton->setFixedSize(TOOL_BUTTON_SIZE);
@@ -833,63 +835,76 @@ void SubToolWidget::showAIAssistantWidget()
833835
// 更新保存按钮的提示信息
834836
void SubToolWidget::updateSaveButtonTip()
835837
{
836-
// SaveWays t_saveWays = ConfigSettings::instance()->getValue("shot", "save_ways").value<SaveWays>();
837-
// QString tipText;
838-
// if (t_saveWays == Ask) {
839-
// tipText = tr("Save to local");
840-
// } else if (t_saveWays == SpecifyLocation) {
841-
// // 获取当前保存设置
842-
// SaveAction saveAction = ConfigSettings::instance()->getValue("shot", "save_op").value<SaveAction>();
843-
844-
// switch (saveAction) {
845-
// case SaveToDesktop: {
846-
// tipText = tr("Save to Desktop");
847-
// break;
848-
// }
849-
// case SaveToImage: {
850-
// tipText = tr("Save to Pictures");
851-
// break;
852-
// }
853-
// case SaveToSpecificDir: {
854-
// bool changeIsChecked = m_changeSaveToSpecialPath && ((m_changeSaveToSpecialPath &&m_changeSaveToSpecialPath->isChecked()) || (m_scrollChangeSaveToSpecialPath && m_scrollChangeSaveToSpecialPath->isChecked()));
855-
// qWarning() << "changeIsChecked:"<<changeIsChecked;
856-
// QString specificPath = ConfigSettings::instance()->getValue("shot", "save_dir").toString();
857-
// bool specialPathExits = !specificPath.isEmpty() && QFileInfo::exists(specificPath);
858-
// qWarning() << "specialPathExits:"<<specialPathExits;
859-
// // 保存时更新
860-
// bool tipsUpdateSaved = specialPathExits && changeIsChecked;
861-
// qWarning() << "tipsUpdateSaved:"<<tipsUpdateSaved;
862-
// // 保存时设置(选中且目录为空不为空)
863-
// bool tipsSetSaved = changeIsChecked;
864-
// qWarning() << "tipsSetSaved:"<<tipsSetSaved;
865-
// // 保存到目录 (目录不为空且存在)
866-
// bool tipsSpecialSaved = m_saveToSpecialPathAction && m_saveToSpecialPathAction->isChecked() && specialPathExits;
867-
// qWarning() << "tipsSpecialSaved:"<<tipsSpecialSaved;
868-
869-
// if (tipsUpdateSaved) {
870-
// tipText = tr("Change the path on save");
871-
// qWarning() << "tipsUpdateSaved";
872-
873-
// }
874-
// else if(tipsSetSaved) {
875-
// tipText = tr("Set a path on save");
876-
// qWarning() << "tipsSetSaved";
877-
// } else if(tipsSpecialSaved) {
878-
// tipText = tr("Save to %1").arg(specificPath);
879-
// qWarning() << "tipsSpecialSaved";
880-
// } else {
881-
// tipText = tr("Save to local");
882-
// qWarning() << "not set saved";
883-
// }
884-
// qWarning() << tipText;
885-
// break;
886-
// }
887-
// default:
888-
// tipText = tr("Save to local");
889-
// break;
890-
// }
891-
// }
892-
// installTipHint(m_saveLocalDirButton, tipText);
838+
qCWarning(dsrApp) << "========== updateSaveButtonTip 开始 ==========";
839+
840+
if (!m_saveLocalDirButton) {
841+
qCWarning(dsrApp) << "updateSaveButtonTip: m_saveLocalDirButton 为空,直接返回";
842+
return;
843+
}
844+
845+
// 参考saveAction函数的读取方式
846+
SaveWays saveWays = ConfigSettings::instance()->getValue("shot", "save_ways").value<SaveWays>();
847+
SaveAction saveOp = ConfigSettings::instance()->getValue("shot", "save_op").value<SaveAction>();
848+
bool isChangeOnSave = ConfigSettings::instance()->getValue("shot", "save_dir_change").toBool();
849+
QString savedPath = ConfigSettings::instance()->getValue("shot", "save_dir").toString();
850+
const bool hasHistoryPath = !savedPath.isEmpty() && QFileInfo::exists(savedPath);
851+
852+
qCWarning(dsrApp) << "updateSaveButtonTip: saveWays=" << static_cast<int>(saveWays)
853+
<< "saveOp=" << static_cast<int>(saveOp)
854+
<< "isChangeOnSave=" << isChangeOnSave
855+
<< "savedPath=" << savedPath
856+
<< "hasHistoryPath=" << hasHistoryPath;
857+
858+
QString tipText;
859+
if (saveWays == Ask) {
860+
// 每次询问模式
861+
tipText = tr("Save to local");
862+
qCWarning(dsrApp) << "updateSaveButtonTip: 进入每次询问模式,tipText=" << tipText;
863+
} else if (saveWays == SpecifyLocation) {
864+
// 指定位置模式,根据save_op显示具体保存位置
865+
qCWarning(dsrApp) << "updateSaveButtonTip: 进入指定位置模式,saveOp=" << static_cast<int>(saveOp);
866+
switch (saveOp) {
867+
case SaveToDesktop:
868+
tipText = tr("Save to Desktop");
869+
qCWarning(dsrApp) << "updateSaveButtonTip: SaveToDesktop分支,tipText=" << tipText;
870+
break;
871+
case SaveToImage:
872+
tipText = tr("Save to Pictures");
873+
qCWarning(dsrApp) << "updateSaveButtonTip: SaveToImage分支,tipText=" << tipText;
874+
break;
875+
case SaveToSpecificDir:
876+
qCWarning(dsrApp) << "updateSaveButtonTip: SaveToSpecificDir分支,isChangeOnSave=" << isChangeOnSave;
877+
if (isChangeOnSave) {
878+
// 保存时选择/更新位置
879+
tipText = hasHistoryPath ? tr("Update the location when saving")
880+
: tr("Select a location when saving");
881+
qCWarning(dsrApp) << "updateSaveButtonTip: isChangeOnSave=true,hasHistoryPath=" << hasHistoryPath
882+
<< "tipText=" << tipText;
883+
} else {
884+
// 保存到指定路径
885+
tipText = hasHistoryPath ? tr("Save to %1").arg(savedPath)
886+
: tr("Save to local");
887+
qCWarning(dsrApp) << "updateSaveButtonTip: isChangeOnSave=false,hasHistoryPath=" << hasHistoryPath
888+
<< "tipText=" << tipText;
889+
}
890+
break;
891+
default:
892+
// 其他情况(SaveToClipboard, AutoSave, CustomScreenSave等)
893+
tipText = tr("Save to local");
894+
qCWarning(dsrApp) << "updateSaveButtonTip: default分支,saveOp=" << static_cast<int>(saveOp)
895+
<< "tipText=" << tipText;
896+
break;
897+
}
898+
} else {
899+
// 其他情况,保持原来的方式
900+
tipText = tr("Save to local");
901+
qCWarning(dsrApp) << "updateSaveButtonTip: 其他情况分支,saveWays=" << static_cast<int>(saveWays)
902+
<< "tipText=" << tipText;
903+
}
904+
905+
qCWarning(dsrApp) << "updateSaveButtonTip: 最终tipText=" << tipText;
906+
installTipHint(m_saveLocalDirButton, tipText);
907+
qCWarning(dsrApp) << "========== updateSaveButtonTip 结束 ==========";
893908
}
894909

895910
void SubToolWidget::initShotOption()
@@ -1459,6 +1474,8 @@ void SubToolWidget::initScrollLabel()
14591474
// 创建并设置保存菜单管理器
14601475
SaveMenuManager *scrollSaveMenuManager = new SaveMenuManager(this);
14611476
m_saveLocalDirButton->setOptionsMenu(scrollSaveMenuManager->getMenu());
1477+
// 连接保存选项改变信号,更新tooltip
1478+
connect(scrollSaveMenuManager, &SaveMenuManager::saveOptionChanged, this, &SubToolWidget::updateSaveButtonTip);
14621479

14631480
m_shotBtnGroup->addButton(m_saveLocalDirButton);
14641481
// m_saveLocalDirButton->setFixedSize(TOOL_BUTTON_SIZE);
@@ -1913,34 +1930,6 @@ QPoint SubToolWidget::getAiButtonGlobalCenter() const
19131930
// 屏蔽DMenu,触发QAction Trigger时,收回菜单
19141931
bool SubToolWidget::eventFilter(QObject *watched, QEvent *event)
19151932
{
1916-
// 为保存按钮提供动态 ToolTip 文案
1917-
if (watched == m_saveLocalDirButton) {
1918-
if (event->type() == QEvent::ToolTip) {
1919-
int saveWays = ConfigSettings::instance()->getValue("shot", "save_ways").toInt(); // 0: Ask, 1: Specify
1920-
bool isChangeOnSave = ConfigSettings::instance()->getValue("shot", "save_dir_change").toBool();
1921-
QString savedPath = ConfigSettings::instance()->getValue("shot", "save_dir").toString();
1922-
const bool hasHistoryPath = !savedPath.isEmpty() && QFileInfo::exists(savedPath);
1923-
1924-
QString tipText;
1925-
if (saveWays == 0) {
1926-
tipText = tr("Save to local");
1927-
} else {
1928-
if (isChangeOnSave) {
1929-
tipText = hasHistoryPath ? tr("Update the location when saving")
1930-
: tr("Select a location when saving");
1931-
} else {
1932-
// 菜单选中具体的自定义路径 → 显示"保存到[路径]"
1933-
tipText = hasHistoryPath ? tr("Save to %1").arg(savedPath)
1934-
: tr("Save to local");
1935-
}
1936-
}
1937-
1938-
if (m_saveLocalDirButton)
1939-
installTipHint(m_saveLocalDirButton, tipText);
1940-
1941-
return true;
1942-
}
1943-
}
19441933

19451934

19461935
if (watched == m_recordOptionMenu || watched == m_optionMenu || watched == m_scrollOptionMenu || watched == m_saveToSpecialPathMenu || watched == m_scrollSaveToSpecialPathMenu) {

translations/deepin-screen-recorder_ar.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,14 @@ Hold down Shift to draw squares or circles.</source>
749749
<source>AI Screenshot (A)</source>
750750
<translation>ملخص (A)</translation>
751751
</message>
752+
<message>
753+
<source>Save to Desktop</source>
754+
<translation>حفظ إلى سطح المكتب</translation>
755+
</message>
756+
<message>
757+
<source>Save to Pictures</source>
758+
<translation>حفظ إلى الصور</translation>
759+
</message>
752760
</context>
753761
<context>
754762
<name>ToolBarWidget</name>

translations/deepin-screen-recorder_bo.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,14 @@ Shiftམནན་ནས་གྲུ་བཞི་ཁ་གང་འབྲི་
750750
<source>AI Screenshot (A)</source>
751751
<translation>སྒྲིག་བཀོད་བྱ་རྒྱུ་ (A)</translation>
752752
</message>
753+
<message>
754+
<source>Save to Desktop</source>
755+
<translation>ཅོག་ངོས་དུ་ཉར་བ།</translation>
756+
</message>
757+
<message>
758+
<source>Save to Pictures</source>
759+
<translation>བཤུས་འགོད་དུ་ཉར་བ།</translation>
760+
</message>
753761
</context>
754762
<context>
755763
<name>ToolBarWidget</name>

translations/deepin-screen-recorder_br.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,14 @@ Hold down Shift to draw squares or circles.</source>
749749
<source>AI Screenshot (A)</source>
750750
<translation>Tapadenn AI (A)</translation>
751751
</message>
752+
<message>
753+
<source>Save to Desktop</source>
754+
<translation>Enrollañ e-barzh ar burev</translation>
755+
</message>
756+
<message>
757+
<source>Save to Pictures</source>
758+
<translation>Enrollañ e-barzh ar skeudenn</translation>
759+
</message>
752760
</context>
753761
<context>
754762
<name>ToolBarWidget</name>

translations/deepin-screen-recorder_ca.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,14 @@ Hold down Shift to draw squares or circles.</source>
749749
<source>AI Screenshot (A)</source>
750750
<translation>Resum (A)</translation>
751751
</message>
752+
<message>
753+
<source>Save to Desktop</source>
754+
<translation>Desa a l&apos;escriptori</translation>
755+
</message>
756+
<message>
757+
<source>Save to Pictures</source>
758+
<translation>Desa a les imatges</translation>
759+
</message>
752760
</context>
753761
<context>
754762
<name>ToolBarWidget</name>

translations/deepin-screen-recorder_cs.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,14 @@ Hold down Shift to draw squares or circles.</source>
749749
<source>AI Screenshot (A)</source>
750750
<translation>Snímek AI (A)</translation>
751751
</message>
752+
<message>
753+
<source>Save to Desktop</source>
754+
<translation>Uložit na plochu</translation>
755+
</message>
756+
<message>
757+
<source>Save to Pictures</source>
758+
<translation>Uložit do obrázků</translation>
759+
</message>
752760
</context>
753761
<context>
754762
<name>ToolBarWidget</name>

0 commit comments

Comments
 (0)