| 134 | } |
| 135 | |
| 136 | void QCodeEditor::updateStyle() |
| 137 | { |
| 138 | if (m_highlighter) |
| 139 | { |
| 140 | m_highlighter->rehighlight(); |
| 141 | } |
| 142 | |
| 143 | if (m_syntaxStyle) |
| 144 | { |
| 145 | auto currentPalette = palette(); |
| 146 | |
| 147 | // Setting text format/color |
| 148 | currentPalette.setColor( |
| 149 | QPalette::ColorRole::Text, |
| 150 | m_syntaxStyle->getFormat("Text").foreground().color()); |
| 151 | |
| 152 | // Setting common background |
| 153 | currentPalette.setColor( |
| 154 | QPalette::Base, m_syntaxStyle->getFormat("Text").background().color()); |
| 155 | |
| 156 | // Setting selection color |
| 157 | currentPalette.setColor( |
| 158 | QPalette::Highlight, |
| 159 | m_syntaxStyle->getFormat("Selection").background().color()); |
| 160 | currentPalette.setColor( |
| 161 | QPalette::HighlightedText, |
| 162 | m_syntaxStyle->getFormat("Selection").foreground().color()); |
| 163 | |
| 164 | setPalette(currentPalette); |
| 165 | |
| 166 | if (m_completer && m_completer->popup()) |
| 167 | { |
| 168 | m_completer->popup()->setFont(font()); |
| 169 | m_completer->popup()->setPalette(currentPalette); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | updateExtraSelection(); |
| 174 | } |
| 175 | |
| 176 | void QCodeEditor::onSelectionChanged() |
| 177 | { |