void LineEdit::init() { m_leftWidget = new SideWidget(this); m_leftWidget->resize(0, 0); m_leftLayout = new QHBoxLayout(m_leftWidget); m_leftLayout->setContentsMargins(0, 0, 0, 0); if (isRightToLeft()) m_leftLayout->setDirection(QBoxLayout::RightToLeft); else m_leftLayout->setDirection(QBoxLayout::LeftToRight); m_leftLayout->setSizeConstraint(QLayout::SetFixedSize); m_rightWidget = new SideWidget(this); m_rightWidget->resize(0, 0); m_rightLayout = new QHBoxLayout(m_rightWidget); if (isRightToLeft()) m_rightLayout->setDirection(QBoxLayout::RightToLeft); else m_rightLayout->setDirection(QBoxLayout::LeftToRight); m_rightLayout->setContentsMargins(0, 0, 0, 0); QSpacerItem *horizontalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); m_rightLayout->addItem(horizontalSpacer); setWidgetSpacing(3); connect(m_leftWidget, SIGNAL(sizeHintChanged()), this, SLOT(updateTextMargins())); connect(m_rightWidget, SIGNAL(sizeHintChanged()), this, SLOT(updateTextMargins())); }
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())); }
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(); }
void SearchLineEdit::init() { // search button on the left m_searchButton = new SearchButton(this); addWidget(m_searchButton, LeftSide); // clear button on the right m_clearButton = new ClearButton(this); connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clear())); connect(this, SIGNAL(textChanged(const QString&)), m_clearButton, SLOT(textChanged(const QString&))); addWidget(m_clearButton, RightSide); m_clearButton->hide(); setWidgetSpacing(5); updateTextMargins(); setInactiveText(tr("Search")); }