VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp

Last change on this file was 104290, checked in by vboxsync, 2 months ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in the runtime UI related classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.7 KB
Line 
1/* $Id: UIInformationRuntime.cpp 104290 2024-04-11 09:37:29Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIInformationRuntime class implementation.
4 */
5
6/*
7 * Copyright (C) 2016-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 <QAction>
30#include <QApplication>
31#include <QClipboard>
32#include <QHeaderView>
33#include <QMenu>
34#include <QVBoxLayout>
35#include <QTableWidget>
36#include <QTimer>
37
38/* GUI includes: */
39#include "UIConverter.h"
40#include "UIGlobalSession.h"
41#include "UIIconPool.h"
42#include "UIInformationRuntime.h"
43#include "UIGuestOSType.h"
44#include "UIMachine.h"
45#include "UITranslationEventListener.h"
46
47/* COM includes: */
48#include "CDisplay.h"
49#include "CGraphicsAdapter.h"
50#include "CMachineDebugger.h"
51#include "CVRDEServerInfo.h"
52
53enum InfoRow
54{
55 InfoRow_Title = 0,
56 InfoRow_Resolution,
57 InfoRow_Uptime,
58 InfoRow_ClipboardMode,
59 InfoRow_DnDMode,
60 InfoRow_ExecutionEngine,
61 InfoRow_NestedPaging,
62 InfoRow_UnrestrictedExecution,
63 InfoRow_Paravirtualization,
64 InfoRow_GuestAdditions,
65 InfoRow_GuestOSType,
66 InfoRow_RemoteDesktop,
67 InfoRow_Max
68};
69
70/*********************************************************************************************************************************
71* UIRuntimeInfoWidget definition. *
72*********************************************************************************************************************************/
73/** A QTablWidget extention to show some runtime attributes */
74class UIRuntimeInfoWidget : public QTableWidget
75{
76
77 Q_OBJECT;
78
79public:
80
81 UIRuntimeInfoWidget(QWidget *pParent);
82 void updateScreenInfo(int iScreenId = -1);
83 void updateGAsVersion();
84 void updateVRDE();
85 void updateClipboardMode(KClipboardMode enmMode = KClipboardMode_Max);
86 void updateDnDMode(KDnDMode enmMode = KDnDMode_Max);
87 QString tableData() const;
88
89private slots:
90
91 void sltRetranslateUI();
92 void sltTimeout();
93
94private:
95
96 void createInfoRows();
97 void updateUpTime();
98 void updateTitleRow();
99 void updateOSTypeRow();
100 void updateVirtualizationInfo();
101
102 /** Searches the table for the @p item of enmLine and replaces its text. if not found inserts a new
103 * row to the end of the table. Assumes only one line of the @p enmLine exists. */
104 void updateInfoRow(InfoRow enmLine, const QString &strColumn0, const QString &strColumn1);
105 QString screenResolution(int iScreenId);
106 /** Creates to QTableWidgetItems of the @enmInfoRow using the @p strLabel and @p strInfo and inserts it
107 * to the row @p iRow. If @p iRow is -1 then the items inserted to the end of the table. */
108 void insertInfoRow(InfoRow enmInfoRow, const QString& strLabel, const QString &strInfo, int iRow = -1);
109 void computeMinimumWidth();
110
111 /** @name Cached translated strings.
112 * @{ */
113 QString m_strTableTitle;
114 QString m_strScreenResolutionLabel;
115 QString m_strMonitorTurnedOff;
116 QString m_strUptimeLabel;
117 QString m_strClipboardModeLabel;
118 QString m_strDragAndDropLabel;
119 QString m_strExcutionEngineLabel;
120 QString m_strNestedPagingLabel;
121 QString m_strUnrestrictedExecutionLabel;
122 QString m_strParavirtualizationLabel;
123 QString m_strNestedPagingActive;
124 QString m_strNestedPagingInactive;
125 QString m_strUnrestrictedExecutionActive;
126 QString m_strUnrestrictedExecutionInactive;
127 QString m_strVRDEPortNotAvailable;
128 QString m_strGuestAdditionsLabel;
129 QString m_strGuestOSTypeLabel;
130 QString m_strRemoteDesktopLabel;
131 QString m_strExecutionEngineNotSet;
132 QString m_strOSNotDetected;
133 QString m_strGANotDetected;
134 /** @} */
135
136 int m_iFontHeight;
137 /** Computed by computing the maximum length line. Used to avoid having horizontal scroll bars. */
138 int m_iMinimumWidth;
139 QVector<QString> m_screenResolutions;
140 QVector<QString*> m_labels;
141 QTimer *m_pTimer;
142};
143
144/*********************************************************************************************************************************
145* UIRuntimeInfoWidget implementation. *
146*********************************************************************************************************************************/
147
148UIRuntimeInfoWidget::UIRuntimeInfoWidget(QWidget *pParent)
149 : QTableWidget(pParent)
150 , m_iMinimumWidth(0)
151 , m_pTimer(0)
152{
153 setContextMenuPolicy(Qt::CustomContextMenu);
154 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
155 setAlternatingRowColors(true);
156 m_iFontHeight = QFontMetrics(font()).height();
157
158 setColumnCount(2);
159 verticalHeader()->hide();
160 horizontalHeader()->hide();
161 setShowGrid(false);
162 setEditTriggers(QAbstractItemView::NoEditTriggers);
163 setFocusPolicy(Qt::NoFocus);
164 setSelectionMode(QAbstractItemView::NoSelection);
165
166 m_pTimer = new QTimer(this);
167 if (m_pTimer)
168 {
169 connect(m_pTimer, &QTimer::timeout, this, &UIRuntimeInfoWidget::sltTimeout);
170 m_pTimer->start(5000);
171 }
172
173 m_labels << &m_strScreenResolutionLabel
174 << &m_strUptimeLabel
175 << &m_strDragAndDropLabel
176 << &m_strExcutionEngineLabel
177 << &m_strNestedPagingLabel
178 << &m_strUnrestrictedExecutionLabel
179 << &m_strParavirtualizationLabel
180 << &m_strGuestAdditionsLabel
181 << &m_strGuestOSTypeLabel
182 << &m_strRemoteDesktopLabel;
183
184
185 sltRetranslateUI();
186 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
187 this, &UIRuntimeInfoWidget::sltRetranslateUI);
188 computeMinimumWidth();
189}
190
191void UIRuntimeInfoWidget::sltRetranslateUI()
192{
193 m_strTableTitle = QApplication::translate("UIVMInformationDialog", "Runtime Attributes");
194 m_strScreenResolutionLabel = QApplication::translate("UIVMInformationDialog", "Screen Resolution");
195 m_strMonitorTurnedOff = QApplication::translate("UIVMInformationDialog", "turned off", "Screen");
196 m_strUptimeLabel = QApplication::translate("UIVMInformationDialog", "VM Uptime");
197 m_strClipboardModeLabel = QApplication::translate("UIVMInformationDialog", "Clipboard Mode");
198 m_strDragAndDropLabel = QApplication::translate("UIVMInformationDialog", "Drag and Drop Mode");
199 m_strExcutionEngineLabel = QApplication::translate("UIVMInformationDialog", "VM Execution Engine");
200 m_strNestedPagingLabel = QApplication::translate("UIVMInformationDialog", "Nested Paging");
201 m_strUnrestrictedExecutionLabel = QApplication::translate("UIVMInformationDialog", "Unrestricted Execution");
202 m_strParavirtualizationLabel = QApplication::translate("UIVMInformationDialog", "Paravirtualization Interface");
203 m_strNestedPagingActive = QApplication::translate("UIVMInformationDialog", "Active", "Nested Paging");
204 m_strNestedPagingInactive = QApplication::translate("UIVMInformationDialog", "Inactive", "Nested Paging");
205 m_strUnrestrictedExecutionActive = QApplication::translate("UIVMInformationDialog", "Active", "Unrestricted Execution");
206 m_strUnrestrictedExecutionInactive = QApplication::translate("UIVMInformationDialog", "Inactive", "Unrestricted Execution");
207 m_strVRDEPortNotAvailable = QApplication::translate("UIVMInformationDialog", "Not Available", "VRDE Port");
208 m_strGuestAdditionsLabel = QApplication::translate("UIVMInformationDialog", "Guest Additions");
209 m_strGuestOSTypeLabel = QApplication::translate("UIVMInformationDialog", "Guest OS Type");
210 m_strRemoteDesktopLabel = QApplication::translate("UIVMInformationDialog", "Remote Desktop Server Port");
211 m_strExecutionEngineNotSet = QApplication::translate("UIVMInformationDialog", "not set", "Execution Engine");
212 m_strOSNotDetected = QApplication::translate("UIVMInformationDialog", "Not Detected", "Guest OS Type");
213 m_strGANotDetected = QApplication::translate("UIVMInformationDialog", "Not Detected", "Guest Additions Version");
214
215 QString* strLongest = 0;
216 foreach (QString *strLabel, m_labels)
217 {
218 if (!strLongest)
219 strLongest = strLabel;
220 if (strLabel && strLongest->length() < strLabel->length())
221 strLongest = strLabel;
222 }
223 QFontMetrics fontMetrics(font());
224#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
225 setColumnWidth(0, 1.5 * fontMetrics.horizontalAdvance(*strLongest));
226#else
227 setColumnWidth(0, 1.5 * fontMetrics.width(*strLongest));
228#endif
229
230 /* Make the API calls and populate the table: */
231 createInfoRows();
232}
233
234void UIRuntimeInfoWidget::insertInfoRow(InfoRow enmInfoRow, const QString& strLabel, const QString &strInfo, int iRow /* = -1 */)
235{
236 int iNewRow = rowCount();
237 if (iRow != -1 && iRow <= iNewRow)
238 iNewRow = iRow;
239 insertRow(iNewRow);
240 setItem(iNewRow, 1, new QTableWidgetItem(strLabel, enmInfoRow));
241 setItem(iNewRow, 2, new QTableWidgetItem(strInfo, enmInfoRow));
242 int iMargin = 0.2 * qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin);
243 setRowHeight(iNewRow, 2 * iMargin + m_iFontHeight);
244}
245
246QString UIRuntimeInfoWidget::screenResolution(int iScreenID)
247{
248 AssertPtrReturn(gpMachine, QString());
249 /* Determine resolution: */
250 ulong uWidth = 0;
251 ulong uHeight = 0;
252 ulong uBpp = 0;
253 long xOrigin = 0;
254 long yOrigin = 0;
255 KGuestMonitorStatus monitorStatus = KGuestMonitorStatus_Enabled;
256 gpMachine->acquireGuestScreenParameters(iScreenID, uWidth, uHeight, uBpp, xOrigin, yOrigin, monitorStatus);
257 QString strResolution = QString("%1x%2").arg(uWidth).arg(uHeight);
258 if (uBpp)
259 strResolution += QString("x%1").arg(uBpp);
260 strResolution += QString(" @%1,%2").arg(xOrigin).arg(yOrigin);
261 if (monitorStatus == KGuestMonitorStatus_Disabled)
262 {
263 strResolution += QString(" ");
264 strResolution += m_strMonitorTurnedOff;
265 }
266 return strResolution;
267}
268
269void UIRuntimeInfoWidget::sltTimeout()
270{
271 updateUpTime();
272}
273
274void UIRuntimeInfoWidget::updateScreenInfo(int iScreenID /* = -1 */)
275{
276 AssertPtrReturnVoid(gpMachine);
277 ulong uGuestScreens = 0;
278 gpMachine->acquireMonitorCount(uGuestScreens);
279 AssertReturnVoid(uGuestScreens > 0);
280
281 m_screenResolutions.resize(uGuestScreens);
282 if (iScreenID != -1 && iScreenID >= (int)uGuestScreens)
283 return;
284 if (iScreenID == -1)
285 {
286 for (ULONG iScreen = 0; iScreen < uGuestScreens; ++iScreen)
287 m_screenResolutions[iScreen] = screenResolution(iScreen);
288 }
289 else
290 m_screenResolutions[iScreenID] = screenResolution(iScreenID);
291 /* Delete all the rows (not only the updated screen's row) and reinsert them: */
292 int iRowCount = rowCount();
293 for (int i = iRowCount - 1; i >= 0; --i)
294 {
295 QTableWidgetItem *pItem = item(i, 1);
296 if (pItem && pItem->type() == InfoRow_Resolution)
297 removeRow(i);
298 }
299 for (ULONG iScreen = 0; iScreen < uGuestScreens; ++iScreen)
300 {
301 QString strLabel = uGuestScreens > 1 ?
302 QString("%1 %2").arg(m_strScreenResolutionLabel).arg(QString::number(iScreen)) :
303 QString("%1").arg(m_strScreenResolutionLabel);
304 /* Insert the screen resolution row at the top of the table. Row 0 is the title row: */
305 insertInfoRow(InfoRow_Resolution, strLabel, m_screenResolutions[iScreen], iScreen + 1);
306 }
307 resizeColumnToContents(1);
308 horizontalHeader()->setStretchLastSection(true);
309}
310
311void UIRuntimeInfoWidget::updateUpTime()
312{
313 AssertPtrReturnVoid(gpMachine);
314 LONG64 uUptime;
315 if (!gpMachine->acquireUptime(uUptime))
316 return;
317 uint64_t uUpSecs = (uUptime / 5000) * 5;
318 char szUptime[32];
319 uint64_t uUpDays = uUpSecs / (60 * 60 * 24);
320 uUpSecs -= uUpDays * 60 * 60 * 24;
321 uint64_t uUpHours = uUpSecs / (60 * 60);
322 uUpSecs -= uUpHours * 60 * 60;
323 uint64_t uUpMins = uUpSecs / 60;
324 uUpSecs -= uUpMins * 60;
325 RTStrPrintf(szUptime, sizeof(szUptime), "%dd %02d:%02d:%02d",
326 uUpDays, uUpHours, uUpMins, uUpSecs);
327 QString strUptime = QString(szUptime);
328 updateInfoRow(InfoRow_Uptime, QString("%1").arg(m_strUptimeLabel), strUptime);
329}
330
331void UIRuntimeInfoWidget::updateTitleRow()
332{
333 /* Add the title row always as 0th row: */
334 QTableWidgetItem *pTitleIcon = new QTableWidgetItem(UIIconPool::iconSet(":/state_running_16px.png"), "", InfoRow_Title);
335 QTableWidgetItem *pTitleItem = new QTableWidgetItem(m_strTableTitle, InfoRow_Title);
336 QFont titleFont(font());
337 titleFont.setBold(true);
338 pTitleItem->setFont(titleFont);
339 if (rowCount() < 1)
340 insertRow(0);
341 setItem(0, 0, pTitleIcon);
342 setItem(0, 1, pTitleItem);
343 resizeColumnToContents(0);
344}
345
346void UIRuntimeInfoWidget::updateOSTypeRow()
347{
348 AssertPtrReturnVoid(gpMachine);
349 QString strOSType = gpMachine->osTypeId();
350 if (strOSType.isEmpty())
351 strOSType = m_strOSNotDetected;
352 else
353 {
354 strOSType = gpGlobalSession->guestOSTypeManager().getDescription(strOSType);
355 }
356 updateInfoRow(InfoRow_GuestOSType, QString("%1").arg(m_strGuestOSTypeLabel), strOSType);
357}
358
359void UIRuntimeInfoWidget::updateVirtualizationInfo()
360{
361 AssertPtrReturnVoid(gpMachine);
362 KVMExecutionEngine enmExecutionEngineType = gpMachine->vmExecutionEngine();
363
364 QString strExecutionEngine;
365 switch (enmExecutionEngineType)
366 {
367 case KVMExecutionEngine_HwVirt:
368 strExecutionEngine = "VT-x/AMD-V"; /* no translation */
369 break;
370 case KVMExecutionEngine_Interpreter:
371 strExecutionEngine = "IEM (Interpreter)"; /* no translation */
372 break;
373 case KVMExecutionEngine_Recompiler:
374 strExecutionEngine = "IEM (Recompiler)"; /* no translation */
375 break;
376 case KVMExecutionEngine_NativeApi:
377 strExecutionEngine = "native API"; /* no translation */
378 break;
379 default:
380 AssertFailed();
381 RT_FALL_THRU();
382 case KVMExecutionEngine_NotSet:
383 strExecutionEngine = m_strExecutionEngineNotSet;
384 break;
385 }
386 QString strNestedPaging = gpMachine->isHWVirtExNestedPagingEnabled() ?
387 m_strNestedPagingActive : m_strNestedPagingInactive;
388 QString strUnrestrictedExecution = gpMachine->isHWVirtExUXEnabled() ?
389 m_strUnrestrictedExecutionActive : m_strUnrestrictedExecutionInactive;
390 QString strParavirtProvider = gpConverter->toString(gpMachine->paravirtProvider());
391
392 updateInfoRow(InfoRow_ExecutionEngine, QString("%1").arg(m_strExcutionEngineLabel), strExecutionEngine);
393 updateInfoRow(InfoRow_NestedPaging, QString("%1").arg(m_strNestedPagingLabel), strNestedPaging);
394 updateInfoRow(InfoRow_UnrestrictedExecution, QString("%1").arg(m_strUnrestrictedExecutionLabel), strUnrestrictedExecution);
395 updateInfoRow(InfoRow_Paravirtualization, QString("%1").arg(m_strParavirtualizationLabel), strParavirtProvider);
396}
397
398void UIRuntimeInfoWidget::updateGAsVersion()
399{
400 AssertPtrReturnVoid(gpMachine);
401 QString strGAVersion;
402 gpMachine->acquireGuestAdditionsVersion(strGAVersion);
403 if (strGAVersion.isEmpty())
404 strGAVersion = m_strGANotDetected;
405 else
406 {
407 ulong uRevision = 0;
408 gpMachine->acquireGuestAdditionsRevision(uRevision);
409 if (uRevision != 0)
410 strGAVersion += QString(" r%1").arg(uRevision);
411 }
412 updateInfoRow(InfoRow_GuestAdditions, QString("%1").arg(m_strGuestAdditionsLabel), strGAVersion);
413}
414
415void UIRuntimeInfoWidget::updateVRDE()
416{
417 AssertPtrReturnVoid(gpMachine);
418 long iVRDEPort = 0;
419 gpMachine->acquireVRDEServerPort(iVRDEPort);
420 const QString strVRDEInfo = (iVRDEPort == 0 || iVRDEPort == -1)
421 ? m_strVRDEPortNotAvailable
422 : QString("%1").arg(iVRDEPort);
423 updateInfoRow(InfoRow_RemoteDesktop, QString("%1").arg(m_strRemoteDesktopLabel), strVRDEInfo);
424}
425
426void UIRuntimeInfoWidget::updateClipboardMode(KClipboardMode enmMode /* = KClipboardMode_Max */)
427{
428 AssertPtrReturnVoid(gpMachine);
429 if (enmMode == KClipboardMode_Max)
430 {
431 KClipboardMode enmClipboardMode = KClipboardMode_Max;
432 gpMachine->acquireClipboardMode(enmClipboardMode);
433 updateInfoRow(InfoRow_ClipboardMode, QString("%1").arg(m_strClipboardModeLabel),
434 gpConverter->toString(enmClipboardMode));
435 }
436 else
437 updateInfoRow(InfoRow_ClipboardMode, QString("%1").arg(m_strClipboardModeLabel),
438 gpConverter->toString(enmMode));
439}
440
441void UIRuntimeInfoWidget::updateDnDMode(KDnDMode enmMode /* = KDnDMode_Max */)
442{
443 AssertPtrReturnVoid(gpMachine);
444 if (enmMode == KDnDMode_Max)
445 {
446 KDnDMode enmDnDMode = KDnDMode_Max;
447 gpMachine->acquireDnDMode(enmDnDMode);
448 updateInfoRow(InfoRow_DnDMode, QString("%1").arg(m_strDragAndDropLabel),
449 gpConverter->toString(enmDnDMode));
450 }
451 else
452 updateInfoRow(InfoRow_DnDMode, QString("%1").arg(m_strDragAndDropLabel),
453 gpConverter->toString(enmMode));
454}
455
456QString UIRuntimeInfoWidget::tableData() const
457{
458 AssertReturn(columnCount() == 3, QString());
459 QStringList data;
460 for (int i = 0; i < rowCount(); ++i)
461 {
462 /* Skip the first column as it contains only icon and no text: */
463 QTableWidgetItem *pItem = item(i, 1);
464 QString strColumn1 = pItem ? pItem->text() : QString();
465 pItem = item(i, 2);
466 QString strColumn2 = pItem ? pItem->text() : QString();
467 if (strColumn2.isEmpty())
468 data << strColumn1;
469 else
470 data << strColumn1 << ": " << strColumn2;
471 data << "\n";
472 }
473 return data.join(QString());
474}
475
476void UIRuntimeInfoWidget::updateInfoRow(InfoRow enmLine, const QString &strColumn0, const QString &strColumn1)
477{
478 QTableWidgetItem *pItem = 0;
479 for (int i = 0; i < rowCount() && !pItem; ++i)
480 {
481 pItem = item(i, 2);
482 if (!pItem)
483 continue;
484 if (pItem->type() != enmLine)
485 pItem = 0;
486 }
487 if (!pItem)
488 insertInfoRow(enmLine, strColumn0, strColumn1);
489 else
490 pItem->setText(strColumn1);
491}
492
493void UIRuntimeInfoWidget::createInfoRows()
494{
495 clear();
496 setRowCount(0);
497 setColumnCount(3);
498 updateTitleRow();
499 updateScreenInfo();
500 updateUpTime();
501 updateClipboardMode();
502 updateDnDMode();
503 updateVirtualizationInfo();
504 updateGAsVersion();
505 updateOSTypeRow();
506 updateVRDE();
507 resizeColumnToContents(1);
508}
509
510void UIRuntimeInfoWidget::computeMinimumWidth()
511{
512 m_iMinimumWidth = 0;
513 for (int j = 0; j < columnCount(); ++j)
514 m_iMinimumWidth += columnWidth(j);
515}
516
517
518
519/*********************************************************************************************************************************
520* UIInformationRuntime implementation. *
521*********************************************************************************************************************************/
522
523UIInformationRuntime::UIInformationRuntime(QWidget *pParent)
524 : QWidget(pParent)
525 , m_pMainLayout(0)
526 , m_pRuntimeInfoWidget(0)
527 , m_pCopyWholeTableAction(0)
528{
529 connect(gpMachine, &UIMachine::sigAdditionsStateChange, this, &UIInformationRuntime::sltGuestAdditionsStateChange);
530 connect(gpMachine, &UIMachine::sigGuestMonitorChange, this, &UIInformationRuntime::sltGuestMonitorChange);
531 connect(gpMachine, &UIMachine::sigVRDEChange, this, &UIInformationRuntime::sltVRDEChange);
532 connect(gpMachine, &UIMachine::sigClipboardModeChange, this, &UIInformationRuntime::sltClipboardChange);
533 connect(gpMachine, &UIMachine::sigDnDModeChange, this, &UIInformationRuntime::sltDnDModeChange);
534
535 prepareObjects();
536 sltRetranslateUI();
537 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
538 this, &UIInformationRuntime::sltRetranslateUI);
539}
540
541void UIInformationRuntime::sltRetranslateUI()
542{
543 if (m_pCopyWholeTableAction)
544 m_pCopyWholeTableAction->setText(QApplication::translate("UIVMInformationDialog", "Copy All"));
545}
546
547void UIInformationRuntime::prepareObjects()
548{
549 m_pMainLayout = new QVBoxLayout(this);
550 if (!m_pMainLayout)
551 return;
552 m_pMainLayout->setSpacing(0);
553
554 m_pRuntimeInfoWidget = new UIRuntimeInfoWidget(0);
555 AssertReturnVoid(m_pRuntimeInfoWidget);
556 connect(m_pRuntimeInfoWidget, &UIRuntimeInfoWidget::customContextMenuRequested,
557 this, &UIInformationRuntime::sltHandleTableContextMenuRequest);
558 m_pMainLayout->addWidget(m_pRuntimeInfoWidget);
559 m_pRuntimeInfoWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
560
561 m_pCopyWholeTableAction = new QAction(this);
562 connect(m_pCopyWholeTableAction, &QAction::triggered, this, &UIInformationRuntime::sltHandleCopyWholeTable);
563}
564
565void UIInformationRuntime::sltGuestAdditionsStateChange()
566{
567 if (m_pRuntimeInfoWidget)
568 m_pRuntimeInfoWidget->updateGAsVersion();
569}
570
571void UIInformationRuntime::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo)
572{
573 Q_UNUSED(changeType);
574 Q_UNUSED(screenGeo);
575 if (m_pRuntimeInfoWidget)
576 m_pRuntimeInfoWidget->updateScreenInfo(uScreenId);
577}
578
579void UIInformationRuntime::sltVRDEChange()
580{
581 if (m_pRuntimeInfoWidget)
582 m_pRuntimeInfoWidget->updateVRDE();
583}
584
585void UIInformationRuntime::sltClipboardChange(KClipboardMode enmMode)
586{
587 if (m_pRuntimeInfoWidget)
588 m_pRuntimeInfoWidget->updateClipboardMode(enmMode);
589}
590
591void UIInformationRuntime::sltDnDModeChange(KDnDMode enmMode)
592{
593 if (m_pRuntimeInfoWidget)
594 m_pRuntimeInfoWidget->updateDnDMode(enmMode);
595}
596
597void UIInformationRuntime::sltHandleTableContextMenuRequest(const QPoint &position)
598{
599 if (!m_pCopyWholeTableAction)
600 return;
601
602 QMenu menu(this);
603 menu.addAction(m_pCopyWholeTableAction);
604 menu.exec(mapToGlobal(position));
605}
606
607void UIInformationRuntime::sltHandleCopyWholeTable()
608{
609 QClipboard *pClipboard = QApplication::clipboard();
610 if (!pClipboard)
611 return;
612 if (!m_pRuntimeInfoWidget)
613 return;
614
615 pClipboard->setText(m_pRuntimeInfoWidget->tableData(), QClipboard::Clipboard);
616}
617
618#include "UIInformationRuntime.moc"
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use