void KHTMLPartBrowserExtension::editableWidgetBlurred( QWidget * /*widget*/ ) { QWidget *oldWidget = m_editableFormWidget; m_editableFormWidget = 0; enableAction( "cut", false ); enableAction( "paste", false ); m_part->emitSelectionChanged(); if ( m_connectedToClipboard ) { disconnect( QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(updateEditActions()) ); if ( oldWidget ) { if ( oldWidget->inherits( "QLineEdit" ) || oldWidget->inherits( "QTextEdit" ) ) disconnect( oldWidget, SIGNAL(selectionChanged()), this, SLOT(updateEditActions()) ); } m_connectedToClipboard = false; } editableWidgetBlurred(); }
void KHTMLPartBrowserExtension::editableWidgetFocused(QWidget *widget) { m_editableFormWidget = widget; updateEditActions(); if(!m_connectedToClipboard && m_editableFormWidget) { connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(updateEditActions())); if(m_editableFormWidget->inherits("QLineEdit") || m_editableFormWidget->inherits("QTextEdit")) connect(m_editableFormWidget, SIGNAL(selectionChanged()), this, SLOT(updateEditActions())); m_connectedToClipboard = true; } editableWidgetFocused(); }
void SourceViewerWebWidget::showContextMenu(const QPoint &position) { updateHitTestResult(position); updateEditActions(); QWidget *child(childAt(position.isNull() ? mapFromGlobal(QCursor::pos()) : position)); QMenu menu; if (child && child->metaObject()->className() == QLatin1String("Otter::MarginWidget")) { QAction *showLineNumbersAction(menu.addAction(tr("Show Line Numbers"))); showLineNumbersAction->setCheckable(true); showLineNumbersAction->setChecked(SettingsManager::getValue(QLatin1String("SourceViewer/ShowLineNumbers")).toBool()); connect(showLineNumbersAction, SIGNAL(triggered(bool)), this, SLOT(setShowLineNumbers(bool))); }
void KWebKitPart::connectWebPageSignals(WebPage* page) { if (!page) return; connect(page, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted())); connect(page, SIGNAL(loadAborted(QUrl)), this, SLOT(slotLoadAborted(QUrl))); connect(page, SIGNAL(linkHovered(QString,QString,QString)), this, SLOT(slotLinkHovered(QString,QString,QString))); connect(page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)), this, SLOT(slotSaveFrameState(QWebFrame*,QWebHistoryItem*))); connect(page, SIGNAL(restoreFrameStateRequested(QWebFrame*)), this, SLOT(slotRestoreFrameState(QWebFrame*))); connect(page, SIGNAL(statusBarMessage(QString)), this, SLOT(slotSetStatusBarText(QString))); connect(page, SIGNAL(windowCloseRequested()), this, SLOT(slotWindowCloseRequested())); connect(page, SIGNAL(printRequested(QWebFrame*)), m_browserExtension, SLOT(slotPrintRequested(QWebFrame*))); connect(page, SIGNAL(frameCreated(QWebFrame*)), this, SLOT(slotFrameCreated(QWebFrame*))); connect(m_webView, SIGNAL(linkShiftClicked(QUrl)), page, SLOT(downloadUrl(QUrl))); connect(page, SIGNAL(loadProgress(int)), m_browserExtension, SIGNAL(loadingProgress(int))); connect(page, SIGNAL(selectionChanged()), m_browserExtension, SLOT(updateEditActions())); connect(m_browserExtension, SIGNAL(saveUrl(QUrl)), page, SLOT(downloadUrl(QUrl))); connect(page->mainFrame(), SIGNAL(loadFinished(bool)), this, SLOT(slotMainFrameLoadFinished(bool))); KWebWallet *wallet = page->wallet(); if (wallet) { connect(wallet, SIGNAL(saveFormDataRequested(QString,QUrl)), this, SLOT(slotSaveFormDataRequested(QString,QUrl))); connect(wallet, SIGNAL(fillFormRequestCompleted(bool)), this, SLOT(slotFillFormRequestCompleted(bool))); connect(wallet, SIGNAL(walletClosed()), this, SLOT(slotWalletClosed())); } }
void WebWidget::showContextMenu(const QPoint &position) { m_contextMenuReason = QContextMenuEvent::Other; const bool hasSelection = (this->hasSelection() && !getSelectedText().trimmed().isEmpty()); if (m_ignoreContextMenu || (position.isNull() && (!hasSelection || m_clickPosition.isNull()))) { return; } const QPoint hitPosition = (position.isNull() ? m_clickPosition : position); if (isScrollBar(hitPosition) || (SettingsManager::getValue(QLatin1String("Browser/JavaScriptCanDisableContextMenu")).toBool() && !canShowContextMenu(hitPosition))) { return; } updateHitTestResult(hitPosition); updateEditActions(); QStringList flags; if (m_hitResult.flags.testFlag(IsFormTest)) { flags.append(QLatin1String("form")); } if (!m_hitResult.imageUrl.isValid() && m_hitResult.flags.testFlag(IsSelectedTest) && hasSelection) { flags.append(QLatin1String("selection")); } if (m_hitResult.linkUrl.isValid()) { if (m_hitResult.linkUrl.scheme() == QLatin1String("mailto")) { flags.append(QLatin1String("mail")); } else { flags.append(QLatin1String("link")); } } if (!m_hitResult.imageUrl.isEmpty()) { flags.append(QLatin1String("image")); } if (m_hitResult.mediaUrl.isValid()) { flags.append(QLatin1String("media")); } if (m_hitResult.flags.testFlag(IsContentEditableTest)) { flags.append(QLatin1String("edit")); } if (flags.isEmpty() || (flags.size() == 1 && flags.first() == QLatin1String("form"))) { flags.append(QLatin1String("standard")); if (m_hitResult.frameUrl.isValid()) { flags.append(QLatin1String("frame")); } } if (flags.isEmpty()) { return; } Menu menu(Menu::NoMenuRole, this); menu.load(QLatin1String("menu/webWidget.json"), flags); menu.exec(mapToGlobal(hitPosition)); }