trikRuntime
commandsListWidget.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 #else
25  #include <QtWidgets/QWidget>
26  #include <QtWidgets/QLabel>
27  #include <QtWidgets/QVBoxLayout>
28  #include <QtWidgets/QListWidget>
29 #endif
30 
31 #include <QtCore/QString>
32 
33 #include "trikGuiDialog.h"
34 #include "controller.h"
35 
36 namespace trikGui {
37 
40 {
41  Q_OBJECT
42 
43 public:
48  CommandsListWidget(Controller &controller, const QString &name, QWidget *parent = 0);
49 
51  static QString menuEntry();
52 
53  void renewFocus() override;
54 
56  QString value() const;
57 
59  QString script() const;
60 
61 protected:
62  void keyPressEvent(QKeyEvent *event) override;
63 
64 private slots:
66  void motorBehaviour();
67 
71  void sensorBehaviour(const QString &port, bool isEncoder);
72 
73 private:
74  QVBoxLayout mLayout;
75  QLabel mTitle;
76  QListWidget mCommands;
77  Controller &mController;
78 
80  QString mValue;
81 
83  QString mScript;
84 };
85 
86 }
CommandsListWidget(Controller &controller, const QString &name, QWidget *parent=0)
Constructor.
Definition: commandsListWidget.cpp:27
Provides backend features like Qt Script runner for frontend.
Definition: controller.h:35
static const int port
Definition: trikCommunicatorTest.cpp:24
Base class for all trikGui dialog widgets.
Definition: trikGuiDialog.h:24
void keyPressEvent(QKeyEvent *event) override
Definition: commandsListWidget.cpp:73
static QString menuEntry()
Returns menu entry for this widget.
Definition: commandsListWidget.cpp:63
Definition: abstractIndicator.h:21
void renewFocus() override
Set focus properly on this widget or one of its children.
Definition: commandsListWidget.cpp:68
Widget which allows to choose commands for robot.
Definition: commandsListWidget.h:39
QString script() const
Returns string with part of script.
Definition: commandsListWidget.cpp:162
QString value() const
Returns string with new name of command.
Definition: commandsListWidget.cpp:157