Mercurial > hg > easyhg
comparison src/findwidget.cpp @ 626:51887087f1ae
* Added Ctrl-F shortcut for find button
author | Sam Izzo <sam@humbug.net> |
---|---|
date | Sun, 26 Aug 2012 02:19:36 +1000 |
parents | 1ff2a1bf0a40 |
children | ae67ea0af696 |
comparison
equal
deleted
inserted
replaced
625:3c3827eb5106 | 626:51887087f1ae |
---|---|
31 | 31 |
32 QToolButton *button = new QToolButton(); | 32 QToolButton *button = new QToolButton(); |
33 layout->addWidget(button, 0, 0); | 33 layout->addWidget(button, 0, 0); |
34 button->setText(tr("Find...")); | 34 button->setText(tr("Find...")); |
35 button->setToolButtonStyle(Qt::ToolButtonTextOnly); | 35 button->setToolButtonStyle(Qt::ToolButtonTextOnly); |
36 button->setShortcut(tr("Ctrl+F")); | |
36 connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed())); | 37 connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed())); |
37 | 38 |
38 m_lineEdit = new QLineEdit(); | 39 m_lineEdit = new QLineEdit(); |
39 layout->addWidget(m_lineEdit, 0, 1); | 40 layout->addWidget(m_lineEdit, 0, 1); |
40 | 41 |
57 FindWidget::buttonPressed() | 58 FindWidget::buttonPressed() |
58 { | 59 { |
59 QAbstractButton *button = qobject_cast<QAbstractButton *>(sender()); | 60 QAbstractButton *button = qobject_cast<QAbstractButton *>(sender()); |
60 if (!button) return; | 61 if (!button) return; |
61 if (m_lineEdit->isVisible()) { | 62 if (m_lineEdit->isVisible()) { |
62 m_lineEdit->hide(); | 63 m_lineEdit->hide(); |
63 button->setText(tr("Find...")); | 64 button->setText(tr("Find...")); |
64 if (m_lineEdit->text() != "") { | 65 if (m_lineEdit->text() != "") { |
65 emit findTextChanged(""); | 66 emit findTextChanged(""); |
66 } | 67 } |
67 } else { | 68 } else { |
68 m_lineEdit->show(); | 69 m_lineEdit->show(); |
69 m_lineEdit->setFocus(Qt::OtherFocusReason); | 70 m_lineEdit->setFocus(Qt::OtherFocusReason); |
70 button->setText(tr("Find:")); | 71 button->setText(tr("Find:")); |
71 if (m_lineEdit->text() != "") { | 72 if (m_lineEdit->text() != "") { |
72 emit findTextChanged(m_lineEdit->text()); | 73 emit findTextChanged(m_lineEdit->text()); |
73 } | 74 } |
74 } | 75 } |
75 } | 76 } |