Changeset 71354 in vbox
- Timestamp:
- Mar 15, 2018 2:27:38 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/QIWithRetranslateUI.h
r69500 r71354 5 5 6 6 /* 7 * Copyright (C) 2008-201 7Oracle Corporation7 * Copyright (C) 2008-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ QIWithRetranslateUI_h19 #define __ QIWithRetranslateUI_h18 #ifndef ___QIWithRetranslateUI_h___ 19 #define ___QIWithRetranslateUI_h___ 20 20 21 /* Global includes*/21 /* Qt includes: */ 22 22 #include <QApplication> 23 23 #include <QEvent> 24 #include <QGraphicsWidget> 24 25 #include <QObject> 25 #include <Q GraphicsWidget>26 #include <QWidget> 26 27 28 29 /** Template for automatic language translations of underlying QWidget. */ 27 30 template <class Base> 28 class QIWithRetranslateUI : public Base31 class QIWithRetranslateUI : public Base 29 32 { 30 33 public: 31 34 35 /** Constructs translatable widget passing @a pParent to the base-class. */ 32 36 QIWithRetranslateUI(QWidget *pParent = 0) : Base(pParent) {} 33 37 34 38 protected: 35 39 40 /** Handles standard Qt change @a pEvent. */ 36 41 virtual void changeEvent(QEvent *pEvent) 37 42 { 38 Base::changeEvent (pEvent); 43 /* Call to base-class: */ 44 Base::changeEvent(pEvent); 45 /* Handle LanguageChange events: */ 39 46 switch (pEvent->type()) 40 47 { … … 50 57 } 51 58 59 /** Handles translation event. */ 52 60 virtual void retranslateUi() = 0; 53 61 }; 54 62 63 64 /** Template for automatic language translations of underlying QWidget with certain flags. */ 55 65 template <class Base> 56 class QIWithRetranslateUI2 : public Base66 class QIWithRetranslateUI2 : public Base 57 67 { 58 68 public: 59 69 70 /** Constructs translatable widget passing @a pParent and @a fFlags to the base-class. */ 60 71 QIWithRetranslateUI2(QWidget *pParent = 0, Qt::WindowFlags fFlags = 0) : Base(pParent, fFlags) {} 61 72 62 73 protected: 63 74 75 /** Handles standard Qt change @a pEvent. */ 64 76 virtual void changeEvent(QEvent *pEvent) 65 77 { 66 Base::changeEvent (pEvent); 78 /* Call to base-class: */ 79 Base::changeEvent(pEvent); 80 /* Handle LanguageChange events: */ 67 81 switch (pEvent->type()) 68 82 { … … 78 92 } 79 93 94 /** Handles translation event. */ 80 95 virtual void retranslateUi() = 0; 81 96 }; 82 97 98 99 /** Template for automatic language translations of underlying QObject. */ 83 100 template <class Base> 84 class QIWithRetranslateUI3 : public Base101 class QIWithRetranslateUI3 : public Base 85 102 { 86 103 public: 87 104 105 /** Constructs translatable widget passing @a pParent to the base-class. */ 88 106 QIWithRetranslateUI3(QObject *pParent = 0) 89 107 : Base(pParent) … … 94 112 protected: 95 113 114 /** Pre-handles standard Qt @a pEvent for passed @a pObject. */ 96 115 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) 97 116 { 98 /* Handle events for qApp only: */117 /* Handle LanguageChange events for qApp only: */ 99 118 if (pObject == qApp) 100 119 { … … 109 128 } 110 129 130 /** Handles translation event. */ 111 131 virtual void retranslateUi() = 0; 112 132 }; 113 133 134 135 /** Template for automatic language translations of underlying QGraphicsWidget. */ 114 136 template <class Base> 115 class QIWithRetranslateUI4 : public Base137 class QIWithRetranslateUI4 : public Base 116 138 { 117 139 public: 118 140 141 /** Constructs translatable widget passing @a pParent to the base-class. */ 119 142 QIWithRetranslateUI4(QGraphicsWidget *pParent = 0) 120 143 : Base(pParent) … … 125 148 protected: 126 149 150 /** Pre-handles standard Qt @a pEvent for passed @a pObject. */ 127 151 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) 128 152 { 153 /* Handle LanguageChange events: */ 129 154 switch (pEvent->type()) 130 155 { 131 case QEvent::LanguageChange: 132 { 133 retranslateUi(); 134 break; 135 } 136 default: 137 break; 156 case QEvent::LanguageChange: retranslateUi(); break; 157 default: break; 138 158 } 159 /* Call to base-class: */ 139 160 return Base::eventFilter(pObject, pEvent); 140 161 } 141 162 163 /** Handles translation event. */ 142 164 virtual void retranslateUi() = 0; 143 165 }; 144 166 145 #endif /* __QIWithRetranslateUI_h */146 167 168 #endif /* !___QIWithRetranslateUI_h___ */ 169
Note:
See TracChangeset
for help on using the changeset viewer.

