History

Toggle next for search on Log

kunalgosar committed 9 years ago

Commit c01d0b31 parent 3e520912 files · +29 −1Browse files

Showing the changes to interface/src/ui/BaseLogDialog.cpp (1 of 2 files). Show all

Unified · Split

interface/src/ui/BaseLogDialog.cpp+27−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
14#include <QDir>14#include <QDir>
15#include <QLineEdit>15#include <QLineEdit>
16#include <QPlainTextEdit>16#include <QPlainTextEdit>
17#include <QTextCursor>
17#include <QPushButton>18#include <QPushButton>
18#include <QSyntaxHighlighter>19#include <QSyntaxHighlighter>
19 20
@@ -25,6 +26,7 @@ const int INITIAL_HEIGHT = 480; · 5 unmodified lines
25const int MINIMAL_WIDTH = 570;26const int MINIMAL_WIDTH = 570;
26const int SEARCH_BUTTON_LEFT = 25;27const int SEARCH_BUTTON_LEFT = 25;
27const int SEARCH_BUTTON_WIDTH = 20;28const int SEARCH_BUTTON_WIDTH = 20;
29const int SEARCH_NEXT_BUTTON_WIDTH = 50;
28const int SEARCH_TEXT_WIDTH = 240;30const int SEARCH_TEXT_WIDTH = 240;
29const QColor HIGHLIGHT_COLOR = QColor("#3366CC");31const QColor HIGHLIGHT_COLOR = QColor("#3366CC");
30 32
@@ -75,9 +77,16 @@ void BaseLogDialog::initControls() { · 44 unmodified lines
75 // disable blue outline in Mac77 // disable blue outline in Mac
76 _searchTextBox->setAttribute(Qt::WA_MacShowFocusRect, false);78 _searchTextBox->setAttribute(Qt::WA_MacShowFocusRect, false);
77 _searchTextBox->setGeometry(_leftPad, ELEMENT_MARGIN, SEARCH_TEXT_WIDTH, ELEMENT_HEIGHT);79 _searchTextBox->setGeometry(_leftPad, ELEMENT_MARGIN, SEARCH_TEXT_WIDTH, ELEMENT_HEIGHT);
78 _leftPad += SEARCH_TEXT_WIDTH + CHECKBOX_MARGIN;80 _leftPad += SEARCH_TEXT_WIDTH;
79 _searchTextBox->show();81 _searchTextBox->show();
80 connect(_searchTextBox, SIGNAL(textChanged(QString)), SLOT(handleSearchTextChanged(QString)));82 connect(_searchTextBox, SIGNAL(textChanged(QString)), SLOT(handleSearchTextChanged(QString)));
83
84 _searchNextButton = new QPushButton(this);
85 _searchNextButton->setObjectName("searchNextButton");
86 _searchNextButton->setGeometry(_leftPad, ELEMENT_MARGIN, SEARCH_NEXT_BUTTON_WIDTH, ELEMENT_HEIGHT);
87 _leftPad += SEARCH_NEXT_BUTTON_WIDTH + CHECKBOX_MARGIN;
88 _searchNextButton->show();
89 connect(_searchNextButton, SIGNAL(clicked()), SLOT(toggleSearchNext()));
81 90
82 _logTextBox = new QPlainTextEdit(this);91 _logTextBox = new QPlainTextEdit(this);
83 _logTextBox->setReadOnly(true);92 _logTextBox->setReadOnly(true);
@@ -105,11 +114,28 @@ void BaseLogDialog::handleSearchButton() { · 21 unmodified lines
105}114}
106 115
107void BaseLogDialog::handleSearchTextChanged(QString searchText) {116void BaseLogDialog::handleSearchTextChanged(QString searchText) {
117 QTextCursor searchCursor = _logTextBox->textCursor();
118 searchCursor.setPosition(0, QTextCursor::MoveAnchor);
119 _logTextBox->setTextCursor(searchCursor);
120 bool foundTerm = _logTextBox->find(searchText);
121
122 if (!foundTerm) {
123 searchCursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
124 }
125
108 _searchTerm = searchText;126 _searchTerm = searchText;
109 _highlighter->keyword = searchText;127 _highlighter->keyword = searchText;
110 _highlighter->rehighlight();128 _highlighter->rehighlight();
111}129}
112 130
131void BaseLogDialog::toggleSearchNext() {
132 QTextCursor searchCursor = _logTextBox->textCursor();
133 if (searchCursor.hasSelection()) {
134 QString selectedTerm = searchCursor.selectedText();
135 _logTextBox->find(selectedTerm);
136 }
137}
138
113void BaseLogDialog::showLogData() {139void BaseLogDialog::showLogData() {
114 _logTextBox->clear();140 _logTextBox->clear();
115 _logTextBox->appendPlainText(getCurrentLog());141 _logTextBox->appendPlainText(getCurrentLog());

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t