void SearchDialog::showContextMenu(const QPoint &pt) { QMenu *menu = ui->lineEditSearchSkyObject->createStandardContextMenu(); menu->addSeparator(); menu->addAction(q_("Paste and Search"), this, SLOT(pasteAndGo())); menu->exec(ui->lineEditSearchSkyObject->mapToGlobal(pt)); delete menu; }
WebSearchBar::WebSearchBar(BrowserWindow* window) : LineEdit(window) , m_window(window) , m_reloadingEngines(false) { setObjectName("websearchbar"); setDragEnabled(true); m_buttonSearch = new WebSearchBar_Button(this); m_boxSearchType = new ButtonWithMenu(this); m_boxSearchType->setObjectName("websearchbar-searchprovider-comobobox"); // RTL Support // If we don't add 'm_boxSearchType' by following code, then we should use suitable padding-left value // but then, when typing RTL text the layout dynamically changed and within RTL layout direction // padding-left is equivalent to padding-right and vice versa, and because style sheet is // not changed dynamically this create padding problems. addWidget(m_boxSearchType, LineEdit::LeftSide); addWidget(m_buttonSearch, LineEdit::RightSide); connect(m_buttonSearch, SIGNAL(clicked(QPoint)), this, SLOT(search())); connect(m_buttonSearch, SIGNAL(middleClicked(QPoint)), this, SLOT(searchInNewTab())); connect(m_boxSearchType, SIGNAL(activeItemChanged(ButtonWithMenu::Item)), this, SLOT(searchChanged(ButtonWithMenu::Item))); setWidgetSpacing(0); m_searchManager = mApp->searchEnginesManager(); connect(m_boxSearchType->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu())); m_completer = new QCompleter(this); m_completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion); m_completerModel = new QStringListModel(this); m_completer->setModel(m_completerModel); m_completer->popup()->setMinimumHeight(90); setCompleter(m_completer); m_openSearchEngine = new OpenSearchEngine(this); m_openSearchEngine->setNetworkAccessManager(mApp->networkManager()); connect(m_openSearchEngine, SIGNAL(suggestions(QStringList)), this, SLOT(addSuggestions(QStringList))); connect(this, SIGNAL(textEdited(QString)), m_openSearchEngine, SLOT(requestSuggestions(QString))); editAction(PasteAndGo)->setText(tr("Paste And &Search")); editAction(PasteAndGo)->setIcon(QIcon::fromTheme(QSL("edit-paste"))); connect(editAction(PasteAndGo), SIGNAL(triggered()), this, SLOT(pasteAndGo())); QTimer::singleShot(0, this, SLOT(setupEngines())); }
void LocationBar::contextMenuEvent(QContextMenuEvent* event) { if (!m_pasteAndGoAction) { m_pasteAndGoAction = new QAction(QIcon::fromTheme("edit-paste"), tr("Paste And &Go"), this); m_pasteAndGoAction->setShortcut(QKeySequence("Ctrl+Shift+V")); connect(m_pasteAndGoAction, SIGNAL(triggered()), this, SLOT(pasteAndGo())); } QMenu* menu = createContextMenu(m_pasteAndGoAction); menu->setAttribute(Qt::WA_DeleteOnClose); // Prevent choosing first option with double rightclick QPoint pos = event->globalPos(); pos.setY(pos.y() + 1); menu->popup(pos); }
void SearchDialog::showContextMenu(const QPoint &pt) { QMenu *menu = ui->lineEditSearchSkyObject->createStandardContextMenu(); menu->addSeparator(); QString clipText; QClipboard *clipboard = QApplication::clipboard(); if (clipboard) clipText = clipboard->text(); if (!clipText.isEmpty()) { if (clipText.length()>12) clipText = clipText.right(9) + "..."; clipText = "\t(" + clipText + ")"; } menu->addAction(q_("Paste and Search") + clipText, this, SLOT(pasteAndGo())); menu->exec(ui->lineEditSearchSkyObject->mapToGlobal(pt)); delete menu; }
void WebSearchBar::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_V: if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) { pasteAndGo(); event->accept(); return; } break; case Qt::Key_Return: case Qt::Key_Enter: if (event->modifiers() == Qt::AltModifier) { searchInNewTab(); } else { search(); } break; case Qt::Key_Up: if (event->modifiers() == Qt::ControlModifier) { m_boxSearchType->selectPreviousItem(); } break; case Qt::Key_Down: if (event->modifiers() == Qt::ControlModifier) { m_boxSearchType->selectNextItem(); } break; default: break; } LineEdit::keyPressEvent(event); }
void LocationBar::keyPressEvent(QKeyEvent* event) { switch (event->key()) { case Qt::Key_V: if (event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) { pasteAndGo(); event->accept(); return; } break; case Qt::Key_Down: m_completer->complete(text()); break; case Qt::Key_Left: m_completer->closePopup(); break; case Qt::Key_Escape: m_webView->setFocus(); showUrl(m_webView->url()); event->accept(); break; case Qt::Key_Alt: m_holdingAlt = true; break; case Qt::Key_Return: case Qt::Key_Enter: switch (event->modifiers()) { case Qt::ControlModifier: setText(text().append(QLatin1String(".com"))); requestLoadUrl(); m_holdingAlt = false; break; case Qt::AltModifier: m_completer->closePopup(); m_window->tabWidget()->addView(createLoadRequest()); m_holdingAlt = false; break; default: requestLoadUrl(); m_holdingAlt = false; } break; case Qt::Key_0: case Qt::Key_1: case Qt::Key_2: case Qt::Key_3: case Qt::Key_4: case Qt::Key_5: case Qt::Key_6: case Qt::Key_7: case Qt::Key_8: case Qt::Key_9: if (event->modifiers() & Qt::AltModifier || event->modifiers() & Qt::ControlModifier) { event->ignore(); m_holdingAlt = false; return; } break; default: m_holdingAlt = false; } LineEdit::keyPressEvent(event); }
LocationBar::LocationBar(BrowserWindow* window) : LineEdit(window) , m_window(window) , m_webView(0) , m_holdingAlt(false) , m_oldTextLength(0) , m_currentTextLength(0) , m_loadProgress(0) , m_progressVisible(false) { setObjectName("locationbar"); setDragEnabled(true); // Disable Oxygen QLineEdit transitions, it breaks with setText() && home() setProperty("_kde_no_animations", QVariant(true)); m_bookmarkIcon = new BookmarksIcon(this); m_goIcon = new GoIcon(this); m_siteIcon = new SiteIcon(m_window, this); m_autofillIcon = new AutoFillIcon(this); DownIcon* down = new DownIcon(this); addWidget(m_siteIcon, LineEdit::LeftSide); addWidget(m_autofillIcon, LineEdit::RightSide); addWidget(m_bookmarkIcon, LineEdit::RightSide); addWidget(m_goIcon, LineEdit::RightSide); addWidget(down, LineEdit::RightSide); m_completer = new LocationCompleter(this); m_completer->setMainWindow(m_window); m_completer->setLocationBar(this); connect(m_completer, SIGNAL(showCompletion(QString)), this, SLOT(showCompletion(QString))); connect(m_completer, SIGNAL(showDomainCompletion(QString)), this, SLOT(showDomainCompletion(QString))); connect(m_completer, SIGNAL(loadCompletion()), this, SLOT(requestLoadUrl())); connect(m_completer, SIGNAL(clearCompletion()), this, SLOT(clearCompletion())); m_domainCompleterModel = new QStringListModel(this); QCompleter* domainCompleter = new QCompleter(this); domainCompleter->setCompletionMode(QCompleter::InlineCompletion); domainCompleter->setModel(m_domainCompleterModel); setCompleter(domainCompleter); m_progressTimer = new QTimer(this); m_progressTimer->setInterval(700); m_progressTimer->setSingleShot(true); connect(m_progressTimer, &QTimer::timeout, this, &LocationBar::hideProgress); editAction(PasteAndGo)->setText(tr("Paste And &Go")); editAction(PasteAndGo)->setIcon(QIcon::fromTheme(QSL("edit-paste"))); connect(editAction(PasteAndGo), SIGNAL(triggered()), this, SLOT(pasteAndGo())); connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdited(QString))); connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(requestLoadUrl())); connect(down, SIGNAL(clicked(QPoint)), m_completer, SLOT(showMostVisited())); connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText())); connect(mApp->searchEnginesManager(), SIGNAL(defaultEngineChanged()), this, SLOT(updatePlaceHolderText())); connect(mApp, SIGNAL(settingsReloaded()), SLOT(loadSettings())); loadSettings(); updateSiteIcon(); // Hide icons by default m_goIcon->setVisible(qzSettings->alwaysShowGoIcon); m_autofillIcon->hide(); QTimer::singleShot(0, this, SLOT(updatePlaceHolderText())); }
void LocationBar::pasteAndGo() { clear(); paste(); urlEnter(); } void LocationBar::contextMenuEvent(QContextMenuEvent* event) { Q_UNUSED(event) if (!m_pasteAndGoAction) { m_pasteAndGoAction = new QAction(QIcon::fromTheme("edit-paste"), tr("Paste And &Go"), this); m_pasteAndGoAction->setShortcut(QKeySequence("Ctrl+Shift+V")); connect(m_pasteAndGoAction, SIGNAL(triggered()), this, SLOT(pasteAndGo())); } if (!m_clearAction) { m_clearAction = new QAction(QIcon::fromTheme("edit-clear"), tr("Clear All"), this); connect(m_clearAction, SIGNAL(triggered()), this, SLOT(clear())); } QMenu* tempMenu = createStandardContextMenu(); QMenu menu(this); int i = 0; foreach(QAction * act, tempMenu->actions()) { menu.addAction(act); switch (i) {