24 #include <QDialogButtonBox>
26 #include <QFontMetrics>
27 #include <QFormLayout>
28 #include <QHBoxLayout>
29 #include <QPushButton>
30 #include <QStringList>
31 #include <QVBoxLayout>
38 "* Multiline Comment\n"
40 "#include <QApplication>\n"
41 "#include <iostream>\n"
45 "int main(int argc, char *argv[])\n"
47 " QApplication a(argc, argv);\n"
50 " // single line comment\n"
51 " // line below is highlighted\n"
52 " fwdClass( nLife );\n"
56 "void class fwdClass( double dValue ) {\n"
57 " std::cout << \"Ipsum Lorem: \"\n"
63 QStringList(QStringList()
72 mStyleIncoming(newStyle),
73 mStyleOutgoing(newStyle)
75 auto *vboxMain =
new QVBoxLayout(
this);
76 auto *hboxEdit =
new QHBoxLayout();
78 auto *flEditControls =
new QFormLayout();
80 flEditControls->addRow(QObject::tr(
"Editor Foreground Color"),
83 flEditControls->addRow(QObject::tr(
"Editor Background Color"),
86 flEditControls->addRow(QObject::tr(
"Highlight Background Color"),
89 flEditControls->addRow(QObject::tr(
"Line Number Foreground Color"),
92 flEditControls->addRow(QObject::tr(
"Line Number Background Color"),
95 flEditControls->addRow(QObject::tr(
"Keyword Foreground Color"),
98 flEditControls->addRow(QObject::tr(
"Keyword Font Weight"),
101 flEditControls->addRow(QObject::tr(
"Class Foreground Color"),
104 flEditControls->addRow(QObject::tr(
"Class Font Weight"),
107 flEditControls->addRow(QObject::tr(
"Quote Foreground Color"),
110 flEditControls->addRow(QObject::tr(
"Quote Font Weight"),
113 flEditControls->addRow(QObject::tr(
"Comment Foreground Color"),
116 flEditControls->addRow(QObject::tr(
"Comment Font Weight"),
119 flEditControls->addRow(QObject::tr(
"Symbol Foreground Color"),
122 flEditControls->addRow(QObject::tr(
"Symbol Background Color"),
125 flEditControls->addRow(QObject::tr(
"Symbol Font Weight"),
127 hboxEdit->addLayout(flEditControls);
130 QFont sampleFont(
"Monospace");
131 QFontMetrics fm(sampleFont);
132 #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
133 mSampleEditor->setMinimumWidth(fm.horizontalAdvance(QString(40,
'W')));
141 vboxMain->addLayout(hboxEdit);
144 auto *hboxDefaultControls =
new QHBoxLayout();
149 hboxDefaultControls->addStretch(1);
152 hboxDefaultControls->addStretch(1);
153 vboxMain->addLayout(hboxDefaultControls);
154 vboxMain->addStretch(2);
156 auto *dBtnBox =
new QDialogButtonBox(
157 QDialogButtonBox::Cancel |
158 QDialogButtonBox::Ok |
159 QDialogButtonBox::Reset);
160 vboxMain->addStretch(1);
161 vboxMain->addWidget(dBtnBox);
167 connect(dBtnBox, SIGNAL(accepted()),
this, SLOT(accept()));
168 connect(dBtnBox, SIGNAL(rejected()),
this, SLOT(reject()));
169 connect(dBtnBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()),
QFont::Weight classWeight
QFont::Weight commentWeight
QFont::Weight quoteWeight
QFont::Weight symbolWeight
QFont::Weight keywordWeight
void setStyle(const CodeEditorStyle &newStyle)
void setError(const QString &code, int errorLine, const QStringList &symbols)
Set source code to show, goto error line and highlight that line.
void setWeight(QFont::Weight weight)
CodeEditor * mSampleEditor
void colorChangedLineNumFG(const QColor &newColor)
SelectFontWeightCombo * mCBCommentWeight
SelectColorButton * mBtnLineNumBG
void colorChangedCommentFG(const QColor &newColor)
void colorChangedSymbolBG(const QColor &newColor)
static const QStringList mErrSymbolsList
SelectColorButton * mBtnQuoteFG
void colorChangedLineNumBG(const QColor &newColor)
void weightChangedClass(QFont::Weight newWeight)
void weightChangedComment(QFont::Weight newWeight)
QPushButton * mBtnDefaultLight
void colorChangedQuoteFG(const QColor &newColor)
SelectColorButton * mBtnKeywordFG
void weightChangedSymbol(QFont::Weight newWeight)
void colorChangedWidgetFG(const QColor &newColor)
SelectColorButton * mBtnLineNumFG
void colorChangedClassFG(const QColor &newColor)
void weightChangedKeyword(QFont::Weight newWeight)
CodeEditorStyle mStyleOutgoing
SelectColorButton * mBtnClassFG
static const int mErrLineNum
void weightChangedQuote(QFont::Weight newWeight)
SelectFontWeightCombo * mCBClassWeight
SelectColorButton * mBtnSymbolBG
void colorChangedWidgetBG(const QColor &newColor)
void setStyleDefaultDark()
StyleEditDialog(const CodeEditorStyle &newStyle, QWidget *parent=nullptr)
SelectColorButton * mBtnSymbolFG
SelectColorButton * mBtnHighlightBG
void colorChangedHighlightBG(const QColor &newColor)
SelectFontWeightCombo * mCBQuoteWeight
SelectFontWeightCombo * mCBKeywordWeight
SelectColorButton * mBtnWidgetColorBG
QPushButton * mBtnDefaultDark
void colorChangedKeywordFG(const QColor &newColor)
SelectColorButton * mBtnCommentFG
SelectFontWeightCombo * mCBSymbolWeight
void colorChangedSymbolFG(const QColor &newColor)
static const QString mSampleDocument
SelectColorButton * mBtnWidgetColorFG
CodeEditorStyle mStyleIncoming
CodeEditorStyle getStyle()
void setStyleDefaultLight()
static const CodeEditorStyle defaultStyleLight(Qt::black, QColor(240, 240, 240), QColor(255, 220, 220), Qt::black, QColor(240, 240, 240), Qt::darkBlue, QFont::Bold, Qt::darkMagenta, QFont::Bold, Qt::darkGreen, QFont::Normal, Qt::gray, QFont::Normal, Qt::red, QColor(220, 220, 255), QFont::Normal)
static const CodeEditorStyle defaultStyleDark(QColor(218, 218, 218), QColor(16, 16, 32), QColor(64, 64, 64), QColor(43, 145, 175), QColor(16, 16, 32), QColor(0, 204, 204), QFont::Bold, QColor(218, 0, 218), QFont::Bold, QColor(0, 204, 0), QFont::Normal, QColor(180, 180, 180), QFont::Normal, QColor(218, 32, 32), QColor(32, 32, 108), QFont::Normal)