raise confirmation alert before quit
Some checks failed
Build Debian packages / bookworm (push) Has been cancelled
Build Debian packages / bullseye (push) Has been cancelled
Build Debian packages / trixie (push) Has been cancelled
Build on FreeBSD / with UPnP (push) Has been cancelled
Build on OSX / With USE_UPNP=no (push) Has been cancelled
Build on OSX / With USE_UPNP=yes (push) Has been cancelled
Build on Windows / clang-x86_64 (push) Has been cancelled
Build on Windows / i686 (push) Has been cancelled
Build on Windows / ucrt-x86_64 (push) Has been cancelled
Build on Windows / x86_64 (push) Has been cancelled
Build on Windows / CMake clang-x86_64 (push) Has been cancelled
Build on Windows / CMake i686 (push) Has been cancelled
Build on Windows / CMake ucrt-x86_64 (push) Has been cancelled
Build on Windows / CMake x86_64 (push) Has been cancelled
Build on Windows / XP (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=no (push) Has been cancelled
Build on Ubuntu / Make with USE_UPNP=yes (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Has been cancelled
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Has been cancelled
Build containers / Building container for linux/amd64 (push) Has been cancelled
Build containers / Building container for linux/arm64 (push) Has been cancelled
Build containers / Building container for linux/arm/v7 (push) Has been cancelled
Build containers / Building container for linux/386 (push) Has been cancelled
Build containers / Pushing merged manifest (push) Has been cancelled

This commit is contained in:
orignal 2025-10-18 09:55:36 -04:00
parent 80080fd8f5
commit 1891bd5ba5

View file

@ -47,6 +47,7 @@ class MainWindow: public BWindow
private:
void MessageReceived (BMessage * msg) override;
bool QuitRequested () override;
void UpdateMainView ();
@ -54,6 +55,7 @@ class MainWindow: public BWindow
BMessenger m_Messenger;
BStringView * m_MainView;
std::unique_ptr<BMessageRunner> m_MainViewUpdateTimer, m_GracefulShutdownTimer;
bool m_IsGracefulShutdownComplete = false;
};
class I2PApp: public BApplication
@ -130,14 +132,10 @@ void MainWindow::MessageReceived (BMessage * msg)
{
m_GracefulShutdownTimer = nullptr;
Daemon.gracefulShutdownInterval = 0;
m_IsGracefulShutdownComplete = true;
m_Messenger.SendMessage (B_QUIT_REQUESTED);
}
break;
case B_QUIT_REQUESTED:
m_MainViewUpdateTimer = nullptr;
m_GracefulShutdownTimer = nullptr;
BWindow::MessageReceived (msg);
break;
case M_RUN_PEER_TEST:
i2p::transport::transports.PeerTest ();
break;
@ -146,6 +144,24 @@ void MainWindow::MessageReceived (BMessage * msg)
}
}
bool MainWindow::QuitRequested ()
{
bool isQuit = true;
if (!m_IsGracefulShutdownComplete)
{
auto alert = new BAlert (nullptr, "This will stop i2pd. Are you sure?", "Cancel", "Yes", "No",
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
alert->SetShortcut (0, B_ESCAPE);
isQuit = alert->Go () == 1; // Yes
}
if (isQuit)
{
m_MainViewUpdateTimer = nullptr;
m_GracefulShutdownTimer = nullptr;
}
return isQuit;
}
I2PApp::I2PApp (): BApplication("application/x-vnd.purplei2p-i2pd")
{
}