@@ -25,7 +25,7 @@ QFrame *MainWindow::newFindFrame(QSplitter *split)
2525 findLayout->setContentsMargins (11 , 11 , 11 , 11 );
2626 findLayout->setObjectName (QStringLiteral (" findLayout" ));
2727 findLayout->setContentsMargins (4 , 4 , 4 , 0 );
28-
28+
2929 /* "Find:" */
3030 findLabel = new QLabel ();
3131 findLabel->setObjectName (QStringLiteral (" findLabel" ));
@@ -48,37 +48,37 @@ QFrame *MainWindow::newFindFrame(QSplitter *split)
4848 findPreviousBtn = new QToolButton ();
4949 findPreviousBtn->setObjectName (QStringLiteral (" findPreviousBtn" ));
5050 findPreviousBtn->setStyleSheet (" QToolButton {\
51- background: url(:/icons/find-previous.png) center no-repeat;\
52- width: 24;\
53- height: 24;\
54- border-width: 0;\
55- border: none;\
56- }\
57- QToolButton:pressed {\
58- background: url(:/icons/find-previous-pressed.png) center no-repeat;\
59- border-width: 0;\
60- border: none;\
61- }\
62- " );
51+ background: url(:/icons/find-previous.png) center no-repeat;\
52+ width: 24;\
53+ height: 24;\
54+ border-width: 0;\
55+ border: none;\
56+ }\
57+ QToolButton:pressed {\
58+ background: url(:/icons/find-previous-pressed.png) center no-repeat;\
59+ border-width: 0;\
60+ border: none;\
61+ }\
62+ " );
6363 findLayout->addWidget (findPreviousBtn);
6464 connect (findPreviousBtn,SIGNAL (clicked ()),this ,SLOT (findPrevClicked ()));
6565
6666 /* find-next button */
6767 findNextBtn = new QToolButton ();
6868 findNextBtn->setObjectName (QStringLiteral (" findNextBtn" ));
6969 findNextBtn->setStyleSheet (" QToolButton {\
70- background: url(:/icons/find-next.png) center no-repeat;\
71- width: 24;\
72- height: 24;\
73- border-width: 0;\
74- border: none;\
75- }\
76- QToolButton:pressed {\
77- background: url(:/icons/find-next-pressed.png) center no-repeat;\
78- border-width: 0;\
79- border: none;\
80- }\
81- " );
70+ background: url(:/icons/find-next.png) center no-repeat;\
71+ width: 24;\
72+ height: 24;\
73+ border-width: 0;\
74+ border: none;\
75+ }\
76+ QToolButton:pressed {\
77+ background: url(:/icons/find-next-pressed.png) center no-repeat;\
78+ border-width: 0;\
79+ border: none;\
80+ }\
81+ " );
8282 findLayout->addWidget (findNextBtn);
8383 connect (findNextBtn,SIGNAL (clicked ()),this ,SLOT (findNextClicked ()));
8484
@@ -150,7 +150,7 @@ QFrame *MainWindow::newFindFrame(QSplitter *split)
150150 replaceAllBtn->setObjectName (QStringLiteral (" replaceAllBtn" ));
151151 replaceLayout->addWidget (replaceAllBtn);
152152 connect (replaceAllBtn,SIGNAL (clicked ()),this ,SLOT (replaceAllClicked ()));
153-
153+
154154 /* add replace feature to the layout */
155155 verticalLayout->addLayout (replaceLayout);
156156
@@ -199,13 +199,8 @@ void MainWindow::showFindFrame()
199199 clearFindText ();
200200 }
201201
202- if (findFrame->isVisible ()) {
203- findFrame->setVisible (false );
204- }
205- else {
206- findEdit->setFocus ();
207- findFrame->setVisible (true );
208- }
202+ findEdit->setFocus ();
203+ findFrame->setVisible (true );
209204}
210205
211206void MainWindow::hideFindFrame ()
@@ -373,12 +368,6 @@ void MainWindow::findPrevClicked()
373368
374369 if (count > 0 ) {
375370 QTextCursor cur = editor->textCursor ();
376- // the following code was setting the cursor left by 1
377- // int len = cur.selectedText().length();
378- // cur.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor);
379- // cur.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor);
380- // cur.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor,len);
381- // editor->setTextCursor(cur);
382371 findPosition = editor->textCursor ().position ();
383372 }
384373}
@@ -407,9 +396,7 @@ void MainWindow::replaceClicked()
407396 hide ();
408397 }
409398}
410- /*
411- * If find text is highlighted, replace and find again.
412- */
399+
413400void MainWindow::replaceNextClicked ()
414401{
415402 Editor *editor = getEditor (editorTabs->currentIndex ());
@@ -427,9 +414,6 @@ void MainWindow::replaceNextClicked()
427414 }
428415}
429416
430- /*
431- * If find text is highlighted, replace and find again.
432- */
433417void MainWindow::replacePrevClicked ()
434418{
435419 Editor *editor = getEditor (editorTabs->currentIndex ());
@@ -485,7 +469,7 @@ void MainWindow::replaceAllClicked()
485469 editor->textCursor ().endEditBlock ();
486470
487471 QMessageBox::information (this , tr (" Replace Done" ),
488- tr (" Replaced %1 instances of \" %2\" ." ).arg (count).arg (text));
472+ tr (" Replaced %1 instances of \" %2\" ." ).arg (count).arg (text));
489473}
490474
491475QString MainWindow::getReplaceText ()
@@ -497,11 +481,15 @@ void MainWindow::clearReplaceText()
497481 replaceEdit->clear ();
498482}
499483
500- bool MainWindow::showBeginMessage (QString type)
484+
485+ bool MainWindow::showFindMessage (QString text)
501486{
502- QMessageBox::StandardButton ret = QMessageBox::information (
503- this , type, type+tr (" from beginning?" ),
504- QMessageBox::Cancel, QMessageBox::Ok);
487+ QMessageBox msgBox;
488+ msgBox.setText (text);
489+ msgBox.setStandardButtons (QMessageBox::Cancel | QMessageBox::Ok);
490+ msgBox.setDefaultButton (QMessageBox::Ok);
491+ int ret = msgBox.exec ();
492+
505493 if (ret == QMessageBox::Cancel) {
506494 return false ;
507495 }
@@ -514,19 +502,12 @@ bool MainWindow::showBeginMessage(QString type)
514502 return true ;
515503}
516504
505+ bool MainWindow::showBeginMessage (QString type)
506+ {
507+ return showFindMessage (type+tr (" from beginning?" ));
508+ }
509+
517510bool MainWindow::showEndMessage (QString type)
518511{
519- QMessageBox::StandardButton ret = QMessageBox::information (
520- this , type, type+tr (" from end?" ),
521- QMessageBox::Cancel, QMessageBox::Ok);
522- if (ret == QMessageBox::Cancel) {
523- return false ;
524- }
525- Editor *editor = getEditor (editorTabs->currentIndex ());
526- if (editor == NULL )
527- return false ;
528- QTextCursor cur = editor->textCursor ();
529- cur.movePosition (QTextCursor::End, QTextCursor::MoveAnchor);
530- editor->setTextCursor (cur);
531- return true ;
512+ return showFindMessage (type+tr (" from end?" ));
532513}
0 commit comments