trikRuntime
motorsWidget.h
Go to the documentation of this file.
1 /* Copyright 2014 Roman Kurbatov
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/QVBoxLayout>
22  #include <QtGui/QScrollArea>
23 #else
24  #include <QtWidgets/QWidget>
25  #include <QtWidgets/QVBoxLayout>
26  #include <QtWidgets/QScrollArea>
27 #endif
28 
29 #include <QtCore/QString>
30 #include <QtCore/QStringList>
31 #include <QtCore/QVector>
32 
34 
35 #include "trikGuiDialog.h"
36 
37 namespace trikGui {
38 
39 class MotorLever;
40 
43 {
44  Q_OBJECT
45 
46 public:
53  , QWidget *parent = 0);
54 
56  ~MotorsWidget() override;
57 
59  static QString menuEntry(trikControl::MotorInterface::Type type);
60 
61  void renewFocus() override;
62 
63  bool eventFilter(QObject *, QEvent *event) override;
64 
65 protected:
66  void keyPressEvent(QKeyEvent *event) override;
67 
68 private:
69  void ensureFocusedWidgetVisible();
70 
71 private slots:
74  void fixLeversPosition();
75 
76 private:
78  QStringList mPorts;
79  QVector<MotorLever *> mLevers; // Has ownership.
80  QScrollArea *mScrollArea; // Has ownership.
81 };
82 
83 }
Base class for all trikGui dialog widgets.
Definition: trikGuiDialog.h:24
MotorsWidget(trikControl::BrickInterface &brick, trikControl::MotorInterface::Type type, QWidget *parent=0)
Constructor.
Definition: motorsWidget.cpp:35
Widget that allows to test motors connected to TRIK controller.
Definition: motorsWidget.h:42
bool eventFilter(QObject *, QEvent *event) override
Definition: motorsWidget.cpp:97
void keyPressEvent(QKeyEvent *event) override
Definition: motorsWidget.cpp:129
Definition: abstractIndicator.h:21
void renewFocus() override
Set focus properly on this widget or one of its children.
Definition: motorsWidget.cpp:90
Type
Definition: motorInterface.h:31
~MotorsWidget() override
Destructor.
Definition: motorsWidget.cpp:71
static QString menuEntry(trikControl::MotorInterface::Type type)
Title for this widget in a main menu.
Definition: motorsWidget.cpp:76
Interface representing TRIK controller board and devices installed on it, also provides access to per...
Definition: brickInterface.h:46