Merge pull request #3735 from love-code-yeyixiao/master

Add an optional option for automatic unmount
This commit is contained in:
DavidXanatos 2024-03-23 12:26:24 +01:00 committed by GitHub
commit 2cb4a9cab5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 151 additions and 145 deletions

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>518</width> <width>518</width>
<height>268</height> <height>307</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -25,148 +25,151 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QGridLayout" name="gridLayout"> <widget class="QLabel" name="lblIcon">
<item row="5" column="3"> <property name="text">
<widget class="QLabel" name="lblImageSizeKb"> <string>TextLabel</string>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> </widget>
<horstretch>0</horstretch> </item>
<verstretch>0</verstretch> <item row="0" column="1" colspan="2">
</sizepolicy> <widget class="QLabel" name="lblInfo">
</property> <property name="text">
<property name="text"> <string>TextLabel</string>
<string>kilobytes</string> </property>
</property> <property name="wordWrap">
</widget> <bool>true</bool>
</item> </property>
<item row="2" column="2" colspan="3"> </widget>
<widget class="QLineEdit" name="txtNewPassword"> </item>
<property name="echoMode"> <item row="1" column="0" colspan="2">
<enum>QLineEdit::Password</enum> <widget class="QLabel" name="lblPassword">
</property> <property name="text">
</widget> <string>Enter Password</string>
</item> </property>
<item row="3" column="2" colspan="3"> <property name="alignment">
<widget class="QLineEdit" name="txtRepeatPassword"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="echoMode"> </property>
<enum>QLineEdit::Password</enum> </widget>
</property> </item>
</widget> <item row="1" column="2" colspan="2">
</item> <widget class="QLineEdit" name="txtPassword">
<item row="7" column="2" colspan="3"> <property name="echoMode">
<widget class="QCheckBox" name="chkProtect"> <enum>QLineEdit::Password</enum>
<property name="text"> </property>
<string>Protect Box Root from access by unsandboxed processes</string> </widget>
</property> </item>
<property name="checked"> <item row="2" column="0" colspan="2">
<bool>true</bool> <widget class="QLabel" name="lblNewPassword">
</property> <property name="text">
</widget> <string>New Password</string>
</item> </property>
<item row="5" column="2"> <property name="alignment">
<widget class="QLineEdit" name="txtImageSize"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="maximumSize"> </property>
<size> </widget>
<width>100</width> </item>
<height>16777215</height> <item row="2" column="2" colspan="2">
</size> <widget class="QLineEdit" name="txtNewPassword">
</property> <property name="echoMode">
</widget> <enum>QLineEdit::Password</enum>
</item> </property>
<item row="8" column="0" colspan="5"> </widget>
<widget class="QDialogButtonBox" name="buttonBox"> </item>
<property name="standardButtons"> <item row="3" column="0" colspan="2">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <widget class="QLabel" name="lblRepeatPassword">
</property> <property name="text">
</widget> <string>Repeat Password</string>
</item> </property>
<item row="6" column="2" colspan="2"> <property name="alignment">
<widget class="QComboBox" name="cmbCipher"/> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</item> </property>
<item row="1" column="2" colspan="3"> </widget>
<widget class="QLineEdit" name="txtPassword"> </item>
<property name="echoMode"> <item row="3" column="2" colspan="2">
<enum>QLineEdit::Password</enum> <widget class="QLineEdit" name="txtRepeatPassword">
</property> <property name="echoMode">
</widget> <enum>QLineEdit::Password</enum>
</item> </property>
<item row="0" column="0"> </widget>
<widget class="QLabel" name="lblIcon"> </item>
<property name="text"> <item row="4" column="4">
<string>TextLabel</string> <widget class="QCheckBox" name="chkShow">
</property> <property name="text">
</widget> <string>Show Password</string>
</item> </property>
<item row="4" column="4"> </widget>
<widget class="QCheckBox" name="chkShow"> </item>
<property name="text"> <item row="5" column="0" colspan="2">
<string>Show Password</string> <widget class="QLabel" name="lblImageSize">
</property> <property name="text">
</widget> <string>Disk Image Size</string>
</item> </property>
<item row="1" column="0" colspan="2"> <property name="alignment">
<widget class="QLabel" name="lblPassword"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="text"> </property>
<string>Enter Password</string> </widget>
</property> </item>
<property name="alignment"> <item row="5" column="2">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <widget class="QLineEdit" name="txtImageSize">
</property> <property name="maximumSize">
</widget> <size>
</item> <width>100</width>
<item row="2" column="0" colspan="2"> <height>16777215</height>
<widget class="QLabel" name="lblNewPassword"> </size>
<property name="text"> </property>
<string>New Password</string> </widget>
</property> </item>
<property name="alignment"> <item row="5" column="3">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <widget class="QLabel" name="lblImageSizeKb">
</property> <property name="sizePolicy">
</widget> <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
</item> <horstretch>0</horstretch>
<item row="3" column="0" colspan="2"> <verstretch>0</verstretch>
<widget class="QLabel" name="lblRepeatPassword"> </sizepolicy>
<property name="text"> </property>
<string>Repeat Password</string> <property name="text">
</property> <string>kilobytes</string>
<property name="alignment"> </property>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </widget>
</property> </item>
</widget> <item row="6" column="0" colspan="2">
</item> <widget class="QLabel" name="lblCipher">
<item row="5" column="0" colspan="2"> <property name="text">
<widget class="QLabel" name="lblImageSize"> <string>Encryption Cipher</string>
<property name="text"> </property>
<string>Disk Image Size</string> <property name="alignment">
</property> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="alignment"> </property>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </widget>
</property> </item>
</widget> <item row="6" column="2">
</item> <widget class="QComboBox" name="cmbCipher"/>
<item row="6" column="0" colspan="2"> </item>
<widget class="QLabel" name="lblCipher"> <item row="7" column="2" colspan="3">
<property name="text"> <widget class="QCheckBox" name="chkProtect">
<string>Encryption Cipher</string> <property name="text">
</property> <string>Protect Box Root from access by unsandboxed processes</string>
<property name="alignment"> </property>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <property name="checked">
</property> <bool>true</bool>
</widget> </property>
</item> </widget>
<item row="0" column="1" colspan="4"> </item>
<widget class="QLabel" name="lblInfo"> <item row="8" column="2" colspan="3">
<property name="text"> <widget class="QCheckBox" name="chkAutoLock">
<string>TextLabel</string> <property name="text">
</property> <string>Lock the box when all processes stop.</string>
<property name="wordWrap"> </property>
<bool>true</bool> </widget>
</property> </item>
</widget> <item row="9" column="0" colspan="3">
</item> <widget class="QDialogButtonBox" name="buttonBox">
</layout> <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -1718,7 +1718,7 @@ SB_STATUS CSandMan::ImBoxMount(const CSandBoxPtr& pBox, bool bAutoUnmount)
CBoxImageWindow window(CBoxImageWindow::eMount, this); CBoxImageWindow window(CBoxImageWindow::eMount, this);
if (theGUI->SafeExec(&window) != 1) if (theGUI->SafeExec(&window) != 1)
return SB_ERR(SB_Canceled); return SB_ERR(SB_Canceled);
return pBox->ImBoxMount(window.GetPassword(), window.UseProtection(), bAutoUnmount); return pBox->ImBoxMount(window.GetPassword(), window.UseProtection(), window.AutoUnMount());
} }
void CSandMan::dropEvent(QDropEvent* e) void CSandMan::dropEvent(QDropEvent* e)

View File

@ -93,8 +93,10 @@ CBoxImageWindow::CBoxImageWindow(EAction Action, QWidget *parent)
ui.cmbCipher->addItem("Serpent-AES", 5); ui.cmbCipher->addItem("Serpent-AES", 5);
ui.cmbCipher->addItem("AES-Twofish-Serpent", 6); ui.cmbCipher->addItem("AES-Twofish-Serpent", 6);
if (m_Action != eMount) if (m_Action != eMount) {
ui.chkProtect->setVisible(false); ui.chkProtect->setVisible(false);
ui.chkAutoLock->setVisible(false);
}
//restoreGeometry(theConf->GetBlob("BoxImageWindow/Window_Geometry")); //restoreGeometry(theConf->GetBlob("BoxImageWindow/Window_Geometry"));
} }
@ -158,4 +160,4 @@ void CBoxImageWindow::CheckPassword()
} }
accept(); accept();
} }

View File

@ -25,6 +25,7 @@ public:
void SetImageSize(quint64 uSize) const { return ui.txtImageSize->setText(QString::number(uSize / 1024)); } void SetImageSize(quint64 uSize) const { return ui.txtImageSize->setText(QString::number(uSize / 1024)); }
quint64 GetImageSize() const { return ui.txtImageSize->text().toULongLong() * 1024; } quint64 GetImageSize() const { return ui.txtImageSize->text().toULongLong() * 1024; }
bool UseProtection() const { return ui.chkProtect->isChecked(); } bool UseProtection() const { return ui.chkProtect->isChecked(); }
bool AutoUnMount() const { return ui.chkAutoLock->isChecked(); }
private slots: private slots:
void OnShowPassword(); void OnShowPassword();