[win] fix bug 66039: add to recent

This commit is contained in:
SimplestStudio
2024-05-16 12:32:49 +03:00
parent fecbe2c259
commit a59ba77685
3 changed files with 17 additions and 3 deletions

View File

@ -101,6 +101,7 @@ HRESULT _CreateShellLink(PCWSTR pszArguments, PCWSTR pszTitle, IShellLink **ppsl
HRESULT _AddTasksToList(ICustomDestinationList *pcdl, QStringList list)
{
pcdl->AppendKnownCategory(KDC_RECENT);
IObjectCollection *poc;
HRESULT hr = CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&poc));
if (SUCCEEDED(hr))
@ -145,6 +146,7 @@ void CreateJumpList(const QStringList &list)
ICustomDestinationList *pcdl;
hr = CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pcdl));
if (SUCCEEDED(hr)) {
pcdl->SetAppID(TEXT(APP_USER_MODEL_ID));
UINT cMinSlots;
IObjectArray *poaRemoved;
hr = pcdl->BeginList(&cMinSlots, IID_PPV_ARGS(&poaRemoved));

View File

@ -2045,6 +2045,7 @@ begin
if Length(argsArray[1]) <> 0 then
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0], '', argsArray[1]);
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0], 'AppUserModelID', ExpandConstant('{#APP_USER_MODEL_ID}'));
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0] + '\DefaultIcon', '', ExpandConstant('{app}\{#iconsExe},' + argsArray[2]));
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Classes\' + argsArray[0] + '\shell\open\command', '', ExpandConstant('"{app}\{#iconsExe}" "%1"'));
//end;

View File

@ -714,11 +714,22 @@ bool Utils::updatesAllowed()
void Utils::addToRecent(const std::wstring &path)
{
QString _path = QString::fromStdWString(path);
#ifdef _WIN32
QString appPath = qApp->applicationDirPath();
QProcess::startDetached(appPath + "/" + QString(REG_APP_NAME), {"--add-to-recent", QDir::toNativeSeparators(_path)}, appPath);
std::wstring _path(path);
std::replace(_path.begin(), _path.end(), '/', '\\');
# ifdef __OS_WIN_XP
SHAddToRecentDocs(SHARD_PATH, _path.c_str());
# else
if (LPITEMIDLIST idl = ILCreateFromPath(_path.c_str())) {
SHARDAPPIDINFOIDLIST inf;
inf.pidl = static_cast<PCIDLIST_ABSOLUTE>(idl);
inf.pszAppID = TEXT(APP_USER_MODEL_ID);
SHAddToRecentDocs(SHARD_APPIDINFOIDLIST, &inf);
ILFree(idl);
}
# endif
#else
QString _path = QString::fromStdWString(path);
std::string uri = "file://" + _path.toStdString();
add_to_recent(uri.c_str());
#endif