trikRuntime
programmingWidget.h
Go to the documentation of this file.
1 /* Copyright 2016 Mikhail Kita
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/qglobal.h>
18 
19 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
20  #include <QtGui/QWidget>
21  #include <QtGui/QLabel>
22  #include <QtGui/QVBoxLayout>
23  #include <QtGui/QListWidget>
24  #include <QtGui/QMessageBox>
25  #include <QtGui/QScrollArea>
26 #else
27  #include <QtWidgets/QWidget>
28  #include <QtWidgets/QLabel>
29  #include <QtWidgets/QVBoxLayout>
30  #include <QtWidgets/QListWidget>
31  #include <QtWidgets/QMessageBox>
32  #include <QtWidgets/QScrollArea>
33 #endif
34 
35 #include <QtCore/QString>
36 
37 #include "trikGuiDialog.h"
38 #include "controller.h"
39 #include "connectButton.h"
40 #include "scriptHolder.h"
41 
42 namespace trikGui {
43 
46 {
47  Q_OBJECT
48 
49 public:
53  explicit ProgrammingWidget(Controller &controller, QWidget *parent = 0);
54 
56  static QString menuEntry();
57 
58  void renewFocus() override;
59 
60 protected:
61  void keyPressEvent(QKeyEvent *event) override;
62 
63 private slots:
65  void addCommand();
66 
67 private:
68  QLabel mTitle;
69  QVBoxLayout mLayout;
70  QListWidget mCommands;
71  Controller &mController;
72 
74  int mEmptyCommandsCounter;
75 
77  const QString mScript =
78  "var __interpretation_started_timestamp__;\n"
79  "var pi = 3.14159265;\n\n"
80  "var main = function()\n"
81  "{\n"
82  " __interpretation_started_timestamp__ = Date.now();\n";
83 };
84 
85 }
Provides backend features like Qt Script runner for frontend.
Definition: controller.h:35
Widget which allows to write simple programs via the robot interface.
Definition: programmingWidget.h:45
Base class for all trikGui dialog widgets.
Definition: trikGuiDialog.h:24
ProgrammingWidget(Controller &controller, QWidget *parent=0)
Constructor.
Definition: programmingWidget.cpp:26
void keyPressEvent(QKeyEvent *event) override
Definition: programmingWidget.cpp:65
Definition: abstractIndicator.h:21
static QString menuEntry()
Returns menu entry for this widget.
Definition: programmingWidget.cpp:55
void renewFocus() override
Set focus properly on this widget or one of its children.
Definition: programmingWidget.cpp:60