Merge pull request #4089 from love-code-yeyixiao/master
OpenFilePath Shell
This commit is contained in:
commit
d44447934d
|
@ -523,6 +523,43 @@ void CSbieUtils::RemoveContextMenu3()
|
||||||
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\addforce");
|
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\addforce");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CSbieUtils::HasContextMenu4()
|
||||||
|
{
|
||||||
|
const wchar_t* key = L"Software\\Classes\\*\\shell\\addopen\\command";
|
||||||
|
//const wchar_t* key2 = L"Software\\Classes\\*\\Folder\\addforce\\command";
|
||||||
|
HKEY hkey, hKey2;
|
||||||
|
LONG rc = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey);
|
||||||
|
if (rc != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
|
||||||
|
|
||||||
|
/*rc = RegOpenKeyEx(HKEY_CURRENT_USER, key2, 0, KEY_READ, &hkey2);
|
||||||
|
if (rc != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RegCloseKey(hkey2);*/
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSbieUtils::AddContextMenu4(const QString& StartPath, const QString& RunStr, const QString& IconPath)
|
||||||
|
{
|
||||||
|
std::wstring start_path = L"\"" + StartPath.toStdWString() + L"\"";
|
||||||
|
std::wstring icon_path = L"\"" + (IconPath.isEmpty() ? StartPath : IconPath).toStdWString() + L"\"";
|
||||||
|
|
||||||
|
CreateShellEntry(L"*", L"addopen", RunStr.toStdWString(), icon_path, start_path + L" /add_open \"%1\" %*");
|
||||||
|
CreateShellEntry(L"Folder", L"addopen", RunStr.toStdWString(), icon_path, start_path + L" /add_open \"%1\" %*");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSbieUtils::RemoveContextMenu4()
|
||||||
|
{
|
||||||
|
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\addopen");
|
||||||
|
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\addopen");
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// Shortcuts
|
// Shortcuts
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,10 @@ public:
|
||||||
static void AddContextMenu3(const QString& StartPath, const QString& RunStr, const QString& IconPath = QString());
|
static void AddContextMenu3(const QString& StartPath, const QString& RunStr, const QString& IconPath = QString());
|
||||||
static void RemoveContextMenu3();
|
static void RemoveContextMenu3();
|
||||||
|
|
||||||
|
static bool HasContextMenu4();
|
||||||
|
static void AddContextMenu4(const QString& StartPath, const QString& RunStr, const QString& IconPath = QString());
|
||||||
|
static void RemoveContextMenu4();
|
||||||
|
|
||||||
static bool CreateShortcut(const QString& StartExe, QString LinkPath, const QString &LinkName, const QString &boxname, const QString &arguments, const QString &iconPath = QString(), int iconIndex = 0, const QString &workdir = QString(), bool bRunElevated = false);
|
static bool CreateShortcut(const QString& StartExe, QString LinkPath, const QString &LinkName, const QString &boxname, const QString &arguments, const QString &iconPath = QString(), int iconIndex = 0, const QString &workdir = QString(), bool bRunElevated = false);
|
||||||
static bool GetStartMenuShortcut(class CSbieAPI* pApi, QString &BoxName, QString &LinkPath, QString &IconPath, quint32& IconIndex, QString &WorkDir);
|
static bool GetStartMenuShortcut(class CSbieAPI* pApi, QString &BoxName, QString &LinkPath, QString &IconPath, quint32& IconIndex, QString &WorkDir);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
<enum>QTabWidget::North</enum>
|
<enum>QTabWidget::North</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>5</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabGeneral">
|
<widget class="QWidget" name="tabGeneral">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -477,7 +477,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="3">
|
<item row="2" column="1" colspan="2">
|
||||||
<widget class="QCheckBox" name="chkSvcStart">
|
<widget class="QCheckBox" name="chkSvcStart">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Start UI when a sandboxed process is started</string>
|
<string>Start UI when a sandboxed process is started</string>
|
||||||
|
@ -544,14 +544,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="2" colspan="2">
|
<item row="5" column="2">
|
||||||
<widget class="QCheckBox" name="chkAlwaysDefault">
|
<widget class="QCheckBox" name="chkAlwaysDefault">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Always use DefaultBox</string>
|
<string>Always use DefaultBox</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="2" colspan="2">
|
<item row="6" column="2">
|
||||||
<widget class="QCheckBox" name="chkShellMenu2">
|
<widget class="QCheckBox" name="chkShellMenu2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add 'Run Un-Sandboxed' to the context menu</string>
|
<string>Add 'Run Un-Sandboxed' to the context menu</string>
|
||||||
|
@ -565,7 +565,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="8" column="1" colspan="3">
|
||||||
|
<widget class="QCheckBox" name="chkShellMenu4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add 'Open Path to Certain Sandbox' to context menu</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="lblStartMenu">
|
<widget class="QLabel" name="lblStartMenu">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
@ -579,14 +586,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1" colspan="3">
|
<item row="10" column="1" colspan="2">
|
||||||
<widget class="QCheckBox" name="chkScanMenu">
|
<widget class="QCheckBox" name="chkScanMenu">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Scan shell folders and offer links in run menu</string>
|
<string>Scan shell folders and offer links in run menu</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0" colspan="2">
|
<item row="11" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_22">
|
<widget class="QLabel" name="label_22">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Integrate with Host Start Menu</string>
|
<string>Integrate with Host Start Menu</string>
|
||||||
|
@ -599,10 +606,10 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="2">
|
<item row="11" column="2">
|
||||||
<widget class="QComboBox" name="cmbIntegrateMenu"/>
|
<widget class="QComboBox" name="cmbIntegrateMenu"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="0" colspan="2">
|
<item row="12" column="0">
|
||||||
<widget class="QLabel" name="label_29">
|
<widget class="QLabel" name="label_29">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Integrate with Host Desktop</string>
|
<string>Integrate with Host Desktop</string>
|
||||||
|
@ -615,10 +622,10 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="11" column="2">
|
<item row="12" column="2">
|
||||||
<widget class="QComboBox" name="cmbIntegrateDesk"/>
|
<widget class="QComboBox" name="cmbIntegrateDesk"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="1">
|
<item row="13" column="1">
|
||||||
<spacer name="verticalSpacer_6">
|
<spacer name="verticalSpacer_6">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
@ -631,7 +638,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="3">
|
<item row="13" column="3">
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
|
|
@ -1636,7 +1636,7 @@ void CSandMan::OnMessage(const QString& MsgData)
|
||||||
setWindowState(Qt::WindowActive);
|
setWindowState(Qt::WindowActive);
|
||||||
SetForegroundWindow(MainWndHandle);
|
SetForegroundWindow(MainWndHandle);
|
||||||
}
|
}
|
||||||
else if (Message.left(4) == "Add:")
|
else if (Message.left(9) == "AddForce:")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -1660,6 +1660,24 @@ void CSandMan::OnMessage(const QString& MsgData)
|
||||||
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("Users canceled this operation."), QMessageBox::Yes, 0);
|
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("Users canceled this operation."), QMessageBox::Yes, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (Message.left(8) == "AddOpen:")
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
QString response = QInputDialog::getText(g_GUIParent, tr("Which box you want to add in?"), tr("Type the box name which you are going to set:"));
|
||||||
|
if (!response.isEmpty())
|
||||||
|
{
|
||||||
|
if (theAPI->GetBoxByName(response) != NULL) {
|
||||||
|
theAPI->GetBoxByName(response)->AppendText("OpenFilePath", Message.mid(4).replace("\"", ""));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("You typed a wrong box name!Nothing was changed."), QMessageBox::Ok, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("Users canceled this operation."), QMessageBox::Yes, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (Message.left(4) == "Run:")
|
else if (Message.left(4) == "Run:")
|
||||||
{
|
{
|
||||||
QString BoxName;
|
QString BoxName;
|
||||||
|
|
|
@ -332,6 +332,8 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
|
||||||
connect(ui.chkAlwaysDefault, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
connect(ui.chkAlwaysDefault, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
||||||
connect(ui.chkShellMenu2, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
connect(ui.chkShellMenu2, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
||||||
connect(ui.chkShellMenu3, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
connect(ui.chkShellMenu3, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
||||||
|
connect(ui.chkShellMenu4, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
||||||
|
|
||||||
|
|
||||||
connect(ui.chkScanMenu, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
connect(ui.chkScanMenu, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
|
||||||
connect(ui.cmbIntegrateMenu, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged()));
|
connect(ui.cmbIntegrateMenu, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged()));
|
||||||
|
@ -893,6 +895,7 @@ void CSettingsWindow::LoadSettings()
|
||||||
ui.chkShellMenu->setCheckState(IsContextMenu());
|
ui.chkShellMenu->setCheckState(IsContextMenu());
|
||||||
ui.chkShellMenu2->setChecked(CSbieUtils::HasContextMenu2());
|
ui.chkShellMenu2->setChecked(CSbieUtils::HasContextMenu2());
|
||||||
ui.chkShellMenu3->setChecked(CSbieUtils::HasContextMenu3());
|
ui.chkShellMenu3->setChecked(CSbieUtils::HasContextMenu3());
|
||||||
|
ui.chkShellMenu4->setChecked(CSbieUtils::HasContextMenu4());
|
||||||
ui.chkAlwaysDefault->setChecked(theConf->GetBool("Options/RunInDefaultBox", false));
|
ui.chkAlwaysDefault->setChecked(theConf->GetBool("Options/RunInDefaultBox", false));
|
||||||
|
|
||||||
ui.cmbDPI->setCurrentIndex(theConf->GetInt("Options/DPIScaling", 1));
|
ui.cmbDPI->setCurrentIndex(theConf->GetInt("Options/DPIScaling", 1));
|
||||||
|
@ -1609,6 +1612,15 @@ void CSettingsWindow::SaveSettings()
|
||||||
else
|
else
|
||||||
CSbieUtils::RemoveContextMenu3();
|
CSbieUtils::RemoveContextMenu3();
|
||||||
}
|
}
|
||||||
|
if (ui.chkShellMenu4->isChecked() != CSbieUtils::HasContextMenu4()) {
|
||||||
|
if (ui.chkShellMenu4->isChecked()) {
|
||||||
|
CSbieUtils::AddContextMenu4(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe",
|
||||||
|
tr("&Open Path to Certain Sandbox"),
|
||||||
|
QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CSbieUtils::RemoveContextMenu4();
|
||||||
|
}
|
||||||
theConf->SetValue("Options/RunInDefaultBox", ui.chkAlwaysDefault->isChecked());
|
theConf->SetValue("Options/RunInDefaultBox", ui.chkAlwaysDefault->isChecked());
|
||||||
|
|
||||||
theConf->SetValue("Options/CheckSilentMode", ui.chkSilentMode->isChecked());
|
theConf->SetValue("Options/CheckSilentMode", ui.chkSilentMode->isChecked());
|
||||||
|
|
|
@ -112,14 +112,20 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
int DfpPos = Args.indexOf("/disable_force", Qt::CaseInsensitive);
|
int DfpPos = Args.indexOf("/disable_force", Qt::CaseInsensitive);
|
||||||
int AfpPos = Args.indexOf("/add_force", Qt::CaseInsensitive);
|
int AfpPos = Args.indexOf("/add_force", Qt::CaseInsensitive);
|
||||||
|
int AOPos = Args.indexOf("/add_open", Qt::CaseInsensitive);
|
||||||
|
|
||||||
//Add_Force has the highest priority.
|
//Add_Force has the highest priority.
|
||||||
if (AfpPos != -1) {
|
if (AfpPos != -1) {
|
||||||
DfpPos = -1;
|
DfpPos = -1;
|
||||||
BoxPos = -1;
|
BoxPos = -1;
|
||||||
}else
|
}
|
||||||
|
else if (AOPos != -1)
|
||||||
|
{
|
||||||
|
DfpPos = -1;
|
||||||
|
BoxPos = -1;
|
||||||
|
}
|
||||||
// the first argument wins
|
// the first argument wins
|
||||||
if (BoxPos != -1 && DfpPos != -1) {
|
else if (BoxPos != -1 && DfpPos != -1) {
|
||||||
if (BoxPos < DfpPos) DfpPos = -1;
|
if (BoxPos < DfpPos) DfpPos = -1;
|
||||||
else BoxPos = -1;
|
else BoxPos = -1;
|
||||||
}
|
}
|
||||||
|
@ -169,10 +175,17 @@ int main(int argc, char *argv[])
|
||||||
LPWSTR cmdLine0 = wcsstr(GetCommandLineW(), L"/add_force");
|
LPWSTR cmdLine0 = wcsstr(GetCommandLineW(), L"/add_force");
|
||||||
if (!cmdLine0) return -1;
|
if (!cmdLine0) return -1;
|
||||||
LPWSTR cmdLine = cmdLine0 + 10;
|
LPWSTR cmdLine = cmdLine0 + 10;
|
||||||
g_PendingMessage = "Add:" + QString::fromWCharArray(cmdLine + 1);
|
g_PendingMessage = "AddForce:" + QString::fromWCharArray(cmdLine + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AOPos != -1) {
|
||||||
|
LPWSTR cmdLine0 = wcsstr(GetCommandLineW(), L"/add_open");
|
||||||
|
if (!cmdLine0) return -1;
|
||||||
|
LPWSTR cmdLine = cmdLine0 + 10;
|
||||||
|
g_PendingMessage = "AddOpen:" + QString::fromWCharArray(cmdLine + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (IsBoxed) {
|
if (IsBoxed) {
|
||||||
QMessageBox::critical(NULL, "Sandboxie-Plus", CSandMan::tr("Sandboxie Manager can not be run sandboxed!"));
|
QMessageBox::critical(NULL, "Sandboxie-Plus", CSandMan::tr("Sandboxie Manager can not be run sandboxed!"));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue