VirtualBox

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

Last change on this file since 35740 was 33540, checked in by vboxsync, 14 years ago

*: spelling fixes, thanks Timeless!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/* $Id: QIArrowButtonSwitch.cpp 33540 2010-10-28 09:27:05Z vboxsync $ */
2/** @file
3 *
4 * VBox frontends: Qt GUI ("VirtualBox"):
5 * VirtualBox Qt extensions: QIArrowButtonSwitch class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2008 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20/* VBox includes */
21#include "QIArrowButtonSwitch.h"
22#include "UIIconPool.h"
23
24/* Qt includes */
25#include <QKeyEvent>
26
27
28/** @class QIArrowButtonSwitch
29 *
30 * The QIArrowButtonSwitch class is an arrow tool-button with text-label,
31 * used as collaps/expand switch in QIMessageBox class.
32 *
33 */
34
35QIArrowButtonSwitch::QIArrowButtonSwitch (QWidget *aParent)
36 : QIRichToolButton (aParent)
37 , mIsExpanded (false)
38{
39 updateIcon();
40}
41
42QIArrowButtonSwitch::QIArrowButtonSwitch (const QString &aName, QWidget *aParent)
43 : QIRichToolButton (aName, aParent)
44 , mIsExpanded (false)
45{
46 updateIcon();
47}
48
49void QIArrowButtonSwitch::buttonClicked()
50{
51 mIsExpanded = !mIsExpanded;
52 updateIcon();
53 QIRichToolButton::buttonClicked();
54}
55
56void QIArrowButtonSwitch::updateIcon()
57{
58 mButton->setIcon(UIIconPool::iconSet(mIsExpanded ?
59 ":/arrow_down_10px.png" : ":/arrow_right_10px.png"));
60}
61
62bool QIArrowButtonSwitch::eventFilter (QObject *aObject, QEvent *aEvent)
63{
64 /* Process only QIArrowButtonSwitch or children */
65 if (!(aObject == this || children().contains (aObject)))
66 return QIRichToolButton::eventFilter (aObject, aEvent);
67
68 /* Process keyboard events */
69 if (aEvent->type() == QEvent::KeyPress)
70 {
71 QKeyEvent *kEvent = static_cast <QKeyEvent*> (aEvent);
72 if ((mIsExpanded && kEvent->key() == Qt::Key_Minus) ||
73 (!mIsExpanded && kEvent->key() == Qt::Key_Plus))
74 animateClick();
75 }
76
77 /* Default one handler */
78 return QIRichToolButton::eventFilter (aObject, aEvent);
79}
80
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use