소스 검색

more work on proper ui

Zoadian 10 년 전
부모
커밋
0653613748
6개의 변경된 파일365개의 추가작업 그리고 22개의 파일을 삭제
  1. 72 0
      ccsim.cpp
  2. 3 0
      ccsim.h
  3. 1 1
      ccsim.pro.user
  4. 255 6
      ccsim.ui
  5. 32 14
      syntaxhighlighter.cpp
  6. 2 1
      syntaxhighlighter.h

+ 72 - 0
ccsim.cpp

@@ -15,9 +15,81 @@ CCSim::CCSim(QWidget *parent) :
    if (file.open(QFile::ReadOnly | QFile::Text))
    if (file.open(QFile::ReadOnly | QFile::Text))
        ui->pteEditor->setPlainText(file.readAll());
        ui->pteEditor->setPlainText(file.readAll());
 
 
+
+
+   connect(ui->btnEditor, &QPushButton::clicked, this, [this](){
+       ui->stackedWidget->setCurrentWidget(ui->pgEditor);
+   });
+
+   connect(ui->btnSimulator, &QPushButton::clicked, this, [this](){
+       ui->stackedWidget->setCurrentWidget(ui->pgSimulator);
+   });
+
+   connect(ui->btnTournament, &QPushButton::clicked, this, [this](){
+       ui->stackedWidget->setCurrentWidget(ui->pgTournament);
+   });
+
+   connect(ui->btnOptionSet, &QPushButton::clicked, this, [this](){
+       ui->stackedWidget->setCurrentWidget(ui->pgOptionSet);
+   });
+
+   connect(ui->btnPreferences, &QPushButton::clicked, this, [this](){
+       ui->stackedWidget->setCurrentWidget(ui->pgPreferences);
+   });
+
+   connect(ui->btnHelp, &QPushButton::clicked, this, [this](){
+       ui->stackedWidget->setCurrentWidget(ui->pgHelp);
+   });
+
+   connect(ui->actionEditorNew, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionEditorLoad, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionEditorSave, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionEditorSaveAs, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionSimulatorStop, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionSimulatorSingleStep, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionSimulatorStart, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionTournamentStop, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionTournamentStart, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->actionTournamentSaveResults, &QAction::triggered, this, [this](){
+   });
+
+   connect(ui->stackedWidget, &QStackedWidget::currentChanged, this, [this](int index){
+       updateUiElements();
+   });
+
+   ui->stackedWidget->setCurrentWidget(ui->pgEditor);
+   updateUiElements();
 }
 }
 
 
 CCSim::~CCSim()
 CCSim::~CCSim()
 {
 {
     delete ui;
     delete ui;
 }
 }
+
+void CCSim::updateUiElements()
+{
+    ui->tbEditor->setVisible(ui->stackedWidget->currentWidget() == ui->pgEditor);
+    ui->tbSimulator->setVisible(ui->stackedWidget->currentWidget() == ui->pgSimulator);
+    ui->tbTournament->setVisible(ui->stackedWidget->currentWidget() == ui->pgTournament);
+    ui->tbOptionSet->setVisible(ui->stackedWidget->currentWidget() == ui->pgOptionSet);
+    ui->tbPreferences->setVisible(ui->stackedWidget->currentWidget() == ui->pgPreferences);
+    ui->tbHelp->setVisible(ui->stackedWidget->currentWidget() == ui->pgHelp);
+}

+ 3 - 0
ccsim.h

@@ -17,6 +17,9 @@ public:
 
 
 private:
 private:
     Ui::CCSim *ui;
     Ui::CCSim *ui;
+
+public slots:
+    void updateUiElements();
 };
 };
 
 
 #endif // CCSIM_H
 #endif // CCSIM_H

+ 1 - 1
ccsim.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.6.0, 2016-01-24T21:36:35. -->
+<!-- Written by QtCreator 3.6.0, 2016-01-25T21:55:13. -->
 <qtcreator>
 <qtcreator>
  <data>
  <data>
   <variable>EnvironmentId</variable>
   <variable>EnvironmentId</variable>

+ 255 - 6
ccsim.ui

@@ -14,11 +14,38 @@
    <string>MainWindow</string>
    <string>MainWindow</string>
   </property>
   </property>
   <widget class="QWidget" name="centralwidget">
   <widget class="QWidget" name="centralwidget">
-   <layout class="QVBoxLayout" name="verticalLayout">
+   <layout class="QHBoxLayout" name="horizontalLayout">
+    <property name="spacing">
+     <number>0</number>
+    </property>
+    <property name="leftMargin">
+     <number>0</number>
+    </property>
+    <property name="topMargin">
+     <number>0</number>
+    </property>
+    <property name="rightMargin">
+     <number>0</number>
+    </property>
+    <property name="bottomMargin">
+     <number>0</number>
+    </property>
     <item>
     <item>
-     <layout class="QHBoxLayout" name="horizontalLayout">
+     <layout class="QVBoxLayout" name="verticalLayout_3">
       <item>
       <item>
        <widget class="QPushButton" name="btnEditor">
        <widget class="QPushButton" name="btnEditor">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>64</width>
+          <height>64</height>
+         </size>
+        </property>
         <property name="text">
         <property name="text">
          <string>Editor</string>
          <string>Editor</string>
         </property>
         </property>
@@ -26,6 +53,18 @@
       </item>
       </item>
       <item>
       <item>
        <widget class="QPushButton" name="btnSimulator">
        <widget class="QPushButton" name="btnSimulator">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>64</width>
+          <height>64</height>
+         </size>
+        </property>
         <property name="text">
         <property name="text">
          <string>Simulator</string>
          <string>Simulator</string>
         </property>
         </property>
@@ -33,6 +72,18 @@
       </item>
       </item>
       <item>
       <item>
        <widget class="QPushButton" name="btnTournament">
        <widget class="QPushButton" name="btnTournament">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>64</width>
+          <height>64</height>
+         </size>
+        </property>
         <property name="text">
         <property name="text">
          <string>Tournament</string>
          <string>Tournament</string>
         </property>
         </property>
@@ -40,26 +91,50 @@
       </item>
       </item>
       <item>
       <item>
        <widget class="QPushButton" name="btnOptionSet">
        <widget class="QPushButton" name="btnOptionSet">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>64</width>
+          <height>64</height>
+         </size>
+        </property>
         <property name="text">
         <property name="text">
          <string>Option Set</string>
          <string>Option Set</string>
         </property>
         </property>
        </widget>
        </widget>
       </item>
       </item>
       <item>
       <item>
-       <spacer name="horizontalSpacer">
+       <spacer name="verticalSpacer">
         <property name="orientation">
         <property name="orientation">
-         <enum>Qt::Horizontal</enum>
+         <enum>Qt::Vertical</enum>
         </property>
         </property>
         <property name="sizeHint" stdset="0">
         <property name="sizeHint" stdset="0">
          <size>
          <size>
-          <width>40</width>
-          <height>20</height>
+          <width>20</width>
+          <height>40</height>
          </size>
          </size>
         </property>
         </property>
        </spacer>
        </spacer>
       </item>
       </item>
       <item>
       <item>
        <widget class="QPushButton" name="btnPreferences">
        <widget class="QPushButton" name="btnPreferences">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>64</width>
+          <height>64</height>
+         </size>
+        </property>
         <property name="text">
         <property name="text">
          <string>Preferences</string>
          <string>Preferences</string>
         </property>
         </property>
@@ -67,6 +142,18 @@
       </item>
       </item>
       <item>
       <item>
        <widget class="QPushButton" name="btnHelp">
        <widget class="QPushButton" name="btnHelp">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>64</width>
+          <height>64</height>
+         </size>
+        </property>
         <property name="text">
         <property name="text">
          <string>Help</string>
          <string>Help</string>
         </property>
         </property>
@@ -78,6 +165,21 @@
      <widget class="QStackedWidget" name="stackedWidget">
      <widget class="QStackedWidget" name="stackedWidget">
       <widget class="QWidget" name="pgEditor">
       <widget class="QWidget" name="pgEditor">
        <layout class="QVBoxLayout" name="verticalLayout_2">
        <layout class="QVBoxLayout" name="verticalLayout_2">
+        <property name="spacing">
+         <number>0</number>
+        </property>
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <property name="topMargin">
+         <number>0</number>
+        </property>
+        <property name="rightMargin">
+         <number>0</number>
+        </property>
+        <property name="bottomMargin">
+         <number>0</number>
+        </property>
         <item>
         <item>
          <widget class="WgtCodeEditor" name="pteEditor"/>
          <widget class="WgtCodeEditor" name="pteEditor"/>
         </item>
         </item>
@@ -103,6 +205,153 @@
    </property>
    </property>
   </widget>
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
   <widget class="QStatusBar" name="statusbar"/>
+  <widget class="QToolBar" name="tbEditor">
+   <property name="windowTitle">
+    <string>Editor</string>
+   </property>
+   <property name="movable">
+    <bool>false</bool>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+   <addaction name="actionEditorNew"/>
+   <addaction name="actionEditorLoad"/>
+   <addaction name="actionEditorSave"/>
+   <addaction name="actionEditorSaveAs"/>
+  </widget>
+  <widget class="QToolBar" name="tbSimulator">
+   <property name="windowTitle">
+    <string>Simulator</string>
+   </property>
+   <property name="movable">
+    <bool>false</bool>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+   <addaction name="actionSimulatorStop"/>
+   <addaction name="actionSimulatorSingleStep"/>
+   <addaction name="actionSimulatorStart"/>
+  </widget>
+  <widget class="QToolBar" name="tbTournament">
+   <property name="windowTitle">
+    <string>Tournament</string>
+   </property>
+   <property name="movable">
+    <bool>false</bool>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+   <addaction name="actionTournamentStop"/>
+   <addaction name="actionTournamentStart"/>
+   <addaction name="actionTournamentSaveResults"/>
+  </widget>
+  <widget class="QToolBar" name="tbOptionSet">
+   <property name="windowTitle">
+    <string>OptionSet</string>
+   </property>
+   <property name="movable">
+    <bool>false</bool>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QToolBar" name="tbPreferences">
+   <property name="windowTitle">
+    <string>Preferences</string>
+   </property>
+   <property name="movable">
+    <bool>false</bool>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QToolBar" name="tbHelp">
+   <property name="windowTitle">
+    <string>Help</string>
+   </property>
+   <property name="movable">
+    <bool>false</bool>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <action name="actionEditorSave">
+   <property name="text">
+    <string>EditorSave</string>
+   </property>
+  </action>
+  <action name="actionEditorSaveAs">
+   <property name="text">
+    <string>EditorSaveAs</string>
+   </property>
+  </action>
+  <action name="actionEditorLoad">
+   <property name="text">
+    <string>EditorLoad</string>
+   </property>
+  </action>
+  <action name="actionEditorNew">
+   <property name="text">
+    <string>EditorNew</string>
+   </property>
+  </action>
+  <action name="actionSimulatorStop">
+   <property name="text">
+    <string>SimulatorStop</string>
+   </property>
+  </action>
+  <action name="actionSimulatorSingleStep">
+   <property name="text">
+    <string>SimulatorSingleStep</string>
+   </property>
+  </action>
+  <action name="actionSimulatorStart">
+   <property name="text">
+    <string>SimulatorStart</string>
+   </property>
+   <property name="toolTip">
+    <string>SimulatorStart</string>
+   </property>
+  </action>
+  <action name="actionTournamentStop">
+   <property name="text">
+    <string>TournamentStop</string>
+   </property>
+  </action>
+  <action name="actionTournamentStart">
+   <property name="text">
+    <string>TournamentStart</string>
+   </property>
+  </action>
+  <action name="actionTournamentSaveResults">
+   <property name="text">
+    <string>TournamentSaveResults</string>
+   </property>
+  </action>
  </widget>
  </widget>
  <customwidgets>
  <customwidgets>
   <customwidget>
   <customwidget>

+ 32 - 14
syntaxhighlighter.cpp

@@ -4,23 +4,42 @@ SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent)
     : QSyntaxHighlighter(parent)
     : QSyntaxHighlighter(parent)
 {
 {
     HighlightingRule rule;
     HighlightingRule rule;
+    rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
 
 
-    keywordFormat.setForeground(Qt::darkBlue);
-    keywordFormat.setFontWeight(QFont::Bold);
-    QStringList keywordPatterns;
-
-    keywordPatterns << "\\bCREATE\\b" << "\\bMOVE\\b" << "\\bDIE\\b" << "\\bTRANS\\b" << "\\bRTRANS\\b" << "\\bTURN\\b"
-                    << "\\bJUMP\\b" << "\\bAJUMP\\b" << "\\bBJUMP\\b"
-                    << "\\bSCAN\\b" << "\\bFARSCAN\\b"
-                    << "\\bSET\\b" << "\\bADD\\b" << "\\bSUB\\b" << "\\bMUL\\b" << "\\bDIV\\b" << "\\bMOD\\b" << "\\bMIN\\b" << "\\bMAX\\b" << "\\bRANDOM\\b"
-                    << "\\bIF\\b" << "\\bIFN\\b" << "\\bIFG\\b" << "\\bIFL\\b" << "\\bIFGE\\b" << "\\bIFLE\\b"
-                    << "\\bINIT\\b" << "\\bBREAK\\b" << "\\bRESUME\\b" << "\\bSEIZE\\b" << "\\bSLEEP\\b" << "\\bQUIT\\b"
-                       ;
+    QStringList instructionPatterns;
+    instructionPatterns
+            << "\\bCREATE\\b" << "\\bMOVE\\b" << "\\bDIE\\b" << "\\bTRANS\\b" << "\\bRTRANS\\b" << "\\bTURN\\b"
+            << "\\bJUMP\\b" << "\\bAJUMP\\b" << "\\bBJUMP\\b"
+            << "\\bSCAN\\b" << "\\bFARSCAN\\b"
+            << "\\bSET\\b" << "\\bADD\\b" << "\\bSUB\\b" << "\\bMUL\\b" << "\\bDIV\\b" << "\\bMOD\\b" << "\\bMIN\\b" << "\\bMAX\\b" << "\\bRANDOM\\b"
+            << "\\bIF\\b" << "\\bIFN\\b" << "\\bIFG\\b" << "\\bIFL\\b" << "\\bIFGE\\b" << "\\bIFLE\\b"
+            << "\\bINIT\\b" << "\\bBREAK\\b" << "\\bRESUME\\b" << "\\bSEIZE\\b" << "\\bSLEEP\\b" << "\\bQUIT\\b"
+               ;
+    instructionFormat.setForeground(Qt::darkBlue);
+    instructionFormat.setFontWeight(QFont::Bold);
+    foreach (const QString &pattern, instructionPatterns) {
+        rule.pattern = QRegExp(pattern);
+        rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
+        rule.format = instructionFormat;
+        highlightingRules.append(rule);
+    }
 
 
-    foreach (const QString &pattern, keywordPatterns) {
+    QStringList variablePatterns;
+    variablePatterns
+            << "#1\\b" << "#2\\b" << "#3\\b" << "#4\\b" << "#5\\b" << "#6\\b" << "#7\\b" << "#8\\b" << "#9\\b" << "#10\\b"
+            << "#11\\b" << "#12\\b" << "#13\\b" << "#14\\b" << "#15\\b" << "#16\\b" << "#17\\b" << "#18\\b" << "#19\\b" << "#20\\b"
+            << "#Active\\b" << "\\\\$Banks\\b" << "\\\\$InstrSet\\b" << "\\\\$Mobile\\b" << "\\\\$Age\\b" << "\\\\$Tasks\\b" << "\\\\$Generation\\b" << "\\\\$ID\\b"
+            << "%Active\\b" << "%Banks\\b" << "%InstrSet\\b" << "%Mobile\\b" << "%Age\\b" << "%Tasks\\b" << "%Generation\\b"
+            << "#Pub\\b" << "#Team\\b"
+            << "\\\\$Own\\b" << "\\\\$Others\\b" << "\\\\$Fields\\b" << "\\\\$Time\\b" << "\\\\$Timeout\\b"
+               ;
+    variableFormat.setForeground(Qt::darkRed);
+    variableFormat.setFontWeight(QFont::Normal);
+    variableFormat.setFontItalic(true);
+    foreach (const QString &pattern, variablePatterns) {
         rule.pattern = QRegExp(pattern);
         rule.pattern = QRegExp(pattern);
         rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
         rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
-        rule.format = keywordFormat;
+        rule.format = variableFormat;
         highlightingRules.append(rule);
         highlightingRules.append(rule);
     }
     }
 
 
@@ -28,7 +47,6 @@ SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent)
     bankFormat.setForeground(Qt::white);
     bankFormat.setForeground(Qt::white);
     bankFormat.setBackground(Qt::darkGray);
     bankFormat.setBackground(Qt::darkGray);
     rule.pattern = QRegExp("\\s*BANK.*");
     rule.pattern = QRegExp("\\s*BANK.*");
-    rule.pattern.setCaseSensitivity(Qt::CaseInsensitive);
     rule.format = bankFormat;
     rule.format = bankFormat;
     highlightingRules.append(rule);
     highlightingRules.append(rule);
 
 

+ 2 - 1
syntaxhighlighter.h

@@ -24,7 +24,8 @@ private:
     QRegExp commentStartExpression;
     QRegExp commentStartExpression;
     QRegExp commentEndExpression;
     QRegExp commentEndExpression;
 
 
-    QTextCharFormat keywordFormat;
+    QTextCharFormat instructionFormat;
+    QTextCharFormat variableFormat;
     QTextCharFormat bankFormat;
     QTextCharFormat bankFormat;
     QTextCharFormat singleLineCommentFormat;
     QTextCharFormat singleLineCommentFormat;
     QTextCharFormat multiLineCommentFormat;
     QTextCharFormat multiLineCommentFormat;