VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDialogPanel.cpp@ 82781

Last change on this file since 82781 was 78001, checked in by vboxsync, 5 years ago

FE/Qt: bugref:9072: Removing unused eventFilter from UIDialogPanel, its base-class (QWidget) wouldn't consume event anyway unless it's really required.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: UIDialogPanel.cpp 78001 2019-04-03 15:58:32Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVMLogViewer class implementation.
4 */
5
6/*
7 * Copyright (C) 2010-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* Qt includes: */
19#include <QComboBox>
20#include <QHBoxLayout>
21#include <QLabel>
22#include <QPlainTextEdit>
23#include <QTextCursor>
24#include <QToolButton>
25
26/* GUI includes: */
27#include "QIToolButton.h"
28#include "UIIconPool.h"
29#include "UIDialogPanel.h"
30#ifdef VBOX_WS_MAC
31# include "VBoxUtils-darwin.h"
32#endif
33
34
35UIDialogPanel::UIDialogPanel(QWidget *pParent /* = 0 */)
36 : QIWithRetranslateUI<QWidget>(pParent)
37 , m_pMainLayout(0)
38 , m_pCloseButton(0)
39{
40 prepare();
41}
42
43void UIDialogPanel::setCloseButtonShortCut(QKeySequence shortCut)
44{
45 if (!m_pCloseButton)
46 return;
47 m_pCloseButton->setShortcut(shortCut);
48}
49
50QHBoxLayout* UIDialogPanel::mainLayout()
51{
52 return m_pMainLayout;
53}
54
55void UIDialogPanel::prepare()
56{
57 prepareWidgets();
58 prepareConnections();
59 retranslateUi();
60}
61
62void UIDialogPanel::prepareWidgets()
63{
64 m_pMainLayout = new QHBoxLayout(this);
65 if (m_pMainLayout)
66 {
67#ifdef VBOX_WS_MAC
68 m_pMainLayout->setContentsMargins(5 /* since there is always a button */, 0, 10 /* standard */, 0);
69 m_pMainLayout->setSpacing(10);
70#else
71 m_pMainLayout->setContentsMargins(qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 2, 0,
72 qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) / 2,
73 qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) / 2);
74 m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing));
75#endif
76 }
77 m_pCloseButton = new QIToolButton;
78 if (m_pCloseButton)
79 {
80 m_pCloseButton->setIcon(UIIconPool::iconSet(":/close_16px.png"));
81 m_pMainLayout->addWidget(m_pCloseButton, 0, Qt::AlignLeft);
82 }
83}
84
85void UIDialogPanel::prepareConnections()
86{
87 if (m_pCloseButton)
88 connect(m_pCloseButton, &QIToolButton::clicked, this, &UIDialogPanel::hide);
89}
90
91void UIDialogPanel::retranslateUi()
92{
93 if (m_pCloseButton)
94 m_pCloseButton->setToolTip(QApplication::translate("UIVisoCreator", "Close the pane"));
95}
96
97void UIDialogPanel::showEvent(QShowEvent *pEvent)
98{
99 QWidget::showEvent(pEvent);
100}
101
102void UIDialogPanel::hideEvent(QHideEvent *pEvent)
103{
104 /* Get focused widget: */
105 QWidget *pFocus = QApplication::focusWidget();
106 /* If focus-widget is valid and child-widget of search-panel,
107 * focus next child-widget in line: */
108 if (pFocus && pFocus->parent() == this)
109 focusNextPrevChild(true);
110 emit sigHidePanel(this);
111
112 QWidget::hideEvent(pEvent);
113}
114
115void UIDialogPanel::addVerticalSeparator()
116{
117 QFrame *pSeparator = new QFrame();
118 if (!pSeparator)
119 return;
120 pSeparator->setFrameShape(QFrame::VLine);
121 pSeparator->setFrameShadow(QFrame::Sunken);
122 mainLayout()->addWidget(pSeparator);
123}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use