File tree Expand file tree Collapse file tree 4 files changed +33
-5
lines changed Expand file tree Collapse file tree 4 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,10 @@ CodeEditor::CodeEditor(QWidget* parent)
6060 p.setColor (QPalette::Text, Qt::white);
6161 this ->setPalette (p);
6262}
63-
63+ void CodeEditor::setSingleLine (bool isSingleLine)
64+ {
65+ mSingleLine = isSingleLine;
66+ }
6467int CodeEditor::lineNumberAreaWidth ()
6568{
6669 int digits = 1 ;
@@ -192,6 +195,9 @@ void CodeEditor::keyPressEvent(QKeyEvent* e)
192195 break ;
193196 case Qt::Key_Enter:
194197 case Qt::Key_Return:
198+ if (mSingleLine ){
199+ break ;
200+ }
195201 if (!KeepIndent ()) {
196202 QPlainTextEdit::keyPressEvent (e);
197203 }
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ class CodeEditor : public QPlainTextEdit {
6060 CodeEditor (QWidget* parent = 0 );
6161 void lineNumberAreaPaintEvent (QPaintEvent* event);
6262 int lineNumberAreaWidth ();
63+ void setSingleLine (bool isSingleLine);
6364
6465protected:
6566 void resizeEvent (QResizeEvent* event);
@@ -74,6 +75,7 @@ private slots:
7475 void SelectLineMarginBlock ();
7576 QString GetLine ();
7677 bool KeepIndent ();
78+ bool mSingleLine = false ;
7779};
7880
7981class LineNumberArea : public QWidget {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ MainView::MainView(QWidget* parent)
1818 , ui(new Ui::MainView)
1919{
2020 ui->setupUi (this );
21+ ui->txtOneLiner ->setSingleLine (true );
2122 SetupHighlighter ();
2223 LoadResources ();
2324 LoadSettings ();
Original file line number Diff line number Diff line change 579579 <property name =" orientation" >
580580 <enum >Qt::Horizontal</enum >
581581 </property >
582+ <property name =" sizeType" >
583+ <enum >QSizePolicy::MinimumExpanding</enum >
584+ </property >
582585 <property name =" sizeHint" stdset =" 0" >
583586 <size >
584587 <width >40</width >
587590 </property >
588591 </spacer >
589592 </item >
593+ <item >
594+ <widget class =" QLabel" name =" lblOneLiner" >
595+ <property name =" text" >
596+ <string >One Liner</string >
597+ </property >
598+ </widget >
599+ </item >
590600 <item >
591601 <widget class =" CodeEditor" name =" txtOneLiner" >
602+ <property name =" sizePolicy" >
603+ <sizepolicy hsizetype =" Expanding" vsizetype =" Fixed" >
604+ <horstretch >0</horstretch >
605+ <verstretch >0</verstretch >
606+ </sizepolicy >
607+ </property >
592608 <property name =" minimumSize" >
593609 <size >
594610 <width >0</width >
598614 <property name =" maximumSize" >
599615 <size >
600616 <width >16777215</width >
601- <height >44 </height >
617+ <height >24 </height >
602618 </size >
603619 </property >
604620 <property name =" font" >
608624 </font >
609625 </property >
610626 <property name =" toolTip" >
611- <string >Code Area</string >
627+ <string >One Liner Code</string >
628+ </property >
629+ <property name =" autoFillBackground" >
630+ <bool >false</bool >
612631 </property >
613632 <property name =" inputMethodHints" >
614- <set >Qt::ImhMultiLine </set >
633+ <set >Qt::ImhNone </set >
615634 </property >
616635 <property name =" verticalScrollBarPolicy" >
617- <enum >Qt::ScrollBarAlwaysOn </enum >
636+ <enum >Qt::ScrollBarAlwaysOff </enum >
618637 </property >
619638 <property name =" horizontalScrollBarPolicy" >
620639 <enum >Qt::ScrollBarAlwaysOff</enum >
You can’t perform that action at this time.
0 commit comments