5 #include "findwidget.h"
8 extern QString vymName;
9 extern QString iconPath;
11 FindWidget::FindWidget(QWidget *)
13 QVBoxLayout* mainLayout = new QVBoxLayout;
14 QHBoxLayout *row2Layout = new QHBoxLayout;
17 cancelbutton = new QPushButton;
18 //cancelbutton->setText(tr("Cancel"));
19 cancelbutton->setIcon (QIcon (iconPath+"fileclose.png"));
20 cancelbutton->setShortcut (Qt::Key_Escape);
21 connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
23 QLabel *label=new QLabel;
24 label->setText (tr("Find:","FindWidget"));
26 // Create LineEdit (here QComboBox)
27 findcombo = new QComboBox;
28 findcombo->setMinimumWidth(250);
29 findcombo->setEditable(true);
31 QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
32 findcombo->setSizePolicy(sizePolicy);
33 connect ( findcombo, SIGNAL( highlighted(int) ),
34 this, SLOT( nextPressed() ) );
35 connect ( findcombo, SIGNAL( textChanged(const QString &) ),
36 this, SLOT( findTextChanged(const QString&) ) );
38 nextbutton = new QPushButton;
39 nextbutton->setText (tr("Next","Find widget"));
40 nextbutton->setDefault (true);
41 nextbutton->setShortcut (Qt::Key_Return);
42 //nextbutton->setShortcutContext (Qt::WidgetShortcut);
43 connect ( nextbutton, SIGNAL( clicked() ), this, SLOT( nextPressed() ) );
45 row2Layout->addWidget (cancelbutton);
46 row2Layout->addWidget (label);
47 row2Layout->addWidget(findcombo);
48 row2Layout->addWidget(nextbutton);
50 mainLayout->addLayout (row2Layout);
52 setLayout (mainLayout);
56 void FindWidget::popup()
59 findcombo->lineEdit()->selectAll();
60 findcombo->setFocus();
61 setStatus (Undefined);
64 void FindWidget::cancelPressed()
67 emit (hideFindWidget() );
70 void FindWidget::nextPressed()
72 emit (nextButton(findcombo->currentText() ) );
75 void FindWidget::findTextChanged(const QString&)
77 setStatus (Undefined);
80 void FindWidget::setStatus (Status st)
82 if (st==status) return;
89 case Success: c=QColor (120,255,120); break;
90 case Failed: c=QColor (255,120,120); break;
91 default: c=QColor (255,255,255);
93 p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
94 p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);
95 findcombo->setPalette(p);