VirtualBox

Changeset 103061 in vbox


Ignore:
Timestamp:
Jan 25, 2024 1:22:51 PM (12 months ago)
Author:
vboxsync
Message:

FE/Qt: UIWelcomePane: Heavy cleanup; Coding-style stuff, renaming, comments, reworking HiDPI support.

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

Legend:

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

    r101560 r103061  
    3131#include <QStyle>
    3232#include <QVBoxLayout>
    33 #include <QWindow>
    3433
    3534/* GUI includes */
    3635#include "QIWithRetranslateUI.h"
    3736#include "UICommon.h"
     37#include "UIDesktopWidgetWatchdog.h"
    3838#include "UIIconPool.h"
    3939#include "UIWelcomePane.h"
    40 
    41 /* Forward declarations: */
    42 class QEvent;
    43 class QHBoxLayout;
    44 class QString;
    45 class QResizeEvent;
    46 class QVBoxLayout;
    4740
    4841
     
    134127UIWelcomePane::UIWelcomePane(QWidget *pParent /* = 0 */)
    135128    : QIWithRetranslateUI<QWidget>(pParent)
    136     , m_pLabelText(0)
     129    , m_pLabelGreetings(0)
    137130    , m_pLabelIcon(0)
    138131{
    139     /* Prepare: */
    140132    prepare();
    141133}
     
    163155void UIWelcomePane::retranslateUi()
    164156{
    165     /* Translate welcome text: */
    166     m_pLabelText->setText(tr("<h3>Welcome to VirtualBox!</h3>"
    167                              "<p>The left part of application window contains global tools and "
    168                              "lists all virtual machines and virtual machine groups on your computer. "
    169                              "You can import, add and create new VMs using corresponding toolbar buttons. "
    170                              "You can popup a tools of currently selected element using corresponding element button.</p>"
    171                              "<p>You can press the <b>%1</b> key to get instant help, or visit "
    172                              "<a href=https://www.virtualbox.org>www.virtualbox.org</a> "
    173                              "for more information and latest news.</p>")
    174                              .arg(QKeySequence(QKeySequence::HelpContents).toString(QKeySequence::NativeText)));
     157    /* Translate greetings text: */
     158    m_pLabelGreetings->setText(tr("<h3>Welcome to VirtualBox!</h3>"
     159                                  "<p>The left part of application window contains global tools and "
     160                                  "lists all virtual machines and virtual machine groups on your computer. "
     161                                  "You can import, add and create new VMs using corresponding toolbar buttons. "
     162                                  "You can popup a tools of currently selected element using corresponding element button.</p>"
     163                                  "<p>You can press the <b>%1</b> key to get instant help, or visit "
     164                                  "<a href=https://www.virtualbox.org>www.virtualbox.org</a> "
     165                                  "for more information and latest news.</p>")
     166                                  .arg(QKeySequence(QKeySequence::HelpContents).toString(QKeySequence::NativeText)));
    175167}
    176168
     
    185177    m_icon = UIIconPool::iconSet(":/tools_banner_global_200px.png");
    186178
    187     /* Create main layout: */
     179    /* Prepare main layout: */
    188180    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    189181    if (pMainLayout)
    190182    {
    191         /* Create welcome layout: */
     183        /* Prepare welcome layout: */
    192184        QHBoxLayout *pLayoutWelcome = new QHBoxLayout;
    193185        if (pLayoutWelcome)
    194186        {
    195             /* Configure layout: */
    196187            const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 2;
    197188            pLayoutWelcome->setContentsMargins(iL, 0, 0, 0);
    198189
    199             /* Create welcome text label: */
    200             m_pLabelText = new UIWrappableLabel;
    201             if (m_pLabelText)
     190            /* Prepare greetings label: */
     191            m_pLabelGreetings = new UIWrappableLabel(this);
     192            if (m_pLabelGreetings)
    202193            {
    203                 /* Configure label: */
    204                 m_pLabelText->setWordWrap(true);
    205                 m_pLabelText->setMinimumWidth(160); /// @todo make dynamic
    206                 m_pLabelText->setAlignment(Qt::AlignLeading | Qt::AlignTop);
    207                 m_pLabelText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
    208                 connect(m_pLabelText, &QLabel::linkActivated, this, &UIWelcomePane::sltHandleLinkActivated);
     194                m_pLabelGreetings->setWordWrap(true);
     195                m_pLabelGreetings->setMinimumWidth(160); /// @todo make dynamic
     196                m_pLabelGreetings->setAlignment(Qt::AlignLeading | Qt::AlignTop);
     197                m_pLabelGreetings->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
     198                connect(m_pLabelGreetings, &QLabel::linkActivated, this, &UIWelcomePane::sltHandleLinkActivated);
    209199
    210200                /* Add into layout: */
    211                 pLayoutWelcome->addWidget(m_pLabelText);
     201                pLayoutWelcome->addWidget(m_pLabelGreetings);
    212202            }
    213203
    214             /* Create welcome picture label: */
    215             m_pLabelIcon = new QLabel;
     204            /* Prepare icon label: */
     205            m_pLabelIcon = new QLabel(this);
    216206            if (m_pLabelIcon)
    217207            {
    218                 /* Configure label: */
    219208                m_pLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    220209
     
    232221    }
    233222
     223    /* Assign Help keyword: */
    234224    uiCommon().setHelpKeyword(this, "intro-starting");
    235225
     
    245235    if (!m_icon.isNull())
    246236    {
     237        /* Check which size goes as the default one: */
    247238        const QList<QSize> sizes = m_icon.availableSizes();
    248         const QSize firstOne = sizes.isEmpty() ? QSize(200, 200) : sizes.first();
    249         const qreal fDevicePixelRatio = window() && window()->windowHandle() ? window()->windowHandle()->devicePixelRatio() : 1;
    250         m_pLabelIcon->setPixmap(m_icon.pixmap(QSize(firstOne.width(), firstOne.height()), fDevicePixelRatio));
     239        const QSize defaultSize = sizes.isEmpty() ? QSize(200, 200) : sizes.first();
     240        /* Acquire device-pixel ratio: */
     241        const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(this);
     242        m_pLabelIcon->setPixmap(m_icon.pixmap(defaultSize, fDevicePixelRatio));
    251243    }
    252244}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIWelcomePane.h

    r98103 r103061  
    7676    QIcon  m_icon;
    7777
    78     /** Holds the text label instance. */
    79     QLabel *m_pLabelText;
     78    /** Holds the greetings label instance. */
     79    QLabel *m_pLabelGreetings;
    8080    /** Holds the icon label instance. */
    8181    QLabel *m_pLabelIcon;
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