Prepare layout code generation for editor
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Wed, 27 Jan 2016 21:02:44 +0000 (22:02 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Wed, 27 Jan 2016 21:02:44 +0000 (22:02 +0100)
Makefile.am
src/edit/editor.cpp
src/edit/editor.h
src/edit/ui/editor.ui [new file with mode: 0644]

index bbfc2ba8e22c4617662e47d470351fe90ab1db43..33527d6cbc808f5b23a2f8168420d76f5c4d00c2 100644 (file)
@@ -166,12 +166,18 @@ bin_logedit_CPPFLAGS = $(bin_logedit_CFLAGS)
 bin_logedit_LDADD = $(bin_logedit_LIBS)
 bin_logeditdir = src/edit
 bin_logedit_HEADERS =\
-       src/edit/editor.h
+       src/edit/editor.h \
+       src/edit/ui/editor.h
 
-src/edit/editor.moc.cpp: src/edit/editor.h
+src/edit/editor.moc.cpp: \
+               src/edit/editor.h \
+               src/edit/ui/editor.h
        moc-qt4 src/edit/editor.h -o src/edit/editor.moc.cpp
 #      $(MOC) src/edit/editor.h -o src/edit/editor.moc.cpp
 
+src/edit/ui/editor.h:
+       uic src/edit/ui/editor.ui -o src/edit/ui/editor.h
+
 
 clean-logedit-extra:
        rm -f src/edit/*.moc.cpp
index b51dcc96aa6b780349379b8189787417e22bab1b..b8514b0f886779a41ecced56d8f4d1fc5b69d94b 100644 (file)
@@ -74,30 +74,32 @@ void Editor::closeEvent(QCloseEvent * e) {
 Editor::Editor(char *hdir, QWidget * parent)
        : QMainWindow(parent)
 {
+       setupUi(this);
+
        strcpy(HomeDir, hdir);
        find_text = "";
        sensitive = FALSE;
-       QMenu * file = NULL;
-/*     QMenu * comp = new QMenu();*/
-/*     QMenu * loglan = new QMenu();*/
-       QMenu * medit = NULL;
-       QAction* action = NULL;
-
-       file = menuBar()->addMenu("&File");
-       medit = menuBar()->addMenu("&Edit");
-
-       action = menuBar()->addAction("&Compile", this, SLOT(cmp()));
-
-       /*    m->insertItem( "&LOGLAN ", loglan );*/
-
-       action = menuBar()->addAction("&Properties", this, SLOT(props()));
-
-       file->addAction("New", this, SLOT(create()), QKeySequence(Qt::CTRL + Qt::Key_N));
-       file->addAction("Open", this, SLOT(load()), QKeySequence(Qt::CTRL + Qt::Key_O));
-       file->addAction("Save", this, SLOT(save()), QKeySequence(Qt::CTRL + Qt::Key_S));
-       file->addAction("Save as", this, SLOT(save_as()), QKeySequence(Qt::CTRL + Qt::Key_A));
-       file->addSeparator();
-       file->addAction("Quit ", this, SLOT(close()));
+//     QMenu * file = NULL;
+// /*  QMenu * comp = new QMenu();*/
+// /*  QMenu * loglan = new QMenu();*/
+//     QMenu * medit = NULL;
+//     QAction* action = NULL;
+// 
+//     file = menuBar()->addMenu("&File");
+//     medit = menuBar()->addMenu("&Edit");
+// 
+//     action = menuBar()->addAction("&Compile", this, SLOT(cmp()));
+// 
+//     /*    m->insertItem( "&LOGLAN ", loglan );*/
+// 
+//     action = menuBar()->addAction("&Properties", this, SLOT(props()));
+// 
+//     file->addAction("New", this, SLOT(create()), QKeySequence(Qt::CTRL + Qt::Key_N));
+//     file->addAction("Open", this, SLOT(load()), QKeySequence(Qt::CTRL + Qt::Key_O));
+//     file->addAction("Save", this, SLOT(save()), QKeySequence(Qt::CTRL + Qt::Key_S));
+//     file->addAction("Save as", this, SLOT(save_as()), QKeySequence(Qt::CTRL + Qt::Key_A));
+//     file->addSeparator();
+//     file->addAction("Quit ", this, SLOT(close()));
 
        /* comp->insertItem("Compile ", this, SLOT(cmp()), CTRL + Key_C);*/
        /* comp->insertItem("Gen ", this, SLOT(gen()), CTRL + Key_G);*/
@@ -106,38 +108,38 @@ Editor::Editor(char *hdir, QWidget * parent)
        /* loglan->insertItem( "Program structure", this, SLOT(log_prog()));*/
        /* loglan->insertItem( "Unit structure", this, SLOT(log_unit()));*/
 
-       e = new My_Edit(this, "editor");
-       connect(e, SIGNAL(cursorMove()), this, SLOT(updateline()));
-       medit->addAction("Copy", e, SLOT(copy()), QKeySequence(Qt::CTRL + Qt::Key_Insert));
-       medit->addAction("Paste", e, SLOT(paste()), QKeySequence(Qt::SHIFT + Qt::Key_Insert));
-       medit->addAction("Cut", e, SLOT(cut()), QKeySequence(Qt::CTRL + Qt::Key_Delete));
-       medit->addAction("Clear All", e, SLOT(clear()));
-       medit->addSeparator();
-       medit->addAction("Find", this, SLOT(findText()), QKeySequence(Qt::CTRL + Qt::Key_F));
-       medit->addAction("Find Next", this, SLOT(find_next()), QKeySequence(Qt::CTRL + Qt::Key_L));
-
-       msg = new QTextEdit(this);
-       msg->setReadOnly(TRUE);
-
-       QVBoxLayout * layout = new QVBoxLayout();
-       layout->setContentsMargins (3, 0, 3, 0);
-       layout->addWidget(e);
-       layout->addWidget(msg);
-       QWidget *window = new QWidget();
-       window->setLayout(layout);
-       setCentralWidget(window);
+//     e = new My_Edit(this, "editor");
+//     connect(e, SIGNAL(cursorMove()), this, SLOT(updateline()));
+//     medit->addAction("Copy", e, SLOT(copy()), QKeySequence(Qt::CTRL + Qt::Key_Insert));
+//     medit->addAction("Paste", e, SLOT(paste()), QKeySequence(Qt::SHIFT + Qt::Key_Insert));
+//     medit->addAction("Cut", e, SLOT(cut()), QKeySequence(Qt::CTRL + Qt::Key_Delete));
+//     medit->addAction("Clear All", e, SLOT(clear()));
+//     medit->addSeparator();
+//     medit->addAction("Find", this, SLOT(findText()), QKeySequence(Qt::CTRL + Qt::Key_F));
+//     medit->addAction("Find Next", this, SLOT(find_next()), QKeySequence(Qt::CTRL + Qt::Key_L));
+
+//     msg = new QTextEdit(this);
+//     msg->setReadOnly(TRUE);
+// 
+//     QVBoxLayout * layout = new QVBoxLayout();
+//     layout->setContentsMargins (3, 0, 3, 0);
+//     layout->addWidget(e);
+//     layout->addWidget(msg);
+//     QWidget *window = new QWidget();
+//     window->setLayout(layout);
+//     setCentralWidget(window);
 
        compiler_path.sprintf("%s/%s", HomeDir, "compile/logcomp");
        gen_path.sprintf("%s/%s", HomeDir, "compile/gen");
        file_path.sprintf("%s", HomeDir);
 
-       QColor col(200, 200, 200);
-       QPalette grp(Qt::black, col, col.lighter(), col.darker(), col.darker(), Qt::black, col);
-
-       msg->setPalette(grp);
-
-       position = new QLabel();
-       statusBar()->addPermanentWidget(position);
+//     QColor col(200, 200, 200);
+//     QPalette grp(Qt::black, col, col.lighter(), col.darker(), col.darker(), Qt::black, col);
+// 
+//     msg->setPalette(grp);
+// 
+//     position = new QLabel();
+//     statusBar()->addPermanentWidget(position);
 }
 
 /**
@@ -652,6 +654,39 @@ void Editor::find_next()
                e->find(find_text, flags);
        }
 }
+void Editor::on_actionNew_triggered()
+{
+}
+void Editor::on_actionOpen_triggered()
+{
+}
+void Editor::on_actionSave_triggered()
+{
+}
+void Editor::on_actionSave_as_triggered()
+{
+}
+void Editor::on_actionQuit_triggered()
+{
+}
+void Editor::on_actionCopy_triggered()
+{
+}
+void Editor::on_actionPaste_triggered()
+{
+}
+void Editor::on_actionCut_triggered()
+{
+}
+void Editor::on_actionClear_all_triggered()
+{
+}
+void Editor::on_actionFind_triggered()
+{
+}
+void Editor::on_actionFind_Next_triggered()
+{
+}
 
 /**
  * Program main function.
index 5c8fa502ac99929af98fc7e8e19990c3b137d18d..5e253f3e7dd18c44240a30f590710ccf9653ba8c 100644 (file)
@@ -8,6 +8,8 @@
 #include <QtGui/QLabel>
 
 
+#include "ui/editor.h"
+
 #define COMP_MODE      1
 #define GEN_MODE       2
 #define ALL_MODE       3
@@ -32,7 +34,7 @@ signals:
        void cursorMove();
 };
 
-class Editor : public QMainWindow {
+class Editor : public QMainWindow, private Ui::EditorWindow {
        Q_OBJECT
 public:
        QString compiler_path;
@@ -61,7 +63,7 @@ public slots:
        void log_prog();
 
        void findText();
-       void find_next();
+//     void find_next();
        //void gotoline();
        void updateline();
 
@@ -76,6 +78,19 @@ private:
        QString find_text;
        bool sensitive;
        char HomeDir[255];
+
+private slots:
+       void on_actionNew_triggered();
+       void on_actionOpen_triggered();
+       void on_actionSave_triggered();
+       void on_actionSave_as_triggered();
+       void on_actionQuit_triggered();
+       void on_actionCopy_triggered();
+       void on_actionPaste_triggered();
+       void on_actionCut_triggered();
+       void on_actionClear_all_triggered();
+       void on_actionFind_triggered();
+       void on_actionFind_Next_triggered();
 };
 
 #endif // QWERTY_H
diff --git a/src/edit/ui/editor.ui b/src/edit/ui/editor.ui
new file mode 100644 (file)
index 0000000..a669d79
--- /dev/null
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditorWindow</class>
+ <widget class="QMainWindow" name="EditorWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <layout class="QHBoxLayout" name="horizontalLayout">
+    <property name="leftMargin">
+     <number>3</number>
+    </property>
+    <property name="topMargin">
+     <number>0</number>
+    </property>
+    <property name="rightMargin">
+     <number>3</number>
+    </property>
+    <property name="bottomMargin">
+     <number>0</number>
+    </property>
+    <item>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QTextEdit" name="editor"/>
+      </item>
+      <item>
+       <widget class="QTextEdit" name="messages">
+        <property name="maximumSize">
+         <size>
+          <width>16777215</width>
+          <height>400</height>
+         </size>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">background-color: rgb(200, 200, 200);</string>
+        </property>
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+        <property name="textInteractionFlags">
+         <set>Qt::TextSelectableByMouse</set>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>19</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>File</string>
+    </property>
+    <addaction name="actionNew"/>
+    <addaction name="actionOpen"/>
+    <addaction name="actionSave"/>
+    <addaction name="actionSave_as"/>
+    <addaction name="separator"/>
+    <addaction name="actionQuit"/>
+   </widget>
+   <widget class="QMenu" name="menuEdit">
+    <property name="title">
+     <string>Edit</string>
+    </property>
+    <addaction name="actionCopy"/>
+    <addaction name="actionPaste"/>
+    <addaction name="actionCut"/>
+    <addaction name="actionClear_all"/>
+    <addaction name="separator"/>
+    <addaction name="actionFind"/>
+    <addaction name="actionFind_Next"/>
+   </widget>
+   <widget class="QMenu" name="menuCompile">
+    <property name="title">
+     <string>Compile</string>
+    </property>
+   </widget>
+   <widget class="QMenu" name="menuProperties">
+    <property name="title">
+     <string>Properties</string>
+    </property>
+   </widget>
+   <addaction name="menuFile"/>
+   <addaction name="menuEdit"/>
+   <addaction name="menuCompile"/>
+   <addaction name="menuProperties"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionNew">
+   <property name="text">
+    <string>New</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+N</string>
+   </property>
+  </action>
+  <action name="actionOpen">
+   <property name="text">
+    <string>Open</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+O</string>
+   </property>
+  </action>
+  <action name="actionSave">
+   <property name="text">
+    <string>Save</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+S</string>
+   </property>
+  </action>
+  <action name="actionSave_as">
+   <property name="text">
+    <string>Save as</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Shift+S</string>
+   </property>
+  </action>
+  <action name="actionQuit">
+   <property name="text">
+    <string>Quit</string>
+   </property>
+  </action>
+  <action name="actionCopy">
+   <property name="text">
+    <string>Copy</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Ins</string>
+   </property>
+  </action>
+  <action name="actionPaste">
+   <property name="text">
+    <string>Paste</string>
+   </property>
+   <property name="shortcut">
+    <string>Shift+Ins</string>
+   </property>
+  </action>
+  <action name="actionCut">
+   <property name="text">
+    <string>Cut</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Del</string>
+   </property>
+  </action>
+  <action name="actionClear_all">
+   <property name="text">
+    <string>Clear all</string>
+   </property>
+  </action>
+  <action name="actionFind">
+   <property name="text">
+    <string>Find</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+F</string>
+   </property>
+  </action>
+  <action name="actionFind_Next">
+   <property name="text">
+    <string>Find Next</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+L</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>