VirtualBox

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

Last change on this file since 44453 was 43447, checked in by vboxsync, 12 years ago

FE/Qt: VM group feature: Restoring VM item tool-tip functionality.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 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#include <QGraphicsWidget>
28
29template <class Base>
30class QIWithRetranslateUI: public Base
31{
32public:
33
34 QIWithRetranslateUI(QWidget *pParent = 0) : Base(pParent) {}
35
36protected:
37
38 virtual void changeEvent(QEvent *pEvent)
39 {
40 Base::changeEvent (pEvent);
41 switch (pEvent->type())
42 {
43 case QEvent::LanguageChange:
44 {
45 retranslateUi();
46 pEvent->accept();
47 break;
48 }
49 default:
50 break;
51 }
52 }
53
54 virtual void retranslateUi() = 0;
55};
56
57template <class Base>
58class QIWithRetranslateUI2: public Base
59{
60public:
61
62 QIWithRetranslateUI2(QWidget *pParent = 0, Qt::WindowFlags fFlags = 0) : Base(pParent, fFlags) {}
63
64protected:
65
66 virtual void changeEvent(QEvent *pEvent)
67 {
68 Base::changeEvent (pEvent);
69 switch (pEvent->type())
70 {
71 case QEvent::LanguageChange:
72 {
73 retranslateUi();
74 pEvent->accept();
75 break;
76 }
77 default:
78 break;
79 }
80 }
81
82 virtual void retranslateUi() = 0;
83};
84
85template <class Base>
86class QIWithRetranslateUI3: public Base
87{
88public:
89
90 QIWithRetranslateUI3(QObject *pParent = 0)
91 : Base(pParent)
92 {
93 qApp->installEventFilter(this);
94 }
95
96protected:
97
98 virtual bool eventFilter(QObject *pObject, QEvent *pEvent)
99 {
100 switch (pEvent->type())
101 {
102 case QEvent::LanguageChange:
103 {
104 retranslateUi();
105 break;
106 }
107 default:
108 break;
109 }
110 return Base::eventFilter(pObject, pEvent);
111 }
112
113 virtual void retranslateUi() = 0;
114};
115
116template <class Base>
117class QIWithRetranslateUI4: public Base
118{
119public:
120
121 QIWithRetranslateUI4(QGraphicsWidget *pParent = 0)
122 : Base(pParent)
123 {
124 qApp->installEventFilter(this);
125 }
126
127protected:
128
129 virtual bool eventFilter(QObject *pObject, QEvent *pEvent)
130 {
131 switch (pEvent->type())
132 {
133 case QEvent::LanguageChange:
134 {
135 retranslateUi();
136 break;
137 }
138 default:
139 break;
140 }
141 return Base::eventFilter(pObject, pEvent);
142 }
143
144 virtual void retranslateUi() = 0;
145};
146
147#endif /* __QIWithRetranslateUI_h */
148
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use