VirtualBox

Changeset 98376 in vbox


Ignore:
Timestamp:
Feb 1, 2023 12:20:34 PM (20 months ago)
Author:
vboxsync
Message:

Merging r155184 from gui4 branch: FE/Qt: Runtime UI: Move branding stuff from UISession to UIMachine.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3:79645-79692
        21 /branches/dsen/gui4:155183,155198
         21/branches/dsen/gui4:155183-155184,155198
        2222/trunk/src:92342,154921
  • trunk/src/VBox

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2/src/VBox:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3/src/VBox:79645-79692
        21 /branches/dsen/gui4/src/VBox:155183,155198
         21/branches/dsen/gui4/src/VBox:155183-155184,155198
  • trunk/src/VBox/Frontends

    • Property svn:mergeinfo
      •  

        old new  
        1616/branches/dsen/gui2/src/VBox/Frontends:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        1717/branches/dsen/gui3/src/VBox/Frontends:79645-79692
        18 /branches/dsen/gui4/src/VBox/Frontends:155183,155198
         18/branches/dsen/gui4/src/VBox/Frontends:155183-155184,155198
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98335 r98376  
    2929#include "UICommon.h"
    3030#include "UIExtraDataManager.h"
     31#include "UIIconPool.h"
    3132#include "UIMachine.h"
    3233#include "UISession.h"
     
    221222    , m_enmRequestedVisualState(UIVisualStateType_Invalid)
    222223    , m_pMachineLogic(0)
     224    , m_pMachineWindowIcon(0)
    223225{
    224226    m_spInstance = this;
     
    243245    }
    244246
    245     /* Prepare machine-logic: */
     247    /* Prepare stuff: */
     248    prepareMachineWindowIcon();
    246249    prepareMachineLogic();
     250
     251    /* Load settings: */
     252    loadSessionSettings();
    247253
    248254    /* Try to initialize session UI: */
     
    262268    /* True by default: */
    263269    return true;
     270}
     271
     272void UIMachine::prepareMachineWindowIcon()
     273{
     274    /* Acquire user machine-window icon: */
     275    QIcon icon = generalIconPool().userMachineIcon(uisession()->machine());
     276    /* Use the OS type icon if user one was not set: */
     277    if (icon.isNull())
     278        icon = generalIconPool().guestOSTypeIcon(uisession()->machine().GetOSTypeId());
     279    /* Use the default icon if nothing else works: */
     280    if (icon.isNull())
     281        icon = QIcon(":/VirtualBox_48px.png");
     282    /* Store the icon dynamically: */
     283    m_pMachineWindowIcon = new QIcon(icon);
    264284}
    265285
     
    306326}
    307327
     328void UIMachine::loadSessionSettings()
     329{
     330    /* Load extra-data settings: */
     331    {
     332        /* Get machine ID: */
     333        const QUuid uMachineID = uiCommon().managedVMUuid();
     334        Q_UNUSED(uMachineID);
     335
     336#ifndef VBOX_WS_MAC
     337        /* Load user's machine-window name postfix: */
     338        m_strMachineWindowNamePostfix = gEDataManager->machineWindowNamePostfix(uMachineID);
     339#endif
     340    }
     341}
     342
     343void UIMachine::cleanupMachineWindowIcon()
     344{
     345    /* Cleanup machine-window icon: */
     346    delete m_pMachineWindowIcon;
     347    m_pMachineWindowIcon = 0;
     348}
     349
    308350void UIMachine::cleanupSession()
    309351{
     
    318360    QApplication::sendPostedEvents(0, QEvent::MetaCall);
    319361
    320     /* Cleanup machine-logic: */
     362    /* Cleanup stuff: */
    321363    cleanupMachineLogic();
     364    cleanupMachineWindowIcon();
    322365
    323366    /* Cleanup session UI: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98103 r98376  
    8888    UIVisualStateType requestedVisualState() const;
    8989
     90    /** @name Branding stuff.
     91     ** @{ */
     92        /** Returns the cached machine-window icon. */
     93        QIcon *machineWindowIcon() const { return m_pMachineWindowIcon; }
     94#ifndef VBOX_WS_MAC
     95        /** Returns redefined machine-window name postfix. */
     96        QString machineWindowNamePostfix() const { return m_strMachineWindowNamePostfix; }
     97#endif
     98    /** @} */
     99
    90100public slots:
    91101
     
    109119    /** Prepare routine: Session stuff. */
    110120    bool prepareSession();
     121    /** Prepares machine-window icon. */
     122    void prepareMachineWindowIcon();
    111123    /** Prepare routine: Machine-logic stuff. */
    112124    void prepareMachineLogic();
    113125
     126    /* Settings stuff: */
     127    void loadSessionSettings();
     128
    114129    /** Cleanup routine: Machine-logic stuff. */
    115130    void cleanupMachineLogic();
     131    /** Cleanup machine-window icon. */
     132    void cleanupMachineWindowIcon();
    116133    /** Cleanup routine: Session stuff. */
    117134    void cleanupSession();
     
    138155    /** Holds current machine-logic. */
    139156    UIMachineLogic *m_pMachineLogic;
     157
     158    /** @name Branding stuff.
     159     ** @{ */
     160        /** Holds the cached machine-window icon. */
     161        QIcon *m_pMachineWindowIcon;
     162#ifndef VBOX_WS_MAC
     163        /** Holds redefined machine-window name postfix. */
     164        QString m_strMachineWindowNamePostfix;
     165#endif
     166    /** @} */
    140167};
    141168
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98375 r98376  
    159159                                       UIVisualStateType enmVisualStateType)
    160160{
     161    AssertPtrReturn(pMachine, 0);
     162    AssertPtrReturn(pSession, 0);
     163
    161164    UIMachineLogic *pLogic = 0;
    162165    switch (enmVisualStateType)
     
    16191622
    16201623    /* Assign corresponding icon: */
    1621     if (uisession() && uisession()->machineWindowIcon())
    1622         pDlg->setIcon(*uisession()->machineWindowIcon());
     1624    if (uimachine()->machineWindowIcon())
     1625        pDlg->setIcon(*uimachine()->machineWindowIcon());
    16231626
    16241627    /* Search for the max available filter index: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r98103 r98376  
    3939#include "UIModalWindowManager.h"
    4040#include "UIExtraDataManager.h"
     41#include "UIMachine.h"
    4142#include "UIMessageCenter.h"
    4243#include "UISession.h"
     
    104105void UIMachineWindow::prepare()
    105106{
     107    /* Prepare dialog itself: */
     108    prepareSelf();
     109
    106110    /* Prepare session-connections: */
    107111    prepareSessionConnections();
     
    201205    , m_pRightSpacer(0)
    202206{
    203 #ifndef VBOX_WS_MAC
    204     /* Set machine-window icon if any: */
    205     // On macOS window icon is referenced in info.plist.
    206     if (uisession() && uisession()->machineWindowIcon())
    207         setWindowIcon(*uisession()->machineWindowIcon());
    208 #endif /* !VBOX_WS_MAC */
    209 }
    210 
    211 UIActionPool* UIMachineWindow::actionPool() const
     207}
     208
     209UIMachine *UIMachineWindow::uimachine() const
     210{
     211    return machineLogic()->uimachine();
     212}
     213
     214UISession *UIMachineWindow::uisession() const
     215{
     216    return machineLogic()->uisession();
     217}
     218
     219UIActionPool *UIMachineWindow::actionPool() const
    212220{
    213221    return machineLogic()->actionPool();
    214 }
    215 
    216 UISession* UIMachineWindow::uisession() const
    217 {
    218     return machineLogic()->uisession();
    219222}
    220223
     
    291294#ifndef VBOX_WS_MAC
    292295        /* Append user product name (besides macOS): */
    293         const QString strUserProductName = uisession()->machineWindowNamePostfix();
     296        const QString strUserProductName = uimachine()->machineWindowNamePostfix();
    294297        strMachineName += " - " + (strUserProductName.isEmpty() ? defaultWindowTitle() : strUserProductName);
    295298#endif /* !VBOX_WS_MAC */
     
    436439                                                                  restrictedCloseActions);
    437440        /* Configure close-dialog: */
    438         if (uisession() && uisession()->machineWindowIcon())
    439             pCloseDlg->setIcon(*uisession()->machineWindowIcon());
     441        if (uimachine()->machineWindowIcon())
     442            pCloseDlg->setIcon(*uimachine()->machineWindowIcon());
    440443
    441444        /* Make sure close-dialog is valid: */
     
    543546}
    544547
     548void UIMachineWindow::prepareSelf()
     549{
     550#ifndef VBOX_WS_MAC
     551    /* Set machine-window icon if any: */
     552    // On macOS window icon is referenced in info.plist.
     553    if (uimachine()->machineWindowIcon())
     554        setWindowIcon(*uimachine()->machineWindowIcon());
     555#endif /* !VBOX_WS_MAC */
     556}
     557
    545558void UIMachineWindow::prepareSessionConnections()
    546559{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r98103 r98376  
    5454class QSpacerItem;
    5555class UIActionPool;
     56class UIMachine;
    5657class UISession;
    5758class UIMachineLogic;
     
    8485    UIMachineView* machineView() const { return m_pMachineView; }
    8586    UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
    86     UIActionPool* actionPool() const;
    87     UISession* uisession() const;
     87
     88    /** Returns machine UI reference. */
     89    UIMachine *uimachine() const;
     90    /** Returns session UI reference. */
     91    UISession *uisession() const;
     92
     93    /** Returns action-pool reference. */
     94    UIActionPool *actionPool() const;
    8895
    8996    /** Returns the session reference. */
     
    172179
    173180    /* Prepare helpers: */
     181    virtual void prepareSelf();
    174182    virtual void prepareSessionConnections();
    175183    virtual void prepareMainLayout();
     
    192200    virtual void cleanupMainLayout() {}
    193201    virtual void cleanupSessionConnections();
     202    virtual void cleanupSelf() {}
    194203
    195204    /* Update stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98103 r98376  
    4343#include "UIDesktopWidgetWatchdog.h"
    4444#include "UIExtraDataManager.h"
    45 #include "UIIconPool.h"
    4645#include "UISession.h"
    4746#include "UIMachine.h"
     
    892891    , m_machineStatePrevious(KMachineState_Null)
    893892    , m_machineState(KMachineState_Null)
    894     , m_pMachineWindowIcon(0)
    895893#ifdef VBOX_WS_MAC
    896894    , m_pWatchdogDisplayChange(0)
     
    950948    prepareActions();
    951949    prepareConnections();
    952     prepareMachineWindowIcon();
    953950    prepareScreens();
    954951    prepareSignalHandling();
     
    11321129}
    11331130
    1134 void UISession::prepareMachineWindowIcon()
    1135 {
    1136     /* Acquire user machine-window icon: */
    1137     QIcon icon = generalIconPool().userMachineIcon(machine());
    1138     /* Use the OS type icon if user one was not set: */
    1139     if (icon.isNull())
    1140         icon = generalIconPool().guestOSTypeIcon(machine().GetOSTypeId());
    1141     /* Use the default icon if nothing else works: */
    1142     if (icon.isNull())
    1143         icon = QIcon(":/VirtualBox_48px.png");
    1144     /* Store the icon dynamically: */
    1145     m_pMachineWindowIcon = new QIcon(icon);
    1146 }
    1147 
    11481131void UISession::prepareScreens()
    11491132{
     
    12341217        /* Get machine ID: */
    12351218        const QUuid uMachineID = uiCommon().managedVMUuid();
    1236 
    1237 #ifndef VBOX_WS_MAC
    1238         /* Load user's machine-window name postfix: */
    1239         m_strMachineWindowNamePostfix = gEDataManager->machineWindowNamePostfix(uMachineID);
    1240 #endif
    12411219
    12421220        /* Should guest autoresize? */
     
    13041282}
    13051283
    1306 void UISession::cleanupMachineWindowIcon()
    1307 {
    1308     /* Cleanup machine-window icon: */
    1309     delete m_pMachineWindowIcon;
    1310     m_pMachineWindowIcon = 0;
    1311 }
    1312 
    13131284void UISession::cleanupConnections()
    13141285{
     
    14101381    //cleanupSignalHandling();
    14111382    //cleanupScreens();
    1412     cleanupMachineWindowIcon();
    14131383    cleanupConnections();
    14141384    cleanupActions();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98103 r98376  
    134134    /** Returns currently cached mouse cursor position. */
    135135    QPoint cursorPosition() const { return m_cursorPosition; }
    136 
    137     /** @name Branding stuff.
    138      ** @{ */
    139     /** Returns the cached machine-window icon. */
    140     QIcon *machineWindowIcon() const { return m_pMachineWindowIcon; }
    141 #ifndef VBOX_WS_MAC
    142     /** Returns redefined machine-window name postfix. */
    143     QString machineWindowNamePostfix() const { return m_strMachineWindowNamePostfix; }
    144 #endif
    145     /** @} */
    146136
    147137    /** @name Host-screen configuration variables.
     
    444434    void prepareActions();
    445435    void prepareConnections();
    446     void prepareMachineWindowIcon();
    447436    void prepareScreens();
    448437    void prepareSignalHandling();
     
    454443    //void cleanupSignalHandling();
    455444    //void cleanupScreens() {}
    456     void cleanupMachineWindowIcon();
    457445    void cleanupConnections();
    458446    void cleanupActions();
     
    545533    QPoint   m_cursorPosition;
    546534
    547     /** @name Branding variables.
    548      ** @{ */
    549     /** Holds the cached machine-window icon. */
    550     QIcon *m_pMachineWindowIcon;
    551 #ifndef VBOX_WS_MAC
    552     /** Holds redefined machine-window name postfix. */
    553     QString m_strMachineWindowNamePostfix;
    554 #endif
    555     /** @} */
    556 
    557535    /** @name Host-screen configuration variables.
    558536     * @{ */
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