This commit is contained in:
DavidXanatos 2023-08-03 20:17:52 +02:00
parent b3ca34adf4
commit 7fcdebca8b
4 changed files with 38 additions and 25 deletions

View File

@ -84,8 +84,8 @@ bool CBoxObject::MakeShortcut(const QString& Target, const QVariantMap& Options)
location = QStandardPaths::ApplicationsLocation; location = QStandardPaths::ApplicationsLocation;
else if (Location.compare("documents", Qt::CaseInsensitive) == 0) else if (Location.compare("documents", Qt::CaseInsensitive) == 0)
location = QStandardPaths::DocumentsLocation; location = QStandardPaths::DocumentsLocation;
if (location != -1) {
QString Name = Options["name"].toString(); QString Name = Options["name"].toString();
if (location != -1) {
QString Path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).replace("/", "\\"); QString Path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).replace("/", "\\");
if (Target == "default_browser") if (Target == "default_browser")
Path += "\\" + CSettingsWindow::tr("Sandboxed Web Browser") + ".lnk"; Path += "\\" + CSettingsWindow::tr("Sandboxed Web Browser") + ".lnk";
@ -96,7 +96,7 @@ bool CBoxObject::MakeShortcut(const QString& Target, const QVariantMap& Options)
QString StartExe = theAPI->GetSbiePath() + "\\SandMan.exe"; QString StartExe = theAPI->GetSbiePath() + "\\SandMan.exe";
return CSbieUtils::CreateShortcut(StartExe, Path, "", getName(), Target); return CSbieUtils::CreateShortcut(StartExe, Path, "", getName(), Target);
} }
return CSbieView::CreateShortcut(Target, getName(), Options["iconPath"].toString(), Options["iconIndex"].toInt(), Options["workDir"].toString()); return CSbieView::CreateShortcutEx(Target, getName(), Name, Options["iconPath"].toString(), Options["iconIndex"].toInt(), Options["workDir"].toString());
} }
void CSBoxObject::ApplyChanges(bool bApply) void CSBoxObject::ApplyChanges(bool bApply)

View File

@ -1470,7 +1470,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
if (!CSbieUtils::GetStartMenuShortcut(theAPI, BoxName, LinkPath, IconPath, IconIndex, WorkDir)) if (!CSbieUtils::GetStartMenuShortcut(theAPI, BoxName, LinkPath, IconPath, IconIndex, WorkDir))
return; return;
CreateShortcut(LinkPath, BoxName, IconPath, IconIndex, WorkDir); CreateShortcutEx(LinkPath, BoxName, "", IconPath, IconIndex, WorkDir);
} }
else // custom run menu command else // custom run menu command
{ {
@ -1487,9 +1487,9 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
theGUI->CheckResults(Results, this); theGUI->CheckResults(Results, this);
} }
bool CSbieView::CreateShortcut(const QString& LinkPath, const QString& BoxName, const QString &IconPath, int IconIndex, const QString &WorkDir) bool CSbieView::CreateShortcutEx(const QString& LinkPath, const QString& BoxName, QString LinkName, const QString &IconPath, int IconIndex, const QString &WorkDir)
{ {
QString LinkName; if (LinkName.isEmpty()) {
int pos = LinkPath.lastIndexOf(L'\\'); int pos = LinkPath.lastIndexOf(L'\\');
if (pos == -1) if (pos == -1)
return false; return false;
@ -1501,6 +1501,7 @@ bool CSbieView::CreateShortcut(const QString& LinkPath, const QString& BoxName,
if (pos != -1) if (pos != -1)
LinkName = LinkName.left(pos); LinkName = LinkName.left(pos);
} }
}
QString Path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).replace("/", "\\"); QString Path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).replace("/", "\\");
//Path = QFileDialog::getExistingDirectory(this, tr("Select Directory to create Shortcut in"), Path).replace("/", "\\"); //Path = QFileDialog::getExistingDirectory(this, tr("Select Directory to create Shortcut in"), Path).replace("/", "\\");
@ -1822,6 +1823,7 @@ void CSbieView::OnMenuContextMenu(const QPoint& point)
m_pCtxPinToRun->setData(FoundPin); m_pCtxPinToRun->setData(FoundPin);
m_pCtxMkLink->setData(pBoxPlus->GetFullCommand(LinkTarget)); m_pCtxMkLink->setData(pBoxPlus->GetFullCommand(LinkTarget));
m_pCtxMkLink->setProperty("Name", pAction->text());
m_pCtxMkLink->setProperty("Icon", pBoxPlus->GetFullCommand(pAction->property("Icon").toString())); m_pCtxMkLink->setProperty("Icon", pBoxPlus->GetFullCommand(pAction->property("Icon").toString()));
m_pCtxMkLink->setProperty("IconIndex", pAction->property("IconIndex")); m_pCtxMkLink->setProperty("IconIndex", pAction->property("IconIndex"));
m_pCtxMkLink->setProperty("WorkingDir", pBoxPlus->GetFullCommand(pAction->property("WorkingDir").toString())); m_pCtxMkLink->setProperty("WorkingDir", pBoxPlus->GetFullCommand(pAction->property("WorkingDir").toString()));
@ -1849,12 +1851,13 @@ void CSbieView::OnMenuContextAction()
else if (pAction == m_pCtxMkLink) else if (pAction == m_pCtxMkLink)
{ {
QString LinkTarget = m_pCtxMkLink->data().toString(); QString LinkTarget = m_pCtxMkLink->data().toString();
QString LinkName = m_pCtxMkLink->property("Name").toString();
QString Icon = m_pCtxMkLink->property("Icon").toString(); QString Icon = m_pCtxMkLink->property("Icon").toString();
int IconIndex = m_pCtxMkLink->property("IconIndex").toInt(); int IconIndex = m_pCtxMkLink->property("IconIndex").toInt();
QString WorkingDir = m_pCtxMkLink->property("WorkingDir").toString(); QString WorkingDir = m_pCtxMkLink->property("WorkingDir").toString();
QString BoxName = pBoxPlus->GetName(); QString BoxName = pBoxPlus->GetName();
CreateShortcut(LinkTarget, BoxName, Icon, IconIndex, WorkingDir); CreateShortcutEx(LinkTarget, BoxName, LinkName, Icon, IconIndex, WorkingDir);
} }
} }
@ -1904,16 +1907,26 @@ void CSbieView::UpdateRunMenu(const CSandBoxPtr& pBox)
} else } else
pMenu = GetMenuFolder(FolderName.first.replace("\\", "/"), m_pMenuRun, m_RunFolders); pMenu = GetMenuFolder(FolderName.first.replace("\\", "/"), m_pMenuRun, m_RunFolders);
StrPair IconIndex = Split2(Entry["Icon"].toString(), ",", true); StrPair FileIndex = Split2(Entry["Icon"].toString(), ",", true);
QString IconFile;
int IconIndex = 0;
if (FileIndex.first.isEmpty())
IconFile = pBoxEx->GetCommandFile(Entry["Command"].toString());
else if (FileIndex.second.isEmpty()) {
IconFile = pBoxEx->GetCommandFile(Entry["Command"].toString());
IconIndex = FileIndex.first.toInt();
}
else {
IconFile = FileIndex.first.replace("%BoxRoot%", pBoxEx->GetFileRoot(), Qt::CaseInsensitive);
IconIndex = FileIndex.second.toInt();
}
QAction* pAction = pMenu->addAction(FolderName.second, this, SLOT(OnSandBoxAction())); QAction* pAction = pMenu->addAction(FolderName.second, this, SLOT(OnSandBoxAction()));
if (IconIndex.first.isEmpty()) pAction->setIcon(LoadWindowsIcon(IconFile, IconIndex));
pAction->setIcon(m_IconProvider.icon(QFileInfo(pBoxEx->GetCommandFile(Entry["Command"].toString()))));
else if(IconIndex.second.isEmpty())
pAction->setIcon(LoadWindowsIcon(pBoxEx->GetCommandFile(Entry["Command"].toString()), IconIndex.first.toInt()));
else
pAction->setIcon(LoadWindowsIcon(IconIndex.first.replace("%BoxRoot%", pBoxEx->GetFileRoot(), Qt::CaseInsensitive), IconIndex.second.toInt()));
pAction->setData(Entry["Command"].toString()); pAction->setData(Entry["Command"].toString());
pAction->setProperty("Icon", IconFile);
pAction->setProperty("IconIndex", IconIndex);
pAction->setProperty("WorkingDir", Entry["WorkingDir"]); pAction->setProperty("WorkingDir", Entry["WorkingDir"]);
} }

View File

@ -65,7 +65,7 @@ public:
QMap<QString, QStringList> GetGroups() { return m_Groups; } QMap<QString, QStringList> GetGroups() { return m_Groups; }
static bool CreateShortcut(const QString& LinkPath, const QString& BoxName, const QString& IconPath = QString(), int IconIndex = 0, const QString& WorkDir = QString()); static bool CreateShortcutEx(const QString& LinkPath, const QString& BoxName, QString LinkName = QString(), const QString& IconPath = QString(), int IconIndex = 0, const QString& WorkDir = QString());
signals: signals:
void BoxSelected(); void BoxSelected();

View File

@ -3,7 +3,7 @@
#define VERSION_MJR 1 #define VERSION_MJR 1
#define VERSION_MIN 10 #define VERSION_MIN 10
#define VERSION_REV 2 #define VERSION_REV 2
#define VERSION_UPD 4 #define VERSION_UPD 5
#ifndef STR #ifndef STR
#define STR2(X) #X #define STR2(X) #X