| 24 | |
| 25 | |
| 26 | URLFinder::URLFinder(ScintillaNext *editor) : |
| 27 | EditorDecorator(editor), |
| 28 | timer(new QTimer(this)) |
| 29 | { |
| 30 | // Setup the indicator |
| 31 | indicator = editor->allocateIndicator("url_finder"); |
| 32 | |
| 33 | editor->indicSetStyle(indicator, INDIC_PLAIN); |
| 34 | editor->indicSetFore(indicator, 0xFF0000); |
| 35 | |
| 36 | editor->indicSetHoverStyle(indicator, INDIC_DOTS); |
| 37 | editor->indicSetHoverFore(indicator, 0xFF0000); |
| 38 | |
| 39 | // Resizing the window could reveal more text |
| 40 | connect(editor, &ScintillaNext::resized, timer, qOverload<>(&QTimer::start)); |
| 41 | |
| 42 | timer->setInterval(200); |
| 43 | timer->setSingleShot(true); |
| 44 | connect(timer, &QTimer::timeout, this, &URLFinder::findURLs); |
| 45 | |
| 46 | connect(this, &EditorDecorator::stateChanged, this, [=](bool b) { |
| 47 | if (b) { |
| 48 | connect(editor, &ScintillaNext::resized, timer, qOverload<>(&QTimer::start)); |
| 49 | connect(editor, &ScintillaNext::reloaded, timer, qOverload<>(&QTimer::start)); |
| 50 | findURLs(); |
| 51 | } |
| 52 | else { |
| 53 | disconnect(editor, &ScintillaNext::resized, timer, qOverload<>(&QTimer::start)); |
| 54 | clearURLs(); |
| 55 | } |
| 56 | }); |
| 57 | } |
| 58 | |
| 59 | void URLFinder::findURLs() |
| 60 | { |
nothing calls this directly
no test coverage detected