MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / formatCodeButtonPressed

Method formatCodeButtonPressed

gui/nbrowserwindow.cpp:1175–1191  ·  view source on GitHub ↗

The center align button was pressed

Source from the content-addressed store, hash-verified

1173
1174// The center align button was pressed
1175void NBrowserWindow::formatCodeButtonPressed() {
1176
1177 QString text = editor->selectedText();
1178 if (text.trimmed() == "")
1179 text = tr("Insert your code here.");
1180 QString buffer;
1181 // buffer.append("<pre style=\"font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; font-size: 0.9em; border-radius: 4px; letter-spacing: 0.015em; padding: 1em; border: 1px solid #cccccc; background-color: #f8f8f8; overflow-x: auto;\">");
1182 buffer.append("<br/><pre style=\"font-family: Monaco, Menlo, Consolas, Courier New, monospace; font-size: 0.9em; border-radius: 4px; letter-spacing: 0.015em; padding: 1em; border: 1px solid #cccccc; background-color: #f8f8f8; overflow-x: auto;\">");
1183 buffer.append(text);
1184 buffer.append("</pre><br/>");
1185 QString script = QString("document.execCommand('insertHtml', false, '%1');").arg(buffer);
1186 editor->page()->mainFrame()->evaluateJavaScript(script).toString();
1187
1188 QKeyEvent *left = new QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier);
1189 QCoreApplication::postEvent(editor->editorPage, left);
1190
1191}
1192
1193
1194

Callers

nothing calls this directly

Calls 2

QStringClass · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected