VirtualBox

Changeset 72887 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 4, 2018 3:50:30 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: Full cleanup/rework for UIVMCloseDialog: Doxy/comments, coding-style, proper prepare cascade, handling icon updates while moving dialog between screens with different DPI values.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r72057 r72887  
    362362        /* Configure close-dialog: */
    363363        if (uisession() && uisession()->machineWindowIcon())
    364         {
    365             const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
    366             pCloseDlg->setPixmap(uisession()->machineWindowIcon()->pixmap(QSize(iIconMetric, iIconMetric)));
    367         }
     364            pCloseDlg->setIcon(*uisession()->machineWindowIcon());
    368365
    369366        /* Make sure close-dialog is valid: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r71355 r72887  
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4848
    4949
    50 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &machine,
     50UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &comMachine,
    5151                                 bool fIsACPIEnabled, MachineCloseAction restictedCloseActions)
    5252    : QIWithRetranslateUI<QIDialog>(pParent)
    53     , m_pIcon(0), m_pLabel(0)
    54     , m_pDetachIcon(0), m_pDetachRadio(0)
    55     , m_pSaveIcon(0), m_pSaveRadio(0)
    56     , m_pShutdownIcon(0), m_pShutdownRadio(0)
    57     , m_pPowerOffIcon(0), m_pPowerOffRadio(0), m_pDiscardCheckBox(0)
    58     , m_machine(machine)
     53    , m_comMachine(comMachine)
     54    , m_fIsACPIEnabled(fIsACPIEnabled)
    5955    , m_restictedCloseActions(restictedCloseActions)
    60     , m_fIsACPIEnabled(fIsACPIEnabled)
    6156    , m_fValid(false)
    62     , m_lastCloseAction(MachineCloseAction_Invalid)
    63 {
    64     /* Prepare: */
     57    , m_pMainLayout(0)
     58    , m_pTopLayout(0)
     59    , m_pTopLeftLayout(0)
     60    , m_pTopRightLayout(0)
     61    , m_pChoiceLayout(0)
     62    , m_pLabelIcon(0), m_pLabelText(0)
     63    , m_pLabelIconDetach(0), m_pRadioButtonDetach(0)
     64    , m_pLabelIconSave(0), m_pRadioButtonSave(0)
     65    , m_pLabelIconShutdown(0), m_pRadioButtonShutdown(0)
     66    , m_pLabelIconPowerOff(0), m_pRadioButtonPowerOff(0)
     67    , m_pCheckBoxDiscard(0)
     68    , m_enmLastCloseAction(MachineCloseAction_Invalid)
     69{
    6570    prepare();
    66 
    67     /* Configure: */
    68     configure();
    69 
    70     /* Retranslate: */
    71     retranslateUi();
    72 }
    73 
    74 void UIVMCloseDialog::setPixmap(const QPixmap &pixmap)
    75 {
    76     /* Make sure pixmap is valid: */
    77     if (pixmap.isNull())
     71}
     72
     73void UIVMCloseDialog::setIcon(const QIcon &icon)
     74{
     75    /* Make sure icon is valid: */
     76    if (icon.isNull())
    7877        return;
    7978
    80     /* Assign new pixmap: */
    81     m_pIcon->setPixmap(pixmap);
     79    /* Remember it: */
     80    m_icon = icon;
     81    /* Update pixmaps: */
     82    updatePixmaps();
     83}
     84
     85bool UIVMCloseDialog::eventFilter(QObject *pObject, QEvent *pEvent)
     86{
     87    /* For now we are interested in double-click events only: */
     88    if (pEvent->type() == QEvent::MouseButtonDblClick)
     89    {
     90        /* Make sure it's one of the radio-buttons
     91         * which has this event-filter installed: */
     92        if (qobject_cast<QRadioButton*>(pObject))
     93        {
     94            /* Since on double-click the button will be also selected
     95             * we are just calling for the *accept* slot: */
     96            accept();
     97        }
     98    }
     99
     100    /* Call to base-class: */
     101    return QIWithRetranslateUI<QIDialog>::eventFilter(pObject, pEvent);
     102}
     103
     104bool UIVMCloseDialog::event(QEvent *pEvent)
     105{
     106    /* Handle know event types: */
     107    switch (pEvent->type())
     108    {
     109        case QEvent::Show:
     110        case QEvent::ScreenChangeInternal:
     111        {
     112            /* Update pixmaps: */
     113            updatePixmaps();
     114
     115            // NOTE:
     116            // This thing works after QEvent::Show but isn't
     117            // working after QEvent::ScreenChangeInternal,
     118            // because it is too early, layout isn't calculated.
     119            // We want to "force" it to work, just no idea how.
     120            // Resize to minimum size-hint:
     121            resize(minimumSizeHint());
     122
     123            break;
     124        }
     125        default:
     126            break;
     127    }
     128
     129    /* Call to base-class: */
     130    return QIWithRetranslateUI<QIDialog>::event(pEvent);
     131}
     132
     133void UIVMCloseDialog::retranslateUi()
     134{
     135    /* Translate title: */
     136    setWindowTitle(tr("Close Virtual Machine"));
     137
     138    /* Translate text label: */
     139    m_pLabelText->setText(tr("You want to:"));
     140
     141    /* Translate radio-buttons: */
     142    m_pRadioButtonDetach->setText(tr("&Continue running in the background"));
     143    m_pRadioButtonDetach->setWhatsThis(tr("<p>Close the virtual machine windows but keep the virtual machine running.</p>"
     144                                          "<p>You can use the VirtualBox Manager to return to running the virtual machine "
     145                                          "in a window.</p>"));
     146    m_pRadioButtonSave->setText(tr("&Save the machine state"));
     147    m_pRadioButtonSave->setWhatsThis(tr("<p>Saves the current execution state of the virtual machine to the physical hard disk "
     148                                        "of the host PC.</p>"
     149                                        "<p>Next time this machine is started, it will be restored from the saved state and "
     150                                        "continue execution from the same place you saved it at, which will let you continue "
     151                                        "your work immediately.</p>"
     152                                        "<p>Note that saving the machine state may take a long time, depending on the guest "
     153                                        "operating system type and the amount of memory you assigned to the virtual "
     154                                        "machine.</p>"));
     155    m_pRadioButtonShutdown->setText(tr("S&end the shutdown signal"));
     156    m_pRadioButtonShutdown->setWhatsThis(tr("<p>Sends the ACPI Power Button press event to the virtual machine.</p>"
     157                                            "<p>Normally, the guest operating system running inside the virtual machine will "
     158                                            "detect this event and perform a clean shutdown procedure. This is a recommended "
     159                                            "way to turn off the virtual machine because all applications running inside it "
     160                                            "will get a chance to save their data and state.</p>"
     161                                            "<p>If the machine doesn't respond to this action then the guest operating system "
     162                                            "may be misconfigured or doesn't understand ACPI Power Button events at all. In "
     163                                            "this case you should select the <b>Power off the machine</b> action to stop "
     164                                            "virtual machine execution.</p>"));
     165    m_pRadioButtonPowerOff->setText(tr("&Power off the machine"));
     166    m_pRadioButtonPowerOff->setWhatsThis(tr("<p>Turns off the virtual machine.</p>"
     167                                            "<p>Note that this action will stop machine execution immediately so that the guest "
     168                                            "operating system running inside it will not be able to perform a clean shutdown "
     169                                            "procedure which may result in <i>data loss</i> inside the virtual machine. "
     170                                            "Selecting this action is recommended only if the virtual machine does not respond "
     171                                            "to the <b>Send the shutdown signal</b> action.</p>"));
     172
     173    /* Translate check-box: */
     174    m_pCheckBoxDiscard->setText(tr("&Restore current snapshot '%1'").arg(m_strDiscardCheckBoxText));
     175    m_pCheckBoxDiscard->setToolTip(tr("Restore the machine state stored in the current snapshot"));
     176    m_pCheckBoxDiscard->setWhatsThis(tr("<p>When checked, the machine will be returned to the state stored in the current "
     177                                        "snapshot after it is turned off. This is useful if you are sure that you want to "
     178                                        "discard the results of your last sessions and start again at that snapshot.</p>"));
    82179}
    83180
     
    85182{
    86183    /* Discard option should be enabled only on power-off action: */
    87     m_pDiscardCheckBox->setEnabled(m_pPowerOffRadio->isChecked());
     184    m_pCheckBoxDiscard->setEnabled(m_pRadioButtonPowerOff->isChecked());
    88185}
    89186
     
    91188{
    92189    /* Calculate result: */
    93     if (m_pDetachRadio->isChecked())
     190    if (m_pRadioButtonDetach->isChecked())
    94191        setResult(MachineCloseAction_Detach);
    95     else if (m_pSaveRadio->isChecked())
     192    else if (m_pRadioButtonSave->isChecked())
    96193        setResult(MachineCloseAction_SaveState);
    97     else if (m_pShutdownRadio->isChecked())
     194    else if (m_pRadioButtonShutdown->isChecked())
    98195        setResult(MachineCloseAction_Shutdown);
    99     else if (m_pPowerOffRadio->isChecked())
    100     {
    101         if (!m_pDiscardCheckBox->isChecked() || !m_pDiscardCheckBox->isVisible())
     196    else if (m_pRadioButtonPowerOff->isChecked())
     197    {
     198        if (!m_pCheckBoxDiscard->isChecked() || !m_pCheckBoxDiscard->isVisible())
    102199            setResult(MachineCloseAction_PowerOff);
    103200        else
     
    109206    /* But make sure 'Shutdown' is preserved if temporary unavailable: */
    110207    if (newCloseAction == MachineCloseAction_PowerOff &&
    111         m_lastCloseAction == MachineCloseAction_Shutdown && !m_fIsACPIEnabled)
     208        m_enmLastCloseAction == MachineCloseAction_Shutdown && !m_fIsACPIEnabled)
    112209        newCloseAction = MachineCloseAction_Shutdown;
    113210    gEDataManager->setLastMachineCloseAction(newCloseAction, vboxGlobal().managedVMUuid());
     
    117214}
    118215
    119 void UIVMCloseDialog::setDetachButtonEnabled(bool fEnabled)
    120 {
    121     m_pDetachIcon->setEnabled(fEnabled);
    122     m_pDetachRadio->setEnabled(fEnabled);
    123 }
    124 
    125 void UIVMCloseDialog::setDetachButtonVisible(bool fVisible)
    126 {
    127     m_pDetachIcon->setVisible(fVisible);
    128     m_pDetachRadio->setVisible(fVisible);
    129 }
    130 
    131 void UIVMCloseDialog::setSaveButtonEnabled(bool fEnabled)
    132 {
    133     m_pSaveIcon->setEnabled(fEnabled);
    134     m_pSaveRadio->setEnabled(fEnabled);
    135 }
    136 
    137 void UIVMCloseDialog::setSaveButtonVisible(bool fVisible)
    138 {
    139     m_pSaveIcon->setVisible(fVisible);
    140     m_pSaveRadio->setVisible(fVisible);
    141 }
    142 
    143 void UIVMCloseDialog::setShutdownButtonEnabled(bool fEnabled)
    144 {
    145     m_pShutdownIcon->setEnabled(fEnabled);
    146     m_pShutdownRadio->setEnabled(fEnabled);
    147 }
    148 
    149 void UIVMCloseDialog::setShutdownButtonVisible(bool fVisible)
    150 {
    151     m_pShutdownIcon->setVisible(fVisible);
    152     m_pShutdownRadio->setVisible(fVisible);
    153 }
    154 
    155 void UIVMCloseDialog::setPowerOffButtonEnabled(bool fEnabled)
    156 {
    157     m_pPowerOffIcon->setEnabled(fEnabled);
    158     m_pPowerOffRadio->setEnabled(fEnabled);
    159 }
    160 
    161 void UIVMCloseDialog::setPowerOffButtonVisible(bool fVisible)
    162 {
    163     m_pPowerOffIcon->setVisible(fVisible);
    164     m_pPowerOffRadio->setVisible(fVisible);
    165 }
    166 
    167 void UIVMCloseDialog::setDiscardCheckBoxVisible(bool fVisible)
    168 {
    169     m_pDiscardCheckBox->setVisible(fVisible);
     216void UIVMCloseDialog::setButtonEnabledDetach(bool fEnabled)
     217{
     218    m_pLabelIconDetach->setEnabled(fEnabled);
     219    m_pRadioButtonDetach->setEnabled(fEnabled);
     220}
     221
     222void UIVMCloseDialog::setButtonVisibleDetach(bool fVisible)
     223{
     224    m_pLabelIconDetach->setVisible(fVisible);
     225    m_pRadioButtonDetach->setVisible(fVisible);
     226}
     227
     228void UIVMCloseDialog::setButtonEnabledSave(bool fEnabled)
     229{
     230    m_pLabelIconSave->setEnabled(fEnabled);
     231    m_pRadioButtonSave->setEnabled(fEnabled);
     232}
     233
     234void UIVMCloseDialog::setButtonVisibleSave(bool fVisible)
     235{
     236    m_pLabelIconSave->setVisible(fVisible);
     237    m_pRadioButtonSave->setVisible(fVisible);
     238}
     239
     240void UIVMCloseDialog::setButtonEnabledShutdown(bool fEnabled)
     241{
     242    m_pLabelIconShutdown->setEnabled(fEnabled);
     243    m_pRadioButtonShutdown->setEnabled(fEnabled);
     244}
     245
     246void UIVMCloseDialog::setButtonVisibleShutdown(bool fVisible)
     247{
     248    m_pLabelIconShutdown->setVisible(fVisible);
     249    m_pRadioButtonShutdown->setVisible(fVisible);
     250}
     251
     252void UIVMCloseDialog::setButtonEnabledPowerOff(bool fEnabled)
     253{
     254    m_pLabelIconPowerOff->setEnabled(fEnabled);
     255    m_pRadioButtonPowerOff->setEnabled(fEnabled);
     256}
     257
     258void UIVMCloseDialog::setButtonVisiblePowerOff(bool fVisible)
     259{
     260    m_pLabelIconPowerOff->setVisible(fVisible);
     261    m_pRadioButtonPowerOff->setVisible(fVisible);
     262}
     263
     264void UIVMCloseDialog::setCheckBoxVisibleDiscard(bool fVisible)
     265{
     266    m_pCheckBoxDiscard->setVisible(fVisible);
    170267}
    171268
    172269void UIVMCloseDialog::prepare()
    173270{
    174     /* Prepare 'main' layout: */
    175     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     271    /* Choose default dialog icon: */
     272    m_icon = UIIconPool::iconSet(":/os_unknown.png");
     273
     274    /* Prepare size-grip token: */
     275    setSizeGripEnabled(false);
     276
     277    /* Prepare main layout: */
     278    prepareMainLayout();
     279
     280    /* Update pixmaps: */
     281    updatePixmaps();
     282
     283    /* Configure: */
     284    configure();
     285
     286    /* Apply language settings: */
     287    retranslateUi();
     288}
     289
     290void UIVMCloseDialog::prepareMainLayout()
     291{
     292    /* Create main layout: */
     293    m_pMainLayout = new QVBoxLayout(this);
     294    if (m_pMainLayout)
    176295    {
    177296        /* Configure layout: */
    178297#ifdef VBOX_WS_MAC
    179         pMainLayout->setContentsMargins(40, 20, 40, 20);
    180         pMainLayout->setSpacing(15);
     298        m_pMainLayout->setContentsMargins(40, 20, 40, 20);
     299        m_pMainLayout->setSpacing(15);
    181300#else
    182         pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) * 2);
     301        m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) * 2);
    183302#endif
    184303
    185         /* Prepare 'top' layout: */
    186         QHBoxLayout *pTopLayout = new QHBoxLayout;
    187         {
    188             /* Configure layout: */
     304        /* Prepare top layout: */
     305        prepareTopLayout();
     306
     307        /* Add stretch between top and bottom: */
     308        m_pMainLayout->addStretch(1);
     309
     310        /* Prepare button-box: */
     311        prepareButtonBox();
     312    }
     313}
     314
     315void UIVMCloseDialog::prepareTopLayout()
     316{
     317    /* Create top layout: */
     318    m_pTopLayout = new QHBoxLayout;
     319    if (m_pTopLayout)
     320    {
     321        /* Configure layout: */
    189322#ifdef VBOX_WS_MAC
    190             pTopLayout->setSpacing(20);
     323        m_pTopLayout->setSpacing(20);
    191324#else
    192             pTopLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) * 2);
     325        m_pTopLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) * 2);
    193326#endif
    194327
    195             /* Prepare 'top-left' layout: */
    196             QVBoxLayout *pTopLeftLayout = new QVBoxLayout;
    197             {
    198                 /* Prepare 'icon': */
    199                 m_pIcon = new QLabel(this);
    200                 {
    201                     /* Configure icon: */
    202                     m_pIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    203                     const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
    204                     const QIcon icon = UIIconPool::iconSet(":/os_unknown.png");
    205                     m_pIcon->setPixmap(icon.pixmap(iIconMetric, iIconMetric));
    206                 }
    207 
    208                 /* Add into layout: */
    209                 pTopLeftLayout->addWidget(m_pIcon);
    210                 pTopLeftLayout->addStretch();
    211             }
    212             /* Prepare 'top-right' layout: */
    213             QVBoxLayout *pTopRightLayout = new QVBoxLayout;
    214             {
    215                 /* Configure layout: */
     328        /* Prepare top-left layout: */
     329        prepareTopLeftLayout();
     330        /* Prepare top-right layout: */
     331        prepareTopRightLayout();
     332
     333        /* Add into layout: */
     334        m_pMainLayout->addLayout(m_pTopLayout);
     335    }
     336}
     337
     338void UIVMCloseDialog::prepareTopLeftLayout()
     339{
     340    /* Create top-left layout: */
     341    m_pTopLeftLayout = new QVBoxLayout;
     342    if (m_pTopLeftLayout)
     343    {
     344        /* Create icon label: */
     345        m_pLabelIcon = new QLabel;
     346        if (m_pLabelIcon)
     347        {
     348            /* Configure label: */
     349            m_pLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     350
     351            /* Add into layout: */
     352            m_pTopLeftLayout->addWidget(m_pLabelIcon);
     353        }
     354
     355        /* Add vertical stretch under icon label: */
     356        m_pTopLeftLayout->addStretch();
     357
     358        /* Add into layout: */
     359        m_pTopLayout->addLayout(m_pTopLeftLayout);
     360    }
     361}
     362
     363void UIVMCloseDialog::prepareTopRightLayout()
     364{
     365    /* Create top-right layout: */
     366    m_pTopRightLayout = new QVBoxLayout;
     367    if (m_pTopRightLayout)
     368    {
     369        /* Configure layout: */
    216370#ifdef VBOX_WS_MAC
    217                 pTopRightLayout->setSpacing(10);
     371        m_pTopRightLayout->setSpacing(10);
    218372#else
    219                 pTopRightLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
     373        m_pTopRightLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
    220374#endif
    221375
    222                 /* Prepare 'text' label: */
    223                 m_pLabel = new QLabel(this);
    224                 /* Prepare 'choice' layout: */
    225                 QGridLayout *pChoiceLayout = new QGridLayout;
    226                 {
    227                     /* Configure layout: */
     376        /* Create text label: */
     377        m_pLabelText = new QLabel;
     378        if (m_pLabelText)
     379        {
     380            /* Add into layout: */
     381            m_pTopRightLayout->addWidget(m_pLabelText);
     382        }
     383
     384        /* Prepare choice layout: */
     385        prepareChoiceLayout();
     386
     387        /* Add into layout: */
     388        m_pTopLayout->addLayout(m_pTopRightLayout);
     389    }
     390}
     391
     392void UIVMCloseDialog::prepareChoiceLayout()
     393{
     394    /* Create 'choice' layout: */
     395    m_pChoiceLayout = new QGridLayout;
     396    if (m_pChoiceLayout)
     397    {
     398        /* Configure layout: */
    228399#ifdef VBOX_WS_MAC
    229                     pChoiceLayout->setSpacing(10);
     400        m_pChoiceLayout->setSpacing(10);
    230401#else
    231                     pChoiceLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
     402        m_pChoiceLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
    232403#endif
    233404
    234                     /* Prepare icon metric: */
    235                     const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    236                     /* Prepare 'detach' icon: */
    237                     m_pDetachIcon = new QLabel(this);
    238                     {
    239                         /* Configure icon: */
    240                         m_pDetachIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    241                         const QIcon icon = UIIconPool::iconSet(":/vm_create_shortcut_16px.png");
    242                         m_pDetachIcon->setPixmap(icon.pixmap(iIconMetric, iIconMetric));
    243                     }
    244                     /* Prepare 'detach' radio-button: */
    245                     m_pDetachRadio = new QRadioButton(this);
    246                     {
    247                         /* Configure button: */
    248                         m_pDetachRadio->installEventFilter(this);
    249                         connect(m_pDetachRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
    250                     }
    251                     /* Prepare 'save' icon: */
    252                     m_pSaveIcon = new QLabel(this);
    253                     {
    254                         /* Configure icon: */
    255                         m_pSaveIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    256                         const QIcon icon = UIIconPool::iconSet(":/vm_save_state_16px.png");
    257                         m_pSaveIcon->setPixmap(icon.pixmap(iIconMetric, iIconMetric));
    258                     }
    259                     /* Prepare 'save' radio-button: */
    260                     m_pSaveRadio = new QRadioButton(this);
    261                     {
    262                         /* Configure button: */
    263                         m_pSaveRadio->installEventFilter(this);
    264                         connect(m_pSaveRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
    265                     }
    266                     /* Prepare 'shutdown' icon: */
    267                     m_pShutdownIcon = new QLabel(this);
    268                     {
    269                         /* Configure icon: */
    270                         m_pShutdownIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    271                         const QIcon icon = UIIconPool::iconSet(":/vm_shutdown_16px.png");
    272                         m_pShutdownIcon->setPixmap(icon.pixmap(iIconMetric, iIconMetric));
    273                     }
    274                     /* Prepare 'shutdown' radio-button: */
    275                     m_pShutdownRadio = new QRadioButton(this);
    276                     {
    277                         /* Configure button: */
    278                         m_pShutdownRadio->installEventFilter(this);
    279                         connect(m_pShutdownRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
    280                     }
    281                     /* Prepare 'power-off' icon: */
    282                     m_pPowerOffIcon = new QLabel(this);
    283                     {
    284                         /* Configure icon: */
    285                         m_pPowerOffIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    286                         const QIcon icon = UIIconPool::iconSet(":/vm_poweroff_16px.png");
    287                         m_pPowerOffIcon->setPixmap(icon.pixmap(iIconMetric, iIconMetric));
    288                     }
    289                     /* Prepare 'shutdown' radio-button: */
    290                     m_pPowerOffRadio = new QRadioButton(this);
    291                     {
    292                         /* Configure button: */
    293                         m_pPowerOffRadio->installEventFilter(this);
    294                         connect(m_pPowerOffRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
    295                     }
    296                     /* Prepare 'discard' check-box: */
    297                     m_pDiscardCheckBox = new QCheckBox(this);
    298 
    299                     /* Add into layout: */
    300                     pChoiceLayout->addWidget(m_pDetachIcon, 0, 0);
    301                     pChoiceLayout->addWidget(m_pDetachRadio, 0, 1);
    302                     pChoiceLayout->addWidget(m_pSaveIcon, 1, 0);
    303                     pChoiceLayout->addWidget(m_pSaveRadio, 1, 1);
    304                     pChoiceLayout->addWidget(m_pShutdownIcon, 2, 0);
    305                     pChoiceLayout->addWidget(m_pShutdownRadio, 2, 1);
    306                     pChoiceLayout->addWidget(m_pPowerOffIcon, 3, 0);
    307                     pChoiceLayout->addWidget(m_pPowerOffRadio, 3, 1);
    308                     pChoiceLayout->addWidget(m_pDiscardCheckBox, 4, 1);
    309                 }
    310 
    311                 /* Add into layout: */
    312                 pTopRightLayout->addWidget(m_pLabel);
    313                 pTopRightLayout->addItem(pChoiceLayout);
    314             }
    315 
    316             /* Add into layout: */
    317             pTopLayout->addItem(pTopLeftLayout);
    318             pTopLayout->addItem(pTopRightLayout);
    319         }
    320 
    321         /* Prepare button-box: */
    322         QIDialogButtonBox *pButtonBox = new QIDialogButtonBox(this);
    323         {
    324             /* Configure button-box: */
    325             pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
    326             connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
    327             connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
    328             connect(pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
     405        /* Create 'detach' icon label: */
     406        m_pLabelIconDetach = new QLabel;
     407        if (m_pLabelIconDetach)
     408        {
     409            /* Configure label: */
     410            m_pLabelIconDetach->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     411            /* Add into layout: */
     412            m_pChoiceLayout->addWidget(m_pLabelIconDetach, 0, 0);
     413        }
     414        /* Create 'detach' radio-button: */
     415        m_pRadioButtonDetach = new QRadioButton;
     416        if (m_pRadioButtonDetach)
     417        {
     418            /* Configure button: */
     419            m_pRadioButtonDetach->installEventFilter(this);
     420            connect(m_pRadioButtonDetach, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
     421            /* Add into layout: */
     422            m_pChoiceLayout->addWidget(m_pRadioButtonDetach, 0, 1);
     423        }
     424
     425        /* Create 'save' icon label: */
     426        m_pLabelIconSave = new QLabel;
     427        if (m_pLabelIconSave)
     428        {
     429            /* Configure label: */
     430            m_pLabelIconSave->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     431            /* Add into layout: */
     432            m_pChoiceLayout->addWidget(m_pLabelIconSave, 1, 0);
     433        }
     434        /* Create 'save' radio-button: */
     435        m_pRadioButtonSave = new QRadioButton;
     436        if (m_pRadioButtonSave)
     437        {
     438            /* Configure button: */
     439            m_pRadioButtonSave->installEventFilter(this);
     440            connect(m_pRadioButtonSave, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
     441            /* Add into layout: */
     442            m_pChoiceLayout->addWidget(m_pRadioButtonSave, 1, 1);
     443        }
     444
     445        /* Create 'shutdown' icon label: */
     446        m_pLabelIconShutdown = new QLabel;
     447        if (m_pLabelIconShutdown)
     448        {
     449            /* Configure label: */
     450            m_pLabelIconShutdown->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     451            /* Add into layout: */
     452            m_pChoiceLayout->addWidget(m_pLabelIconShutdown, 2, 0);
     453        }
     454        /* Create 'shutdown' radio-button: */
     455        m_pRadioButtonShutdown = new QRadioButton;
     456        if (m_pRadioButtonShutdown)
     457        {
     458            /* Configure button: */
     459            m_pRadioButtonShutdown->installEventFilter(this);
     460            connect(m_pRadioButtonShutdown, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
     461            /* Add into layout: */
     462            m_pChoiceLayout->addWidget(m_pRadioButtonShutdown, 2, 1);
     463        }
     464
     465        /* Create 'power-off' icon label: */
     466        m_pLabelIconPowerOff = new QLabel;
     467        if (m_pLabelIconPowerOff)
     468        {
     469            /* Configure label: */
     470            m_pLabelIconPowerOff->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     471            /* Add into layout: */
     472            m_pChoiceLayout->addWidget(m_pLabelIconPowerOff, 3, 0);
     473        }
     474        /* Create 'shutdown' radio-button: */
     475        m_pRadioButtonPowerOff = new QRadioButton;
     476        if (m_pRadioButtonPowerOff)
     477        {
     478            /* Configure button: */
     479            m_pRadioButtonPowerOff->installEventFilter(this);
     480            connect(m_pRadioButtonPowerOff, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
     481            /* Add into layout: */
     482            m_pChoiceLayout->addWidget(m_pRadioButtonPowerOff, 3, 1);
     483        }
     484
     485        /* Create 'discard' check-box: */
     486        m_pCheckBoxDiscard = new QCheckBox;
     487        if (m_pCheckBoxDiscard)
     488        {
     489            /* Add into layout: */
     490            m_pChoiceLayout->addWidget(m_pCheckBoxDiscard, 4, 1);
    329491        }
    330492
    331493        /* Add into layout: */
    332         pMainLayout->addItem(pTopLayout);
    333         pMainLayout->addWidget(pButtonBox);
    334     }
    335     /* Prepare size-grip token: */
    336     setSizeGripEnabled(false);
     494        m_pTopRightLayout->addLayout(m_pChoiceLayout);
     495    }
     496}
     497
     498void UIVMCloseDialog::prepareButtonBox()
     499{
     500    /* Create button-box: */
     501    QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
     502    if (pButtonBox)
     503    {
     504        /* Configure button-box: */
     505        pButtonBox->setStandardButtons(  QDialogButtonBox::Cancel
     506                                       | QDialogButtonBox::Help
     507                                       | QDialogButtonBox::NoButton
     508                                       | QDialogButtonBox::Ok);
     509        connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIVMCloseDialog::accept);
     510        connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIVMCloseDialog::reject);
     511        connect(pButtonBox, &QIDialogButtonBox::helpRequested, &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog);
     512
     513        /* Add into layout: */
     514        m_pMainLayout->addWidget(pButtonBox);
     515    }
    337516}
    338517
     
    340519{
    341520    /* Get actual machine-state: */
    342     KMachineState machineState = m_machine.GetState();
     521    KMachineState machineState = m_comMachine.GetState();
    343522
    344523    /* Check which close-actions are resticted: */
     
    350529
    351530    /* Make 'Detach' button visible/hidden depending on restriction: */
    352     setDetachButtonVisible(fIsDetachAllowed);
     531    setButtonVisibleDetach(fIsDetachAllowed);
    353532    /* Make 'Detach' button enabled/disabled depending on machine-state: */
    354     setDetachButtonEnabled(machineState != KMachineState_Stuck);
     533    setButtonEnabledDetach(machineState != KMachineState_Stuck);
    355534
    356535    /* Make 'Save state' button visible/hidden depending on restriction: */
    357     setSaveButtonVisible(fIsStateSavingAllowed);
     536    setButtonVisibleSave(fIsStateSavingAllowed);
    358537    /* Make 'Save state' button enabled/disabled depending on machine-state: */
    359     setSaveButtonEnabled(machineState != KMachineState_Stuck);
     538    setButtonEnabledSave(machineState != KMachineState_Stuck);
    360539
    361540    /* Make 'Shutdown' button visible/hidden depending on restriction: */
    362     setShutdownButtonVisible(fIsACPIShutdownAllowed);
     541    setButtonVisibleShutdown(fIsACPIShutdownAllowed);
    363542    /* Make 'Shutdown' button enabled/disabled depending on console and machine-state: */
    364     setShutdownButtonEnabled(m_fIsACPIEnabled && machineState != KMachineState_Stuck);
     543    setButtonEnabledShutdown(m_fIsACPIEnabled && machineState != KMachineState_Stuck);
    365544
    366545    /* Make 'Power off' button visible/hidden depending on restriction: */
    367     setPowerOffButtonVisible(fIsPowerOffAllowed);
     546    setButtonVisiblePowerOff(fIsPowerOffAllowed);
    368547    /* Make the Restore Snapshot checkbox visible/hidden depending on snapshot count & restrictions: */
    369     setDiscardCheckBoxVisible(fIsPowerOffAndRestoreAllowed && m_machine.GetSnapshotCount() > 0);
     548    setCheckBoxVisibleDiscard(fIsPowerOffAndRestoreAllowed && m_comMachine.GetSnapshotCount() > 0);
    370549    /* Assign Restore Snapshot checkbox text: */
    371     if (!m_machine.GetCurrentSnapshot().isNull())
    372         m_strDiscardCheckBoxText = m_machine.GetCurrentSnapshot().GetName();
     550    if (!m_comMachine.GetCurrentSnapshot().isNull())
     551        m_strDiscardCheckBoxText = m_comMachine.GetCurrentSnapshot().GetName();
    373552
    374553    /* Check which radio-button should be initially chosen: */
    375554    QRadioButton *pRadioButtonToChoose = 0;
    376555    /* If choosing 'last choice' is possible: */
    377     m_lastCloseAction = gEDataManager->lastMachineCloseAction(vboxGlobal().managedVMUuid());
    378     if (m_lastCloseAction == MachineCloseAction_Detach && fIsDetachAllowed)
    379     {
    380         pRadioButtonToChoose = m_pDetachRadio;
    381     }
    382     else if (m_lastCloseAction == MachineCloseAction_SaveState && fIsStateSavingAllowed)
    383     {
    384         pRadioButtonToChoose = m_pSaveRadio;
    385     }
    386     else if (m_lastCloseAction == MachineCloseAction_Shutdown && fIsACPIShutdownAllowed && m_fIsACPIEnabled)
    387     {
    388         pRadioButtonToChoose = m_pShutdownRadio;
    389     }
    390     else if (m_lastCloseAction == MachineCloseAction_PowerOff && fIsPowerOffAllowed)
    391     {
    392         pRadioButtonToChoose = m_pPowerOffRadio;
    393     }
    394     else if (m_lastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed)
    395     {
    396         pRadioButtonToChoose = m_pPowerOffRadio;
    397         m_pDiscardCheckBox->setChecked(true);
     556    m_enmLastCloseAction = gEDataManager->lastMachineCloseAction(vboxGlobal().managedVMUuid());
     557    if (m_enmLastCloseAction == MachineCloseAction_Detach && fIsDetachAllowed)
     558    {
     559        pRadioButtonToChoose = m_pRadioButtonDetach;
     560    }
     561    else if (m_enmLastCloseAction == MachineCloseAction_SaveState && fIsStateSavingAllowed)
     562    {
     563        pRadioButtonToChoose = m_pRadioButtonSave;
     564    }
     565    else if (m_enmLastCloseAction == MachineCloseAction_Shutdown && fIsACPIShutdownAllowed && m_fIsACPIEnabled)
     566    {
     567        pRadioButtonToChoose = m_pRadioButtonShutdown;
     568    }
     569    else if (m_enmLastCloseAction == MachineCloseAction_PowerOff && fIsPowerOffAllowed)
     570    {
     571        pRadioButtonToChoose = m_pRadioButtonPowerOff;
     572    }
     573    else if (m_enmLastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed)
     574    {
     575        pRadioButtonToChoose = m_pRadioButtonPowerOff;
     576        m_pCheckBoxDiscard->setChecked(true);
    398577    }
    399578    /* Else 'default choice' will be used: */
     
    401580    {
    402581        if (fIsDetachAllowed)
    403             pRadioButtonToChoose = m_pDetachRadio;
     582            pRadioButtonToChoose = m_pRadioButtonDetach;
    404583        else if (fIsStateSavingAllowed)
    405             pRadioButtonToChoose = m_pSaveRadio;
     584            pRadioButtonToChoose = m_pRadioButtonSave;
    406585        else if (fIsACPIShutdownAllowed && m_fIsACPIEnabled)
    407             pRadioButtonToChoose = m_pShutdownRadio;
     586            pRadioButtonToChoose = m_pRadioButtonShutdown;
    408587        else if (fIsPowerOffAllowed)
    409             pRadioButtonToChoose = m_pPowerOffRadio;
     588            pRadioButtonToChoose = m_pRadioButtonPowerOff;
    410589    }
    411590
     
    421600}
    422601
    423 void UIVMCloseDialog::retranslateUi()
    424 {
    425     /* Translate title: */
    426     setWindowTitle(tr("Close Virtual Machine"));
    427 
    428     /* Translate 'text' label: */
    429     m_pLabel->setText(tr("You want to:"));
    430 
    431     /* Translate radio-buttons: */
    432     m_pDetachRadio->setText(tr("&Continue running in the background"));
    433     m_pDetachRadio->setWhatsThis(tr("<p>Close the virtual machine windows but keep the virtual machine running.</p>"
    434                                     "<p>You can use the VirtualBox Manager to return to running the virtual machine in a window.</p>"));
    435     m_pSaveRadio->setText(tr("&Save the machine state"));
    436     m_pSaveRadio->setWhatsThis(tr("<p>Saves the current execution state of the virtual machine to the physical hard disk of the host PC.</p>"
    437                                   "<p>Next time this machine is started, it will be restored from the saved state and continue execution "
    438                                   "from the same place you saved it at, which will let you continue your work immediately.</p>"
    439                                   "<p>Note that saving the machine state may take a long time, depending on the guest operating "
    440                                   "system type and the amount of memory you assigned to the virtual machine.</p>"));
    441     m_pShutdownRadio->setText(tr("S&end the shutdown signal"));
    442     m_pShutdownRadio->setWhatsThis(tr("<p>Sends the ACPI Power Button press event to the virtual machine.</p>"
    443                                       "<p>Normally, the guest operating system running inside the virtual machine will detect this event "
    444                                       "and perform a clean shutdown procedure. This is a recommended way to turn off the virtual machine "
    445                                       "because all applications running inside it will get a chance to save their data and state.</p>"
    446                                       "<p>If the machine doesn't respond to this action then the guest operating system may be misconfigured "
    447                                       "or doesn't understand ACPI Power Button events at all. In this case you should select the "
    448                                       "<b>Power off the machine</b> action to stop virtual machine execution.</p>"));
    449     m_pPowerOffRadio->setText(tr("&Power off the machine"));
    450     m_pPowerOffRadio->setWhatsThis(tr("<p>Turns off the virtual machine.</p>"
    451                                       "<p>Note that this action will stop machine execution immediately so that the guest operating system "
    452                                       "running inside it will not be able to perform a clean shutdown procedure which may result in "
    453                                       "<i>data loss</i> inside the virtual machine. Selecting this action is recommended only if the "
    454                                       "virtual machine does not respond to the <b>Send the shutdown signal</b> action.</p>"));
    455     m_pDiscardCheckBox->setText(tr("&Restore current snapshot '%1'").arg(m_strDiscardCheckBoxText));
    456     m_pDiscardCheckBox->setToolTip(tr("Restore the machine state stored in the current snapshot"));
    457     m_pDiscardCheckBox->setWhatsThis(tr("<p>When checked, the machine will be returned to the state stored in the current snapshot after "
    458                                         "it is turned off. This is useful if you are sure that you want to discard the results of your "
    459                                         "last sessions and start again at that snapshot.</p>"));
    460 }
    461 
    462 bool UIVMCloseDialog::eventFilter(QObject *pWatched, QEvent *pEvent)
    463 {
    464     /* For now we are interested in double-click events only: */
    465     if (pEvent->type() == QEvent::MouseButtonDblClick)
    466     {
    467         /* Make sure its one of the radio-buttons
    468          * which has this event-filter installed: */
    469         if (qobject_cast<QRadioButton*>(pWatched))
    470         {
    471             /* Since on double-click the button will be also selected
    472              * we are just calling for the *accept* slot: */
    473             accept();
    474         }
    475     }
    476 
    477     /* Call to base-class: */
    478     return QIWithRetranslateUI<QIDialog>::eventFilter(pWatched, pEvent);
    479 }
    480 
    481 void UIVMCloseDialog::polishEvent(QShowEvent *pEvent)
    482 {
    483     /* Call to base-class: */
    484     QIDialog::polishEvent(pEvent);
    485 
    486     /* Make the dialog-size fixed: */
    487     setFixedSize(size());
    488 }
    489 
     602void UIVMCloseDialog::updatePixmaps()
     603{
     604    /* Acquire hints: */
     605    const int iMetricSmall = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
     606    const int iMetricLarge = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
     607
     608    /* Re-apply pixmap: */
     609    m_pLabelIcon->setPixmap(m_icon.pixmap(windowHandle(), QSize(iMetricLarge, iMetricLarge)));
     610
     611    QIcon icon;
     612    icon = UIIconPool::iconSet(":/vm_create_shortcut_16px.png");
     613    m_pLabelIconDetach->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
     614    icon = UIIconPool::iconSet(":/vm_save_state_16px.png");
     615    m_pLabelIconSave->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
     616    icon = UIIconPool::iconSet(":/vm_shutdown_16px.png");
     617    m_pLabelIconShutdown->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
     618    icon = UIIconPool::iconSet(":/vm_poweroff_16px.png");
     619    m_pLabelIconPowerOff->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
     620}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r71027 r72887  
    55
    66/*
    7  * Copyright (C) 2006-2017 Oracle Corporation
     7 * Copyright (C) 2006-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UIVMCloseDialog_h__
    19 #define __UIVMCloseDialog_h__
     18#ifndef ___UIVMCloseDialog_h___
     19#define ___UIVMCloseDialog_h___
     20
     21/* Qt includes: */
     22#include <QIcon>
    2023
    2124/* GUI includes: */
     25#include "QIDialog.h"
    2226#include "QIWithRetranslateUI.h"
    23 #include "QIDialog.h"
    2427#include "UIExtraDataDefs.h"
    2528
    2629/* Forward declarations: */
    27 class CMachine;
     30class QCheckBox;
     31class QGridLayout;
     32class QHBoxLayout;
    2833class QLabel;
    2934class QRadioButton;
    30 class QCheckBox;
     35class QVBoxLayout;
     36class CMachine;
    3137
    32 /* QIDialog extension to handle Runtime UI close-event: */
     38/** QIDialog extension to handle Runtime UI close-event. */
    3339class UIVMCloseDialog : public QIWithRetranslateUI<QIDialog>
    3440{
     
    3743public:
    3844
    39     /* Constructor: */
    40     UIVMCloseDialog(QWidget *pParent, CMachine &machine,
     45    /** Constructs close dialog passing @a pParent to the base-class.
     46      * @param  comMachine             Brings the machine dialog created for.
     47      * @param  fIsACPIEnabled         Brings whether ACPI is enabled.
     48      * @param  restictedCloseActions  Brings a set of restricted actions. */
     49    UIVMCloseDialog(QWidget *pParent, CMachine &comMachine,
    4150                    bool fIsACPIEnabled, MachineCloseAction restictedCloseActions);
    4251
    43     /* API: Validation stuff: */
     52    /** Returns whether dialog is valid. */
    4453    bool isValid() const { return m_fValid; }
    4554
    46     /* API: Pixmap stuff: */
    47     void setPixmap(const QPixmap &pixmap);
     55    /** Defines dialog @a icon. */
     56    void setIcon(const QIcon &icon);
     57
     58protected:
     59
     60    /** Preprocesses any Qt @a pEvent for passed @a pObject. */
     61    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
     62
     63    /** Handles any Qt @a pEvent. */
     64    virtual bool event(QEvent *pEvent) /* override */;
     65
     66    /** Handles translation event. */
     67    virtual void retranslateUi() /* override */;
    4868
    4969private slots:
    5070
    51     /* Handler: Update stuff: */
     71    /** Updates widgets availability. */
    5272    void sltUpdateWidgetAvailability();
    5373
    54     /* Handler: Accept stuff: */
     74    /** Accepts the dialog. */
    5575    void accept();
    5676
    5777private:
    5878
    59     /* API: Detach-button stuff: */
    60     void setDetachButtonEnabled(bool fEnabled);
    61     void setDetachButtonVisible(bool fVisible);
    62     /* API: Save-button stuff: */
    63     void setSaveButtonEnabled(bool fEnabled);
    64     void setSaveButtonVisible(bool fVisible);
    65     /* API: Shutdown-button stuff: */
    66     void setShutdownButtonEnabled(bool fEnabled);
    67     void setShutdownButtonVisible(bool fVisible);
    68     /* API: Power-off-button stuff: */
    69     void setPowerOffButtonEnabled(bool fEnabled);
    70     void setPowerOffButtonVisible(bool fVisible);
    71     /* API: Discard-check-box stuff: */
    72     void setDiscardCheckBoxVisible(bool fVisible);
     79    /** Defines whether 'Detach' button is enabled. */
     80    void setButtonEnabledDetach(bool fEnabled);
     81    /** Defines whether 'Detach' button is visible. */
     82    void setButtonVisibleDetach(bool fVisible);
    7383
    74     /* Helpers: Prepare stuff: */
     84    /** Defines whether 'Save' button is enabled. */
     85    void setButtonEnabledSave(bool fEnabled);
     86    /** Defines whether 'Save' button is visible. */
     87    void setButtonVisibleSave(bool fVisible);
     88
     89    /** Defines whether 'Shutdown' button is enabled. */
     90    void setButtonEnabledShutdown(bool fEnabled);
     91    /** Defines whether 'Shutdown' button is visible. */
     92    void setButtonVisibleShutdown(bool fVisible);
     93
     94    /** Defines whether 'PowerOff' button is enabled. */
     95    void setButtonEnabledPowerOff(bool fEnabled);
     96    /** Defines whether 'PowerOff' button is visible. */
     97    void setButtonVisiblePowerOff(bool fVisible);
     98
     99    /** Defines whether 'Discard' check-box is visible. */
     100    void setCheckBoxVisibleDiscard(bool fVisible);
     101
     102    /** Prepares all. */
    75103    void prepare();
     104    /** Prepares main layout. */
     105    void prepareMainLayout();
     106    /** Prepares top layout. */
     107    void prepareTopLayout();
     108    /** Prepares top-left layout. */
     109    void prepareTopLeftLayout();
     110    /** Prepares top-right layout. */
     111    void prepareTopRightLayout();
     112    /** Prepares choice layout. */
     113    void prepareChoiceLayout();
     114    /** Prepares button-box. */
     115    void prepareButtonBox();
     116
     117    /** Configures dialog. */
    76118    void configure();
    77119
    78     /* Helper: Translate stuff: */
    79     void retranslateUi();
     120    /** Updates pixmaps. */
     121    void updatePixmaps();
    80122
    81     /* Handler: Event-filtering stuff: */
    82     bool eventFilter(QObject *pWatched, QEvent *pEvent);
     123    /** Holds the live machine reference. */
     124    CMachine                 &m_comMachine;
     125    /** Holds whether ACPI is enabled. */
     126    bool                      m_fIsACPIEnabled;
     127    /** Holds a set of restricted actions. */
     128    const MachineCloseAction  m_restictedCloseActions;
    83129
    84     /* Handler: Polish-event stuff: */
    85     void polishEvent(QShowEvent *pEvent);
     130    /** Holds whether dialog is valid. */
     131    bool  m_fValid;
    86132
    87     /* Widgets: */
    88     QLabel *m_pIcon;
    89     QLabel *m_pLabel;
    90     QLabel *m_pDetachIcon;
    91     QRadioButton *m_pDetachRadio;
    92     QLabel *m_pSaveIcon;
    93     QRadioButton *m_pSaveRadio;
    94     QLabel *m_pShutdownIcon;
    95     QRadioButton *m_pShutdownRadio;
    96     QLabel *m_pPowerOffIcon;
    97     QRadioButton *m_pPowerOffRadio;
    98     QCheckBox *m_pDiscardCheckBox;
     133    /** Holds the dialog icon. */
     134    QIcon  m_icon;
    99135
    100     /* Variables: */
    101     CMachine &m_machine;
    102     const MachineCloseAction m_restictedCloseActions;
    103     bool m_fIsACPIEnabled;
    104     bool m_fValid;
    105     QString m_strDiscardCheckBoxText;
    106     MachineCloseAction m_lastCloseAction;
     136    /** Holds the main layout instance. */
     137    QVBoxLayout *m_pMainLayout;
     138    /** Holds the top layout instance. */
     139    QHBoxLayout *m_pTopLayout;
     140    /** Holds the top-left layout instance. */
     141    QVBoxLayout *m_pTopLeftLayout;
     142    /** Holds the top-right layout instance. */
     143    QVBoxLayout *m_pTopRightLayout;
     144    /** Holds the choice layout instance. */
     145    QGridLayout *m_pChoiceLayout;
     146
     147    /** Holds the icon label instance. */
     148    QLabel *m_pLabelIcon;
     149    /** Holds the text label instance. */
     150    QLabel *m_pLabelText;
     151
     152    /** Holds the 'Detach' icon label instance.  */
     153    QLabel       *m_pLabelIconDetach;
     154    /** Holds the 'Detach' radio-button instance.  */
     155    QRadioButton *m_pRadioButtonDetach;
     156    /** Holds the 'Save' icon label instance.  */
     157    QLabel       *m_pLabelIconSave;
     158    /** Holds the 'Save' radio-button instance.  */
     159    QRadioButton *m_pRadioButtonSave;
     160    /** Holds the 'Shutdown' icon label instance.  */
     161    QLabel       *m_pLabelIconShutdown;
     162    /** Holds the 'Shutdown' radio-button instance.  */
     163    QRadioButton *m_pRadioButtonShutdown;
     164    /** Holds the 'PowerOff' icon label instance.  */
     165    QLabel       *m_pLabelIconPowerOff;
     166    /** Holds the 'PowerOff' radio-button instance.  */
     167    QRadioButton *m_pRadioButtonPowerOff;
     168
     169    /** Holds the 'Discard' check-box instance.  */
     170    QCheckBox *m_pCheckBoxDiscard;
     171    /** Holds the 'Discard' check-box text. */
     172    QString    m_strDiscardCheckBoxText;
     173
     174    /** Holds the last close action. */
     175    MachineCloseAction  m_enmLastCloseAction;
    107176};
    108177
    109 #endif // __UIVMCloseDialog_h__
    110 
     178#endif /* !___UIVMCloseDialog_h___ */
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