VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/QIWithRetranslateUI.h@ 43138

Last change on this file since 43138 was 30194, checked in by vboxsync, 14 years ago

FE/Qt: 5052: Runtime language switching should now translate all QIWithRetranslateUI3 derived objects.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * Declarations of utility classes and functions
5 * VirtualBox Qt extensions: QIWithRetranslateUI class declaration
6 */
7
8/*
9 * Copyright (C) 2008-2010 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#ifndef __QIWithRetranslateUI_h
21#define __QIWithRetranslateUI_h
22
23/* Global includes */
24#include <QApplication>
25#include <QEvent>
26#include <QObject>
27
28template <class Base>
29class QIWithRetranslateUI: public Base
30{
31public:
32
33 QIWithRetranslateUI(QWidget *pParent = 0) : Base(pParent) {}
34
35protected:
36
37 virtual void changeEvent(QEvent *pEvent)
38 {
39 Base::changeEvent (pEvent);
40 switch (pEvent->type())
41 {
42 case QEvent::LanguageChange:
43 {
44 retranslateUi();
45 pEvent->accept();
46 break;
47 }
48 default:
49 break;
50 }
51 }
52
53 virtual void retranslateUi() = 0;
54};
55
56template <class Base>
57class QIWithRetranslateUI2: public Base
58{
59public:
60
61 QIWithRetranslateUI2(QWidget *pParent = 0, Qt::WindowFlags fFlags = 0) : Base(pParent, fFlags) {}
62
63protected:
64
65 virtual void changeEvent(QEvent *pEvent)
66 {
67 Base::changeEvent (pEvent);
68 switch (pEvent->type())
69 {
70 case QEvent::LanguageChange:
71 {
72 retranslateUi();
73 pEvent->accept();
74 break;
75 }
76 default:
77 break;
78 }
79 }
80
81 virtual void retranslateUi() = 0;
82};
83
84template <class Base>
85class QIWithRetranslateUI3: public Base
86{
87public:
88
89 QIWithRetranslateUI3(QObject *pParent = 0)
90 : Base(pParent)
91 {
92 qApp->installEventFilter(this);
93 }
94
95protected:
96
97 virtual bool eventFilter(QObject *pObject, QEvent *pEvent)
98 {
99 switch (pEvent->type())
100 {
101 case QEvent::LanguageChange:
102 {
103 retranslateUi();
104 break;
105 }
106 default:
107 break;
108 }
109 return Base::eventFilter(pObject, pEvent);
110 }
111
112 virtual void retranslateUi() = 0;
113};
114
115#endif /* __QIWithRetranslateUI_h */
116
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use