Options
This commit is contained in:
@@ -190,6 +190,8 @@
|
||||
<input type="checkbox" id="ID_SettingsAutoStart"><br><br>
|
||||
<h2>Launch file manager on mount</h2>
|
||||
<input type="checkbox" id="ID_SettingsLaunchFileManager"><br><br>
|
||||
<h2>Close to system tray</h2>
|
||||
<input type="checkbox" id="ID_SettingsCloseToTray"><br><br>
|
||||
<h2>Use Bundled siad</h2>
|
||||
<input type="checkbox" id="ID_SettingsLaunchServer"><br><br>
|
||||
<h2>API Port</h2>
|
||||
|
@@ -187,6 +187,11 @@
|
||||
setChecked('ID_SettingsLaunchFileManager', launch);
|
||||
}
|
||||
},
|
||||
setCloseToTray: (closeToTray) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setChecked('ID_SettingsCloseToTray', closeToTray);
|
||||
}
|
||||
},
|
||||
displayShutdownWindow: () => {
|
||||
const div = document.getElementById('shutdown_window');
|
||||
document.body.innerHTML = '';
|
||||
@@ -347,7 +352,8 @@
|
||||
'ApiPort': getValue('ID_SettingsApiPort'),
|
||||
'HostPort': getValue('ID_SettingsHostPort'),
|
||||
'RpcPort': getValue('ID_SettingsRPCPort'),
|
||||
'LaunchFileManager': getChecked('ID_SettingsLaunchFileManager')
|
||||
'LaunchFileManager': getChecked('ID_SettingsLaunchFileManager'),
|
||||
'CloseToTray': getChecked('ID_SettingsCloseToTray')
|
||||
}, (success, reason) => {
|
||||
if (success) {
|
||||
beginMainApplication();
|
||||
|
@@ -6,6 +6,8 @@
|
||||
#include <include/base/cef_bind.h>
|
||||
#include <include/wrapper/cef_closure_task.h>
|
||||
#include <filepath.h>
|
||||
#include <siadriveconfig.h>
|
||||
|
||||
using namespace Sia;
|
||||
using namespace Sia::Api;
|
||||
|
||||
@@ -18,6 +20,7 @@ CSiaDriveHandler* g_instance = nullptr;
|
||||
static HMENU g_trayMenu = nullptr;
|
||||
static WNDPROC g_defProc;
|
||||
static NOTIFYICONDATA g_notifyIcon = { 0 };
|
||||
static bool g_trayClose = false;
|
||||
|
||||
static void ToggleWindowVisible(const HWND& wnd)
|
||||
{
|
||||
@@ -89,6 +92,11 @@ static LRESULT CALLBACK SiaWndProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
|
||||
case MENU_ITEM_EXIT:
|
||||
{
|
||||
if (!::IsWindowVisible(wnd))
|
||||
{
|
||||
ToggleWindowVisible(wnd);
|
||||
}
|
||||
g_trayClose = true;
|
||||
::PostMessage(wnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
break;
|
||||
@@ -96,6 +104,7 @@ static LRESULT CALLBACK SiaWndProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ::CallWindowProc(g_defProc, wnd, msg, wparam, lparam);
|
||||
}
|
||||
#endif
|
||||
@@ -190,10 +199,15 @@ bool CSiaDriveHandler::DoClose(CefRefPtr<CefBrowser> browser)
|
||||
|
||||
if (!_isClosing && (_browserList.size() == 1))
|
||||
{
|
||||
// Set a flag to indicate that the window close should be allowed.
|
||||
_isClosing = true;
|
||||
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("shutdownServices");
|
||||
browser->SendProcessMessage(PID_RENDERER, msg);
|
||||
CSiaDriveConfig cfg(false);
|
||||
if (!cfg.GetCloseToTray() || g_trayClose)
|
||||
{
|
||||
// Set a flag to indicate that the window close should be allowed.
|
||||
_isClosing = true;
|
||||
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("shutdownServices");
|
||||
browser->SendProcessMessage(PID_RENDERER, msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user