mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-02-10 18:05:16 +08:00
[win] fix bug 66039: add to recent
This commit is contained in:
@ -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));
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user