hide to tray

This commit is contained in:
Jeff Becker 2020-11-25 07:28:26 -05:00
parent 5c0a4fc3dc
commit 1336536387
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 19 additions and 18 deletions

View File

@ -11,7 +11,7 @@ import "."
ApplicationWindow {
id: window
title: qsTr("Lokinet Control Panel")
visible: nohide
visible: true
flags: nohide ? Qt.Window : Qt.FramelessWindowHint
maximumHeight: minimumHeight
maximumWidth: minimumWidth
@ -27,12 +27,12 @@ ApplicationWindow {
}
}
/*
onClosing: {
if (notray) {
window.exitApp();
}
window.exitApp();
}
*/
ControlPanel {
id: controlPanel
}
@ -50,7 +50,7 @@ ApplicationWindow {
}
function display() {
/*
var rect = platformDetails.getAbsoluteCursorPosition();
console.log("mouse cursor at: "+ rect.x +", "+ rect.y);
@ -82,9 +82,8 @@ ApplicationWindow {
window.x = winX;
window.y = winY;
console.log("updated window popup position: "+ window.x + ", "+ window.y);
*/
window.show();
window.raise();
window.requestActivate();
@ -94,7 +93,7 @@ ApplicationWindow {
SystemTrayIcon {
id: systray
tooltip: qsTr("Loki Network")
visible: !notray
visible: true
iconSource: "qrc:/res/images/icon.svg"
menu: Menu {
@ -109,7 +108,7 @@ ApplicationWindow {
}
MenuItem {
text: qsTr("Hide")
visible: (platformDetails.isDebug() || platformDetails.isLinux())
// visible: (platformDetails.isDebug() || platformDetails.isLinux())
onTriggered: {
window.visible = false;
}
@ -166,6 +165,8 @@ ApplicationWindow {
// left click
case SystemTrayIcon.Trigger:
systrayMenu.open();
break;
case SystemTrayIcon.DoubleClick:
// Qt on MacOS only gives us one event to work with, namely

View File

@ -30,11 +30,11 @@ int32_t main(int32_t argc, char *argv[])
qDebug() << "Run-time Qt Version:" << qVersion();
// crude CLI option parsing
bool nohide = false;
bool nohide = true;
bool notray = true;
for (int i=0; argv[i] != nullptr; ++i) {
std::string arg = argv[i];
if (arg == "--nohide" || arg == "--no-hide") nohide = true;
if (arg == "--hide") nohide = false;
if (arg == "--tray") notray = false;
if (arg == "--rpc" and argv[i+1] != nullptr)
{
@ -42,10 +42,6 @@ int32_t main(int32_t argc, char *argv[])
}
}
// notray implies nohide
if (notray)
nohide = true;
qDebug() << "nohide: " << (nohide ? "T":"F");
qDebug() << "notray: " << (notray ? "T":"F");
qRegisterMetaType<QJSValueList>("QJSValueList");

View File

@ -7,7 +7,8 @@
#include <sstream>
#include <memory>
#include <mutex>
#include <future>
using namespace std::literals::chrono_literals;
constexpr auto MANAGED_KILL_WAIT = 5s;
@ -81,8 +82,11 @@ bool LokinetProcessManager::stopLokinetProcess()
bool LokinetProcessManager::doStopLokinetProcess()
{
bool success = m_apiClient.llarpAdminDie([](auto) {
std::promise<void> waiter;
const auto success = m_apiClient.llarpAdminDie([&waiter](auto) {
waiter.set_value();
});
waiter.get_future().get();
if (!success)
{
qDebug("Failed to stop lokinet process with llarp.admin.die API call");