bool TabbedWebView::isCurrent() { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) { return false; } return (webTab->view() == this); }
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)); }