File tree Expand file tree Collapse file tree 8 files changed +224
-2
lines changed Expand file tree Collapse file tree 8 files changed +224
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,10 @@ set(tui_src
40
40
# EDIT
41
41
# add source for any GUI modules here
42
42
set (gui_src
43
- )
43
+ notebook_app.hpp notebook_app.cpp
44
+ input_widget.hpp input_widget.cpp
45
+ output_widget.hpp output_widget.cpp
46
+ )
44
47
45
48
# EDIT
46
49
# add source for any GUI tests here
Original file line number Diff line number Diff line change
1
+ #include " input_widget.hpp"
2
+
3
+ #include < QWidget>
4
+ #include < QDebug>
5
+ #include < QLineEdit>
6
+
7
+ // public:
8
+ InputWidget::InputWidget (QWidget * parent): QPlainTextEdit(parent){
9
+
10
+ // inputExp = new QLineEdit();
11
+ // inputExp = new QLineEdit();
12
+ // inputExp->setParent(parent);
13
+ // QObject::connect();
14
+
15
+ // Evaluate
16
+ }
17
+ /*
18
+ QString InputWidget::getUserText(){
19
+ return inputExp;
20
+ }
21
+
22
+ Expression InputWidget::getEvalResult(){
23
+ return result;
24
+ }
25
+
26
+ //private slots:
27
+ void InputWidget::textChanged(std::string s){
28
+ qDebug() << s;
29
+ inputExp = s;
30
+ }
31
+ */
32
+ void InputWidget::keyPressEvent (QKeyEvent * event){
33
+ // Stub
34
+ }
35
+
36
+
Original file line number Diff line number Diff line change
1
+ #ifndef INPUT_WIDGET_H
2
+ #define INPUT_WIDGET_H
3
+
4
+ #include < QPlainTextEdit>
5
+ #include < QLineEdit>
6
+ #include < QWidget>
7
+ #include < QDebug>
8
+ #include < QKeyEvent>
9
+
10
+ #include < QString>
11
+ #include < string>
12
+
13
+ class InputWidget : public QPlainTextEdit
14
+ {
15
+ Q_OBJECT // Necessary macro in class definition
16
+
17
+ public:
18
+ InputWidget (QWidget * parent = nullptr );
19
+
20
+ // std::string getUserText();
21
+ // QString getUserText();
22
+ // Expression getEvalResult();
23
+
24
+ // public slots:
25
+
26
+ private slots:
27
+ // void textChanged(QString text);
28
+
29
+ signals:
30
+ // When the shift+enter keys are pushed, the text is put into the stream
31
+ void textChanged (QString text);
32
+
33
+ private:
34
+ // QLineEdit * value;
35
+ // std::string inputExp;
36
+ QString inputExp;
37
+ // QLineEdit * inputExp;
38
+ void keyPressEvent (QKeyEvent *event);
39
+ // signals: // Neither public nor private
40
+ // Expression * result; // Send result to OutputWidget
41
+ };
42
+ #endif // INPUT_WIDGET_H
Original file line number Diff line number Diff line change 1
1
#include < QApplication>
2
2
#include < QWidget>
3
3
4
+ #include " notebook_app.hpp"
5
+
4
6
int main (int argc, char *argv[])
5
7
{
6
8
QApplication app (argc, argv);
7
9
8
- QWidget widget;
10
+ NotebookApp widget;
9
11
10
12
widget.show ();
11
13
Original file line number Diff line number Diff line change
1
+ #include " notebook_app.hpp"
2
+
3
+ // #include <InputWidget>
4
+ // #include <OutputWidget>
5
+
6
+ // #include <QLayout>
7
+ // #include <QDebug>
8
+
9
+ NotebookApp::NotebookApp (QWidget * parent): QWidget(parent){
10
+
11
+ input = new InputWidget ();
12
+ input->setParent (parent);
13
+
14
+ output = new OutputWidget ();
15
+ output->setParent (parent);
16
+
17
+ QObject::connect (input, SIGNAL (textChanged (QString)),
18
+ output, SLOT (showResult (QString)));
19
+
20
+ auto layout = new QGridLayout ();
21
+
22
+ // layout->addWidget(widget, row, column)
23
+ layout->addWidget (input, 0 , 0 );
24
+ layout->addWidget (output, 1 , 0 );
25
+
26
+ setLayout (layout);
27
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef NOTEBOOK_APP_H
2
+ #define NOTEBOOK_APP_H
3
+
4
+ #include < QWidget>
5
+ #include < QLayout>
6
+ #include < QDebug>
7
+
8
+ #include " input_widget.hpp"
9
+ #include " output_widget.hpp"
10
+
11
+ class NotebookApp : public QWidget // Extends QObject base class
12
+ {
13
+ Q_OBJECT // Necessary macro first line of class definition
14
+
15
+ public:
16
+ NotebookApp (QWidget * parent = nullptr );
17
+
18
+ // public slots:
19
+
20
+ private slots:
21
+ // Keypress in the input widget has occurred
22
+ // void plotScriptUpdated(std::string input);
23
+
24
+ private:
25
+ InputWidget * input;
26
+ OutputWidget * output;
27
+
28
+ // signals: // Neither public nor private
29
+
30
+ };
31
+ #endif // NOTEBOOK_APP_H
Original file line number Diff line number Diff line change
1
+ #include " output_widget.hpp"
2
+
3
+ // #include <QGraphicsView>
4
+ // #include <QGraphicsScene>
5
+ // #include <QLineEdit>
6
+ // #include <QDebug>
7
+ #include < QWidget>
8
+ #include < QDebug>
9
+ #include < QLayout>
10
+
11
+
12
+ // public:
13
+ OutputWidget::OutputWidget (QWidget * parent){
14
+
15
+ image = new QGraphicsView;
16
+ // QObject::connect();
17
+
18
+
19
+ display = new QGraphicsScene;
20
+ // QObject::connect();
21
+
22
+ // Display
23
+ auto layout = new QGridLayout ();
24
+ // layout->addWidget(widget, row, column)
25
+ layout->addWidget (image, 0 , 0 );
26
+
27
+ setLayout (layout);
28
+ }
29
+
30
+ // public slots:
31
+ void OutputWidget::showResult (QString res){
32
+ // qDebug() << "Hello World!";
33
+ qDebug () << res;
34
+ result = res;
35
+
36
+ }
37
+ /*
38
+ void OutputWidget::resultEvaluated(Expression res){
39
+ qDebug() << s;
40
+ inputExp = s;
41
+ qDebug() << "Hello World!";
42
+ }
43
+ */
44
+
Original file line number Diff line number Diff line change
1
+ #ifndef OUTPUT_WIDGET_H
2
+ #define OUTPUT_WIDGET_H
3
+
4
+ #include < QWidget>
5
+ #include < QGraphicsView>
6
+ #include < QGraphicsScene>
7
+ #include < QGraphicsLayout>
8
+ #include < QLayout>
9
+ #include < QBoxLayout>
10
+
11
+ // class GraphicsView;
12
+ // class GraphicsScene;
13
+
14
+ class OutputWidget : public QWidget // Extends QWidget base class
15
+ {
16
+ Q_OBJECT // Necessary macro in class definition
17
+
18
+ public:
19
+ OutputWidget (QWidget * parent = nullptr );
20
+
21
+ public slots:
22
+ // void resultEvaluated(Expression res); // Catch the result of evaluating input
23
+ void showResult (QString res);
24
+
25
+ // private slots:
26
+
27
+ private:
28
+ QGraphicsView * image;
29
+ QGraphicsScene * display;
30
+
31
+ QString result;
32
+ // std::string result;
33
+
34
+ // signals: // Neither public nor private
35
+
36
+ };
37
+ #endif // OUTPUT_WIDGET_H
You can’t perform that action at this time.
0 commit comments