1 | /* $Id: UIGuestProcessControlDialog.cpp 104297 2024-04-11 13:20:43Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIGuestProcessControlDialog class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
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
|
---|
26 | */
|
---|
27 |
|
---|
28 | /* Qt includes: */
|
---|
29 | #include <QPushButton>
|
---|
30 | #include <QVBoxLayout>
|
---|
31 |
|
---|
32 | /* GUI includes: */
|
---|
33 | #include "UIDesktopWidgetWatchdog.h"
|
---|
34 | #include "UIExtraDataManager.h"
|
---|
35 | #include "UIIconPool.h"
|
---|
36 | #include "UIGuestControlConsole.h"
|
---|
37 | #include "UIGuestProcessControlDialog.h"
|
---|
38 | #include "UILoggingDefs.h"
|
---|
39 | #include "UIMachine.h"
|
---|
40 | #include "UISession.h"
|
---|
41 | #include "UITranslationEventListener.h"
|
---|
42 |
|
---|
43 |
|
---|
44 | /*********************************************************************************************************************************
|
---|
45 | * Class UIGuestProcessControlDialogFactory implementation. *
|
---|
46 | *********************************************************************************************************************************/
|
---|
47 |
|
---|
48 | UIGuestProcessControlDialogFactory::UIGuestProcessControlDialogFactory()
|
---|
49 | {
|
---|
50 | }
|
---|
51 |
|
---|
52 | void UIGuestProcessControlDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
|
---|
53 | {
|
---|
54 | pDialog = new UIGuestProcessControlDialog(pCenterWidget);
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | /*********************************************************************************************************************************
|
---|
59 | * Class UIGuestProcessControlDialog implementation. *
|
---|
60 | *********************************************************************************************************************************/
|
---|
61 |
|
---|
62 | UIGuestProcessControlDialog::UIGuestProcessControlDialog(QWidget *pCenterWidget)
|
---|
63 | : QIManagerDialog(pCenterWidget)
|
---|
64 | , m_comGuest(gpMachine->uisession()->guest())
|
---|
65 | , m_strMachineName(gpMachine->machineName())
|
---|
66 | {
|
---|
67 | }
|
---|
68 |
|
---|
69 | void UIGuestProcessControlDialog::sltRetranslateUI()
|
---|
70 | {
|
---|
71 | /* Translate window title: */
|
---|
72 | setWindowTitle(tr("%1 - Guest Control").arg(m_strMachineName));
|
---|
73 | /* Translate buttons: */
|
---|
74 | button(ButtonType_Close)->setText(tr("Close"));
|
---|
75 | }
|
---|
76 |
|
---|
77 | void UIGuestProcessControlDialog::configure()
|
---|
78 | {
|
---|
79 | #ifndef VBOX_WS_MAC
|
---|
80 | /* Assign window icon: */
|
---|
81 | setWindowIcon(UIIconPool::iconSetFull(":/performance_monitor_32px.png" ,":/performance_monitor_16px.png"));
|
---|
82 | #endif
|
---|
83 | }
|
---|
84 |
|
---|
85 | void UIGuestProcessControlDialog::configureCentralWidget()
|
---|
86 | {
|
---|
87 | /* Create widget: */
|
---|
88 | UIGuestControlConsole *pConsole = new UIGuestControlConsole(m_comGuest);
|
---|
89 |
|
---|
90 | if (pConsole)
|
---|
91 | {
|
---|
92 | /* Configure widget: */
|
---|
93 | setWidget(pConsole);
|
---|
94 | //setWidgetMenu(pWidget->menu());
|
---|
95 | #ifdef VBOX_WS_MAC
|
---|
96 | //setWidgetToolbar(pWidget->toolbar());
|
---|
97 | #endif
|
---|
98 | /* Add into layout: */
|
---|
99 | centralWidget()->layout()->addWidget(pConsole);
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | void UIGuestProcessControlDialog::finalize()
|
---|
104 | {
|
---|
105 | /* Apply language settings: */
|
---|
106 | sltRetranslateUI();
|
---|
107 | connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
|
---|
108 | this, &UIGuestProcessControlDialog::sltRetranslateUI);
|
---|
109 | }
|
---|
110 |
|
---|
111 | void UIGuestProcessControlDialog::loadSettings()
|
---|
112 | {
|
---|
113 | /* Invent default window geometry: */
|
---|
114 | const QRect availableGeo = gpDesktop->availableGeometry(this);
|
---|
115 | const int iDefaultWidth = availableGeo.width() / 2;
|
---|
116 | const int iDefaultHeight = availableGeo.height() * 3 / 4;
|
---|
117 | QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight);
|
---|
118 |
|
---|
119 | /* Load geometry from extradata: */
|
---|
120 | QRect geo = gEDataManager->guestProcessControlDialogGeometry(this, centerWidget(), defaultGeo);
|
---|
121 | LogRel2(("GUI: UIGuestProcessControlDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
|
---|
122 | geo.x(), geo.y(), geo.width(), geo.height()));
|
---|
123 | restoreGeometry(geo);
|
---|
124 | }
|
---|
125 |
|
---|
126 | void UIGuestProcessControlDialog::saveSettings()
|
---|
127 | {
|
---|
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());
|
---|
133 | }
|
---|
134 |
|
---|
135 | bool UIGuestProcessControlDialog::shouldBeMaximized() const
|
---|
136 | {
|
---|
137 | return gEDataManager->guestProcessControlDialogShouldBeMaximized();
|
---|
138 | }
|
---|
139 |
|
---|
140 | void UIGuestProcessControlDialog::sltSetCloseButtonShortCut(QKeySequence shortcut)
|
---|
141 | {
|
---|
142 | if (button(ButtonType_Close))
|
---|
143 | button(ButtonType_Close)->setShortcut(shortcut);
|
---|
144 | }
|
---|