VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp@ 82781

Last change on this file since 82781 was 79365, checked in by vboxsync, 5 years ago

Renaming VBoxGlobal to UICommon for bugref:9049 as planned.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.8 KB
Line 
1/* $Id: UIVMCloseDialog.cpp 79365 2019-06-26 15:57:32Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVMCloseDialog class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* Qt includes: */
19#include <QCheckBox>
20#include <QGridLayout>
21#include <QHBoxLayout>
22#include <QLabel>
23#include <QPushButton>
24#include <QRadioButton>
25#include <QStyle>
26#include <QVBoxLayout>
27
28/* GUI includes: */
29#include "UIIconPool.h"
30#include "UIVMCloseDialog.h"
31#include "UIExtraDataManager.h"
32#include "UIMessageCenter.h"
33#include "UIConverter.h"
34#include "UICommon.h"
35#include "QIDialogButtonBox.h"
36
37/* COM includes: */
38#include "CMachine.h"
39#include "CSession.h"
40#include "CConsole.h"
41#include "CSnapshot.h"
42
43
44UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, CMachine &comMachine,
45 bool fIsACPIEnabled, MachineCloseAction restictedCloseActions)
46 : QIWithRetranslateUI<QIDialog>(pParent)
47 , m_comMachine(comMachine)
48 , m_fIsACPIEnabled(fIsACPIEnabled)
49 , m_restictedCloseActions(restictedCloseActions)
50 , m_fValid(false)
51 , m_pMainLayout(0)
52 , m_pTopLayout(0)
53 , m_pTopLeftLayout(0)
54 , m_pTopRightLayout(0)
55 , m_pChoiceLayout(0)
56 , m_pLabelIcon(0), m_pLabelText(0)
57 , m_pLabelIconDetach(0), m_pRadioButtonDetach(0)
58 , m_pLabelIconSave(0), m_pRadioButtonSave(0)
59 , m_pLabelIconShutdown(0), m_pRadioButtonShutdown(0)
60 , m_pLabelIconPowerOff(0), m_pRadioButtonPowerOff(0)
61 , m_pCheckBoxDiscard(0)
62 , m_enmLastCloseAction(MachineCloseAction_Invalid)
63{
64 prepare();
65}
66
67void UIVMCloseDialog::setIcon(const QIcon &icon)
68{
69 /* Make sure icon is valid: */
70 if (icon.isNull())
71 return;
72
73 /* Remember it: */
74 m_icon = icon;
75 /* Update pixmaps: */
76 updatePixmaps();
77}
78
79bool UIVMCloseDialog::eventFilter(QObject *pObject, QEvent *pEvent)
80{
81 /* Handle events realted to our radio-buttons only: */
82 if ( pObject != m_pRadioButtonDetach
83 && pObject != m_pRadioButtonSave
84 && pObject != m_pRadioButtonShutdown
85 && pObject != m_pRadioButtonPowerOff)
86 return QIWithRetranslateUI<QIDialog>::eventFilter(pObject, pEvent);
87
88 /* For now we are interested in double-click events only: */
89 if (pEvent->type() == QEvent::MouseButtonDblClick)
90 {
91 /* Make sure it's one of the radio-buttons
92 * which has this event-filter installed: */
93 if (qobject_cast<QRadioButton*>(pObject))
94 {
95 /* Since on double-click the button will be also selected
96 * we are just calling for the *accept* slot: */
97 accept();
98 }
99 }
100
101 /* Call to base-class: */
102 return QIWithRetranslateUI<QIDialog>::eventFilter(pObject, pEvent);
103}
104
105bool UIVMCloseDialog::event(QEvent *pEvent)
106{
107 /* Pre-process in base-class: */
108 const bool fResult = QIWithRetranslateUI<QIDialog>::event(pEvent);
109
110 /* Post-process know event types: */
111 switch (pEvent->type())
112 {
113 case QEvent::ScreenChangeInternal:
114 {
115 /* Update pixmaps: */
116 updatePixmaps();
117 break;
118 }
119 default:
120 break;
121 }
122
123 /* Return pre-processed result: */
124 return fResult;
125}
126
127void UIVMCloseDialog::showEvent(QShowEvent *pEvent)
128{
129 /* Update pixmaps: */
130 updatePixmaps();
131
132 /* Call to base-class: */
133 QIWithRetranslateUI<QIDialog>::showEvent(pEvent);
134}
135
136void UIVMCloseDialog::retranslateUi()
137{
138 /* Translate title: */
139 setWindowTitle(tr("Close Virtual Machine"));
140
141 /* Translate text label: */
142 m_pLabelText->setText(tr("You want to:"));
143
144 /* Translate radio-buttons: */
145 m_pRadioButtonDetach->setText(tr("&Continue running in the background"));
146 m_pRadioButtonDetach->setWhatsThis(tr("<p>Close the virtual machine windows but keep the virtual machine running.</p>"
147 "<p>You can use the VirtualBox Manager to return to running the virtual machine "
148 "in a window.</p>"));
149 m_pRadioButtonSave->setText(tr("&Save the machine state"));
150 m_pRadioButtonSave->setWhatsThis(tr("<p>Saves the current execution state of the virtual machine to the physical hard disk "
151 "of the host PC.</p>"
152 "<p>Next time this machine is started, it will be restored from the saved state and "
153 "continue execution from the same place you saved it at, which will let you continue "
154 "your work immediately.</p>"
155 "<p>Note that saving the machine state may take a long time, depending on the guest "
156 "operating system type and the amount of memory you assigned to the virtual "
157 "machine.</p>"));
158 m_pRadioButtonShutdown->setText(tr("S&end the shutdown signal"));
159 m_pRadioButtonShutdown->setWhatsThis(tr("<p>Sends the ACPI Power Button press event to the virtual machine.</p>"
160 "<p>Normally, the guest operating system running inside the virtual machine will "
161 "detect this event and perform a clean shutdown procedure. This is a recommended "
162 "way to turn off the virtual machine because all applications running inside it "
163 "will get a chance to save their data and state.</p>"
164 "<p>If the machine doesn't respond to this action then the guest operating system "
165 "may be misconfigured or doesn't understand ACPI Power Button events at all. In "
166 "this case you should select the <b>Power off the machine</b> action to stop "
167 "virtual machine execution.</p>"));
168 m_pRadioButtonPowerOff->setText(tr("&Power off the machine"));
169 m_pRadioButtonPowerOff->setWhatsThis(tr("<p>Turns off the virtual machine.</p>"
170 "<p>Note that this action will stop machine execution immediately so that the guest "
171 "operating system running inside it will not be able to perform a clean shutdown "
172 "procedure which may result in <i>data loss</i> inside the virtual machine. "
173 "Selecting this action is recommended only if the virtual machine does not respond "
174 "to the <b>Send the shutdown signal</b> action.</p>"));
175
176 /* Translate check-box: */
177 m_pCheckBoxDiscard->setText(tr("&Restore current snapshot '%1'").arg(m_strDiscardCheckBoxText));
178 m_pCheckBoxDiscard->setToolTip(tr("Restore the machine state stored in the current snapshot"));
179 m_pCheckBoxDiscard->setWhatsThis(tr("<p>When checked, the machine will be returned to the state stored in the current "
180 "snapshot after it is turned off. This is useful if you are sure that you want to "
181 "discard the results of your last sessions and start again at that snapshot.</p>"));
182}
183
184void UIVMCloseDialog::sltUpdateWidgetAvailability()
185{
186 /* Discard option should be enabled only on power-off action: */
187 m_pCheckBoxDiscard->setEnabled(m_pRadioButtonPowerOff->isChecked());
188}
189
190void UIVMCloseDialog::accept()
191{
192 /* Calculate result: */
193 if (m_pRadioButtonDetach->isChecked())
194 setResult(MachineCloseAction_Detach);
195 else if (m_pRadioButtonSave->isChecked())
196 setResult(MachineCloseAction_SaveState);
197 else if (m_pRadioButtonShutdown->isChecked())
198 setResult(MachineCloseAction_Shutdown);
199 else if (m_pRadioButtonPowerOff->isChecked())
200 {
201 if (!m_pCheckBoxDiscard->isChecked() || !m_pCheckBoxDiscard->isVisible())
202 setResult(MachineCloseAction_PowerOff);
203 else
204 setResult(MachineCloseAction_PowerOff_RestoringSnapshot);
205 }
206
207 /* Memorize the last user's choice for the given VM: */
208 MachineCloseAction newCloseAction = static_cast<MachineCloseAction>(result());
209 /* But make sure 'Shutdown' is preserved if temporary unavailable: */
210 if (newCloseAction == MachineCloseAction_PowerOff &&
211 m_enmLastCloseAction == MachineCloseAction_Shutdown && !m_fIsACPIEnabled)
212 newCloseAction = MachineCloseAction_Shutdown;
213 gEDataManager->setLastMachineCloseAction(newCloseAction, uiCommon().managedVMUuid());
214
215 /* Hide the dialog: */
216 hide();
217}
218
219void UIVMCloseDialog::setButtonEnabledDetach(bool fEnabled)
220{
221 m_pLabelIconDetach->setEnabled(fEnabled);
222 m_pRadioButtonDetach->setEnabled(fEnabled);
223}
224
225void UIVMCloseDialog::setButtonVisibleDetach(bool fVisible)
226{
227 m_pLabelIconDetach->setVisible(fVisible);
228 m_pRadioButtonDetach->setVisible(fVisible);
229}
230
231void UIVMCloseDialog::setButtonEnabledSave(bool fEnabled)
232{
233 m_pLabelIconSave->setEnabled(fEnabled);
234 m_pRadioButtonSave->setEnabled(fEnabled);
235}
236
237void UIVMCloseDialog::setButtonVisibleSave(bool fVisible)
238{
239 m_pLabelIconSave->setVisible(fVisible);
240 m_pRadioButtonSave->setVisible(fVisible);
241}
242
243void UIVMCloseDialog::setButtonEnabledShutdown(bool fEnabled)
244{
245 m_pLabelIconShutdown->setEnabled(fEnabled);
246 m_pRadioButtonShutdown->setEnabled(fEnabled);
247}
248
249void UIVMCloseDialog::setButtonVisibleShutdown(bool fVisible)
250{
251 m_pLabelIconShutdown->setVisible(fVisible);
252 m_pRadioButtonShutdown->setVisible(fVisible);
253}
254
255void UIVMCloseDialog::setButtonEnabledPowerOff(bool fEnabled)
256{
257 m_pLabelIconPowerOff->setEnabled(fEnabled);
258 m_pRadioButtonPowerOff->setEnabled(fEnabled);
259}
260
261void UIVMCloseDialog::setButtonVisiblePowerOff(bool fVisible)
262{
263 m_pLabelIconPowerOff->setVisible(fVisible);
264 m_pRadioButtonPowerOff->setVisible(fVisible);
265}
266
267void UIVMCloseDialog::setCheckBoxVisibleDiscard(bool fVisible)
268{
269 m_pCheckBoxDiscard->setVisible(fVisible);
270}
271
272void UIVMCloseDialog::prepare()
273{
274 /* Choose default dialog icon: */
275 m_icon = UIIconPool::iconSet(":/os_unknown.png");
276
277 /* Prepare size-grip token: */
278 setSizeGripEnabled(false);
279
280 /* Prepare main layout: */
281 prepareMainLayout();
282
283 /* Update pixmaps: */
284 updatePixmaps();
285
286 /* Configure: */
287 configure();
288
289 /* Apply language settings: */
290 retranslateUi();
291}
292
293void UIVMCloseDialog::prepareMainLayout()
294{
295 /* Create main layout: */
296 m_pMainLayout = new QVBoxLayout(this);
297 if (m_pMainLayout)
298 {
299 /* Configure layout: */
300#ifdef VBOX_WS_MAC
301 m_pMainLayout->setContentsMargins(40, 20, 40, 20);
302 m_pMainLayout->setSpacing(15);
303#else
304 m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) * 2);
305#endif
306
307 /* Prepare top layout: */
308 prepareTopLayout();
309
310 /* Add stretch between top and bottom: */
311 m_pMainLayout->addStretch(1);
312
313 /* Prepare button-box: */
314 prepareButtonBox();
315 }
316}
317
318void UIVMCloseDialog::prepareTopLayout()
319{
320 /* Create top layout: */
321 m_pTopLayout = new QHBoxLayout;
322 if (m_pTopLayout)
323 {
324 /* Configure layout: */
325#ifdef VBOX_WS_MAC
326 m_pTopLayout->setSpacing(20);
327#else
328 m_pTopLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) * 2);
329#endif
330
331 /* Prepare top-left layout: */
332 prepareTopLeftLayout();
333 /* Prepare top-right layout: */
334 prepareTopRightLayout();
335
336 /* Add into layout: */
337 m_pMainLayout->addLayout(m_pTopLayout);
338 }
339}
340
341void UIVMCloseDialog::prepareTopLeftLayout()
342{
343 /* Create top-left layout: */
344 m_pTopLeftLayout = new QVBoxLayout;
345 if (m_pTopLeftLayout)
346 {
347 /* Create icon label: */
348 m_pLabelIcon = new QLabel;
349 if (m_pLabelIcon)
350 {
351 /* Configure label: */
352 m_pLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
353
354 /* Add into layout: */
355 m_pTopLeftLayout->addWidget(m_pLabelIcon);
356 }
357
358 /* Add vertical stretch under icon label: */
359 m_pTopLeftLayout->addStretch();
360
361 /* Add into layout: */
362 m_pTopLayout->addLayout(m_pTopLeftLayout);
363 }
364}
365
366void UIVMCloseDialog::prepareTopRightLayout()
367{
368 /* Create top-right layout: */
369 m_pTopRightLayout = new QVBoxLayout;
370 if (m_pTopRightLayout)
371 {
372 /* Configure layout: */
373#ifdef VBOX_WS_MAC
374 m_pTopRightLayout->setSpacing(10);
375#else
376 m_pTopRightLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
377#endif
378
379 /* Create text label: */
380 m_pLabelText = new QLabel;
381 if (m_pLabelText)
382 {
383 /* Add into layout: */
384 m_pTopRightLayout->addWidget(m_pLabelText);
385 }
386
387 /* Prepare choice layout: */
388 prepareChoiceLayout();
389
390 /* Add into layout: */
391 m_pTopLayout->addLayout(m_pTopRightLayout);
392 }
393}
394
395void UIVMCloseDialog::prepareChoiceLayout()
396{
397 /* Create 'choice' layout: */
398 m_pChoiceLayout = new QGridLayout;
399 if (m_pChoiceLayout)
400 {
401 /* Configure layout: */
402#ifdef VBOX_WS_MAC
403 m_pChoiceLayout->setSpacing(10);
404#else
405 m_pChoiceLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
406#endif
407
408 /* Create 'detach' icon label: */
409 m_pLabelIconDetach = new QLabel;
410 if (m_pLabelIconDetach)
411 {
412 /* Configure label: */
413 m_pLabelIconDetach->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
414 /* Add into layout: */
415 m_pChoiceLayout->addWidget(m_pLabelIconDetach, 0, 0);
416 }
417 /* Create 'detach' radio-button: */
418 m_pRadioButtonDetach = new QRadioButton;
419 if (m_pRadioButtonDetach)
420 {
421 /* Configure button: */
422 m_pRadioButtonDetach->installEventFilter(this);
423 connect(m_pRadioButtonDetach, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
424 /* Add into layout: */
425 m_pChoiceLayout->addWidget(m_pRadioButtonDetach, 0, 1);
426 }
427
428 /* Create 'save' icon label: */
429 m_pLabelIconSave = new QLabel;
430 if (m_pLabelIconSave)
431 {
432 /* Configure label: */
433 m_pLabelIconSave->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
434 /* Add into layout: */
435 m_pChoiceLayout->addWidget(m_pLabelIconSave, 1, 0);
436 }
437 /* Create 'save' radio-button: */
438 m_pRadioButtonSave = new QRadioButton;
439 if (m_pRadioButtonSave)
440 {
441 /* Configure button: */
442 m_pRadioButtonSave->installEventFilter(this);
443 connect(m_pRadioButtonSave, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
444 /* Add into layout: */
445 m_pChoiceLayout->addWidget(m_pRadioButtonSave, 1, 1);
446 }
447
448 /* Create 'shutdown' icon label: */
449 m_pLabelIconShutdown = new QLabel;
450 if (m_pLabelIconShutdown)
451 {
452 /* Configure label: */
453 m_pLabelIconShutdown->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
454 /* Add into layout: */
455 m_pChoiceLayout->addWidget(m_pLabelIconShutdown, 2, 0);
456 }
457 /* Create 'shutdown' radio-button: */
458 m_pRadioButtonShutdown = new QRadioButton;
459 if (m_pRadioButtonShutdown)
460 {
461 /* Configure button: */
462 m_pRadioButtonShutdown->installEventFilter(this);
463 connect(m_pRadioButtonShutdown, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
464 /* Add into layout: */
465 m_pChoiceLayout->addWidget(m_pRadioButtonShutdown, 2, 1);
466 }
467
468 /* Create 'power-off' icon label: */
469 m_pLabelIconPowerOff = new QLabel;
470 if (m_pLabelIconPowerOff)
471 {
472 /* Configure label: */
473 m_pLabelIconPowerOff->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
474 /* Add into layout: */
475 m_pChoiceLayout->addWidget(m_pLabelIconPowerOff, 3, 0);
476 }
477 /* Create 'shutdown' radio-button: */
478 m_pRadioButtonPowerOff = new QRadioButton;
479 if (m_pRadioButtonPowerOff)
480 {
481 /* Configure button: */
482 m_pRadioButtonPowerOff->installEventFilter(this);
483 connect(m_pRadioButtonPowerOff, &QRadioButton::toggled, this, &UIVMCloseDialog::sltUpdateWidgetAvailability);
484 /* Add into layout: */
485 m_pChoiceLayout->addWidget(m_pRadioButtonPowerOff, 3, 1);
486 }
487
488 /* Create 'discard' check-box: */
489 m_pCheckBoxDiscard = new QCheckBox;
490 if (m_pCheckBoxDiscard)
491 {
492 /* Add into layout: */
493 m_pChoiceLayout->addWidget(m_pCheckBoxDiscard, 4, 1);
494 }
495
496 /* Add into layout: */
497 m_pTopRightLayout->addLayout(m_pChoiceLayout);
498 }
499}
500
501void UIVMCloseDialog::prepareButtonBox()
502{
503 /* Create button-box: */
504 QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
505 if (pButtonBox)
506 {
507 /* Configure button-box: */
508 pButtonBox->setStandardButtons( QDialogButtonBox::Cancel
509 | QDialogButtonBox::Help
510 | QDialogButtonBox::NoButton
511 | QDialogButtonBox::Ok);
512 connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIVMCloseDialog::accept);
513 connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIVMCloseDialog::reject);
514 connect(pButtonBox, &QIDialogButtonBox::helpRequested, &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog);
515
516 /* Add into layout: */
517 m_pMainLayout->addWidget(pButtonBox);
518 }
519}
520
521void UIVMCloseDialog::configure()
522{
523 /* Get actual machine-state: */
524 KMachineState machineState = m_comMachine.GetState();
525
526 /* Check which close-actions are resticted: */
527 bool fIsDetachAllowed = uiCommon().isSeparateProcess() && !(m_restictedCloseActions & MachineCloseAction_Detach);
528 bool fIsStateSavingAllowed = !(m_restictedCloseActions & MachineCloseAction_SaveState);
529 bool fIsACPIShutdownAllowed = !(m_restictedCloseActions & MachineCloseAction_Shutdown);
530 bool fIsPowerOffAllowed = !(m_restictedCloseActions & MachineCloseAction_PowerOff);
531 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(m_restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
532
533 /* Make 'Detach' button visible/hidden depending on restriction: */
534 setButtonVisibleDetach(fIsDetachAllowed);
535 /* Make 'Detach' button enabled/disabled depending on machine-state: */
536 setButtonEnabledDetach(machineState != KMachineState_Stuck);
537
538 /* Make 'Save state' button visible/hidden depending on restriction: */
539 setButtonVisibleSave(fIsStateSavingAllowed);
540 /* Make 'Save state' button enabled/disabled depending on machine-state: */
541 setButtonEnabledSave(machineState != KMachineState_Stuck);
542
543 /* Make 'Shutdown' button visible/hidden depending on restriction: */
544 setButtonVisibleShutdown(fIsACPIShutdownAllowed);
545 /* Make 'Shutdown' button enabled/disabled depending on console and machine-state: */
546 setButtonEnabledShutdown(m_fIsACPIEnabled && machineState != KMachineState_Stuck);
547
548 /* Make 'Power off' button visible/hidden depending on restriction: */
549 setButtonVisiblePowerOff(fIsPowerOffAllowed);
550 /* Make the Restore Snapshot checkbox visible/hidden depending on snapshot count & restrictions: */
551 setCheckBoxVisibleDiscard(fIsPowerOffAndRestoreAllowed && m_comMachine.GetSnapshotCount() > 0);
552 /* Assign Restore Snapshot checkbox text: */
553 if (!m_comMachine.GetCurrentSnapshot().isNull())
554 m_strDiscardCheckBoxText = m_comMachine.GetCurrentSnapshot().GetName();
555
556 /* Check which radio-button should be initially chosen: */
557 QRadioButton *pRadioButtonToChoose = 0;
558 /* If choosing 'last choice' is possible: */
559 m_enmLastCloseAction = gEDataManager->lastMachineCloseAction(uiCommon().managedVMUuid());
560 if (m_enmLastCloseAction == MachineCloseAction_Detach && fIsDetachAllowed)
561 {
562 pRadioButtonToChoose = m_pRadioButtonDetach;
563 }
564 else if (m_enmLastCloseAction == MachineCloseAction_SaveState && fIsStateSavingAllowed)
565 {
566 pRadioButtonToChoose = m_pRadioButtonSave;
567 }
568 else if (m_enmLastCloseAction == MachineCloseAction_Shutdown && fIsACPIShutdownAllowed && m_fIsACPIEnabled)
569 {
570 pRadioButtonToChoose = m_pRadioButtonShutdown;
571 }
572 else if (m_enmLastCloseAction == MachineCloseAction_PowerOff && fIsPowerOffAllowed)
573 {
574 pRadioButtonToChoose = m_pRadioButtonPowerOff;
575 }
576 else if (m_enmLastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed)
577 {
578 pRadioButtonToChoose = m_pRadioButtonPowerOff;
579 m_pCheckBoxDiscard->setChecked(true);
580 }
581 /* Else 'default choice' will be used: */
582 else
583 {
584 if (fIsDetachAllowed)
585 pRadioButtonToChoose = m_pRadioButtonDetach;
586 else if (fIsStateSavingAllowed)
587 pRadioButtonToChoose = m_pRadioButtonSave;
588 else if (fIsACPIShutdownAllowed && m_fIsACPIEnabled)
589 pRadioButtonToChoose = m_pRadioButtonShutdown;
590 else if (fIsPowerOffAllowed)
591 pRadioButtonToChoose = m_pRadioButtonPowerOff;
592 }
593
594 /* If some radio-button chosen: */
595 if (pRadioButtonToChoose)
596 {
597 /* Check and focus it: */
598 pRadioButtonToChoose->setChecked(true);
599 pRadioButtonToChoose->setFocus();
600 sltUpdateWidgetAvailability();
601 m_fValid = true;
602 }
603}
604
605void UIVMCloseDialog::updatePixmaps()
606{
607 /* Acquire hints: */
608 const int iMetricSmall = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
609 const int iMetricLarge = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
610
611 /* Re-apply pixmap: */
612 m_pLabelIcon->setPixmap(m_icon.pixmap(windowHandle(), QSize(iMetricLarge, iMetricLarge)));
613
614 QIcon icon;
615 icon = UIIconPool::iconSet(":/vm_create_shortcut_16px.png");
616 m_pLabelIconDetach->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
617 icon = UIIconPool::iconSet(":/vm_save_state_16px.png");
618 m_pLabelIconSave->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
619 icon = UIIconPool::iconSet(":/vm_shutdown_16px.png");
620 m_pLabelIconShutdown->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
621 icon = UIIconPool::iconSet(":/vm_poweroff_16px.png");
622 m_pLabelIconPowerOff->setPixmap(icon.pixmap(windowHandle(), QSize(iMetricSmall, iMetricSmall)));
623}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use