-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindDialog.cpp
62 lines (52 loc) · 1.84 KB
/
FindDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "FindDialog.h"
#include <QLabel>
#include <QLineEdit>
#include <QCheckBox>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
FindDialog::FindDialog(QWidget *parent) :QDialog(parent) {
label = new QLabel(tr("Find &What:"));
lineEdit = new QLineEdit();
label->setBuddy(lineEdit);
caseCheckBox = new QCheckBox(tr("Match &Case"));
backwardCheckBox = new QCheckBox(tr("Search &Backford"));
findButton = new QPushButton(tr("&Find"));
findButton->setDefault(true);
findButton->setEnabled(false);
closeButton = new QPushButton(tr("Close"));
connect(lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(enableFindButton(const QString&)));
connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout *topLeftLayout = new QHBoxLayout();
topLeftLayout->addWidget(label);
topLeftLayout->addWidget(lineEdit);
QVBoxLayout *leftLayout = new QVBoxLayout();
leftLayout->addLayout(topLeftLayout);
leftLayout->addWidget(caseCheckBox);
leftLayout->addWidget(backwardCheckBox);
QVBoxLayout *rightLayout = new QVBoxLayout();
rightLayout->addWidget(findButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch();
QHBoxLayout *mainLayout = new QHBoxLayout();
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
this->setLayout(mainLayout);
this->setWindowTitle(tr("Find"));
this->setFixedHeight(sizeHint().height());
}
FindDialog::~FindDialog(){}
void FindDialog::findClicked() {
QString text = lineEdit->text();
Qt::CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseInsensitive : Qt::CaseSensitive;
if (backwardCheckBox->isChecked()) {
emit findPrevious(text, cs);
}
else {
emit findNext(text, cs);
}
}
void FindDialog::enableFindButton(const QString& text) {
findButton->setEnabled(!text.isEmpty());
}