[feat] add configuration to minimize to system tray when clicking the close button, refs #4

This commit is contained in:
dijunkun
2025-10-22 17:21:47 +08:00
parent 5fed09c1aa
commit 2f0b0ffc22
12 changed files with 2326 additions and 1940 deletions

View File

@@ -44,6 +44,9 @@ int ConfigCenter::Load() {
enable_self_hosted_ =
ini_.GetBoolValue(section_, "enable_self_hosted", enable_self_hosted_);
enable_minimize_to_tray_ = ini_.GetBoolValue(
section_, "enable_minimize_to_tray", enable_minimize_to_tray_);
return 0;
}
@@ -62,6 +65,8 @@ int ConfigCenter::Save() {
ini_.SetLongValue(section_, "server_port", static_cast<long>(server_port_));
ini_.SetValue(section_, "cert_file_path", cert_file_path_.c_str());
ini_.SetBoolValue(section_, "enable_self_hosted", enable_self_hosted_);
ini_.SetBoolValue(section_, "enable_minimize_to_tray",
enable_minimize_to_tray_);
SI_Error rc = ini_.SaveFile(config_path_.c_str());
if (rc < 0) {
@@ -186,6 +191,11 @@ int ConfigCenter::SetSelfHosted(bool enable_self_hosted) {
return 0;
}
int ConfigCenter::SetMinimizeToTray(bool enable_minimize_to_tray) {
enable_minimize_to_tray_ = enable_minimize_to_tray;
return 0;
}
// getters
ConfigCenter::LANGUAGE ConfigCenter::GetLanguage() const { return language_; }
@@ -226,4 +236,6 @@ std::string ConfigCenter::GetDefaultCertFilePath() const {
return cert_file_path_default_;
}
bool ConfigCenter::IsSelfHosted() const { return enable_self_hosted_; }
bool ConfigCenter::IsSelfHosted() const { return enable_self_hosted_; }
bool ConfigCenter::IsMinimizeToTray() const { return enable_minimize_to_tray_; }

View File

@@ -36,6 +36,7 @@ class ConfigCenter {
int SetServerPort(int server_port);
int SetCertFilePath(const std::string& cert_file_path);
int SetSelfHosted(bool enable_self_hosted);
int SetMinimizeToTray(bool enable_minimize_to_tray);
// read config
@@ -53,6 +54,7 @@ class ConfigCenter {
int GetDefaultServerPort() const;
std::string GetDefaultCertFilePath() const;
bool IsSelfHosted() const;
bool IsMinimizeToTray() const;
int Load();
int Save();
@@ -76,6 +78,7 @@ class ConfigCenter {
int server_port_default_ = 9099;
std::string cert_file_path_default_ = "";
bool enable_self_hosted_ = false;
bool enable_minimize_to_tray_ = false;
};
#endif