VirtualBox

Changeset 79295 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 24, 2019 7:44:49 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6143. Adding code to save and load dialog geometry

Location:
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r79281 r79295  
    3838
    3939/* GUI includes: */
     40#include "UIDesktopWidgetWatchdog.h"
    4041#include "QIDialogButtonBox.h"
    4142#include "QIFileDialog.h"
     
    4849#include "QIToolButton.h"
    4950#include "VBoxGlobal.h"
     51#ifdef VBOX_WS_MAC
     52# include "VBoxUtils-darwin.h"
     53#endif
    5054
    5155/* COM includes: */
     
    27472751void UISoftKeyboard::saveSettings()
    27482752{
     2753    /* Save window geometry to extradata: */
     2754    const QRect saveGeometry = geometry();
     2755#ifdef VBOX_WS_MAC
     2756    /* darwinIsWindowMaximized expects a non-const QWidget*. thus const_cast: */
     2757    QWidget *pw = const_cast<QWidget*>(qobject_cast<const QWidget*>(this));
     2758    gEDataManager->setSoftKeyboardDialogGeometry(saveGeometry, ::darwinIsWindowMaximized(pw));
     2759#else /* !VBOX_WS_MAC */
     2760    gEDataManager->setSoftKeyboardDialogGeometry(saveGeometry, isMaximized());
     2761#endif /* !VBOX_WS_MAC */
     2762    LogRel2(("GUI: Soft Keyboard: Geometry saved as: Origin=%dx%d, Size=%dx%d\n",
     2763             saveGeometry.x(), saveGeometry.y(), saveGeometry.width(), saveGeometry.height()));
    27492764}
    27502765
    27512766void UISoftKeyboard::loadSettings()
    27522767{
     2768    const QRect desktopRect = gpDesktop->availableGeometry(this);
     2769    int iDefaultWidth = desktopRect.width() / 2;
     2770    int iDefaultHeight = desktopRect.height() * 3 / 4;
     2771    QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight);
     2772
     2773    QWidget *pParentWidget = qobject_cast<QWidget*>(parent());
     2774    if (pParentWidget)
     2775        defaultGeometry.moveCenter(pParentWidget->geometry().center());
     2776
     2777    /* Load geometry from extradata: */
     2778    QRect geometry = gEDataManager->softKeyboardDialogGeometry(this, defaultGeometry);
     2779
     2780    /* Restore geometry: */
     2781    LogRel2(("GUI: Soft Keyboard: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
     2782             geometry.x(), geometry.y(), geometry.width(), geometry.height()));
     2783    setDialogGeometry(geometry);
    27532784}
    27542785
     
    27802811}
    27812812
     2813void UISoftKeyboard::setDialogGeometry(const QRect &geometry)
     2814{
     2815#ifdef VBOX_WS_MAC
     2816    /* Use the old approach for OSX: */
     2817    move(geometry.topLeft());
     2818    resize(geometry.size());
     2819#else /* VBOX_WS_MAC */
     2820    /* Use the new approach for Windows/X11: */
     2821    VBoxGlobal::setTopLevelGeometry(this, geometry);
     2822#endif /* !VBOX_WS_MAC */
     2823
     2824    /* Maximize (if necessary): */
     2825    if (gEDataManager->softKeyboardDialogShouldBeMaximized())
     2826        showMaximized();
     2827}
     2828
     2829
    27822830#include "UISoftKeyboard.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r79248 r79295  
    9292    void updateStatusBarMessage(const QString &strLayoutName);
    9393    void updateLayoutSelector();
     94    void setDialogGeometry(const QRect &geometry);
    9495    CKeyboard& keyboard() const;
    9596
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette