5 #include "findwidget.h"
8 extern QString vymName;
10 FindWidget::FindWidget(QWidget *)
12 QVBoxLayout* mainLayout = new QVBoxLayout;
13 QHBoxLayout *row2Layout = new QHBoxLayout;
16 cancelbutton = new QPushButton;
17 cancelbutton->setText(tr("Cancel"));
18 cancelbutton->setShortcut (Qt::Key_Escape);
19 connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
21 QLabel *label=new QLabel;
22 label->setText (tr("Find:","FindWidget"));
24 // Create LineEdit (here QComboBox)
25 findcombo = new QComboBox;
26 findcombo->setMinimumWidth(250);
27 findcombo->setEditable(true);
28 connect ( findcombo, SIGNAL( highlighted(int) ),
29 this, SLOT( nextPressed() ) );
30 connect ( findcombo, SIGNAL( textChanged(const QString &) ),
31 this, SLOT( findTextChanged(const QString&) ) );
33 nextbutton = new QPushButton;
34 nextbutton->setText (tr("Next","Find widget"));
35 nextbutton->setDefault (true);
36 nextbutton->setShortcut (Qt::Key_Return);
37 //nextbutton->setShortcutContext (Qt::WidgetShortcut);
38 connect ( nextbutton, SIGNAL( clicked() ), this, SLOT( nextPressed() ) );
40 row2Layout->addWidget (cancelbutton);
41 row2Layout->addWidget (label);
42 row2Layout->addWidget(findcombo);
43 row2Layout->addWidget(nextbutton);
45 mainLayout->addLayout (row2Layout);
47 setLayout (mainLayout);
48 setStatus (Undefined);
51 void FindWidget::popup()
54 findcombo->lineEdit()->selectAll();
55 findcombo->setFocus();
58 void FindWidget::cancelPressed()
63 void FindWidget::nextPressed()
65 emit (nextButton(findcombo->currentText() ) );
68 void FindWidget::findTextChanged(const QString&)
70 emit (somethingChanged() );
73 void FindWidget::setStatus (Status st)
79 case Success: c=QColor (100,255,100); break;
80 case Failed: c=QColor (255,100,100); break;
81 default: c=QColor (255,255,255);
83 p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
84 p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);
85 findcombo->setPalette(p);