1 | /* $Id: QILabelSeparator.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - Qt extensions: QILabelSeparator class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2008-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 <QLabel>
|
---|
31 |
|
---|
32 | /* GUI includes: */
|
---|
33 | #include "QILabelSeparator.h"
|
---|
34 |
|
---|
35 |
|
---|
36 | QILabelSeparator::QILabelSeparator(QWidget *pParent /* = 0 */, Qt::WindowFlags enmFlags /* = Qt::WindowFlags() */)
|
---|
37 | : QWidget(pParent, enmFlags)
|
---|
38 | , m_pLabel(0)
|
---|
39 | {
|
---|
40 | prepare();
|
---|
41 | }
|
---|
42 |
|
---|
43 | QILabelSeparator::QILabelSeparator(const QString &strText, QWidget *pParent /* = 0 */, Qt::WindowFlags enmFlags /* = Qt::WindowFlags() */)
|
---|
44 | : QWidget(pParent, enmFlags)
|
---|
45 | , m_pLabel(0)
|
---|
46 | {
|
---|
47 | prepare();
|
---|
48 | setText(strText);
|
---|
49 | }
|
---|
50 |
|
---|
51 | QString QILabelSeparator::text() const
|
---|
52 | {
|
---|
53 | return m_pLabel->text();
|
---|
54 | }
|
---|
55 |
|
---|
56 | void QILabelSeparator::setBuddy(QWidget *pBuddy)
|
---|
57 | {
|
---|
58 | m_pLabel->setBuddy(pBuddy);
|
---|
59 | }
|
---|
60 |
|
---|
61 | void QILabelSeparator::clear()
|
---|
62 | {
|
---|
63 | m_pLabel->clear();
|
---|
64 | }
|
---|
65 |
|
---|
66 | void QILabelSeparator::setText(const QString &strText)
|
---|
67 | {
|
---|
68 | m_pLabel->setText(strText);
|
---|
69 | }
|
---|
70 |
|
---|
71 | void QILabelSeparator::prepare()
|
---|
72 | {
|
---|
73 | /* Create layout: */
|
---|
74 | QHBoxLayout *pLayout = new QHBoxLayout(this);
|
---|
75 | if (pLayout)
|
---|
76 | {
|
---|
77 | /* Configure layout: */
|
---|
78 | pLayout->setContentsMargins(0, 0, 0, 0);
|
---|
79 |
|
---|
80 | /* Create label: */
|
---|
81 | m_pLabel = new QLabel;
|
---|
82 | if (m_pLabel)
|
---|
83 | {
|
---|
84 | /* Add into layout: */
|
---|
85 | pLayout->addWidget(m_pLabel);
|
---|
86 | }
|
---|
87 |
|
---|
88 | /* Create separator: */
|
---|
89 | QFrame *pSeparator = new QFrame;
|
---|
90 | {
|
---|
91 | /* Configure separator: */
|
---|
92 | pSeparator->setFrameShape(QFrame::HLine);
|
---|
93 | pSeparator->setFrameShadow(QFrame::Sunken);
|
---|
94 | pSeparator->setEnabled(false);
|
---|
95 | pSeparator->setContentsMargins(0, 0, 0, 0);
|
---|
96 | // pSeparator->setStyleSheet("QFrame {border: 1px outset black; }");
|
---|
97 | pSeparator->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
---|
98 |
|
---|
99 | /* Add into layout: */
|
---|
100 | pLayout->addWidget(pSeparator, Qt::AlignBottom);
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|