VirtualBox

Changeset 74561 in vbox for trunk/src


Ignore:
Timestamp:
Oct 1, 2018 4:52:13 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager: Wipe out excessive stuff from UIWelcomePane, enable this pane as additional Global tool.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneGlobal.cpp

    r74557 r74561  
    55
    66/*
    7  * Copyright (C) 2017 Oracle Corporation
     7 * Copyright (C) 2017-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2929/* GUI includes */
    3030# include "UIActionPoolSelector.h"
    31 # include "UIWelcomePane.h"
    3231# include "UIHostNetworkManager.h"
    33 # include "UIIconPool.h"
    3432# include "UIMediumManager.h"
    3533# include "UIToolPaneGlobal.h"
     34# include "UIWelcomePane.h"
    3635
    3736/* Other VBox includes: */
     
    4241
    4342UIToolPaneGlobal::UIToolPaneGlobal(UIActionPool *pActionPool, QWidget *pParent /* = 0 */)
    44     : QIWithRetranslateUI<QWidget>(pParent)
     43    : QWidget(pParent)
    4544    , m_pActionPool(pActionPool)
    4645    , m_pLayout(0)
    47     , m_pPaneDesktop(0)
     46    , m_pPaneWelcome(0)
    4847    , m_pPaneMedia(0)
    4948    , m_pPaneNetwork(0)
     
    9695            {
    9796                /* Create Desktop pane: */
    98                 m_pPaneDesktop = new UIWelcomePane;
    99                 if (m_pPaneDesktop)
     97                m_pPaneWelcome = new UIWelcomePane;
     98                if (m_pPaneWelcome)
    10099                {
    101100                    /* Configure pane: */
    102                     m_pPaneDesktop->setProperty("ToolType", QVariant::fromValue(ToolTypeGlobal_Welcome));
     101                    m_pPaneWelcome->setProperty("ToolType", QVariant::fromValue(ToolTypeGlobal_Welcome));
    103102
    104103                    /* Add into layout: */
    105                     m_pLayout->addWidget(m_pPaneDesktop);
    106                     m_pLayout->setCurrentWidget(m_pPaneDesktop);
    107 
    108                     /* Retranslate Desktop pane: */
    109                     retranslateDesktopPane();
     104                    m_pLayout->addWidget(m_pPaneWelcome);
     105                    m_pLayout->setCurrentWidget(m_pPaneWelcome);
    110106                }
    111107                break;
     
    171167        switch (enmType)
    172168        {
    173             case ToolTypeGlobal_Welcome: m_pPaneDesktop = 0; break;
     169            case ToolTypeGlobal_Welcome: m_pPaneWelcome = 0; break;
    174170            case ToolTypeGlobal_Media:   m_pPaneMedia = 0; break;
    175171            case ToolTypeGlobal_Network: m_pPaneNetwork = 0; break;
     
    183179}
    184180
    185 void UIToolPaneGlobal::retranslateUi()
    186 {
    187     retranslateDesktopPane();
    188 }
    189 
    190181void UIToolPaneGlobal::prepare()
    191182{
     
    195186    /* Create desktop pane: */
    196187    openTool(ToolTypeGlobal_Media);
    197 
    198     /* Apply language settings: */
    199     retranslateUi();
    200188}
    201189
     
    210198    }
    211199}
    212 
    213 void UIToolPaneGlobal::retranslateDesktopPane()
    214 {
    215     if (!m_pPaneDesktop)
    216         return;
    217 
    218     /* Translate Global Tools welcome screen: */
    219     m_pPaneDesktop->setToolsPaneIcon(UIIconPool::iconSet(":/tools_banner_global_200px.png"));
    220     m_pPaneDesktop->setToolsPaneText(
    221         tr("<h3>Welcome to VirtualBox!</h3>"
    222            "<p>This window represents a set of global tools "
    223            "which are currently opened (or can be opened). "
    224            "They are not related to any particular machine but "
    225            "to the complete VM collection. For a list of currently "
    226            "available tools check the corresponding menu at the right "
    227            "side of the main tool bar located at the top of the window. "
    228            "This list will be extended with new tools in future releases.</p>"
    229            "<p>You can press the <b>%1</b> key to get instant help, or visit "
    230            "<a href=https://www.virtualbox.org>www.virtualbox.org</a> "
    231            "for more information and latest news.</p>")
    232            .arg(QKeySequence(QKeySequence::HelpContents).toString(QKeySequence::NativeText)));
    233 
    234     /* Wipe out the tool descriptions: */
    235     m_pPaneDesktop->removeToolDescriptions();
    236 
    237     /* Add tool descriptions: */
    238     QAction *pAction1 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager);
    239     m_pPaneDesktop->addToolDescription(pAction1,
    240                                        tr("Tool to observe virtual storage media. "
    241                                           "Reflects all the chains of virtual disks you have registered "
    242                                           "(per each storage type) within your virtual machines and allows for media "
    243                                           "operations like copy, remove, release "
    244                                           "(detach it from VMs where it is currently attached to) and observe their properties. "
    245                                           "Allows to edit medium attributes like type, "
    246                                           "location/name, description and size (for dynamical storages "
    247                                           "only)."));
    248     QAction *pAction2 = m_pActionPool->action(UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager);
    249     m_pPaneDesktop->addToolDescription(pAction2,
    250                                        tr("Tool to control host-only network interfaces. "
    251                                           "Reflects host-only networks, their DHCP servers and allows "
    252                                           "for operations on the networks like possibility to create, remove "
    253                                           "and observe their properties. Allows to edit various "
    254                                           "attributes for host-only interface and corresponding DHCP server."));
    255 }
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIToolPaneGlobal.h

    r74557 r74561  
    55
    66/*
    7  * Copyright (C) 2017 Oracle Corporation
     7 * Copyright (C) 2017-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2323
    2424/* GUI includes: */
    25 #include "QIWithRetranslateUI.h"
    2625#include "UIExtraDataDefs.h"
    2726
     
    3938
    4039/** QWidget subclass representing container for tool panes. */
    41 class UIToolPaneGlobal : public QIWithRetranslateUI<QWidget>
     40class UIToolPaneGlobal : public QWidget
    4241{
    4342    Q_OBJECT;
     
    5958    void closeTool(ToolTypeGlobal enmType);
    6059
    61 protected:
    62 
    63     /** Handles translation event. */
    64     virtual void retranslateUi() /* override */;
    65 
    6660private:
    6761
     
    7367    void cleanup();
    7468
    75     /** Handles translation for Desktop pane. */
    76     void retranslateDesktopPane();
    77 
    7869    /** Holds the action pool reference. */
    7970    UIActionPool *m_pActionPool;
     
    8172    /** Holds the stacked-layout instance. */
    8273    QStackedLayout             *m_pLayout;
    83     /** Holds the Desktop pane instance. */
    84     UIWelcomePane              *m_pPaneDesktop;
     74    /** Holds the Welcome pane instance. */
     75    UIWelcomePane              *m_pPaneWelcome;
    8576    /** Holds the Virtual Media Manager instance. */
    8677    UIMediumManagerWidget      *m_pPaneMedia;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r74560 r74561  
    337337                switch (m_pPaneTools->toolsType())
    338338                {
     339                    case UIToolsType_Welcome: enmType = ToolTypeGlobal_Welcome; break;
    339340                    case UIToolsType_Media:   enmType = ToolTypeGlobal_Media; break;
    340341                    case UIToolsType_Network: enmType = ToolTypeGlobal_Network; break;
     
    599600            switch (currentGlobalTool())
    600601            {
     602                case ToolTypeGlobal_Welcome:
     603                {
     604                    m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Application_S_Preferences));
     605                    m_pToolBar->addSeparator();
     606                    m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance));
     607                    m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance));
     608                    m_pToolBar->addSeparator();
     609                    m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_New));
     610                    m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Add));
     611                    break;
     612                }
    601613                case ToolTypeGlobal_Media:
    602614                {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIWelcomePane.cpp

    r74557 r74561  
    2121
    2222/* Qt includes: */
    23 # include <QAction>
    24 # include <QApplication>
    25 # include <QEvent>
    26 # include <QGridLayout>
    2723# include <QHBoxLayout>
    2824# include <QLabel>
    29 # include <QPainter>
    30 # include <QScrollArea>
    31 # include <QScrollBar>
    32 # include <QStackedWidget>
    3325# include <QStyle>
    3426# include <QVBoxLayout>
    3527
    3628/* GUI includes */
     29# include "QIWithRetranslateUI.h"
     30# include "UIIconPool.h"
    3731# include "UIWelcomePane.h"
    38 # include "VBoxUtils.h"
    39 
    40 /* Other VBox includes: */
    41 # include <iprt/assert.h>
     32
     33/* Forward declarations: */
     34class QEvent;
     35class QHBoxLayout;
     36class QString;
     37class QResizeEvent;
     38class QVBoxLayout;
    4239
    4340#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    44 
    45 
    46 /** QScrollArea extension to wrap a tools pane. */
    47 class UIScrollAreaTools : public QScrollArea
    48 {
    49     Q_OBJECT;
    50 
    51 public:
    52 
    53     /** Constructs scroll-area passing @a pParent to the base-class. */
    54     UIScrollAreaTools(QWidget *pParent = 0);
    55 
    56 protected:
    57 
    58     /** Holds the minimum widget size. */
    59     virtual QSize minimumSizeHint() const /* override */;
    60 };
    6141
    6242
     
    7454public:
    7555
    76     /** Constructs scroll-area passing @a pParent to the base-class. */
     56    /** Constructs wrappable label passing @a pParent to the base-class. */
    7757    UIWrappableLabel(QWidget *pParent = 0);
    7858
     
    9171    virtual QSize sizeHint() const /* override */;
    9272};
    93 
    94 
    95 /** Our own skinnable implementation of tool widget for UIWelcomePane. */
    96 class UIWidgetTool : public QWidget
    97 {
    98     Q_OBJECT;
    99 
    100 public:
    101 
    102     /** Constructs tool widget on the basis of passed @a pAction and @a strDescription. */
    103     UIWidgetTool(QAction *pAction, const QString &strDescription);
    104 
    105 protected:
    106 
    107     /** Handles any Qt @a pEvent. */
    108     virtual bool event(QEvent *pEvent) /* override */;
    109 
    110     /** Handles paint @a pEvent. */
    111     virtual void paintEvent(QPaintEvent *pEvent) /* override */;
    112 
    113 private:
    114 
    115     /** Prepares all. */
    116     void prepare();
    117 
    118     /** Updates pixmap. */
    119     void updatePixmap();
    120 
    121     /** Holds the action reference. */
    122     QAction *m_pAction;
    123     /** Holds the widget description. */
    124     QString  m_strDescription;
    125 
    126     /** Holds whether the widget is hovered. */
    127     bool  m_fHovered;
    128 
    129     /** Holds the main layout instance. */
    130     QGridLayout *m_pLayout;
    131     /** Holds the icon label instance. */
    132     QLabel      *m_pLabelIcon;
    133     /** Holds the name label instance. */
    134     QLabel      *m_pLabelName;
    135     /** Holds the description label instance. */
    136     QLabel      *m_pLabelDescription;
    137 };
    138 
    139 
    140 /** QStackedWidget subclass representing container which have two panes:
    141   * 1. Text pane reflecting base information about VirtualBox,
    142   * 2. Error pane reflecting information about currently chosen
    143   *    inaccessible VM and allowing to operate over it. */
    144 class UIWelcomePanePrivate : public QStackedWidget
    145 {
    146     Q_OBJECT;
    147 
    148 public:
    149 
    150     /** Constructs private desktop pane passing @a pParent to the base-class. */
    151     UIWelcomePanePrivate(QWidget *pParent);
    152 
    153     /** Defines a tools pane welcome @a strText. */
    154     void setToolsPaneText(const QString &strText);
    155     /** Defines a tools pane welcome @a icon. */
    156     void setToolsPaneIcon(const QIcon &icon);
    157     /** Add a tool element.
    158       * @param  pAction         Brings tool action reference.
    159       * @param  strDescription  Brings the tool description. */
    160     void addToolDescription(QAction *pAction, const QString &strDescription);
    161     /** Removes all tool elements. */
    162     void removeToolDescriptions();
    163 
    164 protected:
    165 
    166     /** Handles any Qt @a pEvent. */
    167     virtual bool event(QEvent *pEvent) /* override */;
    168 
    169     /** Handles translation event. */
    170     void retranslateUi();
    171 
    172     /** Prepares tools pane. */
    173     void prepareToolsPane();
    174 
    175     /** Updates pixmap. */
    176     void updatePixmap();
    177 
    178 private:
    179 
    180     /** Holds the tools pane scroll-area instance. */
    181     UIScrollAreaTools *m_pScrollArea;
    182     /** Holds the tools pane instance. */
    183     QWidget          *m_pToolsPane;
    184     /** Holds the tools pane widget layout instance. */
    185     QVBoxLayout      *m_pLayoutWidget;
    186     /** Holds the tools pane text label instance. */
    187     QLabel           *m_pLabelToolsPaneText;
    188     /** Holds the tools pane icon label instance. */
    189     QLabel           *m_pLabelToolsPaneIcon;
    190 
    191     /** Holds the tools pane icon instance. */
    192     QIcon  m_icon;
    193 };
    194 
    195 
    196 /*********************************************************************************************************************************
    197 *   Class UIScrollAreaTools implementation.                                                                                      *
    198 *********************************************************************************************************************************/
    199 
    200 UIScrollAreaTools::UIScrollAreaTools(QWidget *pParent /* = 0 */)
    201     : QScrollArea(pParent)
    202 {
    203 }
    204 
    205 QSize UIScrollAreaTools::minimumSizeHint() const
    206 {
    207     // WORKAROUND:
    208     // The idea is simple, hold the minimum size hint to
    209     // avoid horizontal scroll-bar, but allow vertical one.
    210     return   widget()
    211            ? QSize(  widget()->minimumSizeHint().width()
    212                    + verticalScrollBar()->height(),
    213                    200 /* what about something more dynamical? */)
    214            : QScrollArea::minimumSizeHint();
    215 }
    21673
    21774
     
    266123
    267124/*********************************************************************************************************************************
    268 *   Class UIWidgetTool implementation.                                                                                           *
     125*   Class UIWelcomePane implementation.                                                                                          *
    269126*********************************************************************************************************************************/
    270127
    271 UIWidgetTool::UIWidgetTool(QAction *pAction, const QString &strDescription)
    272     : m_pAction(pAction)
    273     , m_strDescription(strDescription)
    274     , m_fHovered(false)
    275     , m_pLayout(0)
     128UIWelcomePane::UIWelcomePane(QWidget *pParent /* = 0 */)
     129    : QIWithRetranslateUI<QWidget>(pParent)
     130    , m_pLabelText(0)
    276131    , m_pLabelIcon(0)
    277     , m_pLabelName(0)
    278     , m_pLabelDescription(0)
    279132{
    280133    /* Prepare: */
     
    282135}
    283136
    284 bool UIWidgetTool::event(QEvent *pEvent)
     137bool UIWelcomePane::event(QEvent *pEvent)
    285138{
    286139    /* Handle known event types: */
    287     switch (pEvent->type())
    288     {
    289         case QEvent::Show:
    290         case QEvent::ScreenChangeInternal:
    291         {
    292             /* Update pixmap: */
    293             updatePixmap();
    294             break;
    295         }
    296 
    297         /* Update the hovered state on/off: */
    298         case QEvent::Enter:
    299         {
    300             m_fHovered = true;
    301             update();
    302             break;
    303         }
    304         case QEvent::Leave:
    305         {
    306             m_fHovered = false;
    307             update();
    308             break;
    309         }
    310 
    311         /* Notify listeners about the item was clicked: */
    312         case QEvent::MouseButtonRelease:
    313         {
    314             m_pAction->trigger();
    315             break;
    316         }
    317 
    318         default:
    319             break;
    320     }
    321     /* Call to base-class: */
    322     return QWidget::event(pEvent);
    323 }
    324 
    325 void UIWidgetTool::paintEvent(QPaintEvent * /* pEvent */)
    326 {
    327     /* Prepare painter: */
    328     QPainter painter(this);
    329 
    330     /* Prepare palette colors: */
    331     const QPalette pal = palette();
    332 #ifdef VBOX_WS_MAC
    333     const QColor color0 = pal.color(QPalette::Base);
    334     const QColor color11 = pal.color(QPalette::Highlight).lighter(120);
    335     const QColor color12 = pal.color(QPalette::Highlight);
    336 #else /* !VBOX_WS_MAC */
    337     const QColor color0 = pal.color(QPalette::Base);
    338     const QColor color11 = pal.color(QPalette::Highlight).lighter(150);
    339     const QColor color12 = pal.color(QPalette::Highlight);
    340 #endif /* !VBOX_WS_MAC */
    341     QColor color2 = pal.color(QPalette::Window).lighter(110);
    342     color2.setAlpha(0);
    343     QColor color3 = pal.color(QPalette::Window).darker(200);
    344 
    345     /* Invent pixel metric: */
    346     const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4;
    347     const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375;
    348     const int iIconMargin = iIconMetric / 2;
    349 
    350     /* Background gradient: */
    351     QLinearGradient grad(QPointF(width(), 0), QPointF(width() - (2 * iIconMargin + iIconMetric), 0));
    352     {
    353         grad.setColorAt(0, color11);
    354         grad.setColorAt(0.95, color12);
    355         grad.setColorAt(1, color2);
    356     }
    357 
    358     /* Top-left corner: */
    359     QRadialGradient grad1(QPointF(iMetric, iMetric), iMetric);
    360     {
    361         grad1.setColorAt(0, color3);
    362         grad1.setColorAt(1, color2);
    363     }
    364     /* Top-right corner: */
    365     QRadialGradient grad2(QPointF(width() - iMetric, iMetric), iMetric);
    366     {
    367         grad2.setColorAt(0, color3);
    368         grad2.setColorAt(1, color2);
    369     }
    370     /* Bottom-left corner: */
    371     QRadialGradient grad3(QPointF(iMetric, height() - iMetric), iMetric);
    372     {
    373         grad3.setColorAt(0, color3);
    374         grad3.setColorAt(1, color2);
    375     }
    376     /* Botom-right corner: */
    377     QRadialGradient grad4(QPointF(width() - iMetric, height() - iMetric), iMetric);
    378     {
    379         grad4.setColorAt(0, color3);
    380         grad4.setColorAt(1, color2);
    381     }
    382 
    383     /* Top line: */
    384     QLinearGradient grad5(QPointF(iMetric, 0), QPointF(iMetric, iMetric));
    385     {
    386         grad5.setColorAt(0, color2);
    387         grad5.setColorAt(1, color3);
    388     }
    389     /* Bottom line: */
    390     QLinearGradient grad6(QPointF(iMetric, height()), QPointF(iMetric, height() - iMetric));
    391     {
    392         grad6.setColorAt(0, color2);
    393         grad6.setColorAt(1, color3);
    394     }
    395     /* Left line: */
    396     QLinearGradient grad7(QPointF(0, height() - iMetric), QPointF(iMetric, height() - iMetric));
    397     {
    398         grad7.setColorAt(0, color2);
    399         grad7.setColorAt(1, color3);
    400     }
    401     /* Right line: */
    402     QLinearGradient grad8(QPointF(width(), height() - iMetric), QPointF(width() - iMetric, height() - iMetric));
    403     {
    404         grad8.setColorAt(0, color2);
    405         grad8.setColorAt(1, color3);
    406     }
    407 
    408     /* Paint hovered item cursor: */
    409     if (m_fHovered)
    410     {
    411         painter.fillRect(QRect(iMetric, iMetric, width() - iMetric * 2, height() - iMetric * 2), color0);
    412         painter.fillRect(QRect(width() - (height() - iMetric), iMetric, height() - iMetric * 2, height() - iMetric * 2), grad);
    413     }
    414 
    415     /* Paint shape/shadow: */
    416     painter.fillRect(QRect(0,                 0,                  iMetric,               iMetric),                grad1);
    417     painter.fillRect(QRect(width() - iMetric, 0,                  iMetric,               iMetric),                grad2);
    418     painter.fillRect(QRect(0,                 height() - iMetric, iMetric,               iMetric),                grad3);
    419     painter.fillRect(QRect(width() - iMetric, height() - iMetric, iMetric,               iMetric),                grad4);
    420     painter.fillRect(QRect(iMetric,           0,                  width() - iMetric * 2, iMetric),                grad5);
    421     painter.fillRect(QRect(iMetric,           height() - iMetric, width() - iMetric * 2, iMetric),                grad6);
    422     painter.fillRect(QRect(0,                 iMetric,            iMetric,               height() - iMetric * 2), grad7);
    423     painter.fillRect(QRect(width() - iMetric, iMetric,            iMetric,               height() - iMetric * 2), grad8);
    424 }
    425 
    426 void UIWidgetTool::prepare()
    427 {
    428     /* Configure self: */
    429     setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    430 
    431     /* Create main layout: */
    432     m_pLayout = new QGridLayout(this);
    433     AssertPtrReturnVoid(m_pLayout);
    434     {
    435         /* Invent pixel metric: */
    436         const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375;
    437         const int iMargin = iMetric / 2;
    438         const int iVerticalSpacing = iMargin / 2;
    439         const int iHorizontalSpacing = iMargin * 2;
    440 
    441         /* Configure layout: */
    442         m_pLayout->setContentsMargins(iMargin + iVerticalSpacing, iMargin, iMargin, iMargin);
    443         m_pLayout->setVerticalSpacing(iVerticalSpacing);
    444         m_pLayout->setHorizontalSpacing(iHorizontalSpacing);
    445 
    446         /* Create name label: */
    447         m_pLabelName = new QLabel;
    448         AssertPtrReturnVoid(m_pLabelName);
    449         {
    450             /* Configure label: */
    451             QFont fontLabel = m_pLabelName->font();
    452             fontLabel.setBold(true);
    453             m_pLabelName->setFont(fontLabel);
    454             m_pLabelName->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    455             m_pLabelName->setText(QString("%1     ").arg(m_pAction->text().remove('&')));
    456 
    457             /* Add into layout: */
    458             m_pLayout->addWidget(m_pLabelName, 0, 0);
    459         }
    460 
    461         /* Create description label: */
    462         m_pLabelDescription = new UIWrappableLabel;
    463         AssertPtrReturnVoid(m_pLabelDescription);
    464         {
    465             /* Configure label: */
    466             m_pLabelDescription->setAttribute(Qt::WA_TransparentForMouseEvents);
    467             m_pLabelDescription->setWordWrap(true);
    468             m_pLabelDescription->setMinimumWidth(315);
    469             m_pLabelDescription->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    470             m_pLabelDescription->setText(m_strDescription);
    471 
    472             /* Add into layout: */
    473             m_pLayout->addWidget(m_pLabelDescription, 1, 0);
    474         }
    475 
    476         /* Create icon label: */
    477         m_pLabelIcon = new QLabel;
    478         AssertPtrReturnVoid(m_pLabelIcon);
    479         {
    480             /* Configure label: */
    481             m_pLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    482 
    483             /* Add into layout: */
    484             m_pLayout->addWidget(m_pLabelIcon, 0, 1, 2, 1);
    485             m_pLayout->setAlignment(m_pLabelIcon, Qt::AlignCenter);
    486         }
    487     }
    488 
    489     /* Update pixmap: */
    490     updatePixmap();
    491 }
    492 
    493 void UIWidgetTool::updatePixmap()
    494 {
    495     const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375;
    496     m_pLabelIcon->setPixmap(m_pAction->icon().pixmap(window()->windowHandle(), QSize(iMetric, iMetric)));
    497 }
    498 
    499 
    500 /*********************************************************************************************************************************
    501 *   Class UIWelcomePanePrivate implementation.                                                                                   *
    502 *********************************************************************************************************************************/
    503 
    504 UIWelcomePanePrivate::UIWelcomePanePrivate(QWidget *pParent)
    505     : QStackedWidget(pParent)
    506     , m_pScrollArea(0), m_pToolsPane(0), m_pLayoutWidget(0), m_pLabelToolsPaneText(0), m_pLabelToolsPaneIcon(0)
    507 {
    508 }
    509 
    510 void UIWelcomePanePrivate::setToolsPaneText(const QString &strText)
    511 {
    512     /* Prepare tools pane if necessary: */
    513     prepareToolsPane();
    514 
    515     /* Assign corresponding text: */
    516     m_pLabelToolsPaneText->setText(strText);
    517 
    518     /* Raise corresponding widget: */
    519     setCurrentWidget(m_pScrollArea);
    520 }
    521 
    522 void UIWelcomePanePrivate::setToolsPaneIcon(const QIcon &icon)
    523 {
    524     /* Prepare tools pane if necessary: */
    525     prepareToolsPane();
    526 
    527     /* Save icon: */
    528     m_icon = icon;
    529     /* Update pixmap: */
    530     updatePixmap();
    531 
    532     /* Raise corresponding widget: */
    533     setCurrentWidget(m_pScrollArea);
    534 }
    535 
    536 void UIWelcomePanePrivate::addToolDescription(QAction *pAction, const QString &strDescription)
    537 {
    538     /* Prepare tools pane if necessary: */
    539     prepareToolsPane();
    540 
    541     /* Add tool widget on the basis of passed description: */
    542     UIWidgetTool *pWidget = new UIWidgetTool(pAction, strDescription);
    543     AssertPtrReturnVoid(pWidget);
    544     {
    545         /* Add into layout: */
    546         m_pLayoutWidget->addWidget(pWidget);
    547     }
    548 
    549     /* Raise corresponding widget: */
    550     setCurrentWidget(m_pScrollArea);
    551 }
    552 
    553 void UIWelcomePanePrivate::removeToolDescriptions()
    554 {
    555     /* Clear the layout: */
    556     QLayoutItem *pChild = 0;
    557     while ((pChild = m_pLayoutWidget->takeAt(0)) != 0)
    558     {
    559         /* Delete widget wrapped by the item first: */
    560         if (pChild->widget())
    561             delete pChild->widget();
    562         /* Then the item itself: */
    563         delete pChild;
    564     }
    565 }
    566 
    567 bool UIWelcomePanePrivate::event(QEvent *pEvent)
    568 {
    569     /* Handle know event types: */
    570140    switch (pEvent->type())
    571141    {
     
    582152
    583153    /* Call to base-class: */
    584     return QStackedWidget::event(pEvent);
    585 }
    586 
    587 void UIWelcomePanePrivate::prepareToolsPane()
    588 {
    589     /* Do nothing if already exists: */
    590     if (m_pScrollArea)
    591         return;
    592 
    593     /* Create scroll-area: */
    594     m_pScrollArea = new UIScrollAreaTools;
    595     AssertPtrReturnVoid(m_pScrollArea);
     154    return QIWithRetranslateUI<QWidget>::event(pEvent);
     155}
     156
     157void UIWelcomePane::retranslateUi()
     158{
     159    /* Translate welcome text: */
     160    m_pLabelText->setText(tr("<h3>Welcome to VirtualBox!</h3>"
     161                             "<p>The left part of application window contains global tools and "
     162                             "lists all virtual machines and virtual machine groups on your computer. "
     163                             "You can import, add and create new VMs using corresponding toolbar buttons. "
     164                             "You can popup a tools of currently selected element using corresponding element button.</p>"
     165                             "<p>You can press the <b>%1</b> key to get instant help, or visit "
     166                             "<a href=https://www.virtualbox.org>www.virtualbox.org</a> "
     167                             "for more information and latest news.</p>")
     168                             .arg(QKeySequence(QKeySequence::HelpContents).toString(QKeySequence::NativeText)));
     169}
     170
     171void UIWelcomePane::prepare()
     172{
     173    /* Prepare default welcome icon: */
     174    m_icon = UIIconPool::iconSet(":/tools_banner_global_200px.png");
     175
     176    /* Create main layout: */
     177    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     178    if (pMainLayout)
    596179    {
    597         /* Configure scroll-area: */
    598         m_pScrollArea->setFrameShape(QFrame::NoFrame);
    599         m_pScrollArea->setWidgetResizable(true);
    600 
    601         /* Create tool pane: */
    602         m_pToolsPane = new QWidget;
    603         AssertPtrReturnVoid(m_pToolsPane);
     180        /* Create welcome layout: */
     181        QHBoxLayout *pLayoutWelcome = new QHBoxLayout;
     182        if (pLayoutWelcome)
    604183        {
    605             /* Create main layout: */
    606             QVBoxLayout *pMainLayout = new QVBoxLayout(m_pToolsPane);
    607             AssertPtrReturnVoid(pMainLayout);
     184            /* Configure layout: */
     185            const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 2;
     186            pLayoutWelcome->setContentsMargins(iL, 0, 0, 0);
     187
     188            /* Create welcome text label: */
     189            m_pLabelText = new UIWrappableLabel;
     190            if (m_pLabelText)
    608191            {
    609                 /* Create welcome layout: */
    610                 QHBoxLayout *pLayoutWelcome = new QHBoxLayout;
    611                 AssertPtrReturnVoid(pLayoutWelcome);
    612                 {
    613                     /* Configure layout: */
    614                     const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 2;
    615                     pLayoutWelcome->setContentsMargins(iL, 0, 0, 0);
    616 
    617                     /* Create welcome text label: */
    618                     m_pLabelToolsPaneText = new UIWrappableLabel;
    619                     AssertPtrReturnVoid(m_pLabelToolsPaneText);
    620                     {
    621                         /* Configure label: */
    622                         m_pLabelToolsPaneText->setWordWrap(true);
    623                         m_pLabelToolsPaneText->setMinimumWidth(160);
    624                         m_pLabelToolsPaneText->setAlignment(Qt::AlignLeading | Qt::AlignTop);
    625                         m_pLabelToolsPaneText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
    626 
    627                         /* Add into layout: */
    628                         pLayoutWelcome->addWidget(m_pLabelToolsPaneText);
    629                     }
    630 
    631                     /* Create welcome picture label: */
    632                     m_pLabelToolsPaneIcon = new QLabel;
    633                     AssertPtrReturnVoid(m_pLabelToolsPaneIcon);
    634                     {
    635                         /* Configure label: */
    636                         m_pLabelToolsPaneIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    637 
    638                         /* Add into layout: */
    639                         pLayoutWelcome->addWidget(m_pLabelToolsPaneIcon);
    640                         pLayoutWelcome->setAlignment(m_pLabelToolsPaneIcon, Qt::AlignHCenter | Qt::AlignTop);
    641                     }
    642 
    643                     /* Add into layout: */
    644                     pMainLayout->addLayout(pLayoutWelcome);
    645                 }
    646 
    647                 /* Create widget layout: */
    648                 m_pLayoutWidget = new QVBoxLayout;
    649                 AssertPtrReturnVoid(m_pLayoutWidget);
    650                 {
    651                     /* Add into layout: */
    652                     pMainLayout->addLayout(m_pLayoutWidget);
    653                 }
    654 
    655                 /* Add stretch: */
    656                 pMainLayout->addStretch();
     192                /* Configure label: */
     193                m_pLabelText->setWordWrap(true);
     194                m_pLabelText->setMinimumWidth(160); /// @todo make dynamic
     195                m_pLabelText->setAlignment(Qt::AlignLeading | Qt::AlignTop);
     196                m_pLabelText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
     197
     198                /* Add into layout: */
     199                pLayoutWelcome->addWidget(m_pLabelText);
    657200            }
    658201
    659             /* Add into the scroll-area: */
    660             m_pScrollArea->setWidget(m_pToolsPane);
     202            /* Create welcome picture label: */
     203            m_pLabelIcon = new QLabel;
     204            if (m_pLabelIcon)
     205            {
     206                /* Configure label: */
     207                m_pLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     208
     209                /* Add into layout: */
     210                pLayoutWelcome->addWidget(m_pLabelIcon);
     211                pLayoutWelcome->setAlignment(m_pLabelIcon, Qt::AlignHCenter | Qt::AlignTop);
     212            }
     213
     214            /* Add into layout: */
     215            pMainLayout->addLayout(pLayoutWelcome);
    661216        }
    662217
    663         /* Add into the stack: */
    664         addWidget(m_pScrollArea);
     218        /* Add stretch: */
     219        pMainLayout->addStretch();
    665220    }
    666 }
    667 
    668 void UIWelcomePanePrivate::updatePixmap()
     221
     222    /* Translate finally: */
     223    retranslateUi();
     224    /* Update pixmap: */
     225    updatePixmap();
     226}
     227
     228void UIWelcomePane::updatePixmap()
    669229{
    670230    /* Assign corresponding icon: */
    671     const QList<QSize> aSizes = m_icon.availableSizes();
    672     const QSize firstOne = aSizes.isEmpty() ? QSize(200, 200) : aSizes.first();
    673     const double dRatio = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize) / 32;
    674231    if (!m_icon.isNull())
    675         m_pLabelToolsPaneIcon->setPixmap(m_icon.pixmap(window()->windowHandle(), QSize(firstOne.width() * dRatio, firstOne.height() * dRatio)));
    676 }
    677 
    678 
    679 /*********************************************************************************************************************************
    680 *   Class UIWelcomePane implementation.                                                                                          *
    681 *********************************************************************************************************************************/
    682 
    683 UIWelcomePane::UIWelcomePane(QWidget *pParent /* = 0 */)
    684     : QWidget(pParent)
    685 {
    686     /* Prepare main layout: */
    687     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    688     pMainLayout->setContentsMargins(0, 0, 0, 0);
    689 
    690     /* Create desktop pane: */
    691     m_pDesktopPrivate = new UIWelcomePanePrivate(this);
    692 
    693     /* Add it to the layout: */
    694     pMainLayout->addWidget(m_pDesktopPrivate);
    695 }
    696 
    697 void UIWelcomePane::setToolsPaneText(const QString &strText)
    698 {
    699     m_pDesktopPrivate->setToolsPaneText(strText);
    700 }
    701 
    702 void UIWelcomePane::setToolsPaneIcon(const QIcon &icon)
    703 {
    704     m_pDesktopPrivate->setToolsPaneIcon(icon);
    705 }
    706 
    707 void UIWelcomePane::addToolDescription(QAction *pAction, const QString &strDescription)
    708 {
    709     m_pDesktopPrivate->addToolDescription(pAction, strDescription);
    710 }
    711 
    712 void UIWelcomePane::removeToolDescriptions()
    713 {
    714     m_pDesktopPrivate->removeToolDescriptions();
     232    {
     233        const QList<QSize> sizes = m_icon.availableSizes();
     234        const QSize firstOne = sizes.isEmpty() ? QSize(200, 200) : sizes.first();
     235        m_pLabelIcon->setPixmap(m_icon.pixmap(window()->windowHandle(),
     236                                                       QSize(firstOne.width(),
     237                                                             firstOne.height())));
     238    }
    715239}
    716240
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIWelcomePane.h

    r74557 r74561  
    2020
    2121/* Qt includes: */
     22#include <QIcon>
    2223#include <QWidget>
    2324
     25/* GUI includes: */
     26#include "QIWithRetranslateUI.h"
     27
    2428/* Forward declarations: */
    25 class QIcon;
    26 class QString;
    27 class UIWelcomePanePrivate;
    28 
     29class QLabel;
    2930
    3031/** QWidget subclass holding Welcome information about VirtualBox. */
    31 class UIWelcomePane : public QWidget
     32class UIWelcomePane : public QIWithRetranslateUI<QWidget>
    3233{
    3334    Q_OBJECT;
     
    3839    UIWelcomePane(QWidget *pParent = 0);
    3940
    40     /** Defines a tools pane welcome @a strText. */
    41     void setToolsPaneText(const QString &strText);
    42     /** Defines a tools pane welcome @a icon. */
    43     void setToolsPaneIcon(const QIcon &icon);
    44     /** Add a tool element.
    45       * @param  pAction         Brings tool action reference.
    46       * @param  strDescription  Brings the tool description. */
    47     void addToolDescription(QAction *pAction, const QString &strDescription);
    48     /** Removes all tool elements. */
    49     void removeToolDescriptions();
     41protected:
     42
     43    /** Handles any Qt @a pEvent. */
     44    virtual bool event(QEvent *pEvent) /* override */;
     45
     46    /** Handles translation event. */
     47    virtual void retranslateUi() /* override */;
    5048
    5149private:
    5250
    53     /** Holds the private Welcome pane instance. */
    54     UIWelcomePanePrivate *m_pDesktopPrivate;
     51    /** Prepares all. */
     52    void prepare();
     53
     54    /** Updates pixmap. */
     55    void updatePixmap();
     56
     57    /** Holds the icon instance. */
     58    QIcon  m_icon;
     59
     60    /** Holds the text label instance. */
     61    QLabel *m_pLabelText;
     62    /** Holds the icon label instance. */
     63    QLabel *m_pLabelIcon;
    5564};
    5665
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.cpp

    r74555 r74561  
    410410    classes << UIToolsClass_Global;
    411411    classes << UIToolsClass_Global;
     412    classes << UIToolsClass_Global;
    412413    classes << UIToolsClass_Machine;
    413414    classes << UIToolsClass_Machine;
     
    416417    /* Prepare types: */
    417418    QList<UIToolsType> types;
     419    types << UIToolsType_Welcome;
    418420    types << UIToolsType_Media;
    419421    types << UIToolsType_Network;
     
    424426    /* Prepare icons: */
    425427    QList<QIcon> icons;
     428    icons << UIIconPool::iconSet(":/log_viewer_save_22px.png"); /// @toso use proper one
    426429    icons << UIIconPool::iconSet(":/media_manager_22px.png");
    427430    icons << UIIconPool::iconSet(":/host_iface_manager_22px.png");
     
    432435    /* Prepare names: */
    433436    QList<QString> names;
     437    names << tr("Welcome");
    434438    names << tr("Media");
    435439    names << tr("Network");
     
    475479    UIToolsType enmTypeGlobal = typeFromString(values.value(0));
    476480    if (!isTypeOfClass(enmTypeGlobal, UIToolsClass_Global))
    477         enmTypeGlobal = UIToolsType_Media;
     481        enmTypeGlobal = UIToolsType_Welcome;
    478482    foreach (UIToolsItem *pItem, items())
    479483        if (pItem->itemType() == enmTypeGlobal)
     
    538542    QMap<UIToolsType, QString> values;
    539543    /* Global classes: */
     544    values[UIToolsType_Welcome]   = "Welcome";
    540545    values[UIToolsType_Media]     = "Media";
    541546    values[UIToolsType_Network]   = "Network";
     
    553558    QMap<QString, UIToolsType> values;
    554559    /* Global classes: */
     560    values["Welcome"]   = UIToolsType_Welcome;
    555561    values["Media"]     = UIToolsType_Media;
    556562    values["Network"]   = UIToolsType_Network;
     
    572578            switch (enmType)
    573579            {
     580                case UIToolsType_Welcome:
    574581                case UIToolsType_Media:
    575582                case UIToolsType_Network:
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