Debian Codegraph @

avogadro/qtgui/containerwidget.cpp

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #include "containerwidget.h"
7
8 #include <QtWidgets/QHBoxLayout>
9 #include <QtWidgets/QLabel>
10 #include <QtWidgets/QPushButton>
11 #include <QtWidgets/QVBoxLayout>
12
13 namespace Avogadro::QtGui {
14
15 ContainerWidget::ContainerWidget(QWidget* p, Qt::WindowFlags f)
16 : QWidget(p, f), m_viewWidget(nullptr),
17 m_label(new QLabel(QStringLiteral(" "), this)), m_active(false)
18 {
19 auto* h = new QHBoxLayout;
20 h->setContentsMargins(0, 0, 0, 0);
21 auto* v = new QVBoxLayout;
22 v->setContentsMargins(0, 0, 0, 0);
23 v->setSpacing(0);
24
25 h->addWidget(m_label);
26 h->addStretch();
27 auto* button = new QPushButton(tr("Split Horizontal"), this);
28 button->setEnabled(false);
29 // connect(button, SIGNAL(clicked()), SIGNAL(splitHorizontal()));
30 h->addWidget(button);
31 button = new QPushButton(tr("Split Vertical"), this);
32 button->setEnabled(false);
33 // connect(button, SIGNAL(clicked()), SIGNAL(splitVertical()));
34 h->addWidget(button);
35 button = new QPushButton(tr("Close"), this);
36 button->setEnabled(false);
37 // connect(button, SIGNAL(clicked()), SIGNAL(closeView()));
38 h->addWidget(button);
39 v->addLayout(h);
40 setLayout(v);
41 }
42
43 ContainerWidget::~ContainerWidget() {}
44
45 void ContainerWidget::setViewWidget(QWidget* widget)
46 {
47 if (m_viewWidget)
48 m_viewWidget->deleteLater();
49 m_viewWidget = widget;
50 layout()->addWidget(widget);
51 }
52
53 QWidget* ContainerWidget::viewWidget()
54 {
55 return m_viewWidget;
56 }
57
58 void ContainerWidget::setActive(bool active)
59 {
60 if (m_active != active) {
61 m_active = active;
62 m_label->setText(active ? " * " : " ");
63 }
64 }
65
66 } // namespace Avogadro::QtGui