Browse Source

implementing running interface

Nicolas Winkler 6 năm trước cách đây
mục cha
commit
d175f327b6
4 tập tin đã thay đổi với 94 bổ sung7 xóa
  1. 11 1
      brainywindow.cpp
  2. 4 0
      brainywindow.h
  3. 78 6
      brainywindow.ui
  4. 1 0
      syntaxhighlighter.cpp

+ 11 - 1
brainywindow.cpp

@@ -15,16 +15,20 @@ BrainyWindow::BrainyWindow(QWidget *parent) :
 {
     ui->setupUi(this);
     ui->textEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
+    ui->runConsole->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
     sh = std::make_unique<SyntaxHighlighter>(ui->textEdit->document());
 
     ui->actionOpen->connect(ui->actionOpen, &QAction::triggered, this, &BrainyWindow::openFile);
     ui->actionSave->connect(ui->actionSave, &QAction::triggered, this, &BrainyWindow::saveFile);
     ui->actionSave_As->connect(ui->actionSave_As, &QAction::triggered, this, &BrainyWindow::saveFileAs);
+    ui->run->connect(ui->run, &QPushButton::clicked, this, &BrainyWindow::startRun);
     ui->actionEditor_Font->connect(ui->actionEditor_Font, &QAction::triggered, this, [this] () {
         bool ok;
         QFont font = QFontDialog::getFont(&ok, ui->textEdit->font(), this);
-        if (ok)
+        if (ok) {
             ui->textEdit->setFont(font);
+            ui->runConsole->setFont(font);
+        }
     });
 }
 
@@ -95,6 +99,12 @@ void BrainyWindow::saveFileAs()
 }
 
 
+void BrainyWindow::startRun()
+{
+    this->ui->runConsole->append("output goes here");
+}
+
+
 bool BrainyWindow::changesToSave() const
 {
     return changedAnything;

+ 4 - 0
brainywindow.h

@@ -10,6 +10,7 @@ namespace Ui
     class BrainyWindow;
 }
 
+
 class BrainyWindow : public QMainWindow
 {
     Q_OBJECT
@@ -23,6 +24,9 @@ public:
     void openFile();
     void saveFile();
     void saveFileAs();
+
+    void startRun();
+
     bool changesToSave() const;
 
 private:

+ 78 - 6
brainywindow.ui

@@ -21,11 +21,11 @@
    <layout class="QVBoxLayout" name="verticalLayout">
     <item>
      <widget class="QTextEdit" name="textEdit">
-      <property name="font">
-       <font>
-        <family>Courier</family>
-        <pointsize>10</pointsize>
-       </font>
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+        <horstretch>0</horstretch>
+        <verstretch>6</verstretch>
+       </sizepolicy>
       </property>
       <property name="layoutDirection">
        <enum>Qt::LeftToRight</enum>
@@ -34,7 +34,79 @@
        <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Courier'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+      </property>
+      <property name="acceptRichText">
+       <bool>false</bool>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <widget class="QPushButton" name="run">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Run</string>
+        </property>
+        <property name="icon">
+         <iconset theme="media-playback-start">
+          <normaloff>.</normaloff>.</iconset>
+        </property>
+        <property name="iconSize">
+         <size>
+          <width>36</width>
+          <height>36</height>
+         </size>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="stop">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Stop</string>
+        </property>
+        <property name="icon">
+         <iconset theme="media-playback-stop"/>
+        </property>
+        <property name="iconSize">
+         <size>
+          <width>36</width>
+          <height>36</height>
+         </size>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+    <item>
+     <widget class="QTextEdit" name="runConsole">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+        <horstretch>0</horstretch>
+        <verstretch>1</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="layoutDirection">
+       <enum>Qt::LeftToRight</enum>
+      </property>
+      <property name="html">
+       <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
 &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New';&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
       </property>
       <property name="acceptRichText">

+ 1 - 0
syntaxhighlighter.cpp

@@ -16,6 +16,7 @@ SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent) :
     levelColor[3].setForeground(Qt::darkYellow);
     levelColor[4].setForeground(Qt::magenta);
     levelColor[5].setForeground(Qt::green);
+
     for (auto& tcf : levelColor) {
         tcf.setFontWeight(99);
     }