void EditBoxImplCommon::onEnter(void) { const char* pText = getText(); if (pText) { setInactiveText(pText); } }
FilterContactsLineEdit::FilterContactsLineEdit(QWidget* parent) : LineEdit(parent) { QLabel* searchIconLabel = new QLabel(this); searchIconLabel->setPixmap(QPixmap(":icons/search_icon.png")); addWidget(searchIconLabel, LeftSide); setInactiveText(tr("Filter contacts")); }
void EditBoxImplCommon::refreshInactiveText() { setInactiveText(_text.c_str()); if(_text.size() == 0) { _label->setVisible(false); _labelPlaceHolder->setVisible(true); } else { _label->setVisible(true); _labelPlaceHolder->setVisible(false); } }
void EditBoxImplCommon::onEndEditing(const std::string& text) { this->setNativeVisible(false); if(text.size() == 0) { _label->setVisible(false); _labelPlaceHolder->setVisible(true); } else { _label->setVisible(true); _labelPlaceHolder->setVisible(false); setInactiveText(text.c_str()); } }
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(); updateTextMargins(); setInactiveText(tr("Search")); }
/* ToolbarSearch is a very basic search widget that also contains a small history. Searches are turned into urls that use Google to perform search */ ToolbarSearch::ToolbarSearch(QWidget *parent) : SearchLineEdit(parent) , m_autosaver(new AutoSaver(this)) , m_maxSavedSearches(10) , m_stringListModel(new QStringListModel(this)) { QMenu *m = menu(); connect(m, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu())); connect(m, SIGNAL(triggered(QAction*)), this, SLOT(triggeredMenuAction(QAction*))); QCompleter *completer = new QCompleter(m_stringListModel, this); completer->setCompletionMode(QCompleter::InlineCompletion); lineEdit()->setCompleter(completer); connect(lineEdit(), SIGNAL(returnPressed()), SLOT(searchNow())); setInactiveText(tr("Google")); load(); }
/* ToolbarSearch is a very basic search widget that also contains a small history. Searches are turned into urls that use Google to perform search */ ToolbarSearch::ToolbarSearch(QWidget *parent) : SearchLineEdit(new QCompleter(parent), parent) , m_autosaver(new AutoSaver(this)) , m_maxSavedSearches(10) , m_model(new QStandardItemModel(this)) , m_suggestionsItem(0) , m_recentSearchesItem(0) { completer()->setModel(m_model); completer()->setCompletionMode(QCompleter::UnfilteredPopupCompletion); connect(completer(), SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); connect(completer(), SIGNAL(highlighted(const QModelIndex &)), this, SLOT(highlighted(const QModelIndex &))); connect(this, SIGNAL(returnPressed()), SLOT(searchNow())); setInactiveText(QLatin1String("Google")); load(); }
int SearchLineEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = ExLineEdit::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = inactiveText(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setInactiveText(*reinterpret_cast< QString*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
/* SearchLineEdit is an enhanced QLineEdit - A Search icon on the left with optional menu - When there is no text and doesn't have focus an "inactive text" is displayed - When there is text a clear button is displayed on the right hand side */ SearchLineEdit::SearchLineEdit(QWidget *parent) : LineEdit(parent) , m_searchButton(0) { setUpdatesEnabled(false); m_searchButton = new SearchButton(this); updateGeometries(); addWidget(m_searchButton, LeftSide); setInactiveText(tr("Search")); QSizePolicy policy = sizePolicy(); setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); // clear button on the right ClearButton *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(); updateTextMargins(); setUpdatesEnabled(true); }