Support adding a separator in the task list when setting jump list.
Author: Chaobin Zhang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77613 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -130,16 +130,25 @@ private:
|
||||
wxDECLARE_NO_COPY_CLASS(wxTaskBarButton);
|
||||
};
|
||||
|
||||
enum WXDLLIMPEXP_CORE wxJumpListItemType {
|
||||
wxJUMP_LIST_SEPARATOR,
|
||||
wxJUMP_LIST_TASK,
|
||||
wxJUMP_LIST_DESTIONATION
|
||||
};
|
||||
|
||||
class WXDLLIMPEXP_CORE wxJumpListItem
|
||||
{
|
||||
public:
|
||||
wxJumpListItem(const wxString& title = wxEmptyString,
|
||||
wxJumpListItem(wxJumpListItemType type,
|
||||
const wxString& title = wxEmptyString,
|
||||
const wxString& filePath = wxEmptyString,
|
||||
const wxString& arguments = wxEmptyString,
|
||||
const wxString& tooltip = wxEmptyString,
|
||||
const wxString& iconPath = wxEmptyString,
|
||||
int iconIndex = 0);
|
||||
|
||||
wxJumpListItemType GetType() const;
|
||||
void SetType(wxJumpListItemType type);
|
||||
const wxString& GetTitle() const;
|
||||
void SetTitle(const wxString& title);
|
||||
const wxString& GetFilePath() const;
|
||||
@@ -154,6 +163,7 @@ public:
|
||||
void SetIconIndex(int iconIndex);
|
||||
|
||||
private:
|
||||
wxJumpListItemType m_type;
|
||||
wxString m_title;
|
||||
wxString m_filePath;
|
||||
wxString m_arguments;
|
||||
|
@@ -141,13 +141,23 @@ bool MyApp::OnInit()
|
||||
return false;
|
||||
wxJumpList jump;
|
||||
wxJumpListItems tasks;
|
||||
wxJumpListItem item(wxT("Task 1"),
|
||||
wxJumpListItem item1(wxJUMP_LIST_TASK,
|
||||
wxT("Task 1"),
|
||||
wxStandardPaths::Get().GetExecutablePath(),
|
||||
wxEmptyString,
|
||||
wxT("Test Task"),
|
||||
wxStandardPaths::Get().GetExecutablePath(),
|
||||
0);
|
||||
tasks.push_back(item);
|
||||
wxJumpListItem item2(wxJUMP_LIST_TASK,
|
||||
wxT("Task 2"),
|
||||
wxStandardPaths::Get().GetExecutablePath(),
|
||||
wxEmptyString,
|
||||
wxT("Test Task"),
|
||||
wxStandardPaths::Get().GetExecutablePath(),
|
||||
0);
|
||||
tasks.push_back(item1);
|
||||
tasks.push_back(wxJumpListItem(wxJUMP_LIST_SEPARATOR));
|
||||
tasks.push_back(item2);
|
||||
jump.SetTasks(tasks);
|
||||
|
||||
MyFrame *frame = new MyFrame("wxTaskBarButton App");
|
||||
|
@@ -122,7 +122,6 @@ public:
|
||||
virtual HRESULT wxSTDCALL SetThumbnailClip(HWND, RECT *) = 0;
|
||||
};
|
||||
|
||||
|
||||
class IShellLinkA : public IUnknown
|
||||
{
|
||||
public:
|
||||
@@ -214,7 +213,7 @@ THUMBBUTTONFLAGS GetNativeThumbButtonFlags(const wxThumbBarButton& button)
|
||||
return static_cast<THUMBBUTTONFLAGS>(flags);
|
||||
}
|
||||
|
||||
IShellLink* CreateShellLink(const wxJumpListItem& item)
|
||||
bool AddShellLink(IObjectCollection *collection, const wxJumpListItem& item)
|
||||
{
|
||||
IShellLink* shellLink = NULL;
|
||||
IPropertyStore* propertyStore = NULL;
|
||||
@@ -230,9 +229,11 @@ IShellLink* CreateShellLink(const wxJumpListItem& item)
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
wxLogApiError("CoCreateInstance(wxCLSID_ShellLink)", hr);
|
||||
return shellLink;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( item.GetType() == wxJUMP_LIST_TASK )
|
||||
{
|
||||
if ( !item.GetFilePath().IsEmpty() )
|
||||
shellLink->SetPath(item.GetFilePath().wc_str());
|
||||
if ( !item.GetArguments().IsEmpty() )
|
||||
@@ -244,25 +245,46 @@ IShellLink* CreateShellLink(const wxJumpListItem& item)
|
||||
}
|
||||
if ( !item.GetTooltip().IsEmpty() )
|
||||
shellLink->SetDescription(item.GetTooltip().wc_str());
|
||||
}
|
||||
|
||||
hr = shellLink->QueryInterface(IID_IPropertyStore,
|
||||
reinterpret_cast<void**>(&(propertyStore)));
|
||||
if ( SUCCEEDED(hr ))
|
||||
if ( FAILED(hr) )
|
||||
{
|
||||
wxLogApiError("IShellLink(QueryInterface)", hr);
|
||||
shellLink->Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
PROPVARIANT pv;
|
||||
if ( item.GetType() == wxJUMP_LIST_TASK )
|
||||
{
|
||||
hr = InitPropVariantFromString(item.GetTitle().wc_str(), &pv);
|
||||
if ( SUCCEEDED(hr) )
|
||||
{
|
||||
hr = propertyStore->SetValue(PKEY_Title, pv);
|
||||
}
|
||||
}
|
||||
else if ( item.GetType() == wxJUMP_LIST_SEPARATOR )
|
||||
{
|
||||
hr = InitPropVariantFromBoolean(TRUE, &pv);
|
||||
if ( SUCCEEDED(hr) )
|
||||
{
|
||||
hr = propertyStore->SetValue(PKEY_AppUserModel_IsDestListSeparator,
|
||||
pv);
|
||||
}
|
||||
}
|
||||
|
||||
//Save the changes we made to the property store
|
||||
// Save the changes we made to the property store.
|
||||
propertyStore->Commit();
|
||||
propertyStore->Release();
|
||||
PropVariantClear(&pv);
|
||||
}
|
||||
|
||||
return shellLink;
|
||||
// Add this IShellLink object to the given collection.
|
||||
hr = collection->AddObject(shellLink);
|
||||
|
||||
shellLink->Release();
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -639,13 +661,15 @@ void wxAppProgressIndicator::Init()
|
||||
}
|
||||
}
|
||||
|
||||
wxJumpListItem::wxJumpListItem(const wxString& title,
|
||||
wxJumpListItem::wxJumpListItem(wxJumpListItemType type,
|
||||
const wxString& title,
|
||||
const wxString& filePath,
|
||||
const wxString& arguments,
|
||||
const wxString& tooltip,
|
||||
const wxString& iconPath,
|
||||
int iconIndex)
|
||||
: m_title(title),
|
||||
: m_type(type),
|
||||
m_title(title),
|
||||
m_filePath(filePath),
|
||||
m_arguments(arguments),
|
||||
m_tooltip(tooltip),
|
||||
@@ -654,6 +678,17 @@ wxJumpListItem::wxJumpListItem(const wxString& title,
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxJumpListItemType wxJumpListItem::GetType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void wxJumpListItem::SetType(wxJumpListItemType type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
const wxString& wxJumpListItem::GetTitle() const
|
||||
{
|
||||
return m_title;
|
||||
@@ -793,7 +828,7 @@ void wxJumpList::AddTasksToDestinationList()
|
||||
iter != m_tasks.end();
|
||||
++iter )
|
||||
{
|
||||
collection->AddObject(CreateShellLink(*iter));
|
||||
AddShellLink(collection, *iter);
|
||||
}
|
||||
m_destinationList->AddUserTasks(objectArray);
|
||||
|
||||
|
Reference in New Issue
Block a user