VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 3 weeks ago

Copyright year updates by scm.

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