- Timestamp:
- Apr 3, 2019 2:35:45 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/QIWithRetranslateUI.h
r77568 r77992 40 40 41 41 /** Constructs translatable widget passing @a pParent to the base-class. */ 42 QIWithRetranslateUI(QWidget *pParent = 0) : Base(pParent) {} 42 QIWithRetranslateUI(QWidget *pParent = 0) : Base(pParent) 43 { 44 qApp->installEventFilter(this); 45 } 43 46 44 47 protected: 45 48 46 /** Handles standard Qt change @a pEvent. */47 virtual void changeEvent(QEvent *pEvent)49 /** Pre-handles standard Qt @a pEvent for passed @a pObject. */ 50 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) 48 51 { 52 /* Handle LanguageChange events for qApp or this object: */ 53 if (pObject == qApp || pObject == this) 54 { 55 switch (pEvent->type()) 56 { 57 case QEvent::LanguageChange: retranslateUi(); break; 58 default: break; 59 } 60 } 49 61 /* Call to base-class: */ 50 Base::changeEvent(pEvent); 51 /* Handle LanguageChange events: */ 52 switch (pEvent->type()) 53 { 54 case QEvent::LanguageChange: 55 { 56 retranslateUi(); 57 pEvent->accept(); 58 break; 59 } 60 default: 61 break; 62 } 62 return Base::eventFilter(pObject, pEvent); 63 63 } 64 64 … … 84 84 85 85 /** Constructs translatable widget passing @a pParent and @a fFlags to the base-class. */ 86 QIWithRetranslateUI2(QWidget *pParent = 0, Qt::WindowFlags fFlags = 0) : Base(pParent, fFlags) {} 86 QIWithRetranslateUI2(QWidget *pParent = 0, Qt::WindowFlags fFlags = 0) : Base(pParent, fFlags) 87 { 88 qApp->installEventFilter(this); 89 } 87 90 88 91 protected: 89 92 90 /** Handles standard Qt change @a pEvent. */91 virtual void changeEvent(QEvent *pEvent)93 /** Pre-handles standard Qt @a pEvent for passed @a pObject. */ 94 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) 92 95 { 96 /* Handle LanguageChange events for qApp or this object: */ 97 if (pObject == qApp || pObject == this) 98 { 99 switch (pEvent->type()) 100 { 101 case QEvent::LanguageChange: retranslateUi(); break; 102 default: break; 103 } 104 } 93 105 /* Call to base-class: */ 94 Base::changeEvent(pEvent); 95 /* Handle LanguageChange events: */ 96 switch (pEvent->type()) 97 { 98 case QEvent::LanguageChange: 99 { 100 retranslateUi(); 101 pEvent->accept(); 102 break; 103 } 104 default: 105 break; 106 } 106 return Base::eventFilter(pObject, pEvent); 107 107 } 108 108 … … 130 130 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) 131 131 { 132 /* Handle LanguageChange events for qApp o nly: */133 if (pObject == qApp )132 /* Handle LanguageChange events for qApp or this object: */ 133 if (pObject == qApp || pObject == this) 134 134 { 135 135 switch (pEvent->type()) … … 175 175 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) 176 176 { 177 /* Handle LanguageChange events : */178 switch (pEvent->type())177 /* Handle LanguageChange events for qApp or this object: */ 178 if (pObject == qApp || pObject == this) 179 179 { 180 case QEvent::LanguageChange: retranslateUi(); break; 181 default: break; 180 /* Handle LanguageChange events: */ 181 switch (pEvent->type()) 182 { 183 case QEvent::LanguageChange: retranslateUi(); break; 184 default: break; 185 } 182 186 } 183 187 /* Call to base-class: */
Note:
See TracChangeset
for help on using the changeset viewer.