1 #ifndef NETCONNECTDIALOG_H 2 #define NETCONNECTDIALOG_H 3 4 #include <QLabel> 5 #include <QDialog> 6 #include <QLineEdit> 7 #include <QEventLoop> 8 #include <QPushButton> 9 10 class inputDialog : public QDialog 11 { 12 Q_OBJECT 13 public: 14 inputDialog(QWidget *parent = nullptr); 15 ~inputDialog(); 16 static inputDialog* getInstance(QWidget *parent = nullptr) 17 { 18 if (!_instance) { 19 _instance = new inputDialog; 20 } 21 return _instance; 22 } 23 void setText(QString yes, QString no, QString text); getEditText()24 QString getEditText(){return wordEdit->text();} 25 int exec(); 26 bool isRunning(); 27 void exit(bool result); 28 29 private: 30 static inputDialog* _instance; 31 QLabel *nameLabel; 32 QLineEdit *wordEdit; 33 QPushButton yBtn; 34 QPushButton nBtn; 35 QEventLoop* m_eventLoop; 36 bool m_chooseResult; 37 38 protected: 39 void closeEvent(QCloseEvent *); 40 41 private slots: 42 void slot_onApplicationFocusChanged(QWidget *, QWidget *); 43 void slot_onYesClicked(); 44 void slot_onNoClicked(); 45 }; 46 47 #endif // NETCONNECTDIALOG_H 48