[70027] | 1 | /* $Id: UIGuestProcessControlDialog.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
[75087] | 3 | * VBox Qt GUI - UIGuestProcessControlDialog class implementation.
|
---|
[70027] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[106061] | 7 | * Copyright (C) 2010-2024 Oracle and/or its affiliates.
|
---|
[70027] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[70027] | 26 | */
|
---|
| 27 |
|
---|
| 28 | /* Qt includes: */
|
---|
[76606] | 29 | #include <QPushButton>
|
---|
| 30 | #include <QVBoxLayout>
|
---|
[70027] | 31 |
|
---|
| 32 | /* GUI includes: */
|
---|
[98876] | 33 | #include "UIDesktopWidgetWatchdog.h"
|
---|
[76606] | 34 | #include "UIExtraDataManager.h"
|
---|
| 35 | #include "UIIconPool.h"
|
---|
[77822] | 36 | #include "UIGuestControlConsole.h"
|
---|
[76606] | 37 | #include "UIGuestProcessControlDialog.h"
|
---|
[103538] | 38 | #include "UILoggingDefs.h"
|
---|
[98647] | 39 | #include "UIMachine.h"
|
---|
| 40 | #include "UISession.h"
|
---|
[104297] | 41 | #include "UITranslationEventListener.h"
|
---|
[70027] | 42 |
|
---|
| 43 |
|
---|
[73693] | 44 | /*********************************************************************************************************************************
|
---|
[75087] | 45 | * Class UIGuestProcessControlDialogFactory implementation. *
|
---|
[73693] | 46 | *********************************************************************************************************************************/
|
---|
| 47 |
|
---|
[98875] | 48 | UIGuestProcessControlDialogFactory::UIGuestProcessControlDialogFactory()
|
---|
[70027] | 49 | {
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[75087] | 52 | void UIGuestProcessControlDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
|
---|
[70027] | 53 | {
|
---|
[98875] | 54 | pDialog = new UIGuestProcessControlDialog(pCenterWidget);
|
---|
[70027] | 55 | }
|
---|
| 56 |
|
---|
[73693] | 57 |
|
---|
| 58 | /*********************************************************************************************************************************
|
---|
[75087] | 59 | * Class UIGuestProcessControlDialog implementation. *
|
---|
[73693] | 60 | *********************************************************************************************************************************/
|
---|
| 61 |
|
---|
[98875] | 62 | UIGuestProcessControlDialog::UIGuestProcessControlDialog(QWidget *pCenterWidget)
|
---|
[104297] | 63 | : QIManagerDialog(pCenterWidget)
|
---|
[98875] | 64 | , m_comGuest(gpMachine->uisession()->guest())
|
---|
| 65 | , m_strMachineName(gpMachine->machineName())
|
---|
[70027] | 66 | {
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[104297] | 69 | void UIGuestProcessControlDialog::sltRetranslateUI()
|
---|
[70027] | 70 | {
|
---|
[73693] | 71 | /* Translate window title: */
|
---|
[75057] | 72 | setWindowTitle(tr("%1 - Guest Control").arg(m_strMachineName));
|
---|
[73693] | 73 | /* Translate buttons: */
|
---|
[77822] | 74 | button(ButtonType_Close)->setText(tr("Close"));
|
---|
[70027] | 75 | }
|
---|
| 76 |
|
---|
[75087] | 77 | void UIGuestProcessControlDialog::configure()
|
---|
[73693] | 78 | {
|
---|
[100896] | 79 | #ifndef VBOX_WS_MAC
|
---|
| 80 | /* Assign window icon: */
|
---|
| 81 | setWindowIcon(UIIconPool::iconSetFull(":/performance_monitor_32px.png" ,":/performance_monitor_16px.png"));
|
---|
| 82 | #endif
|
---|
[73693] | 83 | }
|
---|
| 84 |
|
---|
[75087] | 85 | void UIGuestProcessControlDialog::configureCentralWidget()
|
---|
[70027] | 86 | {
|
---|
[70029] | 87 | /* Create widget: */
|
---|
[77822] | 88 | UIGuestControlConsole *pConsole = new UIGuestControlConsole(m_comGuest);
|
---|
[75057] | 89 |
|
---|
[77822] | 90 | if (pConsole)
|
---|
[70029] | 91 | {
|
---|
| 92 | /* Configure widget: */
|
---|
[77822] | 93 | setWidget(pConsole);
|
---|
[75057] | 94 | //setWidgetMenu(pWidget->menu());
|
---|
[70029] | 95 | #ifdef VBOX_WS_MAC
|
---|
[75057] | 96 | //setWidgetToolbar(pWidget->toolbar());
|
---|
[70029] | 97 | #endif
|
---|
| 98 | /* Add into layout: */
|
---|
[77822] | 99 | centralWidget()->layout()->addWidget(pConsole);
|
---|
[70029] | 100 | }
|
---|
[70027] | 101 | }
|
---|
| 102 |
|
---|
[75087] | 103 | void UIGuestProcessControlDialog::finalize()
|
---|
[70074] | 104 | {
|
---|
[73693] | 105 | /* Apply language settings: */
|
---|
[104297] | 106 | sltRetranslateUI();
|
---|
| 107 | connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
|
---|
| 108 | this, &UIGuestProcessControlDialog::sltRetranslateUI);
|
---|
[70074] | 109 | }
|
---|
| 110 |
|
---|
[75087] | 111 | void UIGuestProcessControlDialog::loadSettings()
|
---|
[70139] | 112 | {
|
---|
[81284] | 113 | /* Invent default window geometry: */
|
---|
[97682] | 114 | const QRect availableGeo = gpDesktop->availableGeometry(this);
|
---|
[81284] | 115 | const int iDefaultWidth = availableGeo.width() / 2;
|
---|
| 116 | const int iDefaultHeight = availableGeo.height() * 3 / 4;
|
---|
| 117 | QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight);
|
---|
[70139] | 118 |
|
---|
| 119 | /* Load geometry from extradata: */
|
---|
[81358] | 120 | QRect geo = gEDataManager->guestProcessControlDialogGeometry(this, centerWidget(), defaultGeo);
|
---|
[75087] | 121 | LogRel2(("GUI: UIGuestProcessControlDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
|
---|
[81284] | 122 | geo.x(), geo.y(), geo.width(), geo.height()));
|
---|
| 123 | restoreGeometry(geo);
|
---|
[70139] | 124 | }
|
---|
| 125 |
|
---|
[86231] | 126 | void UIGuestProcessControlDialog::saveSettings()
|
---|
[70139] | 127 | {
|
---|
[81284] | 128 | /* Save geometry to extradata: */
|
---|
| 129 | const QRect geo = currentGeometry();
|
---|
| 130 | LogRel2(("GUI: UIGuestProcessControlDialog: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",
|
---|
| 131 | geo.x(), geo.y(), geo.width(), geo.height()));
|
---|
| 132 | gEDataManager->setGuestProcessControlDialogGeometry(geo, isCurrentlyMaximized());
|
---|
[70139] | 133 | }
|
---|
| 134 |
|
---|
[75087] | 135 | bool UIGuestProcessControlDialog::shouldBeMaximized() const
|
---|
[70139] | 136 | {
|
---|
[75087] | 137 | return gEDataManager->guestProcessControlDialogShouldBeMaximized();
|
---|
[70139] | 138 | }
|
---|
[71477] | 139 |
|
---|
[75087] | 140 | void UIGuestProcessControlDialog::sltSetCloseButtonShortCut(QKeySequence shortcut)
|
---|
[71477] | 141 | {
|
---|
| 142 | if (button(ButtonType_Close))
|
---|
[73693] | 143 | button(ButtonType_Close)->setShortcut(shortcut);
|
---|
[71477] | 144 | }
|
---|