From e1ee4d52b9379e2861517069ca7aee0338d4337f Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Tue, 24 Jun 2014 21:17:54 +0800 Subject: Add askDialog(title,question) to ScriptEngine use the DefineEscapeDialog to implement this! --- src/fqterm/fqterm_scriptengine.cpp | 12 ++++++++++++ src/fqterm/fqterm_scriptengine.h | 4 +++- src/ui/defineescape.cpp | 7 +++++++ src/ui/defineescape.h | 5 +++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/fqterm/fqterm_scriptengine.cpp b/src/fqterm/fqterm_scriptengine.cpp index f529bac..c42dba2 100644 --- a/src/fqterm/fqterm_scriptengine.cpp +++ b/src/fqterm/fqterm_scriptengine.cpp @@ -522,6 +522,18 @@ bool FQTermScriptEngine::isAutoReply() { article.exec(); } + QString FQTermScriptEngine::askDialog(const QString& title, const QString& question) + { + QString ans; + DefineEscapeDialog dlg(ans, window_); + dlg.setTitleAndText(title, question); + if (dlg.exec()==1){ + return ans; + }else{ + return ""; + } + } + } // namespace FQTerm #include "fqterm_scriptengine.moc" diff --git a/src/fqterm/fqterm_scriptengine.h b/src/fqterm/fqterm_scriptengine.h index 48b937d..9e7277f 100644 --- a/src/fqterm/fqterm_scriptengine.h +++ b/src/fqterm/fqterm_scriptengine.h @@ -23,6 +23,7 @@ #include "fqterm.h" #include "articledialog.h" +#include "defineescape.h" #include #include #include @@ -54,7 +55,8 @@ public slots: //script apis //ui functions. void msgBox(const QString& msg); bool yesnoBox(const QString& msg); - + QString askDialog(const QString& title, const QString& question); + //bbs ui functions int caretX(); int caretY(); diff --git a/src/ui/defineescape.cpp b/src/ui/defineescape.cpp index e9dd655..26474e1 100644 --- a/src/ui/defineescape.cpp +++ b/src/ui/defineescape.cpp @@ -46,6 +46,13 @@ void DefineEscapeDialog::onCancel() { done(0); } + + void DefineEscapeDialog::setTitleAndText(const QString &title, const QString &text) + { + ui_.lblEscape->setText(text); + this->setWindowTitle(title); + } + } //namespace FQTerm #include "defineescape.moc" diff --git a/src/ui/defineescape.h b/src/ui/defineescape.h index 0083603..c102840 100644 --- a/src/ui/defineescape.h +++ b/src/ui/defineescape.h @@ -30,7 +30,8 @@ class DefineEscapeDialog : public QDialog { public: DefineEscapeDialog(QString& strEsc, QWidget *parent_ = 0, Qt::WFlags fl = 0); ~DefineEscapeDialog(); - + void setTitleAndText(const QString &title, const QString &text); + protected slots: void onOK(); void onCancel(); @@ -41,4 +42,4 @@ private: } //namespace FQTerm -#endif //__FQTERM_DEFINEESCAPE__ \ No newline at end of file +#endif //__FQTERM_DEFINEESCAPE__ -- cgit v1.2.3