MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / slotCapturePage

Method slotCapturePage

Plugins/WebBrowser/FrmWebBrowser.cpp:1118–1156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1116}
1117
1118void CFrmWebBrowser::slotCapturePage()
1119{
1120 auto pWeb = CurrentView();
1121 if(!pWeb) return;
1122
1123 QString szMsg;
1124 QPixmap pixmap = pWeb->grab();
1125 QImage image = pixmap.toImage();
1126 QString szFile = m_pPara->m_Record.GetImageFile(true);
1127 if(szFile.isEmpty() && image.isNull()) return;
1128 if(!image.save(szFile, "PNG"))
1129 {
1130 QString szErr;
1131 szErr = tr("Fail: Save capture page to the file: ") + szFile;
1132 qCritical(log) << szErr;
1133 emit sigError(RV::FailCapturePage, szErr);
1134 return;
1135 }
1136 szMsg = tr("Save capture page to the file:") + szFile;
1137 qInfo(log) << szMsg;
1138 emit sigInformation(szMsg);
1139 qDebug(log) << "End action:" << m_pPara->m_Record.GetEndAction();
1140 switch(m_pPara->m_Record.GetEndAction())
1141 {
1142 case CParameterRecord::ENDACTION::OpenFile: {
1143 bool bRet = QDesktopServices::openUrl(QUrl::fromLocalFile(szFile));
1144 if(!bRet)
1145 qCritical(log) << "Fail: Open capture page the file:" << szFile;
1146 break;
1147 }
1148 case CParameterRecord::ENDACTION::OpenFolder: {
1149 QFileInfo fi(szFile);
1150 QDesktopServices::openUrl(QUrl::fromLocalFile(fi.absolutePath()));
1151 break;
1152 }
1153 default:
1154 break;
1155 }
1156}
1157
1158void CFrmWebBrowser::slotCaptureFullPage()
1159{

Callers

nothing calls this directly

Calls 3

GetImageFileMethod · 0.80
GetEndActionMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected