1 | /* $Id: UIGuestProcessControlDialog.cpp 103538 2024-02-22 17:06:26Z 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 "UICommon.h"
|
---|
34 | #include "UIDesktopWidgetWatchdog.h"
|
---|
35 | #include "UIExtraDataManager.h"
|
---|
36 | #include "UIIconPool.h"
|
---|
37 | #include "UIGuestControlConsole.h"
|
---|
38 | #include "UIGuestProcessControlDialog.h"
|
---|
39 | #include "UILoggingDefs.h"
|
---|
40 | #include "UIMachine.h"
|
---|
41 | #include "UISession.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 | : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget)
|
---|
64 | , m_comGuest(gpMachine->uisession()->guest())
|
---|
65 | , m_strMachineName(gpMachine->machineName())
|
---|
66 | {
|
---|
67 | }
|
---|
68 |
|
---|
69 | void UIGuestProcessControlDialog::retranslateUi()
|
---|
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 | retranslateUi();
|
---|
107 | }
|
---|
108 |
|
---|
109 | void UIGuestProcessControlDialog::loadSettings()
|
---|
110 | {
|
---|
111 | /* Invent default window geometry: */
|
---|
112 | const QRect availableGeo = gpDesktop->availableGeometry(this);
|
---|
113 | const int iDefaultWidth = availableGeo.width() / 2;
|
---|
114 | const int iDefaultHeight = availableGeo.height() * 3 / 4;
|
---|
115 | QRect defaultGeo(0, 0, iDefaultWidth, iDefaultHeight);
|
---|
116 |
|
---|
117 | /* Load geometry from extradata: */
|
---|
118 | QRect geo = gEDataManager->guestProcessControlDialogGeometry(this, centerWidget(), defaultGeo);
|
---|
119 | LogRel2(("GUI: UIGuestProcessControlDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
|
---|
120 | geo.x(), geo.y(), geo.width(), geo.height()));
|
---|
121 | restoreGeometry(geo);
|
---|
122 | }
|
---|
123 |
|
---|
124 | void UIGuestProcessControlDialog::saveSettings()
|
---|
125 | {
|
---|
126 | /* Save geometry to extradata: */
|
---|
127 | const QRect geo = currentGeometry();
|
---|
128 | LogRel2(("GUI: UIGuestProcessControlDialog: Saving geometry as: Origin=%dx%d, Size=%dx%d\n",
|
---|
129 | geo.x(), geo.y(), geo.width(), geo.height()));
|
---|
130 | gEDataManager->setGuestProcessControlDialogGeometry(geo, isCurrentlyMaximized());
|
---|
131 | }
|
---|
132 |
|
---|
133 | bool UIGuestProcessControlDialog::shouldBeMaximized() const
|
---|
134 | {
|
---|
135 | return gEDataManager->guestProcessControlDialogShouldBeMaximized();
|
---|
136 | }
|
---|
137 |
|
---|
138 | void UIGuestProcessControlDialog::sltSetCloseButtonShortCut(QKeySequence shortcut)
|
---|
139 | {
|
---|
140 | if (button(ButtonType_Close))
|
---|
141 | button(ButtonType_Close)->setShortcut(shortcut);
|
---|
142 | }
|
---|