VirtualBox

Changeset 52112 in vbox


Ignore:
Timestamp:
Jul 21, 2014 4:14:18 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95135
Message:

FE/Qt: 7345: Runtime UI: Display indicator: Initial implementation.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
12 edited
3 copied

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc

    r51922 r52112  
    5959        <file alias="diskimage_16px.png">images/diskimage_16px.png</file>
    6060        <file alias="diskimage_32px.png">images/diskimage_32px.png</file>
     61        <file alias="display_software_16px.png">images/display_software_16px.png</file>
     62        <file alias="display_hardware_16px.png">images/display_hardware_16px.png</file>
     63        <file alias="display_hardware_write_16px.png">images/display_hardware_write_16px.png</file>
    6164        <file alias="drag_drop_16px.png">images/drag_drop_16px.png</file>
    6265        <file alias="drag_drop_disabled_16px.png">images/drag_drop_disabled_16px.png</file>
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r52097 r52112  
    11021102        case IndicatorType_USB:           strResult = "USB"; break;
    11031103        case IndicatorType_SharedFolders: strResult = "SharedFolders"; break;
     1104        case IndicatorType_Display:       strResult = "Display"; break;
    11041105        case IndicatorType_VideoCapture:  strResult = "VideoCapture"; break;
    11051106        case IndicatorType_Features:      strResult = "Features"; break;
     
    11271128    keys << "USB";           values << IndicatorType_USB;
    11281129    keys << "SharedFolders"; values << IndicatorType_SharedFolders;
     1130    keys << "Display";       values << IndicatorType_Display;
    11291131    keys << "VideoCapture";  values << IndicatorType_VideoCapture;
    11301132    keys << "Features";      values << IndicatorType_Features;
     
    11491151        case IndicatorType_USB:           return UIIconPool::iconSet(":/usb_16px.png");
    11501152        case IndicatorType_SharedFolders: return UIIconPool::iconSet(":/sf_16px.png");
     1153        case IndicatorType_Display:       return UIIconPool::iconSet(":/display_software_16px.png");
    11511154        case IndicatorType_VideoCapture:  return UIIconPool::iconSet(":/video_capture_16px.png");
    11521155        case IndicatorType_Features:      return UIIconPool::iconSet(":/vtx_amdv_16px.png");
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r52100 r52112  
    490490    IndicatorType_Network,
    491491    IndicatorType_SharedFolders,
     492    IndicatorType_Display,
    492493    IndicatorType_VideoCapture,
    493494    IndicatorType_Features,
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r52100 r52112  
    530530        setName(QApplication::translate("UIActionPool", "&View"));
    531531    }
     532};
     533
     534class UIActionMenuViewPopup : public UIActionMenu
     535{
     536    Q_OBJECT;
     537
     538public:
     539
     540    UIActionMenuViewPopup(UIActionPool *pParent)
     541        : UIActionMenu(pParent)
     542    {
     543        retranslateUi();
     544    }
     545
     546protected:
     547
     548    void retranslateUi() {}
    532549};
    533550
     
    14691486        delete m_pool[UIActionIndexRuntime_Menu_View];
    14701487    m_pool[UIActionIndexRuntime_Menu_View] = new UIActionMenuView(this);
     1488    if (m_pool[UIActionIndexRuntime_Menu_ViewPopup])
     1489        delete m_pool[UIActionIndexRuntime_Menu_ViewPopup];
     1490    m_pool[UIActionIndexRuntime_Menu_ViewPopup] = new UIActionMenuViewPopup(this);
    14711491    if (m_pool[UIActionIndexRuntime_Menu_StatusBar])
    14721492        delete m_pool[UIActionIndexRuntime_Menu_StatusBar];
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h

    r52100 r52112  
    4949    /* 'View' menu actions: */
    5050    UIActionIndexRuntime_Menu_View,
     51    UIActionIndexRuntime_Menu_ViewPopup,
    5152    UIActionIndexRuntime_Toggle_Fullscreen,
    5253    UIActionIndexRuntime_Toggle_Seamless,
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r52086 r52112  
    158158    uchar *address() { return m_image.bits(); }
    159159    /** Returns frame-buffer width. */
    160     ulong width() { return m_iWidth; }
     160    ulong width() const { return m_iWidth; }
    161161    /** Returns frame-buffer height. */
    162     ulong height() { return m_iHeight; }
     162    ulong height() const { return m_iHeight; }
    163163    /** Returns frame-buffer bits-per-pixel value. */
    164     ulong bitsPerPixel() { return m_image.depth(); }
     164    ulong bitsPerPixel() const { return m_image.depth(); }
    165165    /** Returns frame-buffer bytes-per-line value. */
    166     ulong bytesPerLine() { return m_image.bytesPerLine(); }
     166    ulong bytesPerLine() const { return m_image.bytesPerLine(); }
    167167    /** Returns default frame-buffer pixel-format. */
    168     ulong pixelFormat() { return FramebufferPixelFormat_FOURCC_RGB; }
     168    ulong pixelFormat() const { return FramebufferPixelFormat_FOURCC_RGB; }
    169169
    170170    /** Locks frame-buffer access. */
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r52100 r52112  
    558558};
    559559
     560/** UISessionStateStatusBarIndicator extension for Runtime UI: Display indicator. */
     561class UIIndicatorDisplay : public UISessionStateStatusBarIndicator
     562{
     563    Q_OBJECT;
     564
     565public:
     566
     567    /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
     568    UIIndicatorDisplay(CSession &session)
     569        : UISessionStateStatusBarIndicator(session)
     570    {
     571        /* Assign state-icons: */
     572        setStateIcon(KDeviceActivity_Null,    UIIconPool::iconSet(":/display_software_16px.png"));
     573        setStateIcon(KDeviceActivity_Idle,    UIIconPool::iconSet(":/display_hardware_16px.png"));
     574        setStateIcon(KDeviceActivity_Writing, UIIconPool::iconSet(":/display_hardware_write_16px.png"));
     575        /* Translate finally: */
     576        retranslateUi();
     577    }
     578
     579private:
     580
     581    /** Retranslation routine. */
     582    void retranslateUi()
     583    {
     584        updateAppearance();
     585    }
     586
     587    /** Update routine. */
     588    void updateAppearance()
     589    {
     590        /* Get machine: */
     591        const CMachine machine = m_session.GetMachine();
     592
     593        /* Prepare tool-tip: */
     594        QString strToolTip = QApplication::translate("UIIndicatorsPool",
     595                                                     "<p style='white-space:pre'>"
     596                                                     "<nobr>Indicates the activity of the display:</nobr>%1</p>");
     597        QString strFullData;
     598
     599        /* Video Memory: */
     600        const ULONG uVRAMSize = machine.GetVRAMSize();
     601        const QString strVRAMSize = VBoxGlobal::tr("<nobr>%1 MB</nobr>", "details report").arg(uVRAMSize);
     602        strFullData += QString("<br><nobr><b>%1:</b>&nbsp;%2</nobr>")
     603                               .arg(VBoxGlobal::tr("Video Memory", "details report"), strVRAMSize);
     604
     605        /* Monitor Count: */
     606        const ULONG uMonitorCount = machine.GetMonitorCount();
     607        if (uMonitorCount > 1)
     608        {
     609            const QString strMonitorCount = QString::number(uMonitorCount);
     610            strFullData += QString("<br><nobr><b>%1:</b>&nbsp;%2</nobr>")
     611                                   .arg(VBoxGlobal::tr("Screens", "details report"), strMonitorCount);
     612        }
     613
     614        /* 3D acceleration: */
     615        const bool fAcceleration3D = machine.GetAccelerate3DEnabled() && vboxGlobal().is3DAvailable();
     616        if (fAcceleration3D)
     617        {
     618            const QString strAcceleration3D = fAcceleration3D
     619                ? VBoxGlobal::tr("Enabled", "details report (3D Acceleration)")
     620                : VBoxGlobal::tr("Disabled", "details report (3D Acceleration)");
     621            strFullData += QString("<br><nobr><b>%1:</b>&nbsp;%2</nobr>")
     622                                   .arg(VBoxGlobal::tr("3D Acceleration", "details report"), strAcceleration3D);
     623        }
     624
     625        /* Update tool-tip: */
     626        setToolTip(strToolTip.arg(strFullData));
     627        /* Set initial indicator state: */
     628        setState(fAcceleration3D ? KDeviceActivity_Idle : KDeviceActivity_Null);
     629    }
     630};
     631
    560632/** UISessionStateStatusBarIndicator extension for Runtime UI: Video-capture indicator. */
    561633class UIIndicatorVideoCapture : public UISessionStateStatusBarIndicator
     
    9811053    if (m_pool.contains(IndicatorType_SharedFolders))
    9821054        updateIndicatorStateForDevice(m_pool.value(IndicatorType_SharedFolders), KDeviceType_SharedFolder);
     1055    if (m_pool.contains(IndicatorType_Display))
     1056        updateIndicatorStateForDevice(m_pool.value(IndicatorType_Display),       KDeviceType_Graphics3D);
    9831057}
    9841058
     
    11181192                case IndicatorType_Network:           m_pool[indicatorType] = new UIIndicatorNetwork(m_session);       break;
    11191193                case IndicatorType_SharedFolders:     m_pool[indicatorType] = new UIIndicatorSharedFolders(m_session); break;
     1194                case IndicatorType_Display:           m_pool[indicatorType] = new UIIndicatorDisplay(m_session);       break;
    11201195                case IndicatorType_VideoCapture:      m_pool[indicatorType] = new UIIndicatorVideoCapture(m_session);  break;
    11211196                case IndicatorType_Features:          m_pool[indicatorType] = new UIIndicatorFeatures(m_session);      break;
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineDefs.h

    r47478 r52112  
    3535    UIVisualElement_USBStuff              = RT_BIT(7),
    3636    UIVisualElement_SharedFolderStuff     = RT_BIT(8),
    37     UIVisualElement_VideoCapture          = RT_BIT(9),
    38     UIVisualElement_FeaturesStuff         = RT_BIT(10),
    39     UIVisualElement_MiniToolBar           = RT_BIT(11),
     37    UIVisualElement_Display               = RT_BIT(9),
     38    UIVisualElement_VideoCapture          = RT_BIT(10),
     39    UIVisualElement_FeaturesStuff         = RT_BIT(11),
     40    UIVisualElement_MiniToolBar           = RT_BIT(12),
    4041    UIVisualElement_AllStuff              = 0xFFFF
    4142};
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r52100 r52112  
    840840    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Reset));
    841841    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown));
     842    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_ViewPopup));
    842843    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen));
    843844    m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless));
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r52100 r52112  
    2828#include "UIStatusBarEditorWindow.h"
    2929#include "UIExtraDataManager.h"
     30#include "UIFrameBuffer.h"
    3031#ifdef Q_WS_MAC
    3132#include "VBoxUtils.h"
    3233#endif /* Q_WS_MAC */
     34
     35/* COM includes: */
     36#include "CConsole.h"
     37#include "CDisplay.h"
    3338
    3439UIMachineLogicNormal::UIMachineLogicNormal(QObject *pParent, UISession *pSession)
     
    119124}
    120125
     126void UIMachineLogicNormal::sltPrepareMenuViewPopup()
     127{
     128    /* Make sure sender is valid: */
     129    QMenu *pMenu = qobject_cast<QMenu*>(sender());
     130    AssertMsgReturnVoid(pMenu, ("This slot should be called only on View popup-menu show!\n"));
     131
     132    /* Clear contents: */
     133    pMenu->clear();
     134
     135    /* Add default contents: */
     136    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow));
     137    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize));
     138    pMenu->addSeparator();
     139
     140    /* Check if guest additions are enabled: */
     141    const bool fGAEnabled = uisession()->isGuestAdditionsActive() &&
     142                            uisession()->isGuestSupportsGraphics();
     143
     144    /* For each the machine-window: */
     145    foreach (UIMachineWindow *pMachineWindow, machineWindows())
     146    {
     147        /* Add 'Virtual Screen %1' menu: */
     148        const int iScreenID = pMachineWindow->screenId();
     149        QMenu *pSubMenu = pMenu->addMenu(QApplication::translate("UIMultiScreenLayout",
     150                                                                 "Virtual Screen %1").arg(iScreenID + 1));
     151        pSubMenu->setProperty("Screen ID", iScreenID);
     152        pSubMenu->setEnabled(fGAEnabled);
     153        connect(pSubMenu, SIGNAL(aboutToShow()), this, SLOT(sltPrepareMenuViewVirtualScreen()));
     154    }
     155}
     156
     157void UIMachineLogicNormal::sltPrepareMenuViewVirtualScreen()
     158{
     159    /* Make sure sender is valid: */
     160    QMenu *pMenu = qobject_cast<QMenu*>(sender());
     161    AssertMsgReturnVoid(pMenu, ("This slot should be called only on 'Virtual Screen %1' menu show!\n"));
     162
     163    /* Clear contents: */
     164    pMenu->clear();
     165
     166    /* Prepare new contents: */
     167    const QList<QSize> sizes = QList<QSize>()
     168                               << QSize(640, 480)
     169                               << QSize(800, 600)
     170                               << QSize(1024, 768)
     171                               << QSize(1280, 720)
     172                               << QSize(1280, 800)
     173                               << QSize(1366, 768)
     174                               << QSize(1440, 900)
     175                               << QSize(1600, 900)
     176                               << QSize(1680, 1050)
     177                               << QSize(1920, 1080)
     178                               << QSize(1920, 1200);
     179
     180    /* Get corresponding screen ID and frame-buffer: */
     181    const int iScreenID = pMenu->property("Screen ID").toInt();
     182    const UIFrameBuffer *pFrameBuffer = uisession()->frameBuffer(iScreenID);
     183
     184    /* Create exclusive action-group: */
     185    QActionGroup *pActionGroup = new QActionGroup(pMenu);
     186    AssertPtrReturnVoid(pActionGroup);
     187    {
     188        /* Configure exclusive action-group: */
     189        pActionGroup->setExclusive(true);
     190        /* For every available size: */
     191        foreach (const QSize &size, sizes)
     192        {
     193            /* Create exclusive action: */
     194            QAction *pAction = pActionGroup->addAction(UIActionPoolRuntime::tr("Resize to %1x%2", "Virtual Screen")
     195                                                                               .arg(size.width()).arg(size.height()));
     196            AssertPtrReturnVoid(pAction);
     197            {
     198                /* Configure exclusive action: */
     199                pAction->setProperty("Screen ID", iScreenID);
     200                pAction->setProperty("Requested Size", size);
     201                pAction->setCheckable(true);
     202                if (pFrameBuffer->width() == size.width() &&
     203                    pFrameBuffer->height() == size.height())
     204                {
     205                    pAction->setChecked(true);
     206                }
     207                /* Insert group actions into menu: */
     208                pMenu->addActions(pActionGroup->actions());
     209            }
     210        }
     211        /* Install listener for exclusive action-group: */
     212        connect(pActionGroup, SIGNAL(triggered(QAction*)),
     213                this, SLOT(sltHandleActionTriggerViewVirtualScreen(QAction*)));
     214    }
     215}
     216
     217void UIMachineLogicNormal::sltHandleActionTriggerViewVirtualScreen(QAction *pAction)
     218{
     219    /* Make sure sender is valid: */
     220    AssertMsgReturnVoid(pAction, ("This slot should be called only on 'Virtual Screen %1' menu action trigger!\n"));
     221
     222    /* Resize guest to required size: */
     223    const int iScreenID = pAction->property("Screen ID").toInt();
     224    const QSize size = pAction->property("Requested Size").toSize();
     225    CDisplay display = session().GetConsole().GetDisplay();
     226    display.SetVideoModeHint(iScreenID, uisession()->isScreenVisible(iScreenID),
     227                             false, 0, 0, size.width(), size.height(), 0);
     228}
     229
    121230void UIMachineLogicNormal::sltPrepareHardDisksMenu()
    122231{
     
    166275
    167276    /* "View" actions connections: */
     277    connect(gActionPool->action(UIActionIndexRuntime_Menu_ViewPopup)->menu(), SIGNAL(aboutToShow()),
     278            this, SLOT(sltPrepareMenuViewPopup()));
    168279    connect(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen), SIGNAL(triggered(bool)),
    169280            this, SLOT(sltChangeVisualStateToFullscreen()));
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h

    r52100 r52112  
    4343    void sltStatusBarSettingsClosed();
    4444    void sltToggleStatusBar();
     45    void sltPrepareMenuViewPopup();
     46    void sltPrepareMenuViewVirtualScreen();
     47    void sltHandleActionTriggerViewVirtualScreen(QAction *pAction);
    4548
    4649    /* Devices menu functionality: */
  • TabularUnified trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r52100 r52112  
    152152        case IndicatorType_Network:       pAction = gActionPool->action(UIActionIndexRuntime_Menu_Network);          break;
    153153        case IndicatorType_SharedFolders: pAction = gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders);    break;
     154        case IndicatorType_Display:       pAction = gActionPool->action(UIActionIndexRuntime_Menu_ViewPopup);          break;
    154155        case IndicatorType_VideoCapture:  pAction = gActionPool->action(UIActionIndexRuntime_Menu_VideoCapture);     break;
    155156        case IndicatorType_Mouse:         pAction = gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration); break;
     
    488489    if (iElement & UIVisualElement_SharedFolderStuff)
    489490        m_pIndicatorsPool->updateAppearance(IndicatorType_SharedFolders);
     491    if (iElement & UIVisualElement_Display)
     492        m_pIndicatorsPool->updateAppearance(IndicatorType_Display);
    490493    if (iElement & UIVisualElement_VideoCapture)
    491494        m_pIndicatorsPool->updateAppearance(IndicatorType_VideoCapture);
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