VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h@ 102493

Last change on this file since 102493 was 101092, checked in by vboxsync, 12 months ago

FE/Qt: bugref:6699, bugref:9072. Fixing 'type to search' functionality of log viewer. take 1.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
Line 
1/* $Id: UIVMLogViewerWidget.h 101092 2023-09-12 12:54:09Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVMLogViewerWidget class declaration.
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#ifndef FEQT_INCLUDED_SRC_logviewer_UIVMLogViewerWidget_h
29#define FEQT_INCLUDED_SRC_logviewer_UIVMLogViewerWidget_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QKeySequence>
36#include <QPair>
37#include <QPointer>
38#include <QSet>
39#include <QWidget>
40#include <QUuid>
41
42/* GUI includes: */
43#include "QIManagerDialog.h"
44#include "QIWithRetranslateUI.h"
45
46/* Forward declarations: */
47class QVBoxLayout;
48class QIToolBar;
49class QIToolButton;
50class UIActionPool;
51class UIDialogPanel;
52class UIMachineListMenu;
53class UITabWidget;
54class UIVirtualMachineItem;
55class UIVMLogPage;
56class UIVMLogTab;
57class UIVMLogViewerBookmarksPanel;
58class UIVMLogViewerPaneContainer;
59class UIVMLogViewerFilterPanel;
60class UIVMLogViewerPanel;
61class CMachine;
62
63/** QWidget extension providing GUI for VirtualBox LogViewer. It
64 * encapsulates log pages, toolbar, a tab widget and manages
65 * interaction between these classes. */
66class SHARED_LIBRARY_STUFF UIVMLogViewerWidget : public QIWithRetranslateUI<QWidget>
67{
68 Q_OBJECT;
69
70signals:
71
72 void sigSetCloseButtonShortCut(QKeySequence);
73
74public:
75
76 /** Constructs the VM Log-Viewer by passing @a pParent to QWidget base-class constructor.
77 * @param enmEmbedding Brings the type of widget embedding.
78 * @param pActionPool Brings the action-pool reference.
79 * @param fShowToolbar Brings whether we should create/show toolbar.
80 * @param uMachineId Brings the machine id for which VM Log-Viewer is requested. */
81 UIVMLogViewerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,
82 bool fShowToolbar = true, const QUuid &uMachineId = QUuid(), QWidget *pParent = 0);
83 ~UIVMLogViewerWidget();
84 /** Returns the width of the current log page. return 0 if there is no current log page: */
85 int defaultLogPageWidth() const;
86
87 /** Returns the menu. */
88 QMenu *menu() const;
89
90#ifdef VBOX_WS_MAC
91 /** Returns the toolbar. */
92 QIToolBar *toolbar() const { return m_pToolBar; }
93#endif
94
95 void setSelectedVMListItems(const QList<UIVirtualMachineItem*> &items);
96 void addSelectedVMListItems(const QList<UIVirtualMachineItem*> &items);
97 QFont currentFont() const;
98
99protected:
100
101 /** Returns whether the window should be maximized when geometry being restored. */
102 virtual bool shouldBeMaximized() const;
103
104private slots:
105
106 /** Rereads the log file shown in the current tab. */
107 void sltRefresh();
108 /** Rereads all the log files . */
109 void sltReload();
110 /** Handles save action triggering. */
111 void sltSave();
112
113 /** @name Bookmark related slots
114 * @{ */
115 /** Deletes the bookmark with @p index from the current logs bookmark list. */
116 void sltDeleteBookmarkByIndex(int index);
117 /** Receives delete all signal from the bookmark panel and notifies UIVMLogPage. */
118 void sltDeleteAllBookmarks();
119 /** Manages bookmark panel update when bookmark vector is updated. */
120 void sltUpdateBookmarkPanel();
121 /** Makes the current UIVMLogPage to goto (scroll) its bookmark with index @a index. */
122 void gotoBookmark(int bookmarkIndex);
123 /** @} */
124
125 void sltPanelActionToggled(bool fChecked);
126 /** Handles the search result highlight changes. */
127 void sltSearchResultHighLigting();
128 void sltHandleSearchUpdated();
129 /** Handles the tab change of the logviewer. */
130 void sltCurrentTabChanged(int tabIndex);
131 void sltFilterApplied();
132 /* Handles the UIVMLogPage signal which is emitted when isFiltered property
133 of UIVMLogPage is changed. */
134 void sltLogPageFilteredChanged(bool isFiltered);
135
136 /** @name Slots to handle signals from settings panel
137 * @{ */
138 void sltShowLineNumbers(bool bShowLineNumbers);
139 void sltWrapLines(bool bWrapLine);
140 void sltFontSizeChanged(int fontSize);
141 void sltChangeFont(QFont font);
142 void sltResetOptionsToDefault();
143 /** @} */
144 void sltCloseMachineLogs();
145 void sltTabCloseButtonClick();
146 void sltCommitDataSignalReceived();
147 void sltPanelContainerHidden();
148 void sltPanelCurrentTabChanged(int iIndex);
149 void sltShowSearchPane();
150
151private:
152
153 /** @name Prepare/Cleanup
154 * @{ */
155 /** Prepares VM Log-Viewer. */
156 void prepare();
157 /** Prepares actions. */
158 void prepareActions();
159 /** Prepares widgets. */
160 void prepareWidgets();
161 /** Prepares toolbar. */
162 void prepareToolBar();
163 void saveOptions();
164 /** Loads options. */
165 void loadOptions();
166 /** @} */
167
168 /** @name Event handling stuff.
169 * @{ */
170 /** Handles translation event. */
171 virtual void retranslateUi() RT_OVERRIDE;
172
173 /** Handles Qt show @a pEvent. */
174 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
175 /** Handles Qt key-press @a pEvent. */
176 virtual void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
177 /** @} */
178
179 /** Returns the newly created log-page using @a strPage filename. */
180 void createLogPage(const QString &strFileName,
181 const QString &strMachineName,
182 const QUuid &machineId, int iLogFileId,
183 const QString &strLogContent, bool noLogsToShow);
184
185 const UIVMLogPage *currentLogPage() const;
186 UIVMLogPage *currentLogPage();
187 /** Returns the log tab at tab with iIndex if it contains a log page. Return 0 otherwise. */
188 UIVMLogTab *logTab(int iIndex);
189 UIVMLogPage *logPage(int iIndex);
190 /** Returns a vector of all the log pages of the tab widget. */
191 QVector<UIVMLogTab*> logTabs();
192
193 void createLogViewerPages(const QVector<QUuid> &machineList);
194 /** Removes the log pages/tabs that shows logs of the machines from @p machineList. */
195 void removeLogViewerPages(const QVector<QUuid> &machineList);
196 void removeAllLogPages();
197 void markLabelTabs();
198
199 /** Resets document (of the current tab) and scrollbar highligthing */
200 void resetHighlighthing();
201 void setMachines(const QVector<QUuid> &machineIDs);
202 /** Returns the content of the ith log file of @comMachine or possibly an empty string */
203 QString readLogFile(const CMachine &comConstMachine, int iLogFileId);
204 /** If the current tab is a label tab then switch to the next tab and return true. Returns false otherwise. */
205 bool labelTabHandler();
206 void uncheckPaneActions();
207
208 /** Holds the widget's embedding type. */
209 const EmbedTo m_enmEmbedding;
210 /** Holds the action-pool reference. Wrapped around with QPointer to avoid use-after-delete case during vm window close.*/
211 QPointer<UIActionPool> m_pActionPool;
212 /** Holds whether we should create/show toolbar. */
213 const bool m_fShowToolbar;
214 QVector<QUuid> m_machines;
215
216 /** Holds whether the dialog is polished. */
217 bool m_fIsPolished;
218
219 /** Holds container for log-pages. */
220 UITabWidget *m_pTabWidget;
221
222 /** @name Panel instances and a QMap for mapping panel instances to related actions.
223 * @{ */
224 QList<UIDialogPanel*> m_visiblePanelsList;
225 /** @} */
226 QVBoxLayout *m_pMainLayout;
227
228 /** @name Toolbar and menu variables.
229 * @{ */
230 QIToolBar *m_pToolBar;
231 /** @} */
232
233 /** @name Toolbar and menu variables. Cache these to restore them after refresh.
234 * @{ */
235 /** Showing/hiding line numbers and line wraping options are set per
236 UIVMLogViewerWidget and applies to all log pages (all tabs) */
237 bool m_bShowLineNumbers;
238 bool m_bWrapLines;
239 QFont m_font;
240 /** @} */
241 QIToolButton *m_pCornerButton;
242 UIMachineListMenu *m_pMachineSelectionMenu;
243 /** All extra data saves are done dynamically (as an option changes etc.). The this flag is true
244 * we should not try to save anything to extra data anymore. */
245 bool m_fCommitDataSignalReceived;
246 QPointer<UIVMLogPage> m_pPreviousLogPage;
247 UIVMLogViewerPaneContainer *m_pPanel;
248 QSet<QAction*> m_paneActions;
249 friend class UIVMLogViewerFilterWidget;
250 friend class UIVMLogViewerPane;
251 friend class UIVMLogViewerDialog;
252};
253
254#endif /* !FEQT_INCLUDED_SRC_logviewer_UIVMLogViewerWidget_h */
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