VirtualBox

Ignore:
Timestamp:
Oct 14, 2019 2:38:47 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133956
Message:

FE/Qt: Reapplying r133952 with build-fixes for macOS (s.a. r133953).

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
1 deleted
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r81258 r81261  
    785785        src/extensions/QILineEdit.h \
    786786        src/extensions/QIMainDialog.h \
    787         src/extensions/QIMainWindow.h \
    788787        src/extensions/QIManagerDialog.h \
    789788        src/extensions/QIMenu.h \
     
    12671266        src/extensions/QILineEdit.cpp \
    12681267        src/extensions/QIMainDialog.cpp \
    1269         src/extensions/QIMainWindow.cpp \
    12701268        src/extensions/QIManagerDialog.cpp \
    12711269        src/extensions/QIMenu.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r81258 r81261  
    5353# include "QIDialogButtonBox.h"
    5454# include "QIFileDialog.h"
    55 # include "QIMainWindow.h"
    5655# include "QISplitter.h"
    5756# include "QIWidgetValidator.h"
     57# include "QIWithRestorableGeometry.h"
    5858# include "VBoxUtils.h"
    5959# include "UIIconPool.h"
     
    458458
    459459
    460 /** QIMainWindow extension
     460/** QMainWindow extension
    461461  * providing Extra Data Manager with UI features. */
    462 class UIExtraDataManagerWindow : public QIMainWindow
     462class UIExtraDataManagerWindow : public QIWithRestorableGeometry<QMainWindow>
    463463{
    464464    Q_OBJECT;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/QIWithRestorableGeometry.h

    r81260 r81261  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - QIMainWindow class declaration.
     3 * VBox Qt GUI - QIWithRestorableGeometry class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_extensions_QIMainWindow_h
    19 #define FEQT_INCLUDED_SRC_extensions_QIMainWindow_h
     18#ifndef FEQT_INCLUDED_SRC_globals_QIWithRestorableGeometry_h
     19#define FEQT_INCLUDED_SRC_globals_QIWithRestorableGeometry_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2525#include <QMainWindow>
    2626#include <QRect>
     27#include <QResizeEvent>
    2728
    2829/* GUI includes: */
    2930#include "UILibraryDefs.h"
     31#ifdef VBOX_WS_MAC
     32# include "VBoxUtils-darwin.h"
     33#endif
     34#ifdef VBOX_WS_X11
     35# include "UICommon.h"
     36# include "UIDesktopWidgetWatchdog.h"
     37#endif
    3038
    31 /* Forward declarations: */
    32 class QWidget;
     39/* Other VBox includes: */
     40#ifdef VBOX_WS_MAC
     41# include "iprt/cpp/utils.h"
     42#endif
    3343
    34 /** QMainWindow extension providing GUI
    35   * with the extended geometry management support. */
    36 class SHARED_LIBRARY_STUFF QIMainWindow : public QMainWindow
     44/** Template with geometry saving/restoring capabilities. */
     45template <class Base>
     46class QIWithRestorableGeometry : public Base
    3747{
    38     Q_OBJECT;
    39 
    4048public:
    4149
    4250    /** Constructs main window passing @a pParent and @a enmFlags to base-class. */
    43     QIMainWindow(QWidget *pParent = 0, Qt::WindowFlags enmFlags = 0);
     51    QIWithRestorableGeometry(QWidget *pParent = 0, Qt::WindowFlags enmFlags = 0)
     52        : Base(pParent, enmFlags)
     53    {}
    4454
    4555protected:
    4656
    4757    /** Handles move @a pEvent. */
    48     virtual void moveEvent(QMoveEvent *pEvent) /* override */;
     58    virtual void moveEvent(QMoveEvent *pEvent) /* override */
     59    {
     60        /* Call to base-class: */
     61        QMainWindow::moveEvent(pEvent);
     62
     63#ifdef VBOX_WS_X11
     64        /* Prevent further handling if fake screen detected: */
     65        if (gpDesktop->isFakeScreenDetected())
     66            return;
     67#endif
     68
     69        /* Prevent handling for yet/already invisible window or if window is in minimized state: */
     70        if (this->isVisible() && (this->windowState() & Qt::WindowMinimized) == 0)
     71        {
     72#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
     73            /* Use the old approach for OSX/Win: */
     74            m_geometry.moveTo(this->frameGeometry().x(), this->frameGeometry().y());
     75#else
     76            /* Use the new approach otherwise: */
     77            m_geometry.moveTo(this->geometry().x(), this->geometry().y());
     78#endif
     79        }
     80    }
     81
    4982    /** Handles resize @a pEvent. */
    50     virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
     83    virtual void resizeEvent(QResizeEvent *pEvent) /* override */
     84    {
     85        /* Call to base-class: */
     86        QMainWindow::resizeEvent(pEvent);
     87
     88#ifdef VBOX_WS_X11
     89        /* Prevent handling if fake screen detected: */
     90        if (gpDesktop->isFakeScreenDetected())
     91            return;
     92#endif
     93
     94        /* Prevent handling for yet/already invisible window or if window is in minimized state: */
     95        if (this->isVisible() && (this->windowState() & Qt::WindowMinimized) == 0)
     96        {
     97            QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
     98            m_geometry.setSize(pResizeEvent->size());
     99        }
     100    }
    51101
    52102    /** Returns whether the window should be maximized when geometry being restored. */
     
    54104
    55105    /** Restores the window geometry to passed @a rect. */
    56     void restoreGeometry(const QRect &rect);
     106    void restoreGeometry(const QRect &rect)
     107    {
     108        m_geometry = rect;
     109#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
     110        /* Use the old approach for OSX/Win: */
     111        this->move(m_geometry.topLeft());
     112        this->resize(m_geometry.size());
     113#else
     114        /* Use the new approach otherwise: */
     115        UICommon::setTopLevelGeometry(this, m_geometry);
     116#endif
     117
     118        /* Maximize (if necessary): */
     119        if (shouldBeMaximized())
     120            this->showMaximized();
     121    }
    57122
    58123    /** Returns current window geometry. */
    59     QRect currentGeometry() const;
     124    QRect currentGeometry() const
     125    {
     126        return m_geometry;
     127    }
     128
    60129    /** Returns whether the window is currently maximized. */
    61     bool isCurrentlyMaximized() const;
     130    bool isCurrentlyMaximized() const
     131    {
     132#ifdef VBOX_WS_MAC
     133        return ::darwinIsWindowMaximized(unconst(this));
     134#else
     135        return this->isMaximized();
     136#endif
     137    }
    62138
    63139private:
     
    67143};
    68144
    69 #endif /* !FEQT_INCLUDED_SRC_extensions_QIMainWindow_h */
     145#endif /* !FEQT_INCLUDED_SRC_globals_QIWithRestorableGeometry_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r81258 r81261  
    128128    /* Ignore for non-active window except for FileOpen event which should be always processed: */
    129129    if (!isActiveWindow() && pEvent->type() != QEvent::FileOpen)
    130         return QIWithRetranslateUI<QIMainWindow>::eventFilter(pObject, pEvent);
     130        return QMainWindowWithRestorableGeometryAndRetranslateUi::eventFilter(pObject, pEvent);
    131131
    132132    /* Ignore for other objects: */
    133133    if (qobject_cast<QWidget*>(pObject) &&
    134134        qobject_cast<QWidget*>(pObject)->window() != this)
    135         return QIWithRetranslateUI<QIMainWindow>::eventFilter(pObject, pEvent);
     135        return QMainWindowWithRestorableGeometryAndRetranslateUi::eventFilter(pObject, pEvent);
    136136
    137137    /* Which event do we have? */
     
    150150
    151151    /* Call to base-class: */
    152     return QIWithRetranslateUI<QIMainWindow>::eventFilter(pObject, pEvent);
     152    return QMainWindowWithRestorableGeometryAndRetranslateUi::eventFilter(pObject, pEvent);
    153153}
    154154#endif /* VBOX_WS_MAC */
     
    184184    }
    185185    /* Call to base-class: */
    186     return QIWithRetranslateUI<QIMainWindow>::event(pEvent);
     186    return QMainWindowWithRestorableGeometryAndRetranslateUi::event(pEvent);
    187187}
    188188
     
    190190{
    191191    /* Call to base-class: */
    192     QIWithRetranslateUI<QIMainWindow>::showEvent(pEvent);
     192    QMainWindowWithRestorableGeometryAndRetranslateUi::showEvent(pEvent);
    193193
    194194    /* Is polishing required? */
     
    211211{
    212212    /* Call to base-class: */
    213     QIWithRetranslateUI<QIMainWindow>::closeEvent(pEvent);
     213    QMainWindowWithRestorableGeometryAndRetranslateUi::closeEvent(pEvent);
    214214
    215215    /* Quit application: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r81258 r81261  
    2323
    2424/* Qt includes: */
     25#include <QMainWindow>
    2526#include <QUrl>
    2627
    2728/* GUI includes: */
    28 #include "QIMainWindow.h"
     29#include "QIWithRestorableGeometry.h"
    2930#include "QIWithRetranslateUI.h"
    3031#include "UICommon.h"
     
    3940
    4041/* Type definitions: */
     42typedef QIWithRestorableGeometry<QMainWindow> QMainWindowWithRestorableGeometry;
     43typedef QIWithRetranslateUI<QMainWindowWithRestorableGeometry> QMainWindowWithRestorableGeometryAndRetranslateUi;
    4144typedef QMap<QString, QIManagerDialog*> VMLogViewerMap;
    4245
    43 /** Singleton QIMainWindow extension used as VirtualBox Manager instance. */
    44 class UIVirtualBoxManager : public QIWithRetranslateUI<QIMainWindow>
     46/** Singleton QMainWindow extension used as VirtualBox Manager instance. */
     47class UIVirtualBoxManager : public QMainWindowWithRestorableGeometryAndRetranslateUi
    4548{
    4649    Q_OBJECT;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.cpp

    r81258 r81261  
    7979
    8080UIVMInformationDialog::UIVMInformationDialog(UIMachineWindow *pMachineWindow)
    81     : QIWithRetranslateUI<QIMainWindow>(0)
     81    : QMainWindowWithRestorableGeometryAndRetranslateUi(0)
    8282    , m_pTabWidget(0)
    8383    , m_pMachineWindow(pMachineWindow)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.h

    r81258 r81261  
    2222#endif
    2323
     24/* Qt includes: */
     25#include <QMainWindow>
     26
    2427/* GUI includes: */
    25 #include "QIMainWindow.h"
     28#include "QIWithRestorableGeometry.h"
    2629#include "QIWithRetranslateUI.h"
    2730
     
    3538class UIMachineWindow;
    3639
     40/* Type definitions: */
     41typedef QIWithRestorableGeometry<QMainWindow> QMainWindowWithRestorableGeometry;
     42typedef QIWithRetranslateUI<QMainWindowWithRestorableGeometry> QMainWindowWithRestorableGeometryAndRetranslateUi;
    3743
    38 /** QIMainWindow subclass providing user
     44
     45/** QMainWindow subclass providing user
    3946  * with the dialog unifying VM details and statistics. */
    40 class UIVMInformationDialog : public QIWithRetranslateUI<QIMainWindow>
     47class UIVMInformationDialog : public QMainWindowWithRestorableGeometryAndRetranslateUi
    4148{
    4249    Q_OBJECT;
Note: See TracChangeset for help on using the changeset viewer.

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