VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPaneContainer.cpp@ 100956

Last change on this file since 100956 was 100956, checked in by vboxsync, 16 months ago

FE/Qt: bugref:10496. Some renaming.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/* $Id: UIPaneContainer.cpp 100956 2023-08-23 11:53:29Z 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 "UIPaneContainer.h"
40#ifdef VBOX_WS_MAC
41# include "VBoxUtils-darwin.h"
42#endif
43
44/* Other VBox includes: */
45#include <iprt/assert.h>
46
47UIPaneContainer::UIPaneContainer(QWidget *pParent /* = 0 */)
48 : QIWithRetranslateUI<QWidget>(pParent)
49 , m_pTabWidget(0)
50 , m_pCloseButton(0)
51{
52 prepare();
53 retranslateUi();
54}
55
56void UIPaneContainer::retranslateUi()
57{
58 if (m_pCloseButton)
59 m_pCloseButton->setToolTip(tr("Close"));
60}
61
62void UIPaneContainer::prepare()
63{
64 QHBoxLayout *pLayout = new QHBoxLayout(this);
65 AssertReturnVoid(pLayout);
66 pLayout->setContentsMargins(0, 0, 0, 0);
67 m_pTabWidget = new QTabWidget();
68 connect(m_pTabWidget, &QTabWidget::currentChanged, this, &UIPaneContainer::sigCurrentTabChanged);
69 AssertReturnVoid(m_pTabWidget);
70 pLayout->addWidget(m_pTabWidget);
71 /* Add a button to close the tab widget: */
72 m_pCloseButton = new QIToolButton;
73 AssertReturnVoid(m_pCloseButton);
74 m_pCloseButton->setIcon(UIIconPool::iconSet(":/close_16px.png"));
75 connect(m_pCloseButton, &QIToolButton::clicked, this, &UIPaneContainer::sltHide);
76
77 m_pTabWidget->setCornerWidget(m_pCloseButton);
78}
79
80void UIPaneContainer::sltHide()
81{
82 hide();
83 emit sigHidden();
84}
85
86void UIPaneContainer::insertTab(int iIndex, QWidget *pPage, const QString &strLabel /* = QString() */)
87{
88 if (m_pTabWidget)
89 m_pTabWidget->insertTab(iIndex, pPage, strLabel);
90}
91
92void UIPaneContainer::setTabText(int iIndex, const QString &strText)
93{
94 if (!m_pTabWidget || iIndex < 0 || iIndex >= m_pTabWidget->count())
95 return;
96 m_pTabWidget->setTabText(iIndex, strText);
97}
98
99void UIPaneContainer::setCurrentIndex(int iIndex)
100{
101 if (!m_pTabWidget || iIndex >= m_pTabWidget->count() || iIndex < 0)
102 return;
103 m_pTabWidget->setCurrentIndex(iIndex);
104}
105
106int UIPaneContainer::currentIndex() const
107{
108 if (!m_pTabWidget)
109 return -1;
110 return m_pTabWidget->currentIndex();
111}
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