-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15238ee
commit c3ac160
Showing
6 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
|
||
#include <app.h> | ||
#include <slint.h> | ||
#include <spdlog/spdlog.h> | ||
#include <thread> | ||
#include <tray.hpp> | ||
|
||
namespace evento { | ||
|
||
class SystemTray { | ||
public: | ||
SystemTray(slint::ComponentWeakHandle<App> uiWeak) | ||
: _tray("Evento Tray", "./app.ico") { | ||
std::thread trayThread([&] { | ||
_tray.addEntry(Tray::Button("显示", [&] { | ||
auto ui = *uiWeak.lock(); | ||
ui->show(); | ||
})); | ||
_tray.addEntry(Tray::Button("关于", [&] { | ||
//TODO: switch to about page | ||
})); | ||
_tray.addEntry(Tray::Button("退出", [&] { | ||
spdlog::info("exiting SAST Evento..."); | ||
_tray.exit(); | ||
slint::quit_event_loop(); | ||
_isRunning = false; | ||
})); | ||
_tray.run(); | ||
}); | ||
trayThread.detach(); | ||
} | ||
~SystemTray() { | ||
if (_isRunning) { | ||
_tray.exit(); | ||
} | ||
} | ||
|
||
private: | ||
Tray::Tray _tray; | ||
bool _isRunning = true; | ||
}; | ||
|
||
} // namespace evento |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters