VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIArrowButtonSwitch.cpp@ 96407

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

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/* $Id: QIArrowButtonSwitch.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QIArrowButtonSwitch class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2022 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/* Qt includes: */
29#include <QKeyEvent>
30
31/* GUI includes: */
32#include "QIArrowButtonSwitch.h"
33
34
35QIArrowButtonSwitch::QIArrowButtonSwitch(QWidget *pParent /* = 0 */)
36 : QIRichToolButton(pParent)
37 , m_fExpanded(false)
38{
39 /* Update icon: */
40 updateIcon();
41}
42
43void QIArrowButtonSwitch::setIcons(const QIcon &iconCollapsed, const QIcon &iconExpanded)
44{
45 /* Assign icons: */
46 m_iconCollapsed = iconCollapsed;
47 m_iconExpanded = iconExpanded;
48 /* Update icon: */
49 updateIcon();
50}
51
52void QIArrowButtonSwitch::setExpanded(bool fExpanded)
53{
54 /* Set button state: */
55 m_fExpanded = fExpanded;
56 /* Update icon: */
57 updateIcon();
58}
59
60void QIArrowButtonSwitch::sltButtonClicked()
61{
62 /* Toggle button state: */
63 m_fExpanded = !m_fExpanded;
64 /* Update icon: */
65 updateIcon();
66}
67
68void QIArrowButtonSwitch::keyPressEvent(QKeyEvent *pEvent)
69{
70 /* Handle different keys: */
71 switch (pEvent->key())
72 {
73 /* Animate-click for the Space key: */
74 case Qt::Key_Minus: if (m_fExpanded) return animateClick(); break;
75 case Qt::Key_Plus: if (!m_fExpanded) return animateClick(); break;
76 default: break;
77 }
78 /* Call to base-class: */
79 QIRichToolButton::keyPressEvent(pEvent);
80}
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