feat: allow setting working directory in app.setUserTasks() / app.setJumpList() (#18148)
This commit is contained in:
parent
326215e1f1
commit
3a5e6f2551
8 changed files with 20 additions and 3 deletions
|
@ -85,6 +85,7 @@ struct Converter<Browser::UserTask> {
|
|||
return false;
|
||||
dict.Get("arguments", &(out->arguments));
|
||||
dict.Get("description", &(out->description));
|
||||
dict.Get("workingDirectory", &(out->working_dir));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -158,6 +159,7 @@ struct Converter<JumpListItem> {
|
|||
|
||||
dict.Get("args", &(out->arguments));
|
||||
dict.Get("description", &(out->description));
|
||||
dict.Get("workingDirectory", &(out->working_dir));
|
||||
return true;
|
||||
|
||||
case JumpListItem::Type::SEPARATOR:
|
||||
|
@ -184,6 +186,7 @@ struct Converter<JumpListItem> {
|
|||
dict.Set("iconPath", val.icon_path);
|
||||
dict.Set("iconIndex", val.icon_index);
|
||||
dict.Set("description", val.description);
|
||||
dict.Set("workingDirectory", val.working_dir);
|
||||
break;
|
||||
|
||||
case JumpListItem::Type::SEPARATOR:
|
||||
|
|
|
@ -197,6 +197,7 @@ class Browser : public WindowListObserver {
|
|||
base::string16 arguments;
|
||||
base::string16 title;
|
||||
base::string16 description;
|
||||
base::FilePath working_dir;
|
||||
base::FilePath icon_path;
|
||||
int icon_index;
|
||||
|
||||
|
|
|
@ -141,6 +141,7 @@ bool Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
|
|||
item.icon_path = task.icon_path;
|
||||
item.icon_index = task.icon_index;
|
||||
item.description = task.description;
|
||||
item.working_dir = task.working_dir;
|
||||
category.items.push_back(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ bool AppendTask(const JumpListItem& item, IObjectCollection* collection) {
|
|||
if (FAILED(link.CoCreateInstance(CLSID_ShellLink)) ||
|
||||
FAILED(link->SetPath(item.path.value().c_str())) ||
|
||||
FAILED(link->SetArguments(item.arguments.c_str())) ||
|
||||
FAILED(link->SetWorkingDirectory(item.working_dir.value().c_str())) ||
|
||||
FAILED(link->SetDescription(item.description.c_str())))
|
||||
return false;
|
||||
|
||||
|
@ -86,6 +87,8 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
|
|||
if (FAILED(shell_link->GetPath(path, base::size(path), nullptr, 0)))
|
||||
return false;
|
||||
|
||||
item->path = base::FilePath(path);
|
||||
|
||||
CComQIPtr<IPropertyStore> property_store = shell_link;
|
||||
base::win::ScopedPropVariant prop;
|
||||
if (SUCCEEDED(
|
||||
|
@ -99,6 +102,9 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
|
|||
item->title = prop.get().pwszVal;
|
||||
}
|
||||
|
||||
if (SUCCEEDED(shell_link->GetWorkingDirectory(path, base::size(path))))
|
||||
item->working_dir = base::FilePath(path);
|
||||
|
||||
int icon_index;
|
||||
if (SUCCEEDED(
|
||||
shell_link->GetIconLocation(path, base::size(path), &icon_index))) {
|
||||
|
|
|
@ -49,6 +49,7 @@ struct JumpListItem {
|
|||
base::string16 arguments;
|
||||
base::string16 title;
|
||||
base::string16 description;
|
||||
base::FilePath working_dir;
|
||||
base::FilePath icon_path;
|
||||
int icon_index = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue