VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerPanel.cpp@ 103977

Last change on this file since 103977 was 103923, checked in by vboxsync, 9 months ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in log viewer classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: UIVMLogViewerPanel.cpp 103923 2024-03-19 17:01:11Z 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 <QPlainTextEdit>
31#include <QPushButton>
32
33/* GUI includes: */
34#include "UIIconPool.h"
35#include "UIVMLogPage.h"
36#include "UIVMLogViewerPanel.h"
37#include "UIVMLogViewerWidget.h"
38#include "UIVMLogViewerSearchWidget.h"
39#include "UIVMLogViewerFilterWidget.h"
40#include "UIVMLogViewerBookmarksWidget.h"
41#include "UIVMLogViewerPreferencesWidget.h"
42#include "UITranslationEventListener.h"
43#ifdef VBOX_WS_MAC
44# include "VBoxUtils-darwin.h"
45#endif
46
47UIVMLogViewerPaneContainer::UIVMLogViewerPaneContainer(QWidget *pParent,
48 UIVMLogViewerWidget *pViewer,
49 EmbedTo enmEmbedTo /* = EmbedTo_Stack */)
50 : UIPaneContainer(pParent, enmEmbedTo, true /* detach allowed */)
51 , m_pViewer(pViewer)
52 , m_pSearchWidget(0)
53 , m_pFilterWidget(0)
54 , m_pBookmarksWidget(0)
55 , m_pPreferencesWidget(0)
56{
57 prepare();
58}
59
60void UIVMLogViewerPaneContainer::prepare()
61{
62 /* Search tab: */
63 m_pSearchWidget = new UIVMLogViewerSearchWidget(0, m_pViewer);
64 insertTab(Page_Search, m_pSearchWidget);
65
66 connect(m_pSearchWidget, &UIVMLogViewerSearchWidget::sigHighlightingUpdated,
67 this, &UIVMLogViewerPaneContainer::sigHighlightingUpdated);
68 connect(m_pSearchWidget, &UIVMLogViewerSearchWidget::sigSearchUpdated,
69 this, &UIVMLogViewerPaneContainer::sigSearchUpdated);
70 connect(m_pSearchWidget, &UIVMLogViewerSearchWidget::sigShowPane,
71 this, &UIVMLogViewerPaneContainer::sigShowSearchPane);
72
73 /* Filter tab: */
74 m_pFilterWidget = new UIVMLogViewerFilterWidget(0, m_pViewer);
75 insertTab(Page_Filter, m_pFilterWidget);
76
77 connect(m_pFilterWidget, &UIVMLogViewerFilterWidget::sigFilterApplied,
78 this, &UIVMLogViewerPaneContainer::sigFilterApplied);
79
80 /* Bookmark tab: */
81 m_pBookmarksWidget = new UIVMLogViewerBookmarksWidget(0, m_pViewer);
82 insertTab(Page_Bookmark, m_pBookmarksWidget);
83
84 connect(m_pBookmarksWidget, &UIVMLogViewerBookmarksWidget::sigDeleteBookmarkByIndex,
85 this, &UIVMLogViewerPaneContainer::sigDeleteBookmarkByIndex);
86 connect(m_pBookmarksWidget, &UIVMLogViewerBookmarksWidget::sigDeleteAllBookmarks,
87 this, &UIVMLogViewerPaneContainer::sigDeleteAllBookmarks);
88 connect(m_pBookmarksWidget, &UIVMLogViewerBookmarksWidget::sigBookmarkSelected,
89 this, &UIVMLogViewerPaneContainer::sigBookmarkSelected);
90
91 /* Preferences tab: */
92 m_pPreferencesWidget = new UIVMLogViewerPreferencesWidget(0, m_pViewer);
93 insertTab(Page_Preferences, m_pPreferencesWidget);
94
95 connect(m_pPreferencesWidget, &UIVMLogViewerPreferencesWidget::sigShowLineNumbers,
96 this, &UIVMLogViewerPaneContainer::sigShowLineNumbers);
97 connect(m_pPreferencesWidget, &UIVMLogViewerPreferencesWidget::sigWrapLines,
98 this, &UIVMLogViewerPaneContainer::sigWrapLines);
99 connect(m_pPreferencesWidget, &UIVMLogViewerPreferencesWidget::sigChangeFontSizeInPoints,
100 this, &UIVMLogViewerPaneContainer::sigChangeFontSizeInPoints);
101 connect(m_pPreferencesWidget, &UIVMLogViewerPreferencesWidget::sigChangeFont,
102 this, &UIVMLogViewerPaneContainer::sigChangeFont);
103 connect(m_pPreferencesWidget, &UIVMLogViewerPreferencesWidget::sigResetToDefaults,
104 this, &UIVMLogViewerPaneContainer::sigResetToDefaults);
105
106 sltRetranslateUI();
107 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
108 this, &UIVMLogViewerPaneContainer::sltRetranslateUI);
109}
110
111void UIVMLogViewerPaneContainer::refreshSearch()
112{
113 if (m_pSearchWidget)
114 m_pSearchWidget->refreshSearch();
115}
116
117QVector<float> UIVMLogViewerPaneContainer::matchLocationVector() const
118{
119 if (!m_pSearchWidget)
120 return QVector<float>();
121 return m_pSearchWidget->matchLocationVector();
122}
123
124int UIVMLogViewerPaneContainer::matchCount() const
125{
126 if (!m_pSearchWidget)
127 return 0;
128 return m_pSearchWidget->matchCount();
129}
130
131void UIVMLogViewerPaneContainer::applyFilter()
132{
133 if (m_pFilterWidget)
134 m_pFilterWidget->applyFilter();
135}
136
137void UIVMLogViewerPaneContainer::updateBookmarkList(const QVector<UIVMLogBookmark>& bookmarkList)
138{
139 if (m_pBookmarksWidget)
140 m_pBookmarksWidget->updateBookmarkList(bookmarkList);
141}
142
143void UIVMLogViewerPaneContainer::disableEnableBookmarking(bool flag)
144{
145 if (m_pBookmarksWidget)
146 m_pBookmarksWidget->disableEnableBookmarking(flag);
147}
148
149void UIVMLogViewerPaneContainer::setShowLineNumbers(bool bShowLineNumbers)
150{
151 if (m_pPreferencesWidget)
152 m_pPreferencesWidget->setShowLineNumbers(bShowLineNumbers);
153}
154
155void UIVMLogViewerPaneContainer::setWrapLines(bool bWrapLines)
156{
157 if (m_pPreferencesWidget)
158 m_pPreferencesWidget->setWrapLines(bWrapLines);
159}
160
161void UIVMLogViewerPaneContainer::setFontSizeInPoints(int fontSizeInPoints)
162{
163 if (m_pPreferencesWidget)
164 m_pPreferencesWidget->setFontSizeInPoints(fontSizeInPoints);
165}
166
167void UIVMLogViewerPaneContainer::sltRetranslateUI()
168{
169 setTabText(Page_Search, UIVMLogViewerWidget::tr("Find"));
170 setTabText(Page_Filter, UIVMLogViewerWidget::tr("Filter"));
171 setTabText(Page_Bookmark, UIVMLogViewerWidget::tr("Bookmarks"));
172 setTabText(Page_Preferences, UIVMLogViewerWidget::tr("Preferences"));
173}
174
175bool UIVMLogViewerPaneContainer::eventFilter(QObject *pObject, QEvent *pEvent)
176{
177 /* Check if the search panel is interested in the event (most prob. key event): */
178 if (m_pSearchWidget && m_pSearchWidget->handleSearchRelatedEvents(pObject, pEvent))
179 return true;
180
181 return UIPaneContainer::eventFilter(pObject, pEvent);
182}
183
184
185/*********************************************************************************************************************************
186* UIVMLogViewerPanel implementation. *
187*********************************************************************************************************************************/
188
189UIVMLogViewerPane::UIVMLogViewerPane(QWidget *pParent, UIVMLogViewerWidget *pViewer)
190 : QWidget(pParent)
191 , m_pViewer(pViewer)
192{
193}
194
195UIVMLogViewerWidget* UIVMLogViewerPane::viewer()
196{
197 return m_pViewer;
198}
199
200const UIVMLogViewerWidget* UIVMLogViewerPane::viewer() const
201{
202 return m_pViewer;
203}
204
205QTextDocument *UIVMLogViewerPane::textDocument()
206{
207 QPlainTextEdit *pEdit = textEdit();
208 if (!pEdit)
209 return 0;
210 return textEdit()->document();
211}
212
213QPlainTextEdit *UIVMLogViewerPane::textEdit()
214{
215 if (!viewer())
216 return 0;
217 UIVMLogPage *logPage = viewer()->currentLogPage();
218 if (!logPage)
219 return 0;
220 return logPage->textEdit();
221}
222
223const QString* UIVMLogViewerPane::logString() const
224{
225 if (!viewer())
226 return 0;
227 const UIVMLogPage* const page = qobject_cast<const UIVMLogPage* const>(viewer()->currentLogPage());
228 if (!page)
229 return 0;
230 return &(page->logString());
231}
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