You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.1 KiB
94 lines
3.1 KiB
#pragma once |
|
|
|
#include <QMainWindow> |
|
#include <QSystemTrayIcon> |
|
#include <QMenu> |
|
#include <QQueue> |
|
#include <QSet> |
|
#include <QTimer> |
|
|
|
class ChannelList; |
|
class MessageList; |
|
class AccountList; |
|
class DbManager; |
|
class UtunNode; |
|
class AudioRecorder; |
|
class ConnMonitorWindow; |
|
class VideoPlayerWindow; |
|
|
|
struct AutoPlayItem { |
|
QString channelId; |
|
qint64 msgId = 0; |
|
bool downloadStarted = false; |
|
float durationSec = 0.0f; |
|
}; |
|
|
|
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 showShareInviteDialog(const QString& channelId); |
|
void showInviteByLinkDialog(const QString& channelId); |
|
void showJoinDialog(); |
|
void onCreateGroupRequested(); |
|
void showSettings(); |
|
void showConnMonitor(); |
|
void openVideo(const QString& filePath); |
|
void showChannelSettings(const QString& channelId); |
|
void autoPlayTimerTick(); |
|
|
|
public: |
|
void onMessageReceived(const char* ch_id, int ch_id_len, uint64_t author); |
|
void onMemberList(const QString& chId, int count, const uint8_t* data, int dataLen); |
|
void onMemberUpdated(const QString& chId, const uint8_t* data); |
|
void onMemberRemoved(const QString& chId, uint64_t nodeId); |
|
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(); |
|
void onAttachmentDownloadedForAutoPlay(const QString& chId, int64_t msgId); |
|
UtunNode* utunNode() const { return m_node; } |
|
|
|
private: |
|
void setupUi(); |
|
void setupTray(); |
|
void setupNode(); |
|
void setupMessaging(); |
|
void setupSoundFromConfig(); |
|
void setupBridgeCallbacks(); |
|
void setupConnects(); |
|
void autoPlayCheckNewMessage(const QString& channelId); |
|
QString autoPlayMediaDir() const; |
|
|
|
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; |
|
AudioRecorder *m_recorder = nullptr; |
|
ConnMonitorWindow *m_connMonitor = nullptr; |
|
VideoPlayerWindow *m_videoPlayer = nullptr; |
|
|
|
QQueue<AutoPlayItem> m_autoPlayQueue; |
|
QTimer* m_autoPlayTimer = nullptr; |
|
QSet<int64_t> m_autoPlayDownloading; /* msgIds with download in progress */ |
|
};
|
|
|