void LocationCompleter::indexShiftActivated(const QModelIndex &index) { Q_ASSERT(index.isValid()); if (index.data(LocationCompleterModel::BookmarkRole).toBool()) { BookmarkItem* bookmark = static_cast<BookmarkItem*>(index.data(LocationCompleterModel::BookmarkItemRole).value<void*>()); bookmark->updateVisitCount(); } const QUrl url = index.data(LocationCompleterModel::UrlRole).toUrl(); const int tabPos = index.data(LocationCompleterModel::TabPositionTabRole).toInt(); // Load url (instead of switching to tab) with shift activation if (tabPos > -1) { loadUrl(url); return; } closePopup(); // Clear locationbar emit clearCompletion(); // Open new window mApp->createWindow(Qz::BW_NewWindow, url); }
void LocationCompleter::openSearchEnginesDialog() { // Clear locationbar emit clearCompletion(); SearchEnginesDialog *dialog = new SearchEnginesDialog(m_window); dialog->open(); }
void LocationCompleter::indexCtrlActivated(const QModelIndex &index) { Q_ASSERT(index.isValid()); Q_ASSERT(m_window); closePopup(); // Clear locationbar emit clearCompletion(); // Load request in new tab m_window->tabWidget()->addView(createLoadRequest(index), Qz::NT_CleanSelectedTab); }
void LocationCompleter::indexShiftActivated(const QModelIndex &index) { Q_ASSERT(index.isValid()); closePopup(); // Clear locationbar emit clearCompletion(); // Load request if (index.data(LocationCompleterModel::VisitSearchItemRole).toBool()) { loadRequest(LoadRequest(QUrl(m_originalText))); } else { loadRequest(createLoadRequest(index)); } }
void LocationCompleter::indexCtrlActivated(const QModelIndex &index) { Q_ASSERT(index.isValid()); Q_ASSERT(m_window); if (index.data(LocationCompleterModel::BookmarkRole).toBool()) { BookmarkItem* bookmark = static_cast<BookmarkItem*>(index.data(LocationCompleterModel::BookmarkItemRole).value<void*>()); bookmark->updateVisitCount(); } const QUrl url = index.data(LocationCompleterModel::UrlRole).toUrl(); const QString title = index.data(LocationCompleterModel::TitleRole).toString(); closePopup(); // Clear locationbar emit clearCompletion(); // Open url in new tab m_window->tabWidget()->addView(url, title, Qz::NT_CleanSelectedTab); }
void LocationCompleter::indexActivated(const QModelIndex &index) { Q_ASSERT(index.isValid()); closePopup(); // Clear locationbar emit clearCompletion(); bool ok; const int tabPos = index.data(LocationCompleterModel::TabPositionTabRole).toInt(&ok); // Switch to tab with simple index activation if (ok && tabPos > -1) { BrowserWindow* window = static_cast<BrowserWindow*>(index.data(LocationCompleterModel::TabPositionWindowRole).value<void*>()); Q_ASSERT(window); switchToTab(window, tabPos); return; } loadRequest(createLoadRequest(index)); }
void LocationCompleter::switchToTab(BrowserWindow* window, int tab) { Q_ASSERT(window); Q_ASSERT(tab >= 0); closePopup(); // Clear locationbar emit clearCompletion(); TabWidget* tabWidget = window->tabWidget(); if (window->isActiveWindow() || tabWidget->currentIndex() != tab) { tabWidget->setCurrentIndex(tab); window->show(); window->activateWindow(); window->raise(); } else { window->weView()->setFocus(); } }
LocationBar::LocationBar(BrowserWindow* window) : LineEdit(window) , m_window(window) , m_webView(0) , m_pasteAndGoAction(0) , m_clearAction(0) , m_holdingAlt(false) , 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_rssIcon = new RssIcon(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_rssIcon, 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); connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEditted())); 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_rssIcon->hide(); m_autofillIcon->hide(); QTimer::singleShot(0, this, SLOT(updatePlaceHolderText())); }
LocationBar::LocationBar(QWidget *parent) : LineEdit(parent) , m_window(nullptr) , m_webView(0) , m_holdingAlt(false) , m_oldTextLength(0) , m_currentTextLength(0) , m_loadProgress(0) , m_progressVisible(false) { setObjectName("locationbar"); setDragEnabled(true); // Disable KDE 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(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->setLocationBar(this); connect(m_completer, SIGNAL(showCompletion(QString,bool)), this, SLOT(showCompletion(QString,bool))); connect(m_completer, SIGNAL(showDomainCompletion(QString)), this, SLOT(showDomainCompletion(QString))); connect(m_completer, SIGNAL(clearCompletion()), this, SLOT(clearCompletion())); connect(m_completer, &LocationCompleter::loadRequested, this, &LocationBar::loadRequest); connect(m_completer, &LocationCompleter::popupClosed, this, &LocationBar::updateSiteIcon); 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())); }