VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UITranslationEventListener.cpp@ 103977

Last change on this file since 103977 was 103920, checked in by vboxsync, 9 months ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in soft keyboard classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1/* $Id: UITranslationEventListener.cpp 103920 2024-03-19 14:40:59Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UITranslationEventListener 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 <QApplication>
30
31/* GUI includes: */
32#include "UITranslationEventListener.h"
33#include "UITranslator.h"
34
35/* static */
36UITranslationEventListener *UITranslationEventListener::s_pInstance = 0;
37
38UITranslationEventListener *UITranslationEventListener::instance()
39{
40 return s_pInstance;
41}
42
43/* static */
44void UITranslationEventListener::create()
45{
46 /* Make sure instance is NOT created yet: */
47 if (s_pInstance)
48 return;
49
50 /* Create instance: */
51 new UITranslationEventListener;
52}
53
54/* static */
55void UITranslationEventListener::destroy()
56{
57 /* Make sure instance is NOT destroyed yet: */
58 if (!s_pInstance)
59 return;
60
61 /* Destroy instance: */
62 delete s_pInstance;
63}
64
65
66UITranslationEventListener::UITranslationEventListener(QObject *pParent /* = 0 */)
67 :QObject(pParent)
68{
69 qApp->installEventFilter(this);
70 s_pInstance = this;
71}
72
73UITranslationEventListener::~UITranslationEventListener()
74{
75 s_pInstance = 0;
76}
77
78bool UITranslationEventListener::eventFilter(QObject *pObject, QEvent *pEvent)
79{
80 if ( !UITranslator::isTranslationInProgress()
81 && pEvent->type() == QEvent::LanguageChange)
82 {
83 //&& (pObject == qApp || pObject == this))
84 emit sigRetranslateUI();
85 }
86 /* Call to base-class: */
87 return QObject::eventFilter(pObject, pEvent);
88}
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