void MainWindow::fileSaveAs() { WebTab *w = currentTab(); KUrl srcUrl = w->url(); // First, try with suggested file name... QString name = w->page()->suggestedFileName(); // Second, with KUrl fileName... if (name.isEmpty()) { name = srcUrl.fileName(); } // Last chance... if(name.isEmpty()) { name = srcUrl.host() + QString(".html"); } const QString destUrl = KFileDialog::getSaveFileName(name, QString(), this); if (destUrl.isEmpty()) return; KIO::Job *job = KIO::file_copy(srcUrl, KUrl(destUrl), -1, KIO::Overwrite); job->addMetaData("MaxCacheSize", "0"); // Don't store in http cache. job->addMetaData("cache", "cache"); // Use entry from cache if available. job->uiDelegate()->setAutoErrorHandlingEnabled(true); }
WebPage *WebPage::createWindow(QWebPage::WebWindowType type) { // added to manage web modal dialogs if (type == QWebPage::WebModalDialog) kDebug() << "Modal Dialog"; WebTab *w = 0; if (ReKonfig::openTabNoWindow()) { w = rApp->mainWindow()->mainView()->newWebTab(!ReKonfig::openTabsBack()); } else { w = rApp->newMainWindow()->mainView()->currentWebTab(); } return w->page(); }
void TabBar::showTabPreview() { //delete previous tab preview delete m_previewPopup.data(); m_previewPopup.clear(); MainView *mv = qobject_cast<MainView *>(parent()); WebTab *indexedTab = mv->webTab(m_currentTabPreviewIndex); WebTab *currentTab = mv->webTab(currentIndex()); // check if view && currentView exist before using them :) if (!currentTab || !indexedTab) return; // no previews during load if (indexedTab->isPageLoading()) return; int w = tabSizeHint(m_currentTabPreviewIndex).width(); int h = w * ((0.0 + currentTab->height()) / currentTab->width()); m_previewPopup = new KPassivePopup(this); m_previewPopup.data()->setFrameShape(QFrame::StyledPanel); m_previewPopup.data()->setFrameShadow(QFrame::Plain); m_previewPopup.data()->setFixedSize(w, h); QLabel *l = new QLabel(); l->setPixmap( WebSnap::renderTabPreview(*indexedTab->page(), w, h) ); m_previewPopup.data()->setView(l); m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); m_previewPopup.data()->layout()->setMargin(0); QPoint pos(tabRect(m_currentTabPreviewIndex).x() , tabRect(m_currentTabPreviewIndex).y() + tabRect(m_currentTabPreviewIndex).height()); m_previewPopup.data()->show(mapToGlobal(pos)); }
void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) { if (this != QApplication::activeWindow()) { return; } // deleting popus if empty msgs if (msg.isEmpty()) { m_hidePopup->start(250); return; } m_hidePopup->stop(); switch (status) { case Rekonq::Url: break; case Rekonq::Info: m_hidePopup->start(500); break; case Rekonq::Success: break; case Rekonq::Error: break; case Rekonq::Download: break; default: break; } int margin = 4; // setting the popup QLabel *label = new QLabel(msg); m_popup->setView(label); QSize labelSize(label->fontMetrics().width(msg) + 2*margin, label->fontMetrics().height() + 2*margin); if (labelSize.width() > width()) labelSize.setWidth(width()); m_popup->setFixedSize(labelSize); m_popup->layout()->setAlignment(Qt::AlignTop); m_popup->layout()->setMargin(margin); // useful values WebTab *tab = m_view->currentWebTab(); // fix crash on window close if (!tab) return; // fix crash on window close if (!tab->page()) return; bool scrollbarIsVisible = tab->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal); int scrollbarSize = 0; if (scrollbarIsVisible) { //TODO: detect QStyle size scrollbarSize = 17; } QPoint webViewOrigin = tab->view()->mapToGlobal(QPoint(0, 0)); int bottomLeftY = webViewOrigin.y() + tab->page()->viewportSize().height() - labelSize.height() - scrollbarSize; // setting popup in bottom-left position int x = geometry().x(); int y = bottomLeftY; QPoint mousePos = tab->mapToGlobal(tab->view()->mousePos()); if (QRect(webViewOrigin.x() , bottomLeftY , labelSize.width() , labelSize.height()).contains(mousePos)) { // setting popup above the mouse y = bottomLeftY - labelSize.height(); } m_popup->show(QPoint(x, y)); }