| 1007 | } |
| 1008 | |
| 1009 | void KDiff3App::slotGoToLine() |
| 1010 | { |
| 1011 | QDialog pDialog; |
| 1012 | QVBoxLayout* l = new QVBoxLayout(&pDialog); |
| 1013 | |
| 1014 | QLineEdit* pLineNumEdit = new QLineEdit(); |
| 1015 | //Limit input to valid 1 based line numbers |
| 1016 | pLineNumEdit->setValidator(new QIntValidator(1, DiffTextWindow::mVScrollBar->maximum(), pLineNumEdit)); |
| 1017 | |
| 1018 | QPushButton* pOkButton = new QPushButton(i18n("Ok")); |
| 1019 | l->addWidget(pLineNumEdit); |
| 1020 | l->addWidget(pOkButton); |
| 1021 | |
| 1022 | chk_connect(pOkButton, &QPushButton::clicked, &pDialog, |
| 1023 | ([&pDialog, pLineNumEdit]() { |
| 1024 | if(pLineNumEdit->text() != "") |
| 1025 | { |
| 1026 | qint32 lineNum = pLineNumEdit->text().toInt(); |
| 1027 | lineNum = qMax(lineNum - 2, 0); |
| 1028 | //No need for anything else here setValue triggers a valueChanged signal internally. |
| 1029 | DiffTextWindow::mVScrollBar->setValue(lineNum); |
| 1030 | } |
| 1031 | pDialog.close(); |
| 1032 | })); |
| 1033 | |
| 1034 | pDialog.setWindowTitle(i18n("Go to Line")); |
| 1035 | pDialog.setWindowFlag(Qt::WindowContextHelpButtonHint, false); |
| 1036 | pDialog.setFixedSize(260, 110); |
| 1037 | pDialog.exec(); |
| 1038 | } |
| 1039 | |
| 1040 | void KDiff3App::choose(e_SrcSelector choice) |
| 1041 | { |