trikRuntime
numberSelectionWidget.h
Go to the documentation of this file.
1 /* Copyright 2014 CyberTech Labs Ltd.
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/QHBoxLayout>
22 #else
23  #include <QtWidgets/QWidget>
24  #include <QtWidgets/QHBoxLayout>
25 #endif
26 
27 #include "digitSelector.h"
28 
29 namespace trikGui {
30 
32 class NumberSelectionWidget : public QWidget
33 {
34  Q_OBJECT
35 
36 public:
44  NumberSelectionWidget(int defaultValue, int digits, int separator, int height, QWidget *parent = 0);
45 
47  int value() const;
48 
50  void setValue(int value);
51 
53  bool hasFocusInside();
54 
55 signals:
57  void valueChanged(int newValue);
58 
61  void upPressed();
62 
65  void downPressed();
66 
67 protected:
68  void keyPressEvent(QKeyEvent *event) override;
69  void focusInEvent(QFocusEvent *event) override;
70 
71 private slots:
72  void onValueChanged();
73 
74 private:
75  QList<DigitSelector *> lineEdits() const;
76 
77  QHBoxLayout mLayout;
78  int mCurrentDigit;
79  int mDigits;
80  bool mEditingMode;
81 };
82 
83 }
void upPressed()
Widget is not in editing mode and user pressed "up".
void setValue(int value)
Sets current value. Does not emit valueChanged() signal.
Definition: numberSelectionWidget.cpp:84
void valueChanged(int newValue)
Emitted when number is changed by user.
Widget that allows to input integer numbers using robot keys.
Definition: numberSelectionWidget.h:32
void focusInEvent(QFocusEvent *event) override
Definition: numberSelectionWidget.cpp:123
void downPressed()
Widget is not in editing mode and user pressed "up".
NumberSelectionWidget(int defaultValue, int digits, int separator, int height, QWidget *parent=0)
Constructor.
Definition: numberSelectionWidget.cpp:27
int value() const
Returns current entered number.
Definition: numberSelectionWidget.cpp:73
Definition: abstractIndicator.h:21
void keyPressEvent(QKeyEvent *event) override
Definition: numberSelectionWidget.cpp:94
bool hasFocusInside()
True, if widget or one of its children has keyboard input focus.
Definition: numberSelectionWidget.cpp:61