tray improvements
This commit is contained in:
DavidXanatos 2023-09-02 10:50:25 +02:00
parent 6302082442
commit 7b964e2d9a
6 changed files with 273 additions and 163 deletions

View File

@ -9,11 +9,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added ### Added
- added update warning when updating with an expired personal certificate - added update warning when updating with an expired personal certificate
- added an option to terminate the UI by clicking close button [#3253](https://github.com/sandboxie-plus/Sandboxie/issues/3253)
- added an option to restore Sandboxie that is minimized to the System Tray with a single click [#3251](https://github.com/sandboxie-plus/Sandboxie/issues/3251)
- added an option to minimize Sandboxie to the System Tray by clicking minimize button [3252](https://github.com/sandboxie-plus/Sandboxie/issues/3252)
### Changed
- moved tray option to an own tab
### Fixed ### Fixed
- fixed subscription certificate recognition issue - fixed subscription certificate recognition issue
## [1.11.1 / 5.66.1] - 2023-08-31 ## [1.11.1 / 5.66.1] - 2023-08-31
### Added ### Added

View File

@ -406,118 +406,33 @@
<layout class="QGridLayout" name="gridLayout_30"> <layout class="QGridLayout" name="gridLayout_30">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_13"> <layout class="QGridLayout" name="gridLayout_13">
<item row="12" column="0"> <item row="9" column="2">
<widget class="QLabel" name="label_21"> <widget class="QComboBox" name="cmbIntegrateMenu"/>
</item>
<item row="4" column="1" colspan="3">
<widget class="QCheckBox" name="chkShellMenu">
<property name="text"> <property name="text">
<string>Show boxes in tray list:</string> <string>Add 'Run Sandboxed' to the explorer context menu</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="1" colspan="2"> <item row="0" column="0">
<widget class="QComboBox" name="cmbTrayBoxes"/> <widget class="QLabel" name="lblStartUp">
</item>
<item row="7" column="0">
<widget class="QLabel" name="lblStartMenu">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>Start Menu Integration</string> <string>Start Sandbox Manager</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="13" column="1" colspan="3"> <item row="2" column="1" colspan="3">
<widget class="QCheckBox" name="chkBoxOpsNotify"> <widget class="QCheckBox" name="chkSvcStart">
<property name="text"> <property name="text">
<string>Show a tray notification when automatic box operations are started</string> <string>Start UI when a sandboxed process is started</string>
</property>
</widget>
</item>
<item row="14" column="1">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="3">
<widget class="QCheckBox" name="chkCompactTray">
<property name="text">
<string>Use Compact Box List</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="lblSysTray">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Systray options</string>
</property>
</widget>
</item>
<item row="5" column="2" colspan="3">
<widget class="QCheckBox" name="chkAlwaysDefault">
<property name="text">
<string>Always use DefaultBox</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblRunBoxed">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Run Sandboxed - Actions</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="3">
<widget class="QCheckBox" name="chkScanMenu">
<property name="text">
<string>Scan shell folders and offer links in run menu</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -528,23 +443,24 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1" colspan="3"> <item row="5" column="2" colspan="3">
<widget class="QCheckBox" name="chkShellMenu"> <widget class="QCheckBox" name="chkAlwaysDefault">
<property name="text"> <property name="text">
<string>Add 'Run Sandboxed' to the explorer context menu</string> <string>Always use DefaultBox</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="2"> <item row="1" column="1" colspan="3">
<widget class="QLabel" name="label_22"> <widget class="QCheckBox" name="chkAutoStart">
<property name="text"> <property name="text">
<string>Integrate with Host Start Menu</string> <string>Start UI with Windows</string>
</property> </property>
<property name="alignment"> </widget>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </item>
</property> <item row="8" column="1" colspan="3">
<property name="openExternalLinks"> <widget class="QCheckBox" name="chkScanMenu">
<bool>true</bool> <property name="text">
<string>Scan shell folders and offer links in run menu</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -561,52 +477,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="9" column="2">
<widget class="QComboBox" name="cmbIntegrateMenu"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblStartUp">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Start Sandbox Manager</string>
</property>
</widget>
</item>
<item row="11" column="1" colspan="2">
<widget class="QComboBox" name="cmbSysTray"/>
</item>
<item row="14" column="3" colspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Show Icon in Systray:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLabel" name="label_37"> <widget class="QLabel" name="label_37">
<property name="maximumSize"> <property name="maximumSize">
@ -620,17 +490,204 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="3"> <item row="3" column="0">
<widget class="QCheckBox" name="chkAutoStart"> <widget class="QLabel" name="lblRunBoxed">
<property name="font">
<font>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text"> <property name="text">
<string>Start UI with Windows</string> <string>Run Sandboxed - Actions</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" colspan="3"> <item row="7" column="0">
<widget class="QCheckBox" name="chkSvcStart"> <widget class="QLabel" name="lblStartMenu">
<property name="font">
<font>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text"> <property name="text">
<string>Start UI when a sandboxed process is started</string> <string>Start Menu Integration</string>
</property>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0" colspan="2">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Integrate with Host Start Menu</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="1">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="10" column="3" colspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTray">
<attribute name="title">
<string>System Tray</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_42">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_41">
<item row="2" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Show boxes in tray list:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Show Icon in Systray:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cmbSysTray"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblSysTray">
<property name="font">
<font>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Systray options</string>
</property>
</widget>
</item>
<item row="6" column="1">
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_14">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="chkCompactTray">
<property name="text">
<string>Use Compact Box List</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="cmbOnClose"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cmbTrayBoxes"/>
</item>
<item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="chkBoxOpsNotify">
<property name="text">
<string>Show a tray notification when automatic box operations are started</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_28">
<property name="text">
<string>On main window close:</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QCheckBox" name="chkSingleShow">
<property name="text">
<string>Open/Close from/to tray with a single click</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="chkMinimize">
<property name="text">
<string>Minimize to tray</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -1295,7 +1295,8 @@ void CSandMan::closeEvent(QCloseEvent *e)
{ {
if (!m_bExit)// && !theAPI->IsConnected()) if (!m_bExit)// && !theAPI->IsConnected())
{ {
if (m_pTrayIcon->isVisible()) QString OnClose = theConf->GetString("Options/OnClose", "ToTray");
if (m_pTrayIcon->isVisible() && OnClose.compare("ToTray", Qt::CaseInsensitive) == 0)
{ {
StoreState(); StoreState();
hide(); hide();
@ -1306,7 +1307,7 @@ void CSandMan::closeEvent(QCloseEvent *e)
e->ignore(); e->ignore();
return; return;
} }
else else if(OnClose.compare("Prompt", Qt::CaseInsensitive) == 0)
{ {
CExitDialog ExitDialog(tr("Do you want to close Sandboxie Manager?")); CExitDialog ExitDialog(tr("Do you want to close Sandboxie Manager?"));
if (!ExitDialog.exec()) if (!ExitDialog.exec())
@ -1349,6 +1350,28 @@ void CSandMan::closeEvent(QCloseEvent *e)
QApplication::quit(); QApplication::quit();
} }
void CSandMan::changeEvent(QEvent* e)
{
if (e->type() == QEvent::WindowStateChange)
{
if (isMinimized())
{
if (m_pTrayIcon->isVisible() && theConf->GetBool("Options/MinimizeToTray", false))
{
StoreState();
hide();
if (theAPI->GetGlobalSettings()->GetBool("ForgetPassword", false))
theAPI->ClearPassword();
e->ignore();
return;
}
}
}
QMainWindow::changeEvent(e);
}
void CSandMan::commitData(QSessionManager& manager) void CSandMan::commitData(QSessionManager& manager)
{ {
//if (manager.allowsInteraction()) //if (manager.allowsInteraction())

View File

@ -135,6 +135,7 @@ protected:
void CheckSupport(); void CheckSupport();
void closeEvent(QCloseEvent* e); void closeEvent(QCloseEvent* e);
void changeEvent(QEvent* e);
void dragEnterEvent(QDragEnterEvent* e); void dragEnterEvent(QDragEnterEvent* e);
void dropEvent(QDropEvent* e); void dropEvent(QDropEvent* e);

View File

@ -341,6 +341,10 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
{ {
static bool TriggerSet = false; static bool TriggerSet = false;
static bool NullifyTrigger = false; static bool NullifyTrigger = false;
if (theConf->GetBool("Options/TraySingleClick", false) && Reason == QSystemTrayIcon::Trigger)
Reason = QSystemTrayIcon::DoubleClick;
switch(Reason) switch(Reason)
{ {
case QSystemTrayIcon::Context: case QSystemTrayIcon::Context:

View File

@ -134,7 +134,8 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
ui.tabsShell->setCurrentIndex(0); ui.tabsShell->setCurrentIndex(0);
ui.tabsShell->setTabIcon(0, CSandMan::GetIcon("Windows")); ui.tabsShell->setTabIcon(0, CSandMan::GetIcon("Windows"));
ui.tabsShell->setTabIcon(1, CSandMan::GetIcon("Run")); ui.tabsShell->setTabIcon(1, CSandMan::GetIcon("TaskBar"));
ui.tabsShell->setTabIcon(2, CSandMan::GetIcon("Run"));
ui.tabsGUI->setCurrentIndex(0); ui.tabsGUI->setCurrentIndex(0);
ui.tabsGUI->setTabIcon(0, CSandMan::GetIcon("Interface")); ui.tabsGUI->setTabIcon(0, CSandMan::GetIcon("Interface"));
@ -234,6 +235,10 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
ui.cmbTrayBoxes->addItem(tr("Active + Pinned")); ui.cmbTrayBoxes->addItem(tr("Active + Pinned"));
ui.cmbTrayBoxes->addItem(tr("Pinned Only")); ui.cmbTrayBoxes->addItem(tr("Pinned Only"));
ui.cmbOnClose->addItem(tr("Close to Tray"), "ToTray");
ui.cmbOnClose->addItem(tr("Prompt before Close"), "Prompt");
ui.cmbOnClose->addItem(tr("Close"), "Close");
ui.cmbDPI->addItem(tr("None"), 0); ui.cmbDPI->addItem(tr("None"), 0);
ui.cmbDPI->addItem(tr("Native"), 1); ui.cmbDPI->addItem(tr("Native"), 1);
ui.cmbDPI->addItem(tr("Qt"), 2); ui.cmbDPI->addItem(tr("Qt"), 2);
@ -315,7 +320,10 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
connect(ui.cmbSysTray, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged())); connect(ui.cmbSysTray, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.cmbTrayBoxes, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged())); connect(ui.cmbTrayBoxes, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkCompactTray, SIGNAL(stateChanged(int)), this, SLOT(OnChangeGUI())); connect(ui.chkCompactTray, SIGNAL(stateChanged(int)), this, SLOT(OnChangeGUI()));
connect(ui.cmbOnClose, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkBoxOpsNotify, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged())); connect(ui.chkBoxOpsNotify, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkMinimize, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkSingleShow, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
// //
// Interface Config // Interface Config
@ -899,6 +907,9 @@ void CSettingsWindow::LoadSettings()
ui.cmbTrayBoxes->setCurrentIndex(theConf->GetInt("Options/SysTrayFilter", 0)); ui.cmbTrayBoxes->setCurrentIndex(theConf->GetInt("Options/SysTrayFilter", 0));
ui.chkCompactTray->setChecked(theConf->GetBool("Options/CompactTray", false)); ui.chkCompactTray->setChecked(theConf->GetBool("Options/CompactTray", false));
ui.chkBoxOpsNotify->setChecked(theConf->GetBool("Options/AutoBoxOpsNotify", false)); ui.chkBoxOpsNotify->setChecked(theConf->GetBool("Options/AutoBoxOpsNotify", false));
ui.cmbOnClose->setCurrentIndex(ui.cmbOnClose->findData(theConf->GetString("Options/OnClose", "ToTray")));
ui.chkMinimize->setChecked(theConf->GetBool("Options/MinimizeToTray", false));
ui.chkSingleShow->setChecked(theConf->GetBool("Options/TraySingleClick", false));
OnLoadAddon(); OnLoadAddon();
@ -1410,6 +1421,9 @@ void CSettingsWindow::SaveSettings()
theConf->SetValue("Options/SysTrayFilter", ui.cmbTrayBoxes->currentIndex()); theConf->SetValue("Options/SysTrayFilter", ui.cmbTrayBoxes->currentIndex());
theConf->SetValue("Options/CompactTray", ui.chkCompactTray->isChecked()); theConf->SetValue("Options/CompactTray", ui.chkCompactTray->isChecked());
theConf->SetValue("Options/AutoBoxOpsNotify", ui.chkBoxOpsNotify->isChecked()); theConf->SetValue("Options/AutoBoxOpsNotify", ui.chkBoxOpsNotify->isChecked());
theConf->SetValue("Options/OnClose", ui.cmbOnClose->currentData());
theConf->SetValue("Options/MinimizeToTray", ui.chkMinimize->isChecked());
theConf->SetValue("Options/TraySingleClick", ui.chkSingleShow->isChecked());
if (theAPI->IsConnected()) if (theAPI->IsConnected())
{ {
@ -1676,6 +1690,10 @@ void CSettingsWindow::reject()
void CSettingsWindow::OnOptChanged() void CSettingsWindow::OnOptChanged()
{ {
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(ui.cmbOnClose->model());
QStandardItem *item = model->item(0);
item->setFlags((ui.cmbSysTray->currentIndex() == 0) ? item->flags() & ~Qt::ItemIsEnabled : item->flags() | Qt::ItemIsEnabled);
if (m_HoldChange) if (m_HoldChange)
return; return;
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true); ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);