void BookmarksToolbar::customContextMenuRequested(const QPoint &pos) { Q_UNUSED(pos) QMenu menu; menu.addAction(tr("&Bookmark Current Page"), p_QupZilla, SLOT(bookmarkPage())); menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addAction(qIconProvider->fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager())); menu.addSeparator(); QAction act(tr("Show Most &Visited"), this); act.setCheckable(true); act.setChecked(m_bookmarksModel->isShowingMostVisited()); connect(&act, SIGNAL(triggered()), this, SLOT(showMostVisited())); menu.addAction(&act); QAction act2(tr("Show Only Icons"), this); act2.setCheckable(true); act2.setChecked(m_bookmarksModel->isShowingOnlyIconsInToolbar()); connect(&act2, SIGNAL(triggered()), this, SLOT(toggleShowOnlyIcons())); menu.addAction(&act2); menu.addSeparator(); menu.addAction(tr("&Hide Toolbar"), this, SLOT(hidePanel())); //Prevent choosing first option with double rightclick QPoint position = mapToGlobal(pos); QPoint p(position.x(), position.y() + 1); menu.exec(p); }
LocationBar::LocationBar(QupZilla* mainClass) : LineEdit(mainClass) , p_QupZilla(mainClass) , m_webView(0) , m_pasteAndGoAction(0) , m_clearAction(0) , m_rssIconVisible(false) , m_holdingAlt(false) , m_loadProgress(0) , m_progressVisible(false) , m_forcePaintEvent(false) , m_inlineCompletionVisible(false) , m_popupClosed(false) { setObjectName("locationbar"); setDragEnabled(true); m_bookmarkIcon = new BookmarksIcon(this); m_goIcon = new GoIcon(this); m_rssIcon = new RssIcon(this); m_siteIcon = new SiteIcon(p_QupZilla, this); m_autofillIcon = new AutoFillIcon(this); DownIcon* down = new DownIcon(this); // RTL Support // if we don't add 'm_siteIcon' 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_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.setLocationBar(this); connect(&m_completer, SIGNAL(showCompletion(QString)), this, SLOT(showCompletion(QString))); connect(&m_completer, SIGNAL(completionActivated()), this, SLOT(urlEnter())); connect(&m_completer, SIGNAL(popupClosed()), this, SLOT(completionPopupClosed())); connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit())); connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter())); 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(message(Qz::AppMessageType,bool)), SLOT(onMessage(Qz::AppMessageType,bool))); loadSettings(); clearIcon(); // Hide icons by default hideGoButton(); m_rssIcon->hide(); m_autofillIcon->hide(); QTimer::singleShot(0, this, SLOT(updatePlaceHolderText())); }
LocationBar::LocationBar(QupZilla* mainClass) : LineEdit() , p_QupZilla(mainClass) , m_webView(0) , m_menu(new QMenu(this)) , m_pasteAndGoAction(0) , m_clearAction(0) , m_holdingAlt(false) { setObjectName("locationbar"); m_bookmarkIcon = new BookmarkIcon(p_QupZilla); m_goIcon = new GoIcon(this); m_rssIcon = new RssIcon(this); m_rssIcon->setToolTip(tr("Add RSS from this page...")); m_siteIcon = new SiteIcon(this); DownIcon* down = new DownIcon(this); addWidget(down, LineEdit::RightSide); addWidget(m_bookmarkIcon, LineEdit::RightSide); addWidget(m_goIcon, LineEdit::RightSide); addWidget(m_rssIcon, LineEdit::RightSide); setWidgetSpacing(0); m_locationCompleter = new LocationCompleter(); setCompleter(m_locationCompleter); // LocationPopup* com = new LocationPopup(this); // connect(down, SIGNAL(clicked(QPoint)), com, SLOT(show())); connect(this, SIGNAL(textEdited(QString)), this, SLOT(textEdit())); connect(this, SIGNAL(textEdited(QString)), m_locationCompleter, SLOT(refreshCompleter(QString))); connect(m_locationCompleter->popup(), SIGNAL(clicked(QModelIndex)), this, SLOT(urlEnter())); connect(m_siteIcon, SIGNAL(clicked()), this, SLOT(showSiteInfo())); connect(m_goIcon, SIGNAL(clicked(QPoint)), this, SLOT(urlEnter())); connect(m_rssIcon, SIGNAL(clicked(QPoint)), this, SLOT(rssIconClicked())); connect(down, SIGNAL(clicked(QPoint)), this, SLOT(showMostVisited())); connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText())); clearIcon(); updatePlaceHolderText(); }
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())); }
void LocationCompleterModel::refreshCompletions(const QString &string) { if (m_lastCompletion == string) { refreshTabPositions(); return; } m_lastCompletion = string; if (string.isEmpty()) { showMostVisited(); return; } clear(); Type showType = (Type) qzSettings->showLocationSuggestions; int limit = string.size() < 3 ? 25 : 15; QList<QUrl> urlList; QList<QStandardItem*> itemList; if (showType == HistoryAndBookmarks || showType == Bookmarks) { QSqlQuery query = createQuery(string, "history.count DESC", urlList, limit, true); query.exec(); while (query.next()) { QStandardItem* item = new QStandardItem(); const QUrl &url = query.value(1).toUrl(); item->setIcon(qIconProvider->iconFromImage(QImage::fromData(query.value(4).toByteArray()))); item->setText(url.toEncoded()); item->setData(query.value(0), IdRole); item->setData(query.value(2), TitleRole); item->setData(query.value(3), CountRole); item->setData(QVariant(true), BookmarkRole); item->setData(string, SearchStringRole); if (qzSettings->showSwitchTab) { item->setData(QVariant::fromValue<TabPosition>(tabPositionForUrl(url)), TabPositionRole); } urlList.append(url); itemList.append(item); } limit -= query.size(); } if (showType == HistoryAndBookmarks || showType == History) { QSqlQuery query = createQuery(string, "count DESC", urlList, limit); query.exec(); while (query.next()) { QStandardItem* item = new QStandardItem(); const QUrl &url = query.value(1).toUrl(); item->setIcon(_iconForUrl(url)); item->setText(url.toEncoded()); item->setData(query.value(0), IdRole); item->setData(query.value(2), TitleRole); item->setData(query.value(3), CountRole); item->setData(QVariant(false), BookmarkRole); item->setData(string, SearchStringRole); if (qzSettings->showSwitchTab) { item->setData(QVariant::fromValue<TabPosition>(tabPositionForUrl(url)), TabPositionRole); } itemList.append(item); } } // Sort by count qSort(itemList.begin(), itemList.end(), countBiggerThan); appendColumn(itemList); }
void BookmarksToolbar::customContextMenuRequested(const QPoint &pos) { Q_UNUSED(pos) QMenu menu; menu.addAction(tr("&Bookmark Current Page"), p_QupZilla, SLOT(bookmarkPage())); menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs())); menu.addAction(IconProvider::fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager())); menu.addSeparator(); menu.addAction(m_bookmarksModel->isShowingMostVisited() ? tr("Hide Most &Visited") : tr("Show Most &Visited"), this, SLOT(showMostVisited())); menu.addAction(tr("&Hide Toolbar"), this, SLOT(hidePanel())); //Prevent choosing first option with double rightclick QPoint position = QCursor::pos(); QPoint p(position.x(), position.y() + 1); menu.exec(p); }
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())); }