qpaperedithandler.cpp 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936
  1. #include "qpaperedithandler.h"
  2. #include <QScroller>
  3. #include <QLabel>
  4. #include <QScrollBar>
  5. #include "QHBoxLayout"
  6. #include <QDir>
  7. #include <QDateTime>
  8. #include <QMovie>
  9. #include "..\Util\Util.h"
  10. int curItem = 0;//当前显示是哪一页
  11. int index[64];//当前步
  12. int total[64];//总步数
  13. vector<QString> editedImglist;
  14. string SaveTempImg(QImage* pimage)
  15. {
  16. std::wstring strModuleDir;
  17. GetModuleDir(strModuleDir);
  18. strModuleDir.append(L"temppain\\");
  19. char buf[32] = { 0 };
  20. index[curItem] += 1;
  21. sprintf(buf, "%d_%d.jpg", curItem, index[curItem]);
  22. QString path;
  23. path = path.fromStdWString(strModuleDir);
  24. path = path + QString::fromLocal8Bit(buf);
  25. pimage->save(path, "JPG", 255);
  26. total[curItem] = index[curItem];
  27. editedImglist[curItem] = path;
  28. return path.toLocal8Bit().toStdString();
  29. }
  30. string getCurPath()
  31. {
  32. std::wstring strModuleDir;
  33. GetModuleDir(strModuleDir);
  34. strModuleDir.append(L"temppain\\");
  35. char buf[32] = { 0 };
  36. sprintf(buf, "%d_%d.jpg", curItem, index[curItem]);
  37. QString path;
  38. path = path.fromStdWString(strModuleDir);
  39. path = path + QString::fromLocal8Bit(buf);
  40. return path.toLocal8Bit().toStdString();
  41. }
  42. //#include <GdiPlus.h>
  43. //#include <comdef.h>
  44. //using namespace Gdiplus;
  45. void getDpiXY(string path, float &xDPI, float &yDPI)
  46. {
  47. /*Gdiplus::Status status = Gdiplus::GenericError;
  48. QString strtmp = QString::fromLocal8Bit(path.c_str());
  49. Gdiplus::Image imgtemp(strtmp.toStdWString().c_str());
  50. status = imgtemp.GetLastStatus();
  51. if (status == Gdiplus::Ok)
  52. {
  53. yDPI = imgtemp.GetVerticalResolution();
  54. xDPI = imgtemp.GetHorizontalResolution();
  55. }
  56. else{
  57. yDPI = 96;
  58. xDPI = 96;
  59. }*/
  60. return;
  61. }
  62. MyItemPainter::MyItemPainter(QWidget *parent)
  63. : QStyledItemDelegate(parent)
  64. {
  65. }
  66. MyItemPainter::~MyItemPainter()
  67. {
  68. }
  69. //设置显示的总高度
  70. QSize MyItemPainter::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
  71. {
  72. //获取每一行的原始大小
  73. QSize size = QStyledItemDelegate::sizeHint(option, index);
  74. //size.setHeight(60);
  75. //重写之前的默认返回值
  76. return QStyledItemDelegate::sizeHint(option, index);
  77. }
  78. void MyItemPainter::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
  79. {
  80. QVariant variant = index.data(Qt::UserRole);
  81. ItemInfo user = variant.value<ItemInfo>();
  82. QRect Rect = option.rect;
  83. Rect.adjust(2, 2, -2, -2);
  84. //取得对应项的数据
  85. QString strDisplay = index.data(Qt::DisplayRole).toString();//名称
  86. QString strTip = index.data(Qt::UserRole + 1).toString();//提示
  87. QString strPath = index.data(Qt::UserRole + 2).toString();//图标路径
  88. //显示操作:当选中某一项时
  89. if (option.state & QStyle::State_On)
  90. {
  91. painter->setPen(QColor(0, 150, 0));
  92. painter->drawRect(Rect);
  93. }
  94. else if (option.state & QStyle::State_Selected)
  95. {
  96. painter->setPen(QColor(22, 174, 105));
  97. painter->drawRect(Rect);
  98. }
  99. else if (option.state & QStyle::State_MouseOver)
  100. {
  101. painter->setPen(QColor(65, 155, 249));
  102. painter->drawRect(Rect);
  103. }
  104. {
  105. QRect dst = Rect;
  106. dst.adjust(1, 1, -1, -1);
  107. dst.setBottom(dst.bottom() - 21);
  108. painter->drawImage(dst, *user.pPreviewImg, QRect(0, 0, user.pPreviewImg->width(), user.pPreviewImg->height()));
  109. dst = Rect;
  110. dst.setTop(dst.bottom() - 21);
  111. if (curItem == user.id)
  112. {
  113. painter->setPen(QColor(22, 174, 105));
  114. }
  115. else
  116. {
  117. painter->setPen(QColor(55, 55, 55));
  118. }
  119. painter->drawText(dst, Qt::AlignCenter, QString::number(user.id + 1));
  120. }
  121. //重写之前的默认返回值
  122. return QStyledItemDelegate::paint(painter, option, index);
  123. }
  124. QPaperEditHandler::QPaperEditHandler(QWidget *parent)
  125. : QWidget(parent), itemPainter(this)
  126. {
  127. ui.setupUi(this);
  128. m_bShowMovie = false;
  129. startPoint = QPoint(0, 0);
  130. endPoint = QPoint(0, 0);
  131. ispressed = false;
  132. mousestatus = Mouse_Normal;
  133. room = 1.0f;
  134. for (int i = 0; i < 64; i++)
  135. {
  136. index[i] = 0;
  137. total[i] = 0;
  138. }
  139. bFirstResize = true;
  140. paper_id = 0;
  141. origionImgpath = "";
  142. offset = QPoint(0, 0);
  143. eraserW = 17;
  144. eraserH = 13;
  145. curItem = 0;
  146. locateW = 40;
  147. locateH = 20;
  148. penW = 2;
  149. penColor = QColor(255, 0, 0);
  150. lineW = 2;
  151. lineColor = QColor(255, 0, 0);
  152. bLoadedPreview = false;
  153. //connect(&cutdlg, SIGNAL(focusOut()), this, SLOT(mergeImg()));
  154. m_titleInfo = "";
  155. editedImglist.clear();
  156. m_bIsEdited = false;
  157. ui.toolButton_preview->setAutoFillBackground(true);
  158. //QPalette patlette;
  159. //patlette.setColor(QPalette::ButtonText, Qt::red); // 设置button 文本颜色红色
  160. //ui.toolButton_preview->setPalette(patlette);
  161. ui.horizontalLayoutWidget->hide();
  162. ui.horizontalLayoutWidget->setStyleSheet("background-color:rgba(233,237,241,0.66);");
  163. HideButtons();
  164. setAttribute(Qt::WA_DeleteOnClose, true);
  165. //ui.toolButton_eraser->installEventFilter(this);
  166. this->setMouseTracking(true);// 追踪鼠标
  167. ui.widget_Drag->hide();
  168. SetPaper(1);
  169. QMovie *movie = new QMovie(QString::fromLocal8Bit(":/painter/Resources/painter/loading.gif"));
  170. ui.label_movie->setMovie(movie);
  171. movie->start();
  172. ui.label_movie->hide();
  173. ui.label_reidentify->hide();
  174. ui.label_shibaiyuanyin->hide();
  175. ClickDrag();
  176. m_curpage = 0;
  177. }
  178. void QPaperEditHandler::ClickSwitchPage()
  179. {
  180. if (origionImglist.size() != 2)
  181. {
  182. return;
  183. }
  184. QString msg = QString::fromLocal8Bit("换页后,将清空所有对图片的修改,");
  185. msg += QString::fromLocal8Bit("确定要换页吗?");
  186. /*if (QBaseDialog::OkButton == QMessageDialog::information(this, QString::fromLocal8Bit("提示"), msg, QBaseDialog::OkCancelButton))*/
  187. {
  188. index[curItem] = 0;//当前步
  189. total[curItem] = 0;//总步数
  190. origionImglist.push_back(origionImglist[0]);
  191. origionImglist.erase(origionImglist.begin());
  192. oldImgpathlist.push_back(oldImgpathlist[0]);
  193. oldImgpathlist.erase(oldImgpathlist.begin());
  194. editedImglist = origionImglist;
  195. SetOrigionImg(origionImglist[curItem],oldImgpathlist[curItem]);
  196. bLoadedPreview = false;
  197. m_bIsEdited = false;
  198. }
  199. }
  200. void QPaperEditHandler::SetPaper(int paper_id)
  201. {
  202. wstring strmoduledir;
  203. GetModuleDir(strmoduledir);
  204. wstring strImage1(strmoduledir);
  205. wstring strImage2(strmoduledir);
  206. strImage1.append(L"zipfile\\ZipFile20211211105822_177A20440374P1_20211230153445\\papers\\Doc1639191470_1.jpg");
  207. strImage2.append(L"zipfile\\ZipFile20211211105822_177A20440374P1_20211230153445\\papers\\Doc1639191470_-1.jpg");
  208. vector<QString> imglist;
  209. vector<string> imgoldpathlist;
  210. imglist.push_back(QString::fromStdWString(strImage1.c_str()));
  211. imgoldpathlist.push_back(UnicodeToGB2312(strImage1.c_str()));
  212. imglist.push_back(QString::fromStdWString(strImage2.c_str()));
  213. imgoldpathlist.push_back(UnicodeToGB2312(strImage2.c_str()));
  214. SetImgList(imglist,imgoldpathlist);
  215. SetOrigionImg(QString::fromStdWString(strImage1.c_str()), UnicodeToGB2312(strImage1.c_str()));
  216. this->paper_id = paper_id;
  217. extern bool g_online_anwser_card;
  218. ui.toolButton_cur->hide();
  219. ui.toolButton_conflict1->hide();
  220. ui.toolButton_conflict2->hide();
  221. ui.toolButton_conflict3->hide();
  222. ui.toolButton_conflict4->hide();
  223. ui.toolButton_conflict5->hide();
  224. }
  225. void QPaperEditHandler::HideButtons()
  226. {
  227. ui.toolButton_locate1->hide();
  228. ui.toolButton_locate2->hide();
  229. ui.toolButton_locate3->hide();
  230. ui.toolButton_line1->hide();
  231. ui.toolButton_line2->hide();
  232. ui.toolButton_line3->hide();
  233. ui.toolButton_pen1->hide();
  234. ui.toolButton_pen2->hide();
  235. ui.toolButton_pen3->hide();
  236. ui.toolButton_penred->hide();
  237. ui.toolButton_penblack->hide();
  238. ui.toolButton_line1->hide();
  239. ui.toolButton_line2->hide();
  240. ui.toolButton_line3->hide();
  241. ui.toolButton_linered->hide();
  242. ui.toolButton_lineblack->hide();
  243. ui.toolButton_eraser1->hide();
  244. ui.toolButton_eraser2->hide();
  245. ui.toolButton_erase3->hide();
  246. ui.toolButton_restore->hide();
  247. ui.toolButton_redo->hide();
  248. ui.toolButton_switchpage->hide();
  249. }
  250. void QPaperEditHandler::Reset()
  251. {
  252. }
  253. QPaperEditHandler::~QPaperEditHandler()
  254. {
  255. ui.listWidget_preview->clear();
  256. for (auto& it : iteminfos)
  257. {
  258. delete it.pPreviewImg;
  259. }
  260. }
  261. void QPaperEditHandler::ClickPreViewLable(int id)
  262. {
  263. id = 1;
  264. }
  265. void QPaperEditHandler::ClickButton()
  266. {
  267. if (mousestatus == Mouse_Cuting)
  268. {
  269. ClickCutDel();
  270. }
  271. HideButtons();
  272. QObject* sender = this->sender();
  273. if (sender == ui.toolButton_drag)
  274. {
  275. ClickDrag();
  276. }
  277. else if (sender == ui.toolButton_roomin)
  278. {
  279. ClickRoomin();
  280. }
  281. else if (sender == ui.toolButton_rommout)
  282. {
  283. ClickRoomout();
  284. }
  285. else if (sender == ui.toolButton_90)
  286. {
  287. ClickRotate90();
  288. }
  289. else if (sender == ui.toolButton_N90)
  290. {
  291. ClickRotateN90();
  292. }
  293. else if (sender == ui.toolButton_locate || sender == ui.toolButton_locate1 || sender == ui.toolButton_locate2 || sender == ui.toolButton_locate3)
  294. {
  295. ClickLocate(sender);
  296. }
  297. else if (sender == ui.toolButton_pen || sender == ui.toolButton_pen1 || sender == ui.toolButton_pen2 || sender == ui.toolButton_pen3
  298. || sender == ui.toolButton_penred || sender == ui.toolButton_penblack)
  299. {
  300. ClickPen(sender);
  301. }
  302. else if (sender == ui.toolButton_line || sender == ui.toolButton_line1 || sender == ui.toolButton_line2 || sender == ui.toolButton_line3
  303. || sender == ui.toolButton_linered || sender == ui.toolButton_lineblack)
  304. {
  305. ClickLine(sender);
  306. }
  307. else if (sender == ui.toolButton_eraser || sender == ui.toolButton_eraser1 || sender == ui.toolButton_eraser2 || sender == ui.toolButton_erase3)
  308. {
  309. ClickEraser(sender);
  310. }
  311. else if (sender == ui.toolButton_undo)
  312. {
  313. ClickUndo();
  314. }
  315. else if (sender == ui.toolButton_redo)
  316. {
  317. ClickRedo();
  318. }
  319. else if (sender == ui.toolButton_cut)
  320. {
  321. ClickCut();
  322. }
  323. else if (sender == ui.toolButton_more)
  324. {
  325. ClickMore();
  326. }
  327. else if (sender == ui.toolButton_pre || sender == ui.toolButton_left)
  328. {
  329. ClickPre();
  330. }
  331. else if (sender == ui.toolButton_preview)
  332. {
  333. ClickPreView();
  334. }
  335. else if (sender == ui.toolButton_restore)
  336. {
  337. ClickRestore();
  338. }
  339. else if (sender == ui.toolButton_next || sender == ui.toolButton_right)
  340. {
  341. ClickNext();
  342. }
  343. else if (sender == ui.toolButton_Switch)
  344. {
  345. ClickSwitchDrag();
  346. //emit switchToShibieYichang();
  347. }
  348. else if (sender == ui.toolButton_cur)
  349. {
  350. ClickCur();
  351. }
  352. else if (sender == ui.toolButton_conflict1)
  353. {
  354. ClickConflict(1);
  355. }
  356. else if (sender == ui.toolButton_conflict2)
  357. {
  358. ClickConflict(2);
  359. }
  360. else if (sender == ui.toolButton_conflict3)
  361. {
  362. ClickConflict(3);
  363. }
  364. else if (sender == ui.toolButton_conflict4)
  365. {
  366. ClickConflict(4);
  367. }
  368. else if (sender == ui.toolButton_conflict5)
  369. {
  370. ClickConflict(5);
  371. }
  372. else if (sender == ui.toolButton_switchpage)
  373. {
  374. ClickSwitchPage();
  375. }
  376. if (curItem == 0)
  377. {
  378. ui.toolButton_pre->setEnabled(false);
  379. ui.toolButton_left->setEnabled(false);
  380. }
  381. else
  382. {
  383. ui.toolButton_pre->setEnabled(true);
  384. ui.toolButton_left->setEnabled(true);
  385. }
  386. if (curItem == origionImglist.size() - 1)
  387. {
  388. ui.toolButton_next->setEnabled(false);
  389. ui.toolButton_right->setEnabled(false);
  390. }
  391. else
  392. {
  393. ui.toolButton_next->setEnabled(true);
  394. ui.toolButton_right->setEnabled(true);
  395. }
  396. }
  397. void QPaperEditHandler::ClickCur()//考号冲突 点击当前页
  398. {
  399. /*ui.horizontalLayoutWidget->hide();
  400. bLoadedPreview = false;
  401. ui.toolButton_preview->setChecked(false);
  402. SetViewMode(false);
  403. emit sig_SetViewMode(false);
  404. PAPER_DETAIL paper_detail;
  405. vector<PAGE_DETAIL> pageList;
  406. vector<GROUP_QUESTION> questionList;
  407. int ret = QueryPaperDetail(paper_id, paper_detail, pageList, questionList);
  408. vector<QString> imglist;
  409. vector<string> imgoldpathlist;
  410. for (auto& it : pageList)
  411. {
  412. imglist.push_back(QString::fromLocal8Bit(it.img_path.c_str()));
  413. imgoldpathlist.push_back(it.img_oldpath);
  414. }
  415. SetImgList(imglist, imgoldpathlist);
  416. curItem = m_curpage;
  417. origionImgpath = QString::fromLocal8Bit(pageList[curItem].img_path.c_str());
  418. oldimgpath = pageList[curItem].img_oldpath;
  419. QString path = QString::fromLocal8Bit(getCurPath().c_str());
  420. bgimage.load(path);
  421. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  422. update();
  423. setFocus();
  424. string sl = pageList[curItem].img_oldpath;
  425. emit PaperChange(QString::fromLocal8Bit(sl.c_str()));
  426. if (curItem == 0)
  427. {
  428. ui.toolButton_pre->setEnabled(false);
  429. ui.toolButton_left->setEnabled(false);
  430. }
  431. else
  432. {
  433. ui.toolButton_pre->setEnabled(true);
  434. ui.toolButton_left->setEnabled(true);
  435. }
  436. if (curItem == origionImglist.size() - 1)
  437. {
  438. ui.toolButton_next->setEnabled(false);
  439. ui.toolButton_right->setEnabled(false);
  440. }
  441. else
  442. {
  443. ui.toolButton_next->setEnabled(true);
  444. ui.toolButton_right->setEnabled(true);
  445. }
  446. char buf[16] = { 0 };
  447. sprintf(buf, "%d/%d", curItem + 1, pageList.size());
  448. ui.toolButton_preview->setText(buf);*/
  449. }
  450. void QPaperEditHandler::ClickConflict(int index)
  451. {
  452. /*bLoadedPreview = false;
  453. ui.horizontalLayoutWidget->hide();
  454. ui.toolButton_preview->setChecked(false);
  455. m_curpage = curItem;
  456. curItem = 0;
  457. SetViewMode(true);
  458. emit sig_SetViewMode(true);
  459. int paper_id = m_conflict_paper[index - 1];
  460. PAPER_DETAIL paper_detail;
  461. vector<PAGE_DETAIL> pageList;
  462. vector<GROUP_QUESTION> questionList;
  463. int ret = QueryPaperDetail(paper_id, paper_detail, pageList, questionList);
  464. vector<QString> imglist;
  465. vector<string> imgoldpathlist;
  466. for (auto& it : pageList)
  467. {
  468. imglist.push_back(QString::fromLocal8Bit(it.img_path.c_str()));
  469. imgoldpathlist.push_back(it.img_oldpath);
  470. }
  471. SetImgList(imglist, imgoldpathlist);
  472. bgimage.load(QString::fromLocal8Bit(pageList[curItem].img_path.c_str()));
  473. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  474. update();
  475. setFocus();
  476. string sl = pageList[0].img_oldpath;
  477. emit PaperChange(QString::fromLocal8Bit(sl.c_str()));
  478. if (curItem == 0)
  479. {
  480. ui.toolButton_pre->setEnabled(false);
  481. ui.toolButton_left->setEnabled(false);
  482. }
  483. else
  484. {
  485. ui.toolButton_pre->setEnabled(true);
  486. ui.toolButton_left->setEnabled(true);
  487. }
  488. if (curItem == origionImglist.size() - 1)
  489. {
  490. ui.toolButton_next->setEnabled(false);
  491. ui.toolButton_right->setEnabled(false);
  492. }
  493. else
  494. {
  495. ui.toolButton_next->setEnabled(true);
  496. ui.toolButton_right->setEnabled(true);
  497. }
  498. char buf[16] = { 0 };
  499. sprintf(buf, "%d/%d", 1, pageList.size());
  500. ui.toolButton_preview->setText(buf);*/
  501. }
  502. void QPaperEditHandler::ClickSwitchDrag()//切换到拖移模式
  503. {
  504. if (ui.widget_Drag->isVisible())
  505. {
  506. ui.widget_Drag->hide();
  507. ui.toolButton_Switch->setStyleSheet(QString::fromUtf8("QToolButton{\n"
  508. " image:url(:/painter/Resources/painter/\346\230\276\347\244\272\346\250\241\346\235\277-\346\255\243\345\270\270.png);\n"
  509. "}\n"
  510. "QToolButton:hover{\n"
  511. " image:url(:/painter/Resources/painter/\346\230\276\347\244\272\346\250\241\346\235\277-\347\247\273\345\205\245.png);\n"
  512. "}"));
  513. ui.widget_Drag->OnDoFinish();
  514. QString path = QString::fromLocal8Bit(getCurPath().c_str());
  515. bgimage.load(path);
  516. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  517. }
  518. else
  519. {
  520. ui.widget_Drag->show();
  521. ui.toolButton_Switch->setStyleSheet(QString::fromUtf8("QToolButton{\n"
  522. " image:url(:/painter/Resources/painter/\351\232\220\350\227\217\346\250\241\346\235\277-\346\255\243\345\270\270.png);\n"
  523. "}\n"
  524. "QToolButton:hover{\n"
  525. " image:url(:/painter/Resources/painter/\351\232\220\350\227\217\346\250\241\346\235\277-\347\247\273\345\205\245.png);\n"
  526. "}"));
  527. ui.widget_Drag->setPaperInfo(paper_id);
  528. }
  529. }
  530. void QPaperEditHandler::ClickDrag()
  531. {
  532. if (ui.toolButton_drag->isChecked())
  533. {
  534. mousestatus = Mouse_Drag;
  535. }
  536. else
  537. {
  538. mousestatus = Mouse_Normal;
  539. }
  540. setCursor(Qt::SizeAllCursor);
  541. }
  542. void QPaperEditHandler::ClickPen(QObject* sender)
  543. {
  544. if (sender == ui.toolButton_pen)
  545. {
  546. if (ui.toolButton_pen->isChecked())
  547. {
  548. mousestatus = Mouse_Pen;
  549. ui.toolButton_pen1->show();
  550. ui.toolButton_pen2->show();
  551. ui.toolButton_pen3->show();
  552. ui.toolButton_penred->show();
  553. ui.toolButton_penblack->show();
  554. }
  555. else
  556. {
  557. mousestatus = Mouse_Normal;
  558. ui.toolButton_pen1->hide();
  559. ui.toolButton_pen2->hide();
  560. ui.toolButton_pen3->hide();
  561. ui.toolButton_penred->hide();
  562. ui.toolButton_penblack->hide();
  563. }
  564. }
  565. else if (sender == ui.toolButton_pen1)
  566. {
  567. penW = 1;
  568. }
  569. else if (sender == ui.toolButton_pen2)
  570. {
  571. penW = 2;
  572. }
  573. else if (sender == ui.toolButton_pen3)
  574. {
  575. penW = 3;
  576. }
  577. else if (sender == ui.toolButton_penred)
  578. {
  579. penColor = QColor(Qt::red);
  580. }
  581. else if (sender == ui.toolButton_penblack)
  582. {
  583. penColor = QColor(0, 0, 0);
  584. }
  585. setCursor(Qt::ArrowCursor);
  586. }
  587. void QPaperEditHandler::ClickEraser(QObject* sender)
  588. {
  589. if (sender == ui.toolButton_eraser)
  590. {
  591. if (ui.toolButton_eraser->isChecked())
  592. {
  593. mousestatus = Mouse_Eraser;
  594. ui.toolButton_eraser1->show();
  595. ui.toolButton_eraser2->show();
  596. ui.toolButton_erase3->show();
  597. }
  598. else
  599. {
  600. mousestatus = Mouse_Normal;
  601. ui.toolButton_eraser1->hide();
  602. ui.toolButton_eraser2->hide();
  603. ui.toolButton_erase3->hide();
  604. }
  605. }
  606. else if (sender == ui.toolButton_eraser1)
  607. {
  608. eraserW = 13;
  609. eraserH = 9;
  610. }
  611. else if (sender == ui.toolButton_eraser2)
  612. {
  613. eraserW = 17;
  614. eraserH = 13;
  615. }
  616. else if (sender == ui.toolButton_erase3)
  617. {
  618. eraserW = 23;
  619. eraserH = 17;
  620. }
  621. QPixmap pixmap(eraserW + 1, eraserH + 1);
  622. QPainter painterim(&pixmap);
  623. painterim.setRenderHint(QPainter::Antialiasing);
  624. pixmap.fill(Qt::white); //填充1像素值
  625. painterim.drawRect(0, 0, eraserW + 1, eraserH + 1);
  626. QCursor cursor(pixmap, 0, 0); //加载xpm生成的图标文件
  627. setCursor(cursor); //设置自定义的鼠标样式
  628. }
  629. void QPaperEditHandler::ClickLine(QObject* sender)
  630. {
  631. if (sender == ui.toolButton_line)
  632. {
  633. if (ui.toolButton_line->isChecked())
  634. {
  635. mousestatus = Mouse_Line;
  636. ui.toolButton_line1->show();
  637. ui.toolButton_line2->show();
  638. ui.toolButton_line3->show();
  639. ui.toolButton_linered->show();
  640. ui.toolButton_lineblack->show();
  641. }
  642. else
  643. {
  644. mousestatus = Mouse_Normal;
  645. ui.toolButton_line1->hide();
  646. ui.toolButton_line2->hide();
  647. ui.toolButton_line3->hide();
  648. ui.toolButton_linered->hide();
  649. ui.toolButton_lineblack->hide();
  650. }
  651. }
  652. else if (sender == ui.toolButton_line1)
  653. {
  654. lineW = 1;
  655. }
  656. else if (sender == ui.toolButton_line2)
  657. {
  658. lineW = 2;
  659. }
  660. else if (sender == ui.toolButton_line3)
  661. {
  662. lineW = 3;
  663. }
  664. else if (sender == ui.toolButton_linered)
  665. {
  666. lineColor = QColor(255, 0, 0);
  667. }
  668. else if (sender == ui.toolButton_lineblack)
  669. {
  670. lineColor = QColor(0, 0, 0);
  671. }
  672. setCursor(Qt::ArrowCursor);
  673. }
  674. void QPaperEditHandler::ClickCut()
  675. {
  676. if (ui.toolButton_cut->isChecked())
  677. {
  678. mousestatus = Mouse_Cut;
  679. }
  680. else
  681. {
  682. mousestatus = Mouse_Normal;
  683. }
  684. setCursor(Qt::ArrowCursor);
  685. }
  686. void QPaperEditHandler::ClickRoomin()
  687. {
  688. offset.setX(0);
  689. offset.setY(0);
  690. room = room*1.1;
  691. //bgimage.scaled(bgimage.width()*room, bgimage.height()* room, Qt::KeepAspectRatio);
  692. update();
  693. if (mousestatus == Mouse_Locate)
  694. {
  695. QPixmap pixmap((locateW + 1)*room, (locateH + 1)*room);
  696. QPainter painterim(&pixmap);
  697. painterim.setRenderHint(QPainter::Antialiasing);
  698. pixmap.fill(Qt::black); //填充1像素值
  699. painterim.drawRect(0, 0, (locateW + 1)*room, (locateH + 1)*room);
  700. QCursor cursor(pixmap, 0, 0); //加载xpm生成的图标文件
  701. setCursor(cursor); //设置自定义的鼠标样式
  702. }
  703. }
  704. void QPaperEditHandler::ClickRoomout()
  705. {
  706. offset.setX(0);
  707. offset.setY(0);
  708. room = room / 1.1;
  709. //bgimage.scaled(bgimage.width()*room, bgimage.height()* room, Qt::KeepAspectRatio);
  710. update();
  711. if (mousestatus == Mouse_Locate)
  712. {
  713. QPixmap pixmap((locateW + 1)*room, (locateH + 1)*room);
  714. QPainter painterim(&pixmap);
  715. painterim.setRenderHint(QPainter::Antialiasing);
  716. pixmap.fill(Qt::black); //填充1像素值
  717. painterim.drawRect(0, 0, (locateW + 1)*room, (locateH + 1)*room);
  718. QCursor cursor(pixmap, 0, 0); //加载xpm生成的图标文件
  719. setCursor(cursor); //设置自定义的鼠标样式
  720. }
  721. }
  722. void QPaperEditHandler::ClickRotate90()
  723. {
  724. offset.setX(0);
  725. offset.setY(0);
  726. QMatrix matrix;
  727. matrix.rotate(90.0);
  728. bgimage = bgimage.transformed(matrix, Qt::FastTransformation);
  729. update();
  730. if (!ui.toolButton_cur->isChecked())
  731. {
  732. return;
  733. }
  734. m_bIsEdited = true;
  735. SaveTempImg(&bgimage);
  736. }
  737. void QPaperEditHandler::ClickRotateN90()
  738. {
  739. offset.setX(0);
  740. offset.setY(0);
  741. QMatrix matrix;
  742. matrix.rotate(-90.0);
  743. bgimage = bgimage.transformed(matrix, Qt::FastTransformation);
  744. update();
  745. if (!ui.toolButton_cur->isChecked())
  746. {
  747. return;
  748. }
  749. m_bIsEdited = true;
  750. SaveTempImg(&bgimage);
  751. }
  752. void QPaperEditHandler::ClickUndo()
  753. {
  754. m_bIsEdited = true;
  755. if (index[curItem] == 0)
  756. {
  757. return;
  758. }
  759. index[curItem]--;
  760. if (index[curItem] == 0)
  761. {
  762. bgimage.load(origionImgpath);
  763. }
  764. else
  765. {
  766. QString path = QString::fromLocal8Bit(getCurPath().c_str());
  767. bgimage.load(path);
  768. }
  769. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  770. update();
  771. }
  772. void QPaperEditHandler::ClickRedo()
  773. {
  774. m_bIsEdited = true;
  775. if (index[curItem] == total[curItem])
  776. {
  777. return;
  778. }
  779. ++index[curItem];
  780. QString path = QString::fromLocal8Bit(getCurPath().c_str());
  781. bgimage.load(path);
  782. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  783. update();
  784. }
  785. void QPaperEditHandler::ClickLocate(QObject* sender)
  786. {
  787. int locX, locY;
  788. if (sender == ui.toolButton_locate)
  789. {
  790. if (ui.toolButton_locate->isChecked())
  791. {
  792. mousestatus = Mouse_Locate;
  793. ui.toolButton_locate1->show();
  794. ui.toolButton_locate2->show();
  795. ui.toolButton_locate3->show();
  796. if (ui.toolButton_locate1->isChecked())
  797. {
  798. locX = 18;
  799. locY = 12;
  800. }
  801. else if (ui.toolButton_locate2->isChecked())
  802. {
  803. locX = 30;
  804. locY = 18;
  805. }
  806. else if (ui.toolButton_locate3->isChecked())
  807. {
  808. locX = 40;
  809. locY = 20;
  810. }
  811. }
  812. else
  813. {
  814. mousestatus = Mouse_Normal;
  815. ui.toolButton_locate1->hide();
  816. ui.toolButton_locate2->hide();
  817. ui.toolButton_locate3->hide();
  818. }
  819. }
  820. else if (sender == ui.toolButton_locate1)
  821. {
  822. locX = 18;
  823. locY = 12;
  824. }
  825. else if (sender == ui.toolButton_locate2)
  826. {
  827. locX = 30;
  828. locY = 18;
  829. }
  830. else if (sender == ui.toolButton_locate3)
  831. {
  832. locX = 40;
  833. locY = 20;
  834. }
  835. float x, y;
  836. getDpiXY(origionImglist[0].toLocal8Bit().toStdString(), x, y);
  837. locateW = locX * (x / 96);
  838. locateH = locY * (y / 96);
  839. QPixmap pixmap((locateW + 1)*room, (locateH + 1)*room);
  840. QPainter painterim(&pixmap);
  841. painterim.setRenderHint(QPainter::Antialiasing);
  842. pixmap.fill(Qt::black); //填充1像素值
  843. painterim.drawRect(0, 0, (locateW + 1)*room, (locateH + 1)*room);
  844. QCursor cursor(pixmap, 0, 0); //加载xpm生成的图标文件
  845. setCursor(cursor); //设置自定义的鼠标样式
  846. }
  847. void QPaperEditHandler::ClickMore()
  848. {
  849. ui.toolButton_redo->show();
  850. ui.toolButton_restore->show();
  851. ui.toolButton_switchpage->show();
  852. }
  853. void QPaperEditHandler::ClickPre()
  854. {
  855. long long currentTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
  856. LoadPreview();
  857. int id = preItem();
  858. if (iteminfos.size() > 0)
  859. {
  860. origionImgpath = iteminfos[id].origion_imgpath;
  861. oldimgpath = iteminfos[id].img_oldpath;
  862. if (ui.toolButton_cur->isChecked())
  863. {
  864. if (index[curItem] > 0)
  865. {
  866. QString path = QString::fromLocal8Bit(getCurPath().c_str());
  867. bgimage.load(path);
  868. if (m_titleInfo.length() == 0)
  869. {
  870. string sl = iteminfos[id].img_oldpath;
  871. emit PaperChange(QString::fromLocal8Bit(sl.c_str()));
  872. }
  873. else
  874. {
  875. emit PaperChange(QString::fromLocal8Bit(m_titleInfo.c_str()));
  876. }
  877. }
  878. else
  879. {
  880. SetOrigionImg(origionImgpath,iteminfos[id].img_oldpath);
  881. }
  882. }
  883. else
  884. {
  885. SetOrigionImg(origionImgpath, iteminfos[id].img_oldpath);
  886. }
  887. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  888. int aaa = QDateTime::currentDateTime().toMSecsSinceEpoch() - currentTime;
  889. update();
  890. ui.listWidget_preview->setItemSelected(iteminfos[id].pItem, true);
  891. ui.listWidget_preview->setCurrentRow(id);
  892. char buf[8] = { 0 };
  893. sprintf(buf, "%d/%d", id + 1, iteminfos.size());
  894. ui.toolButton_preview->setText(buf);
  895. int bbb = QDateTime::currentDateTime().toMSecsSinceEpoch() - currentTime;
  896. bbb += 1;
  897. }
  898. }
  899. void QPaperEditHandler::ClickPreView()
  900. {
  901. LoadPreview();
  902. if (ui.toolButton_preview->isChecked())
  903. {
  904. ui.horizontalLayoutWidget->show();
  905. }
  906. else
  907. {
  908. ui.horizontalLayoutWidget->hide();
  909. }
  910. }
  911. void QPaperEditHandler::ClickNext()
  912. {
  913. LoadPreview();
  914. int id = NextItem();
  915. if (iteminfos.size() > 0)
  916. {
  917. oldimgpath = iteminfos[id].img_oldpath;
  918. origionImgpath = iteminfos[id].origion_imgpath;
  919. if (ui.toolButton_cur->isChecked())
  920. {
  921. if (index[curItem] > 0)
  922. {
  923. QString path = QString::fromLocal8Bit(getCurPath().c_str());
  924. bgimage.load(path);
  925. string sl = iteminfos[id].img_oldpath;
  926. if (m_titleInfo.length() == 0)
  927. {
  928. emit PaperChange(QString::fromLocal8Bit(sl.c_str()));
  929. }
  930. else
  931. {
  932. emit PaperChange(QString::fromLocal8Bit(m_titleInfo.c_str()));
  933. }
  934. }
  935. else
  936. {
  937. SetOrigionImg(origionImgpath, iteminfos[id].img_oldpath);
  938. }
  939. }
  940. else
  941. {
  942. SetOrigionImg(origionImgpath, iteminfos[id].img_oldpath);
  943. }
  944. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  945. update();
  946. ui.listWidget_preview->setItemSelected(iteminfos[id].pItem, true);
  947. ui.listWidget_preview->setCurrentRow(id);
  948. char buf[16] = { 0 };
  949. sprintf(buf, "%d/%d", id + 1, iteminfos.size());
  950. ui.toolButton_preview->setText(buf);
  951. }
  952. }
  953. void QPaperEditHandler::ClickRestore()
  954. {
  955. //QString msg = QString::fromLocal8Bit("还原后,将清空所有对图片的修改,");
  956. //msg += QString::fromLocal8Bit("确定要还原吗?");
  957. //if (QBaseDialog::OkButton == QMessageDialog::information(this, QString::fromLocal8Bit("提示"), msg, QBaseDialog::OkCancelButton))
  958. //{
  959. // room = 1.0f;
  960. // index[curItem] = 0;//当前步
  961. // total[curItem] = 0;//总步数
  962. // offset = QPoint(0, 0);
  963. // SetOrigionImg(origionImgpath,oldimgpath);
  964. // m_bIsEdited = false;
  965. //}
  966. }
  967. void QPaperEditHandler::ClickCutOK()
  968. {
  969. //ctlDlg.ui.label->hide();
  970. //ctlDlg.ui.toolButton_ok->hide();
  971. //ctlDlg.ui.toolButton_del1->hide();
  972. //ctlDlg.ui.toolButton_save->show();
  973. //ctlDlg.ui.toolButton_copy->show();
  974. //ctlDlg.ui.toolButton_del2->show();
  975. //ctlDlg.setStyleSheet("#PainterCutCtl{border:none;background - color: rgb(64, 64, 64);}");
  976. }
  977. void QPaperEditHandler::ClickCutDel()
  978. {
  979. /*cutdlg.hide();
  980. ctlDlg.hide();
  981. mousestatus = Mouse_Cut;*/
  982. }
  983. void QPaperEditHandler::ClickCutSave()
  984. {
  985. mergeImg();
  986. ClickCutDel();
  987. }
  988. void QPaperEditHandler::ClickCutCopy()
  989. {
  990. mergeImg();
  991. }
  992. void QPaperEditHandler::paintEvent(QPaintEvent *e)//将上一个函数得到的全屏灰色图绘制在painter上,并添加宽高信息矩形和边角拖曳小正方形
  993. {
  994. QPainter painter(this);
  995. painter.setRenderHint(QPainter::Antialiasing);
  996. painter.translate(offset.x(), offset.y());
  997. painter.scale(room, room);
  998. painter.drawImage(QPoint(0, 0), bgimage);
  999. if (ispressed)
  1000. {
  1001. if (mousestatus == Mouse_Line)
  1002. {
  1003. pen.setColor(lineColor);
  1004. pen.setWidth(lineW / room);
  1005. painter.setPen(pen);
  1006. painter.drawLine(PointSwitchToImg(startPoint), PointSwitchToImg(endPoint));
  1007. }
  1008. else if (mousestatus == Mouse_Cut)
  1009. {
  1010. /* cutdlg.pen.setWidth(1 / room);
  1011. painter.setPen(cutdlg.pen);
  1012. painter.drawRect(QRect(PointSwitchToImg(startPoint), PointSwitchToImg(endPoint)));
  1013. cutdlg.pen.setWidth(1);*/
  1014. }
  1015. }
  1016. if (m_bShowMovie)
  1017. {
  1018. //QPainter painter2(this);
  1019. //painter2.setRenderHint(QPainter::Antialiasing);
  1020. //QRect rc = ui.label_movie->geometry();
  1021. //QRect rcclient = geometry();
  1022. //rc.setTop(rc.bottom() + 5);
  1023. //rc.setLeft(0);
  1024. //rc.setBottom(rcclient.bottom());
  1025. //rc.setRight(rcclient.right());
  1026. //painter2.setPen(QColor(21, 174, 104));
  1027. //QFont font;
  1028. //font.setFamily(QStringLiteral("Agency FB"));
  1029. //font.setPointSize(30);
  1030. //painter2.setFont(font);
  1031. //painter2.drawText(rc, Qt::AlignHCenter | Qt::AlignTop, QString::fromLocal8Bit("重新识别中…"));
  1032. }
  1033. }
  1034. void QPaperEditHandler::mousePressEvent(QMouseEvent *event)
  1035. {
  1036. /*if (!ui.toolButton_cur->isChecked())
  1037. {
  1038. return;
  1039. }
  1040. HideButtons();
  1041. startPoint = event->pos();
  1042. endPoint = event->pos();
  1043. if (!ui.widget_Drag->isVisible())
  1044. {
  1045. ispressed = true;
  1046. }*/
  1047. }
  1048. void QPaperEditHandler::mouseMoveEvent(QMouseEvent *event)
  1049. {
  1050. if (!ui.toolButton_cur->isChecked())
  1051. {
  1052. return;
  1053. }
  1054. QPainter painterim(&bgimage);
  1055. painterim.setRenderHint(QPainter::Antialiasing);
  1056. if (ispressed)
  1057. {
  1058. if (mousestatus == Mouse_Pen)
  1059. {
  1060. pen.setWidth(penW / room);
  1061. pen.setColor(penColor);
  1062. painterim.setPen(pen);
  1063. endPoint = event->pos();
  1064. painterim.drawLine(PointSwitchToImg(startPoint), PointSwitchToImg(endPoint));
  1065. startPoint = endPoint;
  1066. update();
  1067. }
  1068. else if (mousestatus == Mouse_Line)
  1069. {
  1070. endPoint = event->pos();
  1071. update();
  1072. }
  1073. else if (mousestatus == Mouse_Eraser)
  1074. {
  1075. painterim.eraseRect(RectSwitchImg(QRect(event->pos().x(), event->pos().y(), eraserW, eraserH)));
  1076. update();
  1077. }
  1078. else if (mousestatus == Mouse_Drag)
  1079. {
  1080. endPoint = event->pos();
  1081. offset.setX(endPoint.x() - startPoint.x() + offset.x());
  1082. offset.setY(endPoint.y() - startPoint.y() + offset.y());
  1083. startPoint = endPoint;
  1084. if (bgimage.width()*room <= geometry().width()) //不能拖动
  1085. {
  1086. offset.setX(0);
  1087. }
  1088. else
  1089. {
  1090. int offxMax = 0, offxMin = geometry().width() - bgimage.width()*room;
  1091. if (offset.x() < offxMin)
  1092. {
  1093. offset.setX(offxMin);
  1094. }
  1095. else if (offset.x() > offxMax)
  1096. {
  1097. offset.setX(offxMax);
  1098. }
  1099. }
  1100. if (bgimage.height()*room <= geometry().height()) //不能拖动
  1101. {
  1102. offset.setY(0);
  1103. }
  1104. else
  1105. {
  1106. int offyMax = 0, offyMin = geometry().height() - bgimage.height()*room;
  1107. if (offset.y() < offyMin)
  1108. {
  1109. offset.setY(offyMin);
  1110. }
  1111. else if (offset.y() > offyMax)
  1112. {
  1113. offset.setY(offyMax);
  1114. }
  1115. }
  1116. update();
  1117. }
  1118. else if (mousestatus == Mouse_Cut)
  1119. {
  1120. endPoint = event->pos();
  1121. update();
  1122. }
  1123. }
  1124. }
  1125. void QPaperEditHandler::mouseReleaseEvent(QMouseEvent *event)
  1126. {
  1127. //setCursor(Qt::ArrowCursor);
  1128. if (!ui.toolButton_cur->isChecked())
  1129. {
  1130. return;
  1131. }
  1132. ispressed = false;
  1133. if (mousestatus == Mouse_Line)
  1134. {
  1135. QPainter painterim(&bgimage);
  1136. painterim.setRenderHint(QPainter::Antialiasing);
  1137. pen.setWidth(lineW / room);
  1138. pen.setColor(lineColor);
  1139. painterim.setPen(pen);
  1140. endPoint = event->pos();
  1141. painterim.drawLine(PointSwitchToImg(startPoint), PointSwitchToImg(endPoint));
  1142. m_bIsEdited = true;
  1143. SaveTempImg(&bgimage);
  1144. update();
  1145. }
  1146. else if (mousestatus == Mouse_Cut)
  1147. {
  1148. QRect rcimg(0, 0, bgimage.width(), bgimage.height());
  1149. QRect rcScope = RectSwitchToClient(rcimg);
  1150. QRect rcclient = geometry();
  1151. rcScope.setX(max(rcScope.left(), 0));
  1152. rcScope.setY(max(rcScope.top(), 0));
  1153. rcScope.setRight(min(rcScope.right(), rcclient.right()));
  1154. rcScope.setBottom(min(rcScope.bottom(), rcclient.bottom()));
  1155. endPoint = event->pos();
  1156. QRect rcCut;
  1157. rcCut.setX(min(startPoint.x(), endPoint.x()) - 2);
  1158. rcCut.setY(min(startPoint.y(), endPoint.y()) - 2);
  1159. rcCut.setRight(max(startPoint.x(), endPoint.x()) + 2);
  1160. rcCut.setBottom(max(startPoint.y(), endPoint.y()) + 2);
  1161. rcCut.setX(max(rcScope.left(), rcCut.left()));
  1162. rcCut.setY(max(rcScope.top(), rcCut.top()));
  1163. rcCut.setRight(min(rcScope.right(), rcCut.right()));
  1164. rcCut.setBottom(min(rcScope.bottom(), rcCut.bottom()));
  1165. /* cutdlg.setGeometry(rcCut);
  1166. cutdlg.rcScope = rcScope;*/
  1167. rcCut.adjust(2, 2, -2, -2);
  1168. /* cutdlg.bgimage = bgimage.copy(RectSwitchImg(rcCut));
  1169. cutdlg.show();
  1170. cutdlg.update();
  1171. cutdlg.setFocus();*/
  1172. rcCut.setTop(rcCut.bottom() + 3);
  1173. rcCut.setBottom(rcCut.top() + 28);
  1174. rcCut.setLeft(rcCut.right() - 250);
  1175. if (rcCut.top() > rcScope.bottom() - 28)
  1176. {
  1177. rcCut.setTop(rcScope.bottom() - 35);
  1178. }
  1179. rcCut.setBottom(rcCut.top() + 28);
  1180. if (rcCut.left() < 0)
  1181. {
  1182. rcCut.setLeft(0);
  1183. rcCut.setRight(250);
  1184. }
  1185. /* ctlDlg.setGeometry(rcCut);
  1186. ctlDlg.ui.label->show();
  1187. ctlDlg.ui.toolButton_ok->show();
  1188. ctlDlg.ui.toolButton_del1->show();
  1189. ctlDlg.ui.toolButton_save->hide();
  1190. ctlDlg.ui.toolButton_copy->hide();
  1191. ctlDlg.ui.toolButton_del2->hide();
  1192. ctlDlg.show();*/
  1193. //ctlDlg.setStyleSheet("#PainterCutCtl{\
  1194. // background - color: rgb(64, 64, 64);\
  1195. // border - radius: 4px;\
  1196. //border:1px groove gray;}"
  1197. // );
  1198. update();
  1199. mousestatus = Mouse_Cuting;
  1200. }
  1201. else if (mousestatus == Mouse_Eraser)
  1202. {
  1203. QPainter painterim(&bgimage);
  1204. painterim.setRenderHint(QPainter::Antialiasing);
  1205. painterim.eraseRect(RectSwitchImg(QRect(event->pos().x(), event->pos().y(), eraserW, eraserH)));
  1206. m_bIsEdited = true;
  1207. SaveTempImg(&bgimage);
  1208. update();
  1209. }
  1210. else if (mousestatus == Mouse_Pen)
  1211. {
  1212. m_bIsEdited = true;
  1213. SaveTempImg(&bgimage);
  1214. m_bIsEdited = true;
  1215. update();
  1216. }
  1217. else if (mousestatus == Mouse_Locate)
  1218. {
  1219. QPainter painterim(&bgimage);
  1220. painterim.setRenderHint(QPainter::SmoothPixmapTransform);
  1221. QPoint pt = PointSwitchToImg(event->pos());
  1222. QRect rc(pt.x(), pt.y(), locateW, locateH);
  1223. QRect target = rc;
  1224. painterim.setBrush(Qt::black);
  1225. painterim.drawRect(target);
  1226. m_bIsEdited = true;
  1227. SaveTempImg(&bgimage);
  1228. update();
  1229. }
  1230. }
  1231. void QPaperEditHandler::wheelEvent(QWheelEvent *event) // 滚轮事件
  1232. {
  1233. if (QApplication::keyboardModifiers() == Qt::ControlModifier)
  1234. {
  1235. if (event->delta() > 0)
  1236. { // 当滚轮远离使用者时
  1237. ClickRoomin(); // 进行放大
  1238. }
  1239. else
  1240. { // 当滚轮向使用者方向旋转时
  1241. ClickRoomout(); // 进行缩小
  1242. }
  1243. }
  1244. }
  1245. bool QPaperEditHandler::eventFilter(QObject *watched, QEvent *event)
  1246. {
  1247. //if (this == watched)
  1248. {
  1249. if (QEvent::Enter == event->type()) //鼠标进入
  1250. {
  1251. setCursor(Qt::ArrowCursor);
  1252. return true;
  1253. //if (m_pStandardLabel->isHidden())
  1254. //{ //已经隐藏就显示出来
  1255. // m_pStandardLabel->show();
  1256. // QPoint point = ui->scoreStandardBtn->pos();
  1257. // point.rx() = point.x() - m_pStandardLabel->width() + 120;
  1258. // point.ry() = point.y() + ui->scoreStandardBtn->height() + 40;
  1259. // m_pStandardLabel->move(point);
  1260. // m_pStandardLabel->raise();//显示最顶层
  1261. // return true;
  1262. //}
  1263. }
  1264. else if (QEvent::Leave == event->type())//鼠标离开
  1265. {
  1266. //if (!ui->scoreStandardBtn->geometry().contains(this->mapFromGlobal(QCursor::pos())) //判断鼠标是否在控件上
  1267. // && !m_pStandardLabel->geometry().contains(this->mapFromGlobal(QCursor::pos())))
  1268. //{
  1269. // m_pStandardLabel->hide();
  1270. // return true;
  1271. //}
  1272. //m_floatdlg->setModal(false);
  1273. //m_floatdlg->hide();
  1274. return true;
  1275. }
  1276. }
  1277. return QWidget::eventFilter(watched, event);
  1278. }
  1279. void QPaperEditHandler::resizeEvent(QResizeEvent *event)
  1280. {
  1281. if (bFirstResize)
  1282. {
  1283. bFirstResize = false;
  1284. QRect rc = geometry();
  1285. float roomW = (float)rc.width() / bgimage.width();
  1286. float roomH = (float)rc.height() / bgimage.height();
  1287. room = roomW;
  1288. if (roomH < room)
  1289. {
  1290. room = roomH;
  1291. }
  1292. }
  1293. int w = 44;
  1294. int h = 44;
  1295. QRect rcclient = geometry();
  1296. ui.widget_Drag->setGeometry(rcclient);
  1297. QRect temp1 = rcclient;
  1298. QRect temp2;
  1299. temp1.setLeft(rcclient.right() - w);
  1300. temp1.setBottom(rcclient.top() + h);
  1301. QRect rcUploadErrorInfo = rcclient;
  1302. rcUploadErrorInfo.setTop(rcclient.top() + 25);
  1303. rcUploadErrorInfo.setBottom(rcUploadErrorInfo.top() + 40);
  1304. rcUploadErrorInfo.setLeft(rcUploadErrorInfo.left() + 100);
  1305. rcUploadErrorInfo.setRight(rcUploadErrorInfo.right() - 100);
  1306. ui.label_shibaiyuanyin->setGeometry(rcUploadErrorInfo);//上传失败原因
  1307. ui.toolButton_drag->setGeometry(temp1);//拖拽
  1308. temp1.moveTo(temp1.left(), temp1.bottom());//放大
  1309. ui.toolButton_roomin->setGeometry(temp1);
  1310. temp1.moveTo(temp1.left(), temp1.bottom());//缩小
  1311. ui.toolButton_rommout->setGeometry(temp1);
  1312. temp1.moveTo(temp1.left(), temp1.bottom());//正转
  1313. ui.toolButton_90->setGeometry(temp1);
  1314. temp1.moveTo(temp1.left(), temp1.bottom());//逆转
  1315. ui.toolButton_N90->setGeometry(temp1);
  1316. temp1.moveTo(temp1.left(), temp1.bottom());//定位点
  1317. ui.toolButton_locate->setGeometry(temp1);
  1318. {
  1319. temp2 = temp1;
  1320. temp2.moveTo(temp2.left() - w, temp2.top());
  1321. ui.toolButton_locate1->setGeometry(temp2);
  1322. temp2.moveTo(temp2.left(), temp2.bottom());
  1323. ui.toolButton_locate2->setGeometry(temp2);
  1324. temp2.moveTo(temp2.left(), temp2.bottom());
  1325. ui.toolButton_locate3->setGeometry(temp2);
  1326. }
  1327. temp1.moveTo(temp1.left(), temp1.bottom());
  1328. ui.toolButton_pen->setGeometry(temp1);
  1329. {
  1330. temp2 = temp1;
  1331. temp2.moveTo(temp1.left() - w, temp1.top());
  1332. ui.toolButton_pen1->setGeometry(temp2);
  1333. temp2.moveTo(temp2.left(), temp2.bottom());
  1334. ui.toolButton_pen2->setGeometry(temp2);
  1335. temp2.moveTo(temp2.left(), temp2.bottom());
  1336. ui.toolButton_pen3->setGeometry(temp2);
  1337. temp2.moveTo(temp2.left(), temp2.bottom());
  1338. ui.toolButton_penred->setGeometry(temp2);
  1339. temp2.moveTo(temp2.left(), temp2.bottom());
  1340. ui.toolButton_penblack->setGeometry(temp2);
  1341. }
  1342. temp1.moveTo(temp1.left(), temp1.bottom());
  1343. ui.toolButton_line->setGeometry(temp1);
  1344. {
  1345. temp2 = temp1;
  1346. temp2.moveTo(temp1.left() - w, temp1.top());
  1347. ui.toolButton_line1->setGeometry(temp2);
  1348. temp2.moveTo(temp2.left(), temp2.bottom());
  1349. ui.toolButton_line2->setGeometry(temp2);
  1350. temp2.moveTo(temp2.left(), temp2.bottom());
  1351. ui.toolButton_line3->setGeometry(temp2);
  1352. temp2.moveTo(temp2.left(), temp2.bottom());
  1353. ui.toolButton_linered->setGeometry(temp2);
  1354. temp2.moveTo(temp2.left(), temp2.bottom());
  1355. ui.toolButton_lineblack->setGeometry(temp2);
  1356. }
  1357. temp1.moveTo(temp1.left(), temp1.bottom());
  1358. ui.toolButton_eraser->setGeometry(temp1);
  1359. {
  1360. temp2 = temp1;
  1361. temp2.moveTo(temp2.left() - w, temp2.top());
  1362. ui.toolButton_eraser1->setGeometry(temp2);
  1363. temp2.moveTo(temp2.left(), temp2.bottom());
  1364. ui.toolButton_eraser2->setGeometry(temp2);
  1365. temp2.moveTo(temp2.left(), temp2.bottom());
  1366. ui.toolButton_erase3->setGeometry(temp2);
  1367. }
  1368. temp1.moveTo(temp1.left(), temp1.bottom());
  1369. ui.toolButton_undo->setGeometry(temp1);
  1370. temp1.moveTo(temp1.left(), temp1.bottom());
  1371. ui.toolButton_cut->setGeometry(temp1);
  1372. temp1.moveTo(temp1.left(), temp1.bottom());
  1373. ui.toolButton_more->setGeometry(temp1);
  1374. {
  1375. temp2 = temp1;
  1376. temp2.moveTo(temp2.left() - w, temp2.top());
  1377. ui.toolButton_redo->setGeometry(temp2);
  1378. temp2.moveTo(temp2.left(), temp2.bottom());
  1379. ui.toolButton_restore->setGeometry(temp2);
  1380. if (origionImglist.size() == 2)
  1381. {
  1382. temp2.moveTo(temp2.left(), temp2.bottom());
  1383. ui.toolButton_switchpage->setGeometry(temp2);
  1384. }
  1385. }
  1386. temp1 = rcclient;
  1387. temp1.setLeft(rcclient.right() - w);
  1388. temp1.setTop(rcclient.bottom() - h);
  1389. ui.toolButton_next->setGeometry(temp1);
  1390. temp1.moveTo(temp1.left(), temp1.top() - h + 1);
  1391. ui.toolButton_preview->setGeometry(temp1);
  1392. {
  1393. temp2 = temp1;
  1394. temp2.moveTo(temp2.left() - h - 18 + 1, temp2.top() + 1);
  1395. ui.toolButton_right->setGeometry(temp2);
  1396. temp2.moveTo(rcclient.left() + 18, temp2.top() + 1);
  1397. ui.toolButton_left->setGeometry(temp2);
  1398. temp2 = rcclient;
  1399. temp2.setTop(rcclient.bottom() - 131);
  1400. temp2.setRight(rcclient.right() - w);
  1401. temp2.setLeft(rcclient.left());
  1402. //ui.listWidget_preview->setGeometry(temp2);
  1403. ui.horizontalLayoutWidget->setGeometry(temp2);
  1404. }
  1405. temp1.moveTo(temp1.left(), temp1.top() - h + 1);
  1406. ui.toolButton_pre->setGeometry(temp1);
  1407. temp1.setLeft((rcclient.width() - 128) / 2);
  1408. temp1.setWidth(128);
  1409. temp1.setTop((rcclient.height() - 128) / 2);
  1410. temp1.setHeight(128);
  1411. ui.label_movie->setGeometry(temp1);
  1412. temp1.setTop(temp1.bottom() + 1);
  1413. temp1.setBottom(temp1.top() + 79);
  1414. temp1.setLeft(temp1.left() - 61);
  1415. temp1.setRight(temp1.right() + 65);
  1416. ui.label_reidentify->setGeometry(temp1);
  1417. }
  1418. QPoint QPaperEditHandler::PointSwitchToImg(QPoint sPoint)
  1419. {
  1420. int x = sPoint.x() - offset.x();
  1421. x = x / room;
  1422. int y = sPoint.y() - offset.y();
  1423. y = y / room;
  1424. return QPoint(x, y);
  1425. }
  1426. QRect QPaperEditHandler::RectSwitchImg(QRect sRect)
  1427. {
  1428. QPoint lefttop = PointSwitchToImg(QPoint(sRect.left(), sRect.top()));
  1429. QPoint rightbottom = PointSwitchToImg(QPoint(sRect.right(), sRect.bottom()));
  1430. return QRect(lefttop, rightbottom);
  1431. }
  1432. QPoint QPaperEditHandler::PointSwitchToClient(QPoint sPoint)
  1433. {
  1434. int x = sPoint.x() * room;
  1435. x = x + offset.x();
  1436. int y = sPoint.y() * room;
  1437. y = y + offset.y();
  1438. return QPoint(x, y);
  1439. }
  1440. QRect QPaperEditHandler::RectSwitchToClient(QRect sRect)
  1441. {
  1442. QPoint lefttop = PointSwitchToClient(QPoint(sRect.left(), sRect.top()));
  1443. QPoint rightbottom = PointSwitchToClient(QPoint(sRect.right(), sRect.bottom()));
  1444. return QRect(lefttop, rightbottom);
  1445. }
  1446. void QPaperEditHandler::SetOrigionImg(QString path,string oldpath)
  1447. {
  1448. origionImgpath = path;
  1449. oldimgpath = oldpath;
  1450. bgimage.load(origionImgpath);
  1451. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  1452. update();
  1453. setFocus();
  1454. if (ui.toolButton_cur->isChecked())
  1455. {
  1456. QString path0 = QString::fromLocal8Bit(getCurPath().c_str());
  1457. bgimage.save(path0);
  1458. }
  1459. string sl = oldimgpath;
  1460. if (m_titleInfo.length() == 0)
  1461. {
  1462. emit PaperChange(QString::fromLocal8Bit(sl.c_str()));
  1463. }
  1464. else
  1465. {
  1466. emit PaperChange(QString::fromLocal8Bit(m_titleInfo.c_str()));
  1467. }
  1468. }
  1469. void QPaperEditHandler::LoadPreview()
  1470. {
  1471. if (bLoadedPreview)
  1472. return;
  1473. iteminfos.clear();
  1474. //ui.listWidget_preview->disconnect();
  1475. ui.listWidget_preview->clear();
  1476. ItemInfo info;
  1477. for (int i = 0; i < origionImglist.size(); i++)
  1478. {
  1479. info.id = i;
  1480. info.origion_imgpath = origionImglist[i];
  1481. info.pPreviewImg = new QImage;
  1482. info.pPreviewImg->load(info.origion_imgpath);
  1483. info.pItem = new QListWidgetItem();
  1484. info.img_oldpath = oldImgpathlist[i];
  1485. iteminfos.push_back(info);
  1486. info.pItem->setSizeHint(QSize(156, 132));
  1487. info.pItem->setData(Qt::UserRole, QVariant::fromValue(iteminfos[iteminfos.size() - 1]));
  1488. //info.pItem->setData(Qt::UserRole + 1, "This is Icon of Sage");
  1489. //info.pItem->setData(Qt::UserRole + 2, "D:/123/1.jpg");
  1490. ui.listWidget_preview->addItem(info.pItem);
  1491. }
  1492. ui.listWidget_preview->setViewMode(QListWidget::ListMode);
  1493. ui.listWidget_preview->setFlow(QListWidget::LeftToRight);
  1494. //ui.listWidget_preview->setMovement(QListWidget::Static);
  1495. //设置显示模式为图标模式
  1496. ui.listWidget_preview->setViewMode(QListWidget::ListMode);
  1497. //设置可以换行显示
  1498. ui.listWidget_preview->setLayoutMode(QListWidget::SinglePass);
  1499. //不接受拖放
  1500. ui.listWidget_preview->setAcceptDrops(false);
  1501. //开启排序功能
  1502. //ui.listWidget_preview->setSortingEnabled(true);
  1503. itemPainter.setParent(ui.listWidget_preview);
  1504. ui.listWidget_preview->setItemDelegate(&itemPainter);
  1505. //ui.listWidget_preview->setEditTriggers(QListWidget::CurrentChanged);
  1506. ui.listWidget_preview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  1507. ui.listWidget_preview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  1508. ui.listWidget_preview->setHorizontalScrollMode(QListWidget::ScrollPerPixel);
  1509. QScroller::grabGesture(ui.listWidget_preview, QScroller::LeftMouseButtonGesture);
  1510. //设置当前活动行为0
  1511. ui.listWidget_preview->setCurrentRow(curItem);
  1512. ui.listWidget_preview->setItemSelected(iteminfos[curItem].pItem, true);
  1513. connect(ui.listWidget_preview, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(ListItemChange(QListWidgetItem*)));
  1514. bLoadedPreview = true;
  1515. }
  1516. void QPaperEditHandler::SetShowSchema(bool bshow)
  1517. {
  1518. if (bshow)
  1519. {
  1520. ui.toolButton_Switch->show();
  1521. }
  1522. else
  1523. {
  1524. ui.toolButton_Switch->hide();
  1525. }
  1526. }
  1527. void QPaperEditHandler::SetImgList(vector<QString> imglist,vector<string> oldpathlist)
  1528. {
  1529. this->origionImglist = imglist;
  1530. this->oldImgpathlist = oldpathlist;
  1531. editedImglist = imglist;
  1532. char buf[16] = { 0 };
  1533. sprintf(buf, "%d/%d", 1, imglist.size());
  1534. ui.toolButton_preview->setText(buf);
  1535. if (curItem == 0)
  1536. {
  1537. ui.toolButton_pre->setEnabled(false);
  1538. ui.toolButton_left->setEnabled(false);
  1539. }
  1540. else
  1541. {
  1542. ui.toolButton_pre->setEnabled(true);
  1543. ui.toolButton_left->setEnabled(true);
  1544. }
  1545. if (curItem == imglist.size() - 1)
  1546. {
  1547. ui.toolButton_next->setEnabled(false);
  1548. ui.toolButton_right->setEnabled(false);
  1549. }
  1550. else
  1551. {
  1552. ui.toolButton_next->setEnabled(true);
  1553. ui.toolButton_right->setEnabled(true);
  1554. }
  1555. }
  1556. vector<string> QPaperEditHandler::GetEditedImgs()//点击识别的时候调用
  1557. {
  1558. if (ui.widget_Drag->isVisible())
  1559. {
  1560. m_bIsEdited = ui.widget_Drag->IsEdited();
  1561. ui.widget_Drag->OnDoFinish();
  1562. }
  1563. else
  1564. {
  1565. SaveTempImg(&bgimage);
  1566. }
  1567. vector<string> imgs;
  1568. for (int i = 0; i < origionImglist.size(); i++)
  1569. {
  1570. imgs.push_back(editedImglist[i].toLocal8Bit().toStdString());
  1571. }
  1572. return imgs;
  1573. }
  1574. void QPaperEditHandler::ShowMovie(bool bshow)
  1575. {
  1576. if (bshow)
  1577. {
  1578. ui.label_movie->raise();
  1579. ui.label_movie->show();
  1580. ui.label_reidentify->show();
  1581. ui.label_reidentify->raise();
  1582. }
  1583. else
  1584. {
  1585. ui.label_movie->hide();
  1586. ui.label_reidentify->hide();
  1587. }
  1588. m_bShowMovie = bshow;
  1589. update();
  1590. }
  1591. void QPaperEditHandler::mergeImg()
  1592. {
  1593. /*QRect rc = cutdlg.geometry();
  1594. rc.adjust(2, 2, -2, -2);
  1595. QRect target = RectSwitchImg(rc);
  1596. QPainter painterim(&bgimage);
  1597. painterim.setRenderHint(QPainter::Antialiasing);
  1598. painterim.drawImage(target, cutdlg.bgimage, QRect(0, 0, cutdlg.bgimage.width(), cutdlg.bgimage.height()));
  1599. update();
  1600. m_bIsEdited = true;
  1601. SaveTempImg(&bgimage);*/
  1602. }
  1603. int QPaperEditHandler::NextItem()
  1604. {
  1605. curItem++;
  1606. if (curItem >= iteminfos.size())
  1607. {
  1608. curItem = iteminfos.size() - 1;
  1609. }
  1610. return curItem;
  1611. }
  1612. int QPaperEditHandler::preItem()
  1613. {
  1614. curItem--;
  1615. if (curItem < 0)
  1616. {
  1617. curItem = 0;
  1618. }
  1619. return curItem;
  1620. }
  1621. void QPaperEditHandler::ListItemChange(QListWidgetItem* pitem)
  1622. {
  1623. if (iteminfos.size()>0)
  1624. {
  1625. for (auto &it : iteminfos)
  1626. {
  1627. if (it.pItem == pitem)
  1628. {
  1629. curItem = it.id;
  1630. origionImgpath = it.origion_imgpath;
  1631. if (ui.toolButton_cur->isChecked())
  1632. {
  1633. if (index[curItem] > 0)
  1634. {
  1635. QString path = QString::fromLocal8Bit(getCurPath().c_str());
  1636. bgimage.load(path);
  1637. }
  1638. else
  1639. {
  1640. SetOrigionImg(origionImgpath,it.img_oldpath);
  1641. }
  1642. }
  1643. else
  1644. {
  1645. SetOrigionImg(origionImgpath,it.img_oldpath);
  1646. }
  1647. bgimage = bgimage.convertToFormat(QImage::Format_RGB32);
  1648. update();
  1649. char buf[8] = { 0 };
  1650. sprintf(buf, "%d/%d", curItem + 1, iteminfos.size());
  1651. ui.toolButton_preview->setText(buf);
  1652. }
  1653. }
  1654. }
  1655. if (curItem == 0)
  1656. {
  1657. ui.toolButton_pre->setEnabled(false);
  1658. ui.toolButton_left->setEnabled(false);
  1659. }
  1660. else
  1661. {
  1662. ui.toolButton_pre->setEnabled(true);
  1663. ui.toolButton_left->setEnabled(true);
  1664. }
  1665. if (curItem == origionImglist.size() - 1)
  1666. {
  1667. ui.toolButton_next->setEnabled(false);
  1668. ui.toolButton_right->setEnabled(false);
  1669. }
  1670. else
  1671. {
  1672. ui.toolButton_next->setEnabled(true);
  1673. ui.toolButton_right->setEnabled(true);
  1674. }
  1675. return;
  1676. }
  1677. void QPaperEditHandler::SetViewMode(bool view)
  1678. {
  1679. if (view)
  1680. {
  1681. ui.toolButton_locate1->hide();
  1682. ui.toolButton_locate2->hide();
  1683. ui.toolButton_locate3->hide();
  1684. ui.toolButton_line1->hide();
  1685. ui.toolButton_line2->hide();
  1686. ui.toolButton_line3->hide();
  1687. ui.toolButton_pen1->hide();
  1688. ui.toolButton_pen2->hide();
  1689. ui.toolButton_pen3->hide();
  1690. ui.toolButton_penred->hide();
  1691. ui.toolButton_penblack->hide();
  1692. ui.toolButton_line1->hide();
  1693. ui.toolButton_line2->hide();
  1694. ui.toolButton_line3->hide();
  1695. ui.toolButton_linered->hide();
  1696. ui.toolButton_lineblack->hide();
  1697. ui.toolButton_eraser1->hide();
  1698. ui.toolButton_eraser2->hide();
  1699. ui.toolButton_erase3->hide();
  1700. ui.toolButton_cut->hide();
  1701. ui.toolButton_restore->hide();
  1702. ui.toolButton_redo->hide();
  1703. ui.toolButton_locate->hide();
  1704. ui.toolButton_pen->hide();
  1705. ui.toolButton_line->hide();
  1706. ui.toolButton_eraser->hide();
  1707. ui.toolButton_undo->hide();
  1708. ui.toolButton_more->hide();
  1709. ui.toolButton_Switch->hide();
  1710. ui.widget_Drag->hide();
  1711. ui.toolButton_switchpage->hide();
  1712. }
  1713. else
  1714. {
  1715. ui.toolButton_cut->show();
  1716. ui.toolButton_locate->show();
  1717. ui.toolButton_pen->show();
  1718. ui.toolButton_line->show();
  1719. ui.toolButton_eraser->show();
  1720. ui.toolButton_undo->show();
  1721. ui.toolButton_more->show();
  1722. }
  1723. }
  1724. void QPaperEditHandler::SetTitleInfo(string info)
  1725. {
  1726. m_titleInfo = info;
  1727. }
  1728. void QPaperEditHandler::SetHandlerKaohaoyichang(bool bViewMode)
  1729. {
  1730. if (bViewMode)
  1731. {
  1732. ui.toolButton_locate->hide();
  1733. ui.toolButton_pen->hide();
  1734. ui.toolButton_line->hide();
  1735. ui.toolButton_eraser->hide();
  1736. ui.toolButton_undo->hide();
  1737. ui.toolButton_cut->hide();
  1738. ui.toolButton_more->hide();
  1739. }
  1740. else
  1741. {
  1742. ui.toolButton_locate->show();
  1743. ui.toolButton_pen->show();
  1744. ui.toolButton_line->show();
  1745. ui.toolButton_eraser->show();
  1746. ui.toolButton_undo->show();
  1747. ui.toolButton_cut->show();
  1748. ui.toolButton_more->show();
  1749. }
  1750. }