VirtualBox

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

Last change on this file was 104358, checked in by vboxsync, 5 weeks ago

FE/Qt. bugref:10622. More refactoring around the retranslation functionality.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/* $Id: QIArrowButtonPress.cpp 104358 2024-04-18 05:33:40Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QIArrowButtonPress class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-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/* Qt includes: */
29#include <QKeyEvent>
30
31/* GUI includes: */
32#include "QIArrowButtonPress.h"
33#include "UITranslationEventListener.h"
34
35QIArrowButtonPress::QIArrowButtonPress(QIArrowButtonPress::ButtonType enmButtonType,
36 QWidget *pParent /* = 0 */)
37 : QIRichToolButton(pParent)
38 , m_enmButtonType(enmButtonType)
39{
40 /* Retranslate UI: */
41 sltRetranslateUI();
42 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
43 this, &QIArrowButtonPress::sltRetranslateUI);
44}
45
46void QIArrowButtonPress::sltRetranslateUI()
47{
48 /* Retranslate: */
49 switch (m_enmButtonType)
50 {
51 case ButtonType_Back: setText(tr("&Back")); break;
52 case ButtonType_Next: setText(tr("&Next")); break;
53 default: break;
54 }
55}
56
57void QIArrowButtonPress::keyPressEvent(QKeyEvent *pEvent)
58{
59 /* Handle different keys: */
60 switch (pEvent->key())
61 {
62 /* Animate-click for the Space key: */
63 case Qt::Key_PageUp: if (m_enmButtonType == ButtonType_Next) return animateClick(); break;
64 case Qt::Key_PageDown: if (m_enmButtonType == ButtonType_Back) return animateClick(); break;
65 default: break;
66 }
67 /* Call to base-class: */
68 QIRichToolButton::keyPressEvent(pEvent);
69}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use