VirtualBox

Changeset 92492 in vbox


Ignore:
Timestamp:
Nov 18, 2021 2:00:30 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10141. Dialog geometry restore for the viso creator dialog.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r92487 r92492  
    8383/* VISO Creator: */
    8484const char *UIExtraDataDefs::GUI_VISOCreator_RecentFolder   = "GUI/VISOCreator/RecentFolder";
     85const char *UIExtraDataDefs::GUI_VISOCreator_DialogGeometry   = "GUI/VISOCreator/DialogGeometry";
    8586
    8687/* VirtualBox Manager: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r92487 r92492  
    157157        /** Holds recent folder for VISO creation content. */
    158158        SHARED_LIBRARY_STUFF extern const char *GUI_VISOCreator_RecentFolder;
     159        SHARED_LIBRARY_STUFF extern const char *GUI_VISOCreator_DialogGeometry;
    159160    /** @} */
    160161
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r92437 r92492  
    19081908           << GUI_Input_SelectorShortcuts << GUI_Input_MachineShortcuts
    19091909           << GUI_RecentFolderHD << GUI_RecentFolderCD << GUI_RecentFolderFD
    1910            << GUI_VISOCreator_RecentFolder
     1910           << GUI_VISOCreator_RecentFolder << GUI_VISOCreator_DialogGeometry
    19111911           << GUI_RecentListHD << GUI_RecentListCD << GUI_RecentListFD
    19121912           << GUI_RestrictedNetworkAttachmentTypes
     
    27202720}
    27212721
     2722QRect UIExtraDataManager::visoCreatorDialogGeometry(QWidget *pWidget, QWidget *pParentWidget, const QRect &defaultGeometry)
     2723{
     2724    return dialogGeometry(GUI_VISOCreator_DialogGeometry, pWidget, pParentWidget, defaultGeometry);
     2725}
     2726
     2727void UIExtraDataManager::setVisoCreatorDialogGeometry(const QRect &geometry, bool fMaximized)
     2728{
     2729    setDialogGeometry(GUI_VISOCreator_DialogGeometry, geometry, fMaximized);
     2730}
     2731
     2732bool UIExtraDataManager::visoCreatorDialogShouldBeMaximized()
     2733{
     2734    /* Get corresponding extra-data: */
     2735    const QStringList data = extraDataStringList(GUI_VISOCreator_DialogGeometry);
     2736
     2737    /* Make sure 5th item has required value: */
     2738    return data.size() == 5 && data[4] == GUI_Geometry_State_Max;
     2739}
     2740
    27222741QRect UIExtraDataManager::selectorWindowGeometry(QWidget *pWidget)
    27232742{
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r92437 r92492  
    335335        /** Defines recent folder for VISO creation content as @a strValue. */
    336336        void setVISOCreatorRecentFolder(const QString &strValue);
     337        /** Returns viso creator geometry using @a pWidget as the hint. */
     338        QRect visoCreatorDialogGeometry(QWidget *pWidget, QWidget *pParentWidget, const QRect &defaultGeometry);
     339        /** Set viso creator geometry. */
     340        void setVisoCreatorDialogGeometry(const QRect &geometry, bool fMaximized);
     341        /** Returns whether viso creator dialog should be maximized. */
     342        bool visoCreatorDialogShouldBeMaximized();
    337343    /** @} */
    338344
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp

    r92489 r92492  
    2323#include <QHeaderView>
    2424#include <QMimeData>
     25#include <QTableView>
    2526#include <QTreeView>
    2627
     
    2930#include "UIPathOperations.h"
    3031#include "UIVisoContentBrowser.h"
    31 #include "QITableView.h"
    3232
    3333/*********************************************************************************************************************************
     
    3636
    3737/** An QTableView extension mainly used to handle dropeed file objects from the host browser. */
    38 class UIVisoContentTableView : public QITableView
     38class UIVisoContentTableView : public QTableView
    3939{
    4040    Q_OBJECT;
     
    7777*********************************************************************************************************************************/
    7878UIVisoContentTableView::UIVisoContentTableView(QWidget *pParent /* = 0 */)
    79     :QITableView(pParent)
     79    :QTableView(pParent)
    8080{
    8181}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r92490 r92492  
    2929#include "UIIconPool.h"
    3030#include "UIMessageCenter.h"
     31#include "UIModalWindowManager.h"
    3132#include "QIToolBar.h"
    3233#include "UIVisoHostBrowser.h"
     
    509510*********************************************************************************************************************************/
    510511UIVisoCreatorDialog::UIVisoCreatorDialog(UIActionPool *pActionPool, QWidget *pParent, const QString& strMachineName /* = QString() */)
    511     : QIWithRetranslateUI<QIMainDialog>(pParent)
     512    : QIWithRetranslateUI<QIWithRestorableGeometry<QIMainDialog> >(pParent)
    512513    , m_strMachineName(strMachineName)
    513514    , m_pVisoCreatorWidget(0)
    514515    , m_pButtonBox(0)
    515516    , m_pActionPool(pActionPool)
     517    , m_iGeometrySaveTimerId(-1)
    516518{
    517519    /* Make sure that the base class does not close this dialog upon pressing escape.
     
    520522    prepareWidgets();
    521523    prepareConnections();
     524    loadSettings();
    522525}
    523526
     
    613616}
    614617
     618bool UIVisoCreatorDialog::event(QEvent *pEvent)
     619{
     620    if (pEvent->type() == QEvent::Resize || pEvent->type() == QEvent::Move)
     621    {
     622        if (m_iGeometrySaveTimerId != -1)
     623            killTimer(m_iGeometrySaveTimerId);
     624        m_iGeometrySaveTimerId = startTimer(300);
     625    }
     626    else if (pEvent->type() == QEvent::Timer)
     627    {
     628        QTimerEvent *pTimerEvent = static_cast<QTimerEvent*>(pEvent);
     629        if (pTimerEvent->timerId() == m_iGeometrySaveTimerId)
     630        {
     631            killTimer(m_iGeometrySaveTimerId);
     632            m_iGeometrySaveTimerId = -1;
     633            saveDialogGeometry();
     634        }
     635    }
     636    return QIWithRetranslateUI<QIWithRestorableGeometry<QIMainDialog> >::event(pEvent);
     637}
     638
    615639void UIVisoCreatorDialog::sltSetCancelButtonShortCut(QKeySequence keySequence)
    616640{
     
    618642        m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(keySequence);
    619643}
     644
     645void UIVisoCreatorDialog::loadSettings()
     646{
     647    const QRect availableGeo = gpDesktop->availableGeometry(this);
     648    int iDefaultWidth = availableGeo.width() / 2;
     649    int iDefaultHeight = availableGeo.height() * 3 / 4;
     650    QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight);
     651
     652    QWidget *pParent = windowManager().realParentWindow(parentWidget() ? parentWidget() : windowManager().mainWindowShown());
     653    /* Load geometry from extradata: */
     654    const QRect geo = gEDataManager->visoCreatorDialogGeometry(this, pParent, defaultGeo);
     655    LogRel2(("GUI: UISoftKeyboard: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
     656             geo.x(), geo.y(), geo.width(), geo.height()));
     657
     658    restoreGeometry(geo);
     659}
     660
     661void UIVisoCreatorDialog::saveDialogGeometry()
     662{
     663    const QRect geo = currentGeometry();
     664    LogRel2(("GUI: UIMediumSelector: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",
     665             geo.x(), geo.y(), geo.width(), geo.height()));
     666    gEDataManager->setVisoCreatorDialogGeometry(geo, isCurrentlyMaximized());
     667}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r92490 r92492  
    2727/* GUI includes: */
    2828#include "QIMainDialog.h"
     29#include "QIWithRestorableGeometry.h"
    2930#include "QIWithRetranslateUI.h"
    3031
     
    174175
    175176
    176 class SHARED_LIBRARY_STUFF UIVisoCreatorDialog : public QIWithRetranslateUI<QIMainDialog>
     177class SHARED_LIBRARY_STUFF UIVisoCreatorDialog : public QIWithRetranslateUI<QIWithRestorableGeometry<QIMainDialog> >
    177178{
    178179    Q_OBJECT;
     
    188189    void    setCurrentPath(const QString &strPath);
    189190
     191protected:
     192
     193    virtual bool event(QEvent *pEvent) final override;
     194
    190195private slots:
    191196
     
    196201    void prepareConnections();
    197202    virtual void retranslateUi() final override;
     203    void loadSettings();
     204    void saveDialogGeometry();
    198205
    199206    QString m_strMachineName;
     
    201208    QIDialogButtonBox    *m_pButtonBox;
    202209    QPointer<UIActionPool> m_pActionPool;
     210    int                   m_iGeometrySaveTimerId;
    203211};
    204212#endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoCreator_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.cpp

    r91328 r92492  
    2222#include <QTextEdit>
    2323#include <QTreeView>
     24#include <QTableView>
    2425
    2526/* GUI includes: */
    26 #include "QITableView.h"
    2727#include "UIVisoHostBrowser.h"
    2828
     
    150150    }
    151151
    152     m_pTableView = new QITableView;
     152    m_pTableView = new QTableView;
    153153    if (m_pTableView)
    154154    {
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoHostBrowser.h

    r91328 r92492  
    2727/* Forward declarations: */
    2828class QItemSelection;
    29 class QITableView;
     29class QTableView;
    3030class UIVisoHostBrowserModel;
    3131
     
    7272    UIVisoHostBrowserModel *m_pTreeModel;
    7373    UIVisoHostBrowserModel *m_pTableModel;
    74     QITableView            *m_pTableView;
     74    QTableView            *m_pTableView;
    7575};
    7676
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