MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / WizCodeEditorDialog

Method WizCodeEditorDialog

src/widgets/WizCodeEditorDialog.cpp:30–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#define LASTUSEDCODETYPE "LASTUSEDCODETYPE"
29
30WizCodeEditorDialog::WizCodeEditorDialog(WizExplorerApp& app, WizDocumentWebView* external, QWidget *parent) :
31 WizWebEngineViewContainerDialog(parent)
32 , m_app(app)
33 , m_external(external)
34 , m_codeBrowser(new WizWebEngineView(this))
35{
36 WizWebEngineInjectObjectCollection objects = {
37 {"codeEditor", this},
38 {"external", m_external->publicAPIsObject()}
39 };
40 auto profile = createWebEngineProfile(objects, this);
41 auto webPage = new WizWebEnginePage(objects, profile, m_codeBrowser);
42 m_codeBrowser->setPage(webPage);
43 //
44 //setAttribute(Qt::WA_DeleteOnClose);
45 //setWindowFlags(Qt::WindowStaysOnTopHint); //could cause fullscreen problem on mac when mainwindow was fullscreen
46 setWindowState(windowState() & ~Qt::WindowFullScreen);
47 resize(650, 550);
48 //
49 //
50 QVBoxLayout *verticalLayout = new QVBoxLayout(this);
51 verticalLayout->setSpacing(6);
52 verticalLayout->setContentsMargins(5, 5, 5, 5);
53
54 verticalLayout->addWidget(m_codeBrowser);
55
56 QString strFileName = Utils::WizPathResolve::resourcesPath() + "files/code/insert_code.htm";
57 QString strHtml;
58 ::WizLoadUnicodeTextFromFile(strFileName, strHtml);
59 strHtml.replace("Wiz_Language_Replace", tr("Language"));
60 strHtml.replace("Wiz_OK_Replace", tr("OK"));
61 strHtml.replace("Wiz_Cancel_Replace", tr("Cancel"));
62 QUrl url = QUrl::fromLocalFile(strFileName);
63
64 m_codeBrowser->page()->setHtml(strHtml, url);
65}
66
67WizCodeEditorDialog::~WizCodeEditorDialog()
68{

Callers

nothing calls this directly

Calls 4

createWebEngineProfileFunction · 0.85
setContentsMarginsMethod · 0.80
publicAPIsObjectMethod · 0.45

Tested by

no test coverage detected