Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/axiscontrol.h
1 | /* Atelier KDE Printer Host for 3D Printing | 1 | /* AtCore Test Client | ||
---|---|---|---|---|---|
2 | Copyright (C) <2016> | 2 | Copyright (C) <2016 - 2018> | ||
laysrodrigues: 2016-2018 | |||||
3 | Author: Lays Rodrigues - lays.rodrigues@kde.org | 3 | | ||
4 | Chris Rizzitello - rizzitello@kde.org | 4 | Authors: | ||
5 | Chris Rizzitello <rizzitello@kde.org> | ||||
5 | 6 | | |||
6 | This program is free software: you can redistribute it and/or modify | 7 | This program is free software: you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation, either version 3 of the License, or | 9 | the Free Software Foundation, either version 3 of the License, or | ||
9 | (at your option) any later version. | 10 | (at your option) any later version. | ||
10 | 11 | | |||
11 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
15 | 16 | | |||
16 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 19 | */ | ||
19 | #pragma once | 20 | #pragma once | ||
20 | 21 | #include <QDoubleSpinBox> | |||
21 | #include <QObject> | 22 | #include <QPushButton> | ||
22 | #include <QGraphicsView> | 23 | #include <QString> | ||
23 | #include <QGraphicsEllipseItem> | 24 | #include <QWidget> | ||
24 | 25 | | |||
25 | #include "atcorewidgets_export.h" | 26 | #include "atcorewidgets_export.h" | ||
26 | 27 | | |||
27 | class ATCOREWIDGETS_EXPORT PieButton : public QObject, public QGraphicsEllipseItem | | |||
28 | { | | |||
29 | Q_OBJECT | | |||
30 | public: | | |||
31 | PieButton(QLatin1Char &axis, int value, int size, int angle); | | |||
32 | void setPalette(QPalette palette); | | |||
33 | protected: | | |||
34 | void mousePressEvent(QGraphicsSceneMouseEvent *); | | |||
35 | void hoverEnterEvent(QGraphicsSceneHoverEvent *); | | |||
36 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *); | | |||
37 | signals: | | |||
38 | void clicked(QLatin1Char axis, int value); | | |||
39 | private: | | |||
40 | QLatin1Char _axis; | | |||
41 | int _value; | | |||
42 | QPalette _palette; | | |||
43 | }; | | |||
44 | | ||||
45 | class ATCOREWIDGETS_EXPORT RectButton : public QObject, public QGraphicsRectItem | | |||
46 | { | | |||
47 | Q_OBJECT | | |||
48 | | ||||
49 | public: | | |||
50 | RectButton(QLatin1Char &axis, int value, int size); | | |||
51 | void setPalette(QPalette palette); | | |||
52 | protected: | | |||
53 | void mousePressEvent(QGraphicsSceneMouseEvent *); | | |||
54 | void hoverEnterEvent(QGraphicsSceneHoverEvent *); | | |||
55 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *); | | |||
56 | signals: | | |||
57 | void clicked(QLatin1Char axis, int value); | | |||
58 | private: | | |||
59 | QLatin1Char _axis; | | |||
60 | int _value; | | |||
61 | QPalette _palette; | | |||
62 | }; | | |||
63 | | ||||
64 | /** | 28 | /** | ||
65 | * @brief AxisControl is a Widget to generate axis relative movements. | 29 | * @brief AxisControl is a Widget to generate axis relative movements. | ||
66 | * | 30 | * | ||
67 | * Usage: | 31 | * Usage: | ||
68 | * Create a instance of AxisControl and connect the clicked signal, it will give you the axis and value that was clicked. | 32 | * Create a instance of AxisControl and connect the clicked signal, it will give you the axis and value that was clicked. | ||
69 | */ | 33 | */ | ||
70 | class ATCOREWIDGETS_EXPORT AxisControl : public QGraphicsView | 34 | class ATCOREWIDGETS_EXPORT AxisControl : public QWidget | ||
71 | { | 35 | { | ||
72 | Q_OBJECT | 36 | Q_OBJECT | ||
73 | 37 | | |||
74 | public: | 38 | public: | ||
75 | explicit AxisControl(const QList<int> &movementValues = {1, 10, 25}, QWidget *parent = nullptr); | 39 | /** | ||
76 | 40 | * @brief Create a new AxisControl | |||
77 | private: | 41 | * @param parent | ||
78 | void setLabels(QGraphicsItem *item, QLatin1Char &axis, int value); | 42 | */ | ||
79 | 43 | AxisControl(QWidget *parent = nullptr); | |||
patrickelectric: Sorry for asking, but why explicit is necessary here ? | |||||
80 | protected: | 44 | ~AxisControl() = default; | ||
patrickelectric: = default | |||||
81 | void resizeEvent(QResizeEvent *); | | |||
82 | 45 | | |||
83 | signals: | 46 | signals: | ||
84 | /** | 47 | /** | ||
85 | * @brief User has clicked to move an axis. | 48 | * @brief User has clicked to move an axis. | ||
86 | * @param axis: Axis to move | 49 | * @param axis: Axis to move | ||
87 | * @param value: Amount to move | 50 | * @param value: Amount to move | ||
88 | */ | 51 | */ | ||
89 | void clicked(QLatin1Char axis, int value); | 52 | void clicked(const QLatin1Char axis, double value); | ||
patrickelectric: QLatin1Char& | |||||
sorry, patrick's wrong here. tcanabrava: sorry, patrick's wrong here.
QLatin1Char should be passed as value, not ref.
(the sizeof… | |||||
The documentation says that is a class with functions. struct QLatin1Char { public: Q_DECL_CONSTEXPR inline explicit QLatin1Char(char c) Q_DECL_NOTHROW : ch(c) {} Q_DECL_CONSTEXPR inline char toLatin1() const Q_DECL_NOTHROW { return ch; } Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); } private: char ch; }; patrickelectric: The documentation says that is a class with functions.
http://doc.qt.io/qt-5/qlatin1char.html… | |||||
tcanabrava: so?
| |||||
patrickelectric: Sith, tomaz is correct, I just talked with him. | |||||
Ok no const ref for QLatin1Char. I Will "fix" this for the rest of atcore tonight rizzitello: Ok no const ref for QLatin1Char. I Will "fix" this for the rest of atcore tonight | |||||
90 | 53 | | |||
54 | /** | ||||
55 | * @brief User has changed the units. | ||||
56 | * @param selection: Selection of Metric (0) or Imperial(1) | ||||
57 | */ | ||||
58 | void unitsChanged(int selection); | ||||
59 | | ||||
60 | private: | ||||
61 | /** | ||||
62 | * @brief Create A push button connected to the emit event | ||||
63 | * @param axis: Single letter of the axis (X,Y,Z,E) | ||||
64 | * @param multiplier: Used to set the move direction set to 1 or -1 | ||||
65 | * @param iconSize: size to set the icon | ||||
66 | * @param themeIcon: icon to use "fromTheme" | ||||
67 | * @param fallbackText: Fallback text if theme fails | ||||
68 | * @return The Created PushButton | ||||
69 | */ | ||||
70 | QPushButton *makeButton(const QLatin1Char axis, int multiplier, const QSize &iconSize, const QString &themeIcon, const QString &fallbackText); | ||||
71 | | ||||
72 | /** | ||||
73 | * @brief makeSimpleAxis | ||||
74 | * @param axis: Axis | ||||
75 | * @param iconSize: Size of the icon | ||||
76 | * @return Simple Axis Widget | ||||
77 | */ | ||||
78 | QWidget *makeSimpleAxis(const QLatin1Char axis, const QSize &iconSize); | ||||
79 | QDoubleSpinBox *sbValue = nullptr; | ||||
91 | }; | 80 | }; |
2016-2018