#pragma once #include #include "iAppBase_global.h" class QString; class QStringList; class QLocalServer; class QWidget; // 单例 class I_APPBASE_EXPORT ZxSingleInstance : public QObject { Q_OBJECT public: ZxSingleInstance(const QString& sServerName); ~ZxSingleInstance(); // 检查前一个进程, 如果存在则把命令参数传过去. bool redirect(int argc, char** argv); // 启动服务器 bool startServer(); protected slots: // 处理命令行, 并返回相关的界面元素 virtual QWidget* onCommand(const QStringList &args); private slots: void onNewConnection(); private: QString m_sServerName; QLocalServer* m_pServer; };