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 <QObject>
|
---|
25 | #include <QEvent>
|
---|
26 |
|
---|
27 | template <class Base>
|
---|
28 | class QIWithRetranslateUI: public Base
|
---|
29 | {
|
---|
30 | public:
|
---|
31 |
|
---|
32 | QIWithRetranslateUI(QWidget *pParent = 0) : Base(pParent) {}
|
---|
33 |
|
---|
34 | protected:
|
---|
35 |
|
---|
36 | virtual void changeEvent(QEvent *pEvent)
|
---|
37 | {
|
---|
38 | Base::changeEvent (pEvent);
|
---|
39 | switch (pEvent->type())
|
---|
40 | {
|
---|
41 | case QEvent::LanguageChange:
|
---|
42 | {
|
---|
43 | retranslateUi();
|
---|
44 | pEvent->accept();
|
---|
45 | break;
|
---|
46 | }
|
---|
47 | default:
|
---|
48 | break;
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | virtual void retranslateUi() = 0;
|
---|
53 | };
|
---|
54 |
|
---|
55 | template <class Base>
|
---|
56 | class QIWithRetranslateUI2: public Base
|
---|
57 | {
|
---|
58 | public:
|
---|
59 |
|
---|
60 | QIWithRetranslateUI2(QWidget *pParent = 0, Qt::WindowFlags fFlags = 0) : Base(pParent, fFlags) {}
|
---|
61 |
|
---|
62 | protected:
|
---|
63 |
|
---|
64 | virtual void changeEvent(QEvent *pEvent)
|
---|
65 | {
|
---|
66 | Base::changeEvent (pEvent);
|
---|
67 | switch (pEvent->type())
|
---|
68 | {
|
---|
69 | case QEvent::LanguageChange:
|
---|
70 | {
|
---|
71 | retranslateUi();
|
---|
72 | pEvent->accept();
|
---|
73 | break;
|
---|
74 | }
|
---|
75 | default:
|
---|
76 | break;
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | virtual void retranslateUi() = 0;
|
---|
81 | };
|
---|
82 |
|
---|
83 | template <class Base>
|
---|
84 | class QIWithRetranslateUI3: public Base
|
---|
85 | {
|
---|
86 | public:
|
---|
87 |
|
---|
88 | QIWithRetranslateUI3(QObject *pParent = 0) : Base(pParent) {}
|
---|
89 |
|
---|
90 | protected:
|
---|
91 |
|
---|
92 | virtual bool event(QEvent *pEvent)
|
---|
93 | {
|
---|
94 | bool bResult = Base::event(pEvent);
|
---|
95 | switch (pEvent->type())
|
---|
96 | {
|
---|
97 | case QEvent::LanguageChange:
|
---|
98 | {
|
---|
99 | retranslateUi();
|
---|
100 | pEvent->accept();
|
---|
101 | bResult = true;
|
---|
102 | break;
|
---|
103 | }
|
---|
104 | default:
|
---|
105 | break;
|
---|
106 | }
|
---|
107 | return bResult;
|
---|
108 | }
|
---|
109 |
|
---|
110 | virtual void retranslateUi() = 0;
|
---|
111 | };
|
---|
112 |
|
---|
113 | #endif /* __QIWithRetranslateUI_h */
|
---|
114 |
|
---|