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