1 | /* $Id: QILabelSeparator.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
5 | * VirtualBox Qt extensions: QILabelSeparator class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2008-2009 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 | /* Global includes */
|
---|
21 | #include <QLabel>
|
---|
22 | #include <QHBoxLayout>
|
---|
23 |
|
---|
24 | /* Local includes */
|
---|
25 | #include "QILabelSeparator.h"
|
---|
26 | #include "VBoxGlobal.h"
|
---|
27 |
|
---|
28 | QILabelSeparator::QILabelSeparator (QWidget *aParent /* = NULL */, Qt::WindowFlags aFlags /* = 0 */)
|
---|
29 | : QWidget (aParent, aFlags)
|
---|
30 | , mLabel (0)
|
---|
31 | {
|
---|
32 | init();
|
---|
33 | }
|
---|
34 |
|
---|
35 | QILabelSeparator::QILabelSeparator (const QString &aText, QWidget *aParent /* = NULL */, Qt::WindowFlags aFlags /* = 0 */)
|
---|
36 | : QWidget (aParent, aFlags)
|
---|
37 | , mLabel (0)
|
---|
38 | {
|
---|
39 | init();
|
---|
40 | setText (aText);
|
---|
41 | }
|
---|
42 |
|
---|
43 | QString QILabelSeparator::text() const
|
---|
44 | {
|
---|
45 | return mLabel->text();
|
---|
46 | }
|
---|
47 |
|
---|
48 | void QILabelSeparator::setBuddy (QWidget *aBuddy)
|
---|
49 | {
|
---|
50 | mLabel->setBuddy (aBuddy);
|
---|
51 | }
|
---|
52 |
|
---|
53 | void QILabelSeparator::clear()
|
---|
54 | {
|
---|
55 | mLabel->clear();
|
---|
56 | }
|
---|
57 |
|
---|
58 | void QILabelSeparator::setText (const QString &aText)
|
---|
59 | {
|
---|
60 | mLabel->setText (aText);
|
---|
61 | }
|
---|
62 |
|
---|
63 | void QILabelSeparator::init()
|
---|
64 | {
|
---|
65 | mLabel = new QLabel();
|
---|
66 | QFrame *separator = new QFrame();
|
---|
67 | separator->setFrameShape (QFrame::HLine);
|
---|
68 | separator->setFrameShadow (QFrame::Sunken);
|
---|
69 | separator->setEnabled (false);
|
---|
70 | separator->setContentsMargins (0, 0, 0, 0);
|
---|
71 | // separator->setStyleSheet ("QFrame {border: 1px outset black; }");
|
---|
72 | separator->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
---|
73 |
|
---|
74 | QHBoxLayout *pLayout = new QHBoxLayout (this);
|
---|
75 | VBoxGlobal::setLayoutMargin (pLayout, 0);
|
---|
76 | pLayout->addWidget (mLabel);
|
---|
77 | pLayout->addWidget (separator, Qt::AlignBottom);
|
---|
78 | }
|
---|
79 |
|
---|