Changeset 81285 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 15, 2019 11:22:37 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133980
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r81279 r81285 3520 3520 UISoftKeyboard::UISoftKeyboard(QWidget *pParent, 3521 3521 UISession *pSession, QWidget *pCenterWidget, QString strMachineName /* = QString()*/) 3522 : QIWithRetranslateUI<QMainWindow>(pParent)3522 : QMainWindowWithRestorableGeometryAndRetranslateUi(pParent) 3523 3523 , m_pSession(pSession) 3524 3524 , m_pCenterWidget(pCenterWidget) … … 3560 3560 } 3561 3561 3562 bool UISoftKeyboard::shouldBeMaximized() const 3563 { 3564 return gEDataManager->softKeyboardDialogShouldBeMaximized(); 3565 } 3566 3562 3567 void UISoftKeyboard::sltKeyboardLedsChange() 3563 3568 { … … 3827 3832 void UISoftKeyboard::saveSettings() 3828 3833 { 3829 /* Save window geometry to extradata: */ 3830 const QRect saveGeometry = geometry(); 3831 #ifdef VBOX_WS_MAC 3832 /* darwinIsWindowMaximized expects a non-const QWidget*. thus const_cast: */ 3833 QWidget *pw = const_cast<QWidget*>(qobject_cast<const QWidget*>(this)); 3834 gEDataManager->setSoftKeyboardDialogGeometry(saveGeometry, ::darwinIsWindowMaximized(pw)); 3835 #else /* !VBOX_WS_MAC */ 3836 gEDataManager->setSoftKeyboardDialogGeometry(saveGeometry, isMaximized()); 3837 #endif /* !VBOX_WS_MAC */ 3838 LogRel2(("GUI: Soft Keyboard: Geometry saved as: Origin=%dx%d, Size=%dx%d\n", 3839 saveGeometry.x(), saveGeometry.y(), saveGeometry.width(), saveGeometry.height())); 3834 /* Save geometry to extradata: */ 3835 const QRect geo = currentGeometry(); 3836 LogRel2(("GUI: UISoftKeyboard: Saving geometry as: Origin=%dx%d, Size=%dx%d\n", 3837 geo.x(), geo.y(), geo.width(), geo.height())); 3838 gEDataManager->setSoftKeyboardDialogGeometry(geo, isCurrentlyMaximized()); 3839 3840 /* Save other settings: */ 3840 3841 if (m_pKeyboardWidget) 3841 3842 { … … 3852 3853 void UISoftKeyboard::loadSettings() 3853 3854 { 3855 /* Invent default window geometry: */ 3854 3856 float fKeyboardAspectRatio = 1.0f; 3855 3857 if (m_pKeyboardWidget) 3856 3858 fKeyboardAspectRatio = m_pKeyboardWidget->layoutAspectRatio(); 3857 3858 const QRect desktopRect = gpDesktop->availableGeometry(this); 3859 int iDefaultWidth = desktopRect.width() / 2; 3860 int iDefaultHeight = iDefaultWidth * fKeyboardAspectRatio; 3861 QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight); 3862 3863 3859 const QRect availableGeo = gpDesktop->availableGeometry(this); 3860 const int iDefaultWidth = availableGeo.width() / 2; 3861 const int iDefaultHeight = iDefaultWidth * fKeyboardAspectRatio; 3862 QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight); 3864 3863 if (m_pCenterWidget) 3865 defaultGeometry.moveCenter(m_pCenterWidget->geometry().center()); 3864 defaultGeo.moveCenter(m_pCenterWidget->geometry().center()); 3865 else 3866 defaultGeo.moveCenter(availableGeo.center()); 3867 3866 3868 /* Load geometry from extradata: */ 3867 QRect geometry = gEDataManager->softKeyboardDialogGeometry(this, defaultGeometry);3868 3869 /* Restore geometry: */3870 LogRel2(("GUI: Soft Keyboard: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",3871 geometry.x(), geometry.y(), geometry.width(), geometry.height())); 3872 setDialogGeometry(geometry);3869 const QRect geo = gEDataManager->softKeyboardDialogGeometry(this, defaultGeo); 3870 LogRel2(("GUI: UISoftKeyboard: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n", 3871 geo.x(), geo.y(), geo.width(), geo.height())); 3872 restoreGeometry(geo); 3873 3874 /* Load other settings: */ 3873 3875 if (m_pKeyboardWidget) 3874 3876 { … … 3936 3938 } 3937 3939 3938 void UISoftKeyboard::setDialogGeometry(const QRect &geometry)3939 {3940 #ifdef VBOX_WS_MAC3941 /* Use the old approach for OSX: */3942 move(geometry.topLeft());3943 resize(geometry.size());3944 #else /* VBOX_WS_MAC */3945 /* Use the new approach for Windows/X11: */3946 UICommon::setTopLevelGeometry(this, geometry);3947 #endif /* !VBOX_WS_MAC */3948 3949 /* Maximize (if necessary): */3950 if (gEDataManager->softKeyboardDialogShouldBeMaximized())3951 showMaximized();3952 }3953 3954 3940 #include "UISoftKeyboard.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r81263 r81285 29 29 30 30 /* GUI includes: */ 31 #include "QIWithRestorableGeometry.h" 31 32 #include "QIWithRetranslateUI.h" 32 33 … … 45 46 class QStackedWidget; 46 47 47 class UISoftKeyboard : public QIWithRetranslateUI<QMainWindow> 48 /* Type definitions: */ 49 typedef QIWithRestorableGeometry<QMainWindow> QMainWindowWithRestorableGeometry; 50 typedef QIWithRetranslateUI<QMainWindowWithRestorableGeometry> QMainWindowWithRestorableGeometryAndRetranslateUi; 51 52 class UISoftKeyboard : public QMainWindowWithRestorableGeometryAndRetranslateUi 48 53 { 49 54 Q_OBJECT; … … 58 63 59 64 virtual void retranslateUi() /* override */; 65 66 virtual bool shouldBeMaximized() const /* override */; 60 67 61 68 private slots: … … 98 105 void updateStatusBarMessage(const QString &strLayoutName); 99 106 void updateLayoutSelectorList(); 100 void setDialogGeometry(const QRect &geometry);101 107 CKeyboard& keyboard() const; 102 108
Note:
See TracChangeset
for help on using the changeset viewer.