dialog.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. #include "dialog.h"
  2. #include "ui_dialog.h"
  3. #include <QMessageBox>
  4. #include <QKeyEvent>
  5. #include <QFileDialog>
  6. #include <iostream>
  7. #include <fstream>
  8. #include <QEvent>
  9. #include <QTextCodec>
  10. using namespace std;
  11. // 设备断线回调函数
  12. void CALLBACK DisConnect(LLONG lLoginID, char *pchDVRIP, LONG nDVRPort, LDWORD dwUser)
  13. {
  14. if (0 != dwUser)
  15. {
  16. Dialog* pDialog = (Dialog*)dwUser;
  17. pDialog->OnDisconnect();
  18. }
  19. }
  20. // 回放和倒放数据回调函数
  21. int CALLBACK DataCallBack(LLONG lRealHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, LDWORD dwUser)
  22. {
  23. int nRet = 1;
  24. Dialog * pThis = (Dialog *)dwUser;
  25. if(NULL == pThis)
  26. {
  27. return nRet;
  28. }
  29. if(lRealHandle == pThis->m_lPlayBackId)
  30. {
  31. fstream file("PlayBack.dav",ios::binary| ios::app | ios::out);
  32. if (!file.is_open())
  33. {
  34. return nRet;
  35. }
  36. file.write((char*)pBuffer, dwBufSize);
  37. file.close();
  38. }
  39. else if(lRealHandle == pThis->m_lRewindBackId)
  40. {
  41. fstream file("Rewind.dav",ios::binary| ios::app | ios::out);
  42. if (!file.is_open())
  43. {
  44. return nRet;
  45. }
  46. file.write((char*)pBuffer, dwBufSize);
  47. file.close();
  48. }
  49. else
  50. {
  51. return nRet;
  52. }
  53. return nRet;
  54. }
  55. // 回放和倒放进度回调函数
  56. void CALLBACK PlayCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD dwDownLoadSize, LDWORD dwUser)
  57. {
  58. Dialog * pThis = (Dialog *)dwUser;
  59. if(NULL == pThis)
  60. {
  61. return;
  62. }
  63. pThis->PlaybackPos(dwTotalSize, dwDownLoadSize);
  64. return;
  65. }
  66. // 下载进度回调函数
  67. void CALLBACK TimeDownLoadPosCallBack(LLONG lPlayHandle, DWORD dwTotalSize, DWORD dwDownLoadSize, int index, NET_RECORDFILE_INFO recordfileinfo, LDWORD dwUser)
  68. {
  69. Dialog * pThis = (Dialog *)dwUser;
  70. if(NULL == pThis)
  71. {
  72. return;
  73. }
  74. pThis->PlaybackPos(dwTotalSize, dwDownLoadSize);
  75. return;
  76. }
  77. Dialog::Dialog(QWidget *parent) :
  78. QDialog(parent),
  79. ui(new Ui::Dialog)
  80. {
  81. ui->setupUi(this);
  82. m_lLoginId = 0;
  83. m_lPlayBackId = 0;
  84. m_lRewindBackId = 0;
  85. m_lDownLoadId = 0;
  86. m_nTotalRange = 100;
  87. m_nCurrnetPos = 50;
  88. m_lPlayHandle = 0;
  89. m_bStop = true;
  90. Init();
  91. }
  92. Dialog::~Dialog()
  93. {
  94. if(m_lLoginId)
  95. {
  96. CLIENT_Logout(m_lLoginId);
  97. }
  98. CLIENT_Cleanup();
  99. delete ui;
  100. }
  101. // 初始化函数
  102. void Dialog::Init()
  103. {
  104. // 设置不可以拖动窗口大小
  105. setFixedSize(this->width(), this->height());
  106. // IP控件只可以输入数字和点
  107. QRegExp reqxIP("[0-9.]+$");
  108. ui->lineEdit_ip->setValidator(new QRegExpValidator(reqxIP, ui->lineEdit_ip));
  109. // 端口控件只可以输入数字
  110. QRegExp reqxPoet("[0-9]+$");
  111. ui->lineEdit_port->setValidator(new QRegExpValidator(reqxPoet, ui->lineEdit_ip));
  112. // 密码控件属性设置为数字
  113. ui->lineEdit_password->setEchoMode(QLineEdit::Password);
  114. ui->lineEdit_ip->setText("172.23.12.14");
  115. ui->lineEdit_port->setText("37777");
  116. ui->lineEdit_user->setText("admin");
  117. ui->lineEdit_password->setText("admin123");
  118. ui->pushButton_download->setEnabled(false);
  119. ui->pushButton_rewind->setEnabled(false);
  120. ui->pushButton_playBack->setEnabled(false);
  121. QString strStreamType = "Main Stream";
  122. ui->comboBox_streamType->insertItem(0, strStreamType);
  123. strStreamType = "Sub Stream";
  124. ui->comboBox_streamType->insertItem(1, strStreamType);
  125. QString strFileType = "All";
  126. ui->comboBox_recordType->insertItem(0, strFileType);
  127. strFileType = "Extern Alarm";
  128. ui->comboBox_recordType->insertItem(2, strFileType);
  129. strFileType = "Motton Dection";
  130. ui->comboBox_recordType->insertItem(3, strFileType);
  131. QDate date(QDate::currentDate());
  132. QTime time(QTime::currentTime());
  133. ui->dateEdit->setDate(date);
  134. ui->timeEdit_stratTime->setTime(time);
  135. ui->timeEdit_endTime->setTime(time);
  136. ui->progressBarByRecord->setRange(0, 10000);
  137. QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
  138. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
  139. QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
  140. // SDK 初始化
  141. CLIENT_Init(DisConnect, (LDWORD)this);
  142. LOG_SET_PRINT_INFO stLogPrintInfo = {sizeof(stLogPrintInfo)};
  143. CLIENT_LogOpen(&stLogPrintInfo);
  144. //接受事件
  145. installEventFilter(this);
  146. }
  147. // 传递回放进度
  148. void Dialog::PlaybackPos(DWORD dwTotalSize, DWORD dwDownLoadSize)
  149. {
  150. m_nTotalRange = dwTotalSize;
  151. if (dwDownLoadSize == 0xFFFFFFFF)
  152. {
  153. dwDownLoadSize = m_nTotalRange;
  154. }
  155. m_nCurrnetPos = dwDownLoadSize;
  156. QEvent* event = new QEvent(QEvent::Type(QEvent::User));
  157. QApplication::postEvent((QObject*)this, event);
  158. }
  159. // 断线处理函数
  160. void Dialog::OnDisconnect()
  161. {
  162. QEvent* event = new QEvent(QEvent::Type(QEvent::User+1));
  163. QApplication::postEvent((QObject*)this, event);
  164. }
  165. // 事件过滤函数
  166. bool Dialog::eventFilter(QObject *obj, QEvent *event)//message filter
  167. {
  168. if(event->type() == QEvent::User)
  169. {
  170. //QMessageBox::about(this,tr("Prompt"), tr("eventFilter %1 %2").arg(m_nTotalRange).arg(m_nCurrnetPos));
  171. if(!m_bStop)
  172. {
  173. ui->progressBarByRecord->setRange(0, m_nTotalRange);
  174. ui->progressBarByRecord->setValue(m_nCurrnetPos);
  175. }
  176. else
  177. {
  178. ui->progressBarByRecord->setValue(0);
  179. }
  180. }
  181. if(event->type() == QEvent::User+1)
  182. {
  183. QMessageBox::about(this,tr("Prompt"), tr("Network disconnect!"));
  184. on_pushButton_loginAndLogout_clicked();
  185. }
  186. return QWidget::eventFilter(obj, event);//don't eat event
  187. }
  188. // 将登陆错误码转换为字符串
  189. void Dialog::ConvertLoginError2String(int nErrorCode , QString &strErrorCode)
  190. {
  191. switch(nErrorCode)
  192. {
  193. case 0:
  194. strErrorCode = tr("Login Success");
  195. break;
  196. case 1:
  197. strErrorCode = tr("Account or Password Incorrect");
  198. break;
  199. case 2:
  200. strErrorCode = tr("User Is Not Exist");
  201. break;
  202. case 3:
  203. strErrorCode = tr("Login Timeout");
  204. break;
  205. case 4:
  206. strErrorCode = tr("Repeat Login");
  207. break;
  208. case 5:
  209. strErrorCode = tr("User Account is Locked");
  210. break;
  211. case 6:
  212. strErrorCode = tr("User In Blocklist");
  213. break;
  214. case 7:
  215. strErrorCode = tr("Device Busy");
  216. break;
  217. case 8:
  218. strErrorCode = tr("Sub Connect Failed");
  219. break;
  220. case 9:
  221. strErrorCode = tr("Host Connect Failed");
  222. break;
  223. case 10 :
  224. strErrorCode = tr("Max Connect");
  225. break;
  226. case 11:
  227. strErrorCode = tr("Support Protocol3 Only");
  228. break;
  229. case 12:
  230. strErrorCode = tr("UKey Info Error");
  231. break;
  232. case 13:
  233. strErrorCode = tr("No Authorized");
  234. break;
  235. case 18:
  236. strErrorCode = tr("Device Account isn't Initialized");
  237. break;
  238. default:
  239. strErrorCode = tr("Unknown Error");
  240. break;
  241. }
  242. }
  243. // 登陆登出函数
  244. void Dialog::on_pushButton_loginAndLogout_clicked()
  245. {
  246. if (m_lLoginId == 0)
  247. {
  248. // 登陆设备
  249. QString strIP = "";
  250. QString strName = "";
  251. QString strPwd = "";
  252. QString strPort = "";
  253. strIP = ui->lineEdit_ip->text();
  254. strName = ui->lineEdit_user->text();
  255. strPwd = ui->lineEdit_password->text();
  256. strPort = ui->lineEdit_port->text();
  257. NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY stInparam;
  258. memset(&stInparam, 0, sizeof(stInparam));
  259. stInparam.dwSize = sizeof(stInparam);
  260. strncpy(stInparam.szIP, strIP.toLatin1().data(), sizeof(stInparam.szIP) - 1);
  261. strncpy(stInparam.szPassword, strPwd.toLatin1().data(), sizeof(stInparam.szPassword) - 1);
  262. strncpy(stInparam.szUserName, strName.toLatin1().data(), sizeof(stInparam.szUserName) - 1);
  263. stInparam.nPort = strPort.toInt();
  264. stInparam.emSpecCap = EM_LOGIN_SPEC_CAP_TCP;
  265. NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY stOutparam;
  266. memset(&stOutparam, 0, sizeof(stOutparam));
  267. stOutparam.dwSize = sizeof(stOutparam);
  268. m_lLoginId = CLIENT_LoginWithHighLevelSecurity(&stInparam, &stOutparam);
  269. if(m_lLoginId == 0) // 登陆失败
  270. {
  271. QString strError = "";
  272. ConvertLoginError2String(stOutparam.nError, strError);
  273. QMessageBox::about(NULL,tr("Prompt"),strError);
  274. return;
  275. }
  276. else // 登陆成功
  277. {
  278. for (int i =0; i< stOutparam.stuDeviceInfo.nChanNum; i++)
  279. {
  280. QString strChannel = "";
  281. strChannel.setNum(i+1);
  282. ui->comboBox_channel->insertItem(i, strChannel);
  283. }
  284. ui->pushButton_download->setEnabled(true);
  285. ui->pushButton_rewind->setEnabled((true));
  286. ui->pushButton_playBack->setEnabled((true));
  287. ui->pushButton_loginAndLogout->setText(tr("Logout"));
  288. }
  289. }
  290. else
  291. {
  292. if(m_lPlayBackId != 0)
  293. {
  294. on_pushButton_playBack_clicked();
  295. }
  296. if(m_lRewindBackId != 0)
  297. {
  298. on_pushButton_rewind_clicked();
  299. }
  300. if(m_lDownLoadId != 0)
  301. {
  302. on_pushButton_download_clicked();
  303. }
  304. // 登出设备
  305. CLIENT_Logout(m_lLoginId);
  306. setWindowTitle(tr("PlayBack"));
  307. m_lLoginId = 0;
  308. ui->pushButton_download->setEnabled(false);
  309. ui->pushButton_rewind->setEnabled(false);
  310. ui->pushButton_playBack->setEnabled(false);
  311. ui->pushButton_download->setText(tr("download"));
  312. ui->pushButton_rewind->setText(tr("rewind"));
  313. ui->pushButton_playBack->setText(tr("playback"));
  314. ui->comboBox_channel->clear();
  315. ui->pushButton_loginAndLogout->setText(tr("Login"));
  316. }
  317. }
  318. // 设置回放参数
  319. bool Dialog::setType()
  320. {
  321. int nStreamType =1;
  322. int nIndex = ui->comboBox_streamType->currentIndex();
  323. if(nIndex == 0)
  324. {
  325. nStreamType =1;
  326. }
  327. else
  328. {
  329. nStreamType = 2;
  330. }
  331. BOOL nRet = CLIENT_SetDeviceMode(m_lLoginId, DH_RECORD_STREAM_TYPE, &nStreamType);
  332. if(nRet== false)
  333. {
  334. QMessageBox::about(NULL,tr("Prompt"), tr("Set stream type failed"));
  335. return false;
  336. }
  337. NET_RECORD_TYPE emRecordType = NET_RECORD_TYPE_ALL;
  338. nIndex = ui->comboBox_recordType->currentIndex();
  339. if (nIndex == 0)
  340. {
  341. emRecordType = NET_RECORD_TYPE_ALL;
  342. }
  343. else if(nIndex == 1)
  344. {
  345. emRecordType = NET_RECORD_TYPE_ALARM;
  346. }
  347. else if (nIndex == 2)
  348. {
  349. emRecordType = NET_RECORD_TYPE_MOTION;
  350. }
  351. else
  352. {
  353. return false;
  354. }
  355. nRet = CLIENT_SetDeviceMode(m_lLoginId, DH_RECORD_TYPE, &emRecordType);
  356. if(nRet== false)
  357. {
  358. QMessageBox::about(NULL,tr("Prompt"), tr("Set vedio type failed"));
  359. return false;
  360. }
  361. return true;
  362. }
  363. // 获取日期
  364. void GetDate(QDate& date, NET_TIME& netDate)
  365. {
  366. netDate.dwYear = date.year();
  367. netDate.dwMonth = date.month();
  368. netDate.dwDay = date.day();
  369. }
  370. // 获取时间
  371. void GetTime(QTime& time, NET_TIME& netTime)
  372. {
  373. netTime.dwHour = time.hour();
  374. netTime.dwMinute= time.minute();
  375. netTime.dwSecond= time.second();
  376. }
  377. // 回放开始和停止
  378. void Dialog::on_pushButton_playBack_clicked()
  379. {
  380. if (m_lPlayBackId == 0)
  381. {
  382. if(false == setType())
  383. {
  384. return;
  385. }
  386. int nChannel = ui->comboBox_channel->currentIndex();
  387. QDate date= ui->dateEdit->date();
  388. QTime startTime = ui->timeEdit_stratTime->time();
  389. QTime endTime = ui->timeEdit_endTime->time();
  390. NET_IN_PLAY_BACK_BY_TIME_INFO stuInPlayBackByTime;
  391. NET_OUT_PLAY_BACK_BY_TIME_INFO stuOutPlayBackByTime;
  392. memset(&stuInPlayBackByTime, 0, sizeof(NET_IN_PLAY_BACK_BY_TIME_INFO));
  393. memset(&stuOutPlayBackByTime, 0, sizeof(NET_OUT_PLAY_BACK_BY_TIME_INFO));
  394. GetDate(date, stuInPlayBackByTime.stStartTime);
  395. GetDate(date, stuInPlayBackByTime.stStopTime);
  396. GetTime(startTime, stuInPlayBackByTime.stStartTime);
  397. GetTime(endTime, stuInPlayBackByTime.stStopTime);
  398. stuInPlayBackByTime.hWnd = NULL;
  399. stuInPlayBackByTime.cbDownLoadPos = PlayCallBack;
  400. stuInPlayBackByTime.dwPosUser = (LDWORD)this;
  401. stuInPlayBackByTime.fDownLoadDataCallBack =DataCallBack;
  402. stuInPlayBackByTime.dwDataUser = (LDWORD)this;
  403. stuInPlayBackByTime.nPlayDirection = 0;
  404. stuInPlayBackByTime.nWaittime = 5000;
  405. try
  406. {
  407. // 将文件内容清空
  408. ofstream file("PlayBack.dav", ios::trunc);
  409. file.close();
  410. }
  411. catch(...)
  412. {
  413. QMessageBox::about(NULL,tr("Prompt"), tr("Cautch an file open exception"));
  414. return;
  415. }
  416. m_lPlayBackId = CLIENT_PlayBackByTimeEx2(m_lLoginId, nChannel, &stuInPlayBackByTime, &stuOutPlayBackByTime);
  417. if(m_lPlayBackId == 0)
  418. {
  419. QMessageBox::about(NULL,tr("Prompt"), tr("Play back failed"));
  420. return;
  421. }
  422. ui->pushButton_download->setEnabled(false);
  423. ui->pushButton_rewind->setEnabled((false));
  424. ui->pushButton_playBack->setText(tr("Stop"));
  425. m_bStop = false;
  426. }
  427. else
  428. {
  429. BOOL bRet = CLIENT_StopPlayBack(m_lPlayBackId);
  430. if(bRet == false)
  431. {
  432. QMessageBox::about(NULL,tr("Prompt"), tr("Stop play back failed"));
  433. return;
  434. }
  435. m_lPlayBackId = 0;
  436. ui->pushButton_download->setEnabled(true);
  437. ui->pushButton_rewind->setEnabled((true));
  438. ui->pushButton_playBack->setText(tr("PlayBack"));
  439. m_bStop = true;
  440. ui->progressBarByRecord->setValue(0);
  441. }
  442. }
  443. // 倒放开始和停止
  444. void Dialog::on_pushButton_rewind_clicked()
  445. {
  446. if (m_lRewindBackId == 0)
  447. {
  448. if(false == setType())
  449. {
  450. return;
  451. }
  452. int nChannel = ui->comboBox_channel->currentIndex();
  453. QDate date= ui->dateEdit->date();
  454. QTime startTime = ui->timeEdit_stratTime->time();
  455. QTime endTime = ui->timeEdit_endTime->time();
  456. NET_IN_PLAY_BACK_BY_TIME_INFO stuInPlayBackByTime;
  457. NET_OUT_PLAY_BACK_BY_TIME_INFO stuOutPlayBackByTime;
  458. memset(&stuInPlayBackByTime, 0, sizeof(NET_IN_PLAY_BACK_BY_TIME_INFO));
  459. memset(&stuOutPlayBackByTime, 0, sizeof(NET_OUT_PLAY_BACK_BY_TIME_INFO));
  460. GetDate(date, stuInPlayBackByTime.stStartTime);
  461. GetDate(date, stuInPlayBackByTime.stStopTime);
  462. GetTime(startTime, stuInPlayBackByTime.stStartTime);
  463. GetTime(endTime, stuInPlayBackByTime.stStopTime);
  464. stuInPlayBackByTime.hWnd = NULL;
  465. stuInPlayBackByTime.cbDownLoadPos = PlayCallBack;
  466. stuInPlayBackByTime.dwPosUser = (LDWORD)this;
  467. stuInPlayBackByTime.fDownLoadDataCallBack =DataCallBack;
  468. stuInPlayBackByTime.dwDataUser = (LDWORD)this;
  469. stuInPlayBackByTime.nPlayDirection = 1;
  470. stuInPlayBackByTime.nWaittime = 5000;
  471. m_lRewindBackId = CLIENT_PlayBackByTimeEx2(m_lLoginId, nChannel, &stuInPlayBackByTime, &stuOutPlayBackByTime);
  472. if(m_lRewindBackId == 0)
  473. {
  474. QMessageBox::about(NULL,tr("Prompt"), tr("Play back failed"));
  475. return;
  476. }
  477. try
  478. {
  479. // 将文件内容清空
  480. ofstream file("Rewind.dav", ios::trunc);
  481. file.close();
  482. }
  483. catch(...)
  484. {
  485. QMessageBox::about(NULL,tr("Prompt"), tr("Cautch an file open exception"));
  486. return;
  487. }
  488. ui->pushButton_download->setEnabled(false);
  489. ui->pushButton_playBack->setEnabled((false));
  490. ui->pushButton_rewind->setText(tr("Stop"));
  491. m_bStop = false;
  492. }
  493. else
  494. {
  495. BOOL bRet = CLIENT_StopPlayBack(m_lRewindBackId);
  496. if(bRet == false)
  497. {
  498. QMessageBox::about(NULL,tr("Prompt"), tr("Stop play back failed"));
  499. return;
  500. }
  501. m_lRewindBackId = 0;
  502. ui->pushButton_download->setEnabled(true);
  503. ui->pushButton_playBack->setEnabled((true));
  504. ui->pushButton_rewind->setText(tr("Rewind"));
  505. m_bStop = true;
  506. ui->progressBarByRecord->setValue(0);
  507. }
  508. }
  509. // 下载开始和停止
  510. void Dialog::on_pushButton_download_clicked()
  511. {
  512. if (m_lDownLoadId == 0)
  513. {
  514. if(false == setType())
  515. {
  516. return;
  517. }
  518. int nChannel = ui->comboBox_channel->currentIndex();
  519. QDate date= ui->dateEdit->date();
  520. QTime startTime = ui->timeEdit_stratTime->time();
  521. QTime endTime = ui->timeEdit_endTime->time();
  522. NET_TIME stStartTime = {0};
  523. NET_TIME stEndTime = {0};
  524. GetDate(date, stStartTime);
  525. GetDate(date, stEndTime);
  526. GetTime(startTime, stStartTime);
  527. GetTime(endTime, stEndTime);
  528. int nIndex = ui->comboBox_recordType->currentIndex();
  529. QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"download.dav",tr("dav(*.dav )"));
  530. if(fileName.isEmpty())
  531. {
  532. return;
  533. }
  534. char* szFileName = NULL;
  535. QByteArray ba = fileName.toLocal8Bit();
  536. szFileName = ba.data();
  537. m_lDownLoadId = CLIENT_DownloadByTimeEx(m_lLoginId, nChannel, nIndex, &stStartTime, &stEndTime, szFileName,TimeDownLoadPosCallBack, (LDWORD)this, DataCallBack, (LDWORD)this);
  538. if( m_lDownLoadId == 0)
  539. {
  540. QMessageBox::about(NULL,tr("Prompt"), tr("Download record failed"));
  541. return;
  542. }
  543. ui->pushButton_rewind->setEnabled(false);
  544. ui->pushButton_playBack->setEnabled((false));
  545. ui->pushButton_download->setText(tr("Stop"));
  546. m_bStop = false;
  547. }
  548. else
  549. {
  550. BOOL bRet = CLIENT_StopDownload(m_lDownLoadId);
  551. if(bRet == false)
  552. {
  553. QMessageBox::about(NULL,tr("Prompt"), tr("Stop download record failed"));
  554. return;
  555. }
  556. m_lDownLoadId = 0;
  557. ui->pushButton_rewind->setEnabled(true);
  558. ui->pushButton_playBack->setEnabled((true));
  559. ui->pushButton_download->setText(tr("Download"));
  560. m_bStop = true;
  561. ui->progressBarByRecord->setValue(0);
  562. }
  563. }
  564. // 按键屏蔽
  565. void Dialog::keyPressEvent(QKeyEvent* event)
  566. {
  567. switch(event->key())
  568. {
  569. case Qt::Key_Escape:
  570. break;
  571. case Qt::Key_Enter:
  572. break;
  573. case Qt::Key_Space:
  574. break;
  575. default:
  576. QDialog::keyPressEvent(event);
  577. }
  578. }