VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISlidingWidget.h@ 100347

Last change on this file since 100347 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: UISlidingWidget.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISlidingWidget class declaration.
4 */
5
6/*
7 * Copyright (C) 2017-2023 Oracle and/or its affiliates.
8 *
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
26 */
27
28#ifndef FEQT_INCLUDED_SRC_widgets_UISlidingWidget_h
29#define FEQT_INCLUDED_SRC_widgets_UISlidingWidget_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QWidget>
36
37/* Other VBox includes: */
38#include <iprt/cdefs.h>
39
40/* Forward declarations: */
41class QBoxLayout;
42class QRect;
43class QWidget;
44class UIAnimation;
45
46
47/** Some kind of splitter which allows to switch between
48 * two widgets using horizontal sliding animation. */
49class UISlidingWidget : public QWidget
50{
51 Q_OBJECT;
52 Q_PROPERTY(QRect widgetGeometry READ widgetGeometry WRITE setWidgetGeometry);
53 Q_PROPERTY(QRect startWidgetGeometry READ startWidgetGeometry);
54 Q_PROPERTY(QRect finalWidgetGeometry READ finalWidgetGeometry);
55
56signals:
57
58 /** Commands to move animation forward. */
59 void sigForward();
60 /** Commands to move animation backward. */
61 void sigBackward();
62
63public:
64
65 /** Sliding state. */
66 enum State
67 {
68 State_Start,
69 State_GoingForward,
70 State_Final,
71 State_GoingBackward
72 };
73
74 /** Constructs sliding widget passing @a pParent to the base-class.
75 * @param enmOrientation Brings the widget orientation. */
76 UISlidingWidget(Qt::Orientation enmOrientation, QWidget *pParent = 0);
77
78 /** Holds the minimum widget size. */
79 virtual QSize minimumSizeHint() const /* pverride */;
80
81 /** Defines @a pWidget1 and @a pWidget2. */
82 void setWidgets(QWidget *pWidget1, QWidget *pWidget2);
83
84 /** Returns sliding state. */
85 State state() const { return m_enmState; }
86
87 /** Moves animation forward. */
88 void moveForward() { m_enmState = State_GoingForward; emit sigForward(); }
89 /** Moves animation backward. */
90 void moveBackward() { m_enmState = State_GoingBackward; emit sigBackward(); }
91
92protected:
93
94 /** Handles any Qt @a pEvent. */
95 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
96
97 /** Handles resize @a pEvent. */
98 virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
99
100private slots:
101
102 /** Marks state as start. */
103 void sltSetStateToStart() { m_enmState = State_Start; }
104 /** Marks state as final. */
105 void sltSetStateToFinal() { m_enmState = State_Final; }
106
107private:
108
109 /** Prepares all. */
110 void prepare();
111
112 /** Updates animation. */
113 void updateAnimation();
114
115 /** Defines sub-window geometry. */
116 void setWidgetGeometry(const QRect &rect);
117 /** Returns sub-window geometry. */
118 QRect widgetGeometry() const;
119 /** Returns sub-window start-geometry. */
120 QRect startWidgetGeometry() const { return m_startWidgetGeometry; }
121 /** Returns sub-window final-geometry. */
122 QRect finalWidgetGeometry() const { return m_finalWidgetGeometry; }
123
124 /** Holds the widget orientation. */
125 Qt::Orientation m_enmOrientation;
126
127 /** Holds whether we are in animation final state. */
128 State m_enmState;
129 /** Holds the shift left/right animation instance. */
130 UIAnimation *m_pAnimation;
131 /** Holds sub-window start-geometry. */
132 QRect m_startWidgetGeometry;
133 /** Holds sub-window final-geometry. */
134 QRect m_finalWidgetGeometry;
135
136 /** Holds the private sliding widget instance. */
137 QWidget *m_pWidget;
138 /** Holds the widget layout instance. */
139 QBoxLayout *m_pLayout;
140 /** Holds the 1st widget reference. */
141 QWidget *m_pWidget1;
142 /** Holds the 2nd widget reference. */
143 QWidget *m_pWidget2;
144};
145
146#endif /* !FEQT_INCLUDED_SRC_widgets_UISlidingWidget_h */
147
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette