VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDialogPanel.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: 3.6 KB
Line 
1/* $Id: UIDialogPanel.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 <QComboBox>
30#include <QHBoxLayout>
31#include <QLabel>
32#include <QPlainTextEdit>
33#include <QTextCursor>
34#include <QToolButton>
35
36/* GUI includes: */
37#include "QIToolButton.h"
38#include "UIIconPool.h"
39#include "UIDialogPanel.h"
40#ifdef VBOX_WS_MAC
41# include "VBoxUtils-darwin.h"
42#endif
43
44
45UIDialogPanel::UIDialogPanel(QWidget *pParent /* = 0 */)
46 : QIWithRetranslateUI<QWidget>(pParent)
47 , m_pMainLayout(0)
48 , m_pCloseButton(0)
49{
50 prepare();
51}
52
53void UIDialogPanel::setCloseButtonShortCut(QKeySequence shortCut)
54{
55 if (!m_pCloseButton)
56 return;
57 m_pCloseButton->setShortcut(shortCut);
58}
59
60QHBoxLayout* UIDialogPanel::mainLayout()
61{
62 return m_pMainLayout;
63}
64
65void UIDialogPanel::prepare()
66{
67 prepareWidgets();
68 prepareConnections();
69 retranslateUi();
70}
71
72void UIDialogPanel::prepareWidgets()
73{
74 m_pMainLayout = new QHBoxLayout(this);
75 if (m_pMainLayout)
76 {
77#ifdef VBOX_WS_MAC
78 m_pMainLayout->setContentsMargins(5 /* since there is always a button */, 0, 10 /* standard */, 0);
79 m_pMainLayout->setSpacing(10);
80#else
81 m_pMainLayout->setContentsMargins(qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 2, 0,
82 qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) / 2,
83 qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) / 2);
84 m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
85#endif
86 }
87 m_pCloseButton = new QIToolButton;
88 if (m_pCloseButton)
89 {
90 m_pCloseButton->setIcon(UIIconPool::iconSet(":/close_16px.png"));
91 m_pMainLayout->addWidget(m_pCloseButton, 0, Qt::AlignLeft);
92 }
93}
94
95void UIDialogPanel::prepareConnections()
96{
97 if (m_pCloseButton)
98 connect(m_pCloseButton, &QIToolButton::clicked, this, &UIDialogPanel::hide);
99}
100
101void UIDialogPanel::retranslateUi()
102{
103 if (m_pCloseButton)
104 m_pCloseButton->setToolTip(tr("Close the pane"));
105}
106
107void UIDialogPanel::showEvent(QShowEvent *pEvent)
108{
109 QWidget::showEvent(pEvent);
110}
111
112void UIDialogPanel::hideEvent(QHideEvent *pEvent)
113{
114 /* Get focused widget: */
115 QWidget *pFocus = QApplication::focusWidget();
116 /* If focus-widget is valid and child-widget of search-panel,
117 * focus next child-widget in line: */
118 if (pFocus && pFocus->parent() == this)
119 focusNextPrevChild(true);
120 emit sigHidePanel(this);
121
122 QWidget::hideEvent(pEvent);
123}
124
125void UIDialogPanel::addVerticalSeparator()
126{
127 QFrame *pSeparator = new QFrame();
128 if (!pSeparator)
129 return;
130 pSeparator->setFrameShape(QFrame::VLine);
131 pSeparator->setFrameShadow(QFrame::Sunken);
132 mainLayout()->addWidget(pSeparator);
133}
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