ui: basic CodeView with syntax highlighting
Added CodeView interface and QtCodeView implementation for showing syntax highlighted code snippets. This change avoids using the GuiElement hierarchy by using directly using QtClasses and creating QtCodeView in the QtElementFactory.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#ifndef QT_CODE_VIEW_H
|
||||
#define QT_CODE_VIEW_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#include <QFont>
|
||||
|
||||
#include "component/view/CodeView.h"
|
||||
|
||||
class QtHighlighter;
|
||||
class QTextEdit;
|
||||
class ViewManager;
|
||||
|
||||
class QtCodeView: public CodeView
|
||||
{
|
||||
public:
|
||||
QtCodeView(std::shared_ptr<ViewManager> viewManager);
|
||||
~QtCodeView();
|
||||
|
||||
// CodeView implementation
|
||||
virtual void addCodeSnippet(std::string str);
|
||||
virtual void clearCodeSnippets();
|
||||
|
||||
private:
|
||||
struct Snippet
|
||||
{
|
||||
std::shared_ptr<QTextEdit> textField;
|
||||
std::shared_ptr<QtHighlighter> highlighter;
|
||||
};
|
||||
std::vector<std::shared_ptr<Snippet>> m_snippets;
|
||||
|
||||
QFont m_font;
|
||||
};
|
||||
|
||||
# endif // QT_CODE_VIEW_H
|
||||
Reference in New Issue
Block a user