[55401] | 1 | /* $Id: UIGraphicsRotatorButton.h 103988 2024-03-21 13:49:47Z vboxsync $ */
|
---|
[42526] | 2 | /** @file
|
---|
[52727] | 3 | * VBox Qt GUI - UIGraphicsRotatorButton class declaration.
|
---|
[42526] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
[42526] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[42526] | 26 | */
|
---|
| 27 |
|
---|
[76581] | 28 | #ifndef FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsRotatorButton_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsRotatorButton_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[42526] | 33 |
|
---|
| 34 | /* GUI includes: */
|
---|
| 35 | #include "UIGraphicsButton.h"
|
---|
| 36 |
|
---|
| 37 | /* Forward declarations: */
|
---|
| 38 | class QStateMachine;
|
---|
| 39 | class QPropertyAnimation;
|
---|
| 40 |
|
---|
| 41 | /* Rotator graphics-button states: */
|
---|
| 42 | enum UIGraphicsRotatorButtonState
|
---|
| 43 | {
|
---|
| 44 | UIGraphicsRotatorButtonState_Default,
|
---|
| 45 | UIGraphicsRotatorButtonState_Animating,
|
---|
| 46 | UIGraphicsRotatorButtonState_Rotated
|
---|
| 47 | };
|
---|
| 48 | Q_DECLARE_METATYPE(UIGraphicsRotatorButtonState);
|
---|
| 49 |
|
---|
| 50 | /* Rotator graphics-button representation: */
|
---|
| 51 | class UIGraphicsRotatorButton : public UIGraphicsButton
|
---|
| 52 | {
|
---|
| 53 | Q_OBJECT;
|
---|
| 54 | Q_PROPERTY(UIGraphicsRotatorButtonState state READ state WRITE setState);
|
---|
| 55 |
|
---|
| 56 | signals:
|
---|
| 57 |
|
---|
| 58 | /* Rotation internal stuff: */
|
---|
| 59 | void sigToAnimating();
|
---|
| 60 | void sigToRotated();
|
---|
| 61 | void sigToDefault();
|
---|
| 62 |
|
---|
| 63 | /* Rotation external stuff: */
|
---|
| 64 | void sigRotationStart();
|
---|
| 65 | void sigRotationFinish(bool fRotated);
|
---|
| 66 |
|
---|
| 67 | public:
|
---|
| 68 |
|
---|
| 69 | /* Constructor: */
|
---|
| 70 | UIGraphicsRotatorButton(QIGraphicsWidget *pParent,
|
---|
| 71 | const QString &strPropertyName,
|
---|
| 72 | bool fToggled,
|
---|
| 73 | bool fReflected = false,
|
---|
| 74 | int iAnimationDuration = 300);
|
---|
| 75 |
|
---|
[42856] | 76 | /* API: Button-click stuff: */
|
---|
| 77 | void setAutoHandleButtonClick(bool fEnabled);
|
---|
| 78 |
|
---|
[42526] | 79 | /* API: Toggle stuff: */
|
---|
| 80 | void setToggled(bool fToggled, bool fAnimated = true);
|
---|
| 81 |
|
---|
| 82 | /* API: Subordinate animation stuff: */
|
---|
| 83 | void setAnimationRange(int iStart, int iEnd);
|
---|
| 84 | bool isAnimationRunning() const;
|
---|
| 85 |
|
---|
[42856] | 86 | protected slots:
|
---|
| 87 |
|
---|
| 88 | /* Handler: Button-click stuff: */
|
---|
| 89 | void sltButtonClicked();
|
---|
| 90 |
|
---|
[42526] | 91 | protected:
|
---|
| 92 |
|
---|
| 93 | /* Helpers: Update stuff: */
|
---|
[103988] | 94 | void refresh() RT_OVERRIDE RT_FINAL;
|
---|
[42526] | 95 |
|
---|
| 96 | private:
|
---|
| 97 |
|
---|
| 98 | /* Helpers: Rotate stuff: */
|
---|
| 99 | void updateRotationState();
|
---|
| 100 |
|
---|
| 101 | /* Property stiff: */
|
---|
| 102 | UIGraphicsRotatorButtonState state() const;
|
---|
| 103 | void setState(UIGraphicsRotatorButtonState state);
|
---|
| 104 |
|
---|
| 105 | /* Variables: */
|
---|
| 106 | bool m_fReflected;
|
---|
| 107 | UIGraphicsRotatorButtonState m_state;
|
---|
| 108 | QStateMachine *m_pAnimationMachine;
|
---|
| 109 | int m_iAnimationDuration;
|
---|
| 110 | QPropertyAnimation *m_pForwardButtonAnimation;
|
---|
| 111 | QPropertyAnimation *m_pBackwardButtonAnimation;
|
---|
| 112 | QPropertyAnimation *m_pForwardSubordinateAnimation;
|
---|
| 113 | QPropertyAnimation *m_pBackwardSubordinateAnimation;
|
---|
| 114 | };
|
---|
| 115 |
|
---|
[76581] | 116 | #endif /* !FEQT_INCLUDED_SRC_widgets_graphics_UIGraphicsRotatorButton_h */
|
---|