Add an optional option for automatic unmount.

This commit is contained in:
love-code-yeyixiao 2024-03-23 18:55:45 +08:00
parent c78a6409bb
commit 2e2120d00e
4 changed files with 151 additions and 145 deletions

View File

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

View File

@ -1718,7 +1718,7 @@ SB_STATUS CSandMan::ImBoxMount(const CSandBoxPtr& pBox, bool bAutoUnmount)
CBoxImageWindow window(CBoxImageWindow::eMount, this);
if (theGUI->SafeExec(&window) != 1)
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)

View File

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

View File

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