void WebPage::windowCloseRequested() { WebView* webView = qobject_cast<WebView*>(view()); if (!webView) { return; } webView->closeView(); }
void DownloadFileHelper::handleUnsupportedContent(QNetworkReply* reply, const DownloadManager::DownloadInfo &info) { m_timer = new QTime(); m_timer->start(); m_h_fileName = info.suggestedFileName.isEmpty() ? getFileName(reply) : info.suggestedFileName; m_reply = reply; QFileInfo fileInfo(m_h_fileName); QTemporaryFile tempFile("XXXXXX." + fileInfo.suffix()); tempFile.open(); tempFile.write(m_reply->peek(1024 * 1024)); QFileInfo tempInfo(tempFile.fileName()); m_fileIcon = m_iconProvider->icon(tempInfo).pixmap(30, 30); QString mimeType = m_iconProvider->type(tempInfo); m_fileSize = m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(); if (m_fileSize > 0) { mimeType.append(QString(" (%1)").arg(qz_fileSizeToString(m_fileSize))); } // Close Empty Tab if (info.page) { WebView* view = qobject_cast<WebView*>(info.page->view()); if (!info.page->url().isEmpty()) { m_downloadPage = info.page->url(); } else if (info.page->history()->canGoBack()) { m_downloadPage = info.page->history()->backItem().url(); } else if (view && info.page->history()->count() == 0) { view->closeView(); } } if (info.askWhatToDo && m_downloadPath.isEmpty()) { DownloadOptionsDialog* dialog = new DownloadOptionsDialog(m_h_fileName, m_fileIcon, mimeType, reply->url(), mApp->activeWindow()); dialog->showExternalManagerOption(m_manager->useExternalManager()); dialog->setLastDownloadOption(m_lastDownloadOption); dialog->show(); connect(dialog, SIGNAL(dialogFinished(int)), this, SLOT(optionsDialogAccepted(int))); }