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())); }
void LocationBar::showUrl(const QUrl &url) { if (hasFocus() || url.isEmpty()) { return; } const QString &stringUrl = convertUrlToText(url); if (stringUrl == text()) { return; } setText(stringUrl); hideGoButton(); m_bookmarkIcon->checkBookmark(url); }
void LocationBar::showUrl(const QUrl &url) { if (hasFocus() || url.isEmpty()) { return; } QString stringUrl = qz_urlEncodeQueryString(url); if (stringUrl == "qupzilla:speeddial" || stringUrl == "about:blank") { stringUrl = ""; } if (url.toEncoded() != text()) { setText(stringUrl); } p_QupZilla->statusBarMessage()->clearMessage(); hideGoButton(); m_bookmarkIcon->checkBookmark(url); }