Пример #1
0
SearchBar::SearchBar(QWidget* parent) : QToolBar(parent) {
  _closeAction = addAction(QIcon(":/close.png"), trUtf8("Hide search bar"));
  _closeAction->setShortcut(Qt::Key_Escape);
  QLabel* label = new QLabel(trUtf8("Search"), this);
  addWidget(label);
  _lineEdit = new QLineEdit(this);
  _lineEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
  addWidget(_lineEdit);

  _previousAction = addAction(QIcon(":/previous.png"), trUtf8("Find previous"));
  _previousAction->setShortcut(QKeySequence::FindPrevious);

  _nextAction = addAction(QIcon(":/next.png"), trUtf8("Find next"));
  _nextAction->setShortcut(QKeySequence::FindNext);

  _checkBox = new QCheckBox(trUtf8("Case-sensitive"), this);
  addWidget(_checkBox);

  connect(_closeAction, SIGNAL(triggered()), this, SIGNAL(closeRequested()));
  connect(_lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(changeSearchData()));
  connect(_previousAction, SIGNAL(triggered()), this, SLOT(changeSearchData()));
  connect(_nextAction, SIGNAL(triggered()), this, SLOT(changeSearchData()));
}
Пример #2
0
SearchBar::SearchBar(QWebView * webView, QWidget * parent)
        : QWidget(parent)
        , m_webView(webView)
{
    m_focusShortcut = new QShortcut(QKeySequence::Find, this);

    m_layout = new QHBoxLayout(this);
    m_layout->setMargin(0);
    m_layout->setSpacing(0);

    QLabel * label = new QLabel(trUtf8("Search"), this);
    m_layout->addWidget(label);
    m_lineEdit = new QLineEdit(this);
    m_lineEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    m_layout->addWidget(m_lineEdit);

    connect(m_focusShortcut, SIGNAL(activated()), this, SLOT(getSelection()));
    connect(m_lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(changeSearchData()));
    connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(changeSearchData()));
}