Changes: - UtunNode::requestStop() — async stop from any thread (m_stop+wakeup) - UtunNode::finalize() — cleanup in main thread (etcp_router, chat_sync, chat_core, utun_instance, uasync) - UtunNode::stop() — requestStop + join + finalize (for tray Quit path) - Worker runLoop: only exits poll loop on m_stop, then emits stopped — no cleanup - stopped() handler: calls finalize() in main thread, then qApp->quit() - Tray Quit: calls requestStop(), stopped handler does finalize+quit - Ctrl-C (Windows): SetConsoleCtrlHandler calls requestStop() via g_ctrl_node - Ctrl-C (Linux): signal_handler calls requestStop() via g_currentNode - Removed: g_shutdown, g_signal_ua, utun_node_signal_shutdown globals
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <QMainWindow>
|
|
#include <QSystemTrayIcon>
|
|
#include <QMenu>
|
|
|
|
class ChannelList;
|
|
class MessageList;
|
|
class AccountList;
|
|
class DbManager;
|
|
class UtunNode;
|
|
|
|
class MainWindow : public QMainWindow {
|
|
Q_OBJECT
|
|
public:
|
|
explicit MainWindow(QWidget *parent, DbManager* db, const QString& cfgPath,
|
|
const QString& dbPath = QString(),
|
|
const QString& debugFile = QString(),
|
|
const QString& debugLevel = QString(),
|
|
const QString& debugCategories = QString());
|
|
~MainWindow() override;
|
|
|
|
protected:
|
|
void closeEvent(QCloseEvent *event) override;
|
|
|
|
private slots:
|
|
void onTrayActivated(QSystemTrayIcon::ActivationReason reason);
|
|
void showInviteDialog(const QString& channelId);
|
|
void showJoinDialog();
|
|
void onCreateGroupRequested();
|
|
void showSettings();
|
|
|
|
public:
|
|
void onMessageReceived(const char* ch_id, int ch_id_len, uint64_t author);
|
|
void onMembersChanged(const char* ch_id);
|
|
void onAutoConnectStatus(uint8_t status, uint16_t total, uint16_t totalNodes, uint16_t connected);
|
|
void onChannelPeersOnline(const char* ch_id, int ch_id_len, uint16_t online);
|
|
void reloadChannels();
|
|
UtunNode* utunNode() const { return m_node; }
|
|
|
|
private:
|
|
void setupUi();
|
|
void setupTray();
|
|
void setupNode();
|
|
void setupMessaging();
|
|
void setupSoundFromConfig();
|
|
void setupBridgeCallbacks();
|
|
void setupConnects();
|
|
|
|
ChannelList *m_channelList;
|
|
MessageList *m_messageList;
|
|
AccountList *m_accountList;
|
|
QSystemTrayIcon *m_trayIcon;
|
|
QMenu *m_trayMenu;
|
|
DbManager *m_db;
|
|
UtunNode *m_node = nullptr;
|
|
QString m_cfgPath;
|
|
QString m_cfgDbPath;
|
|
QString m_cfgDebugFile;
|
|
QString m_cfgDebugLevel;
|
|
QString m_cfgDebugCategories;
|
|
QString m_pendingChannelSelect;
|
|
QString m_currentChannelId;
|
|
};
|