File indexing completed on 2024-05-12 04:41:11

0001 /* AtCore KDE Libary for 3D Printers
0002     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0003     SPDX-FileCopyrightText: 2017-2018, 2020 Chris Rizzitello <rizzitello@kde.org>
0004     SPDX-FileCopyrightText: 2018 Lays Rodrigues <lays.rodrigues@kde.org>
0005 */
0006 
0007 #pragma once
0008 #include <QWidget>
0009 
0010 #include "atcorewidgets_export.h"
0011 
0012 class QDoubleSpinBox;
0013 class QPushButton;
0014 class QString;
0015 
0016 /**
0017  * @brief AxisControl is a Widget to generate axis relative movements.
0018  *
0019  * Usage:
0020  * Create a instance of AxisControl and connect the clicked signal, it will give you the axis and value that was clicked.
0021  */
0022 class ATCOREWIDGETS_EXPORT AxisControl : public QWidget
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     /**
0028      * @brief Create a new AxisControl
0029      * @param parent
0030      */
0031     explicit AxisControl(QWidget *parent = nullptr);
0032     ~AxisControl() = default;
0033 
0034 signals:
0035     /**
0036      * @brief User has clicked to move an axis.
0037      * @param axis: Axis to move
0038      * @param value: Amount to move
0039      */
0040     void clicked(const QLatin1Char axis, double value);
0041 
0042     /**
0043      * @brief User has changed the units.
0044      * @param selection: Selection of Metric (0) or Imperial(1)
0045      */
0046     void unitsChanged(int selection);
0047 
0048 private:
0049     /**
0050      * @brief Create A push button connected to the emit event
0051      * @param axis: Single letter of the axis (X,Y,Z,E)
0052      * @param multiplier: Used to set the move direction set to 1 or -1
0053      * @param iconSize: size to set the icon
0054      * @param themeIcon: icon to use "fromTheme"
0055      * @param fallbackText: Fallback text if theme fails
0056      * @return  The Created PushButton
0057      */
0058     QPushButton *makeButton(const QLatin1Char axis, int multiplier, const QSize &iconSize, const QString &themeIcon, const QString &fallbackText);
0059 
0060     /**
0061      * @brief makeSimpleAxis
0062      * @param axis: Axis
0063      * @param iconSize: Size of the icon
0064      * @return Simple Axis Widget
0065      */
0066     QWidget *makeSimpleAxis(const QLatin1Char axis, const QSize &iconSize);
0067     QDoubleSpinBox *sbValue = nullptr;
0068 };