VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerLogPanel.cpp@ 100347

Last change on this file since 100347 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: UIFileManagerLogPanel.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVMLogViewer 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 <QHBoxLayout>
30#include <QMenu>
31#include <QSpinBox>
32#include <QTextEdit>
33#include <QTime>
34
35/* GUI includes: */
36#include "QIToolButton.h"
37#include "UIIconPool.h"
38#include "UIFileManager.h"
39#include "UIFileManagerLogPanel.h"
40
41
42/*********************************************************************************************************************************
43* UIFileManagerLogViewer definition. *
44*********************************************************************************************************************************/
45
46class UIFileManagerLogViewer : public QTextEdit
47{
48
49 Q_OBJECT;
50
51public:
52
53 UIFileManagerLogViewer(QWidget *pParent = 0);
54
55protected:
56
57 virtual void contextMenuEvent(QContextMenuEvent * event) RT_OVERRIDE;
58
59private slots:
60
61 void sltClear();
62};
63
64/*********************************************************************************************************************************
65* UIFileManagerLogViewer implementation. *
66*********************************************************************************************************************************/
67
68UIFileManagerLogViewer::UIFileManagerLogViewer(QWidget *pParent /* = 0 */)
69 :QTextEdit(pParent)
70{
71 setUndoRedoEnabled(false);
72 setReadOnly(true);
73}
74
75void UIFileManagerLogViewer::contextMenuEvent(QContextMenuEvent *event)
76{
77 QMenu *menu = createStandardContextMenu();
78
79 QAction *pClearAction = menu->addAction(UIFileManager::tr("Clear"));
80 connect(pClearAction, &QAction::triggered, this, &UIFileManagerLogViewer::sltClear);
81 menu->exec(event->globalPos());
82 delete menu;
83}
84
85void UIFileManagerLogViewer::sltClear()
86{
87 clear();
88}
89
90
91/*********************************************************************************************************************************
92* UIFileManagerLogPanel implementation. *
93*********************************************************************************************************************************/
94
95UIFileManagerLogPanel::UIFileManagerLogPanel(QWidget *pParent /* = 0 */)
96 : UIDialogPanel(pParent)
97 , m_pLogTextEdit(0)
98{
99 prepare();
100}
101
102void UIFileManagerLogPanel::appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType)
103{
104 if (!m_pLogTextEdit)
105 return;
106 QString strStartTag("<font color=\"Black\">");
107 QString strEndTag("</font>");
108 if (eLogType == FileManagerLogType_Error)
109 {
110 strStartTag = "<b><font color=\"Red\">";
111 strEndTag = "</font></b>";
112 }
113 QString strColoredLog = QString("%1 %2: %3 %4 %5").arg(strStartTag).arg(QTime::currentTime().toString("hh:mm:ss:z")).arg(strMachineName).arg(strLog).arg(strEndTag);
114 m_pLogTextEdit->append(strColoredLog);
115 m_pLogTextEdit->moveCursor(QTextCursor::End);
116 m_pLogTextEdit->ensureCursorVisible();
117 emit sigShowPanel(this);
118}
119
120QString UIFileManagerLogPanel::panelName() const
121{
122 return "LogPanel";
123}
124
125void UIFileManagerLogPanel::prepareWidgets()
126{
127 if (!mainLayout())
128 return;
129 m_pLogTextEdit = new UIFileManagerLogViewer;
130 if (m_pLogTextEdit)
131 {
132 mainLayout()->addWidget(m_pLogTextEdit);
133 }
134}
135
136void UIFileManagerLogPanel::prepareConnections()
137{
138}
139
140void UIFileManagerLogPanel::retranslateUi()
141{
142 UIDialogPanel::retranslateUi();
143
144}
145
146
147#include "UIFileManagerLogPanel.moc"
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette