WidgetsWithToolbar.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::
17 * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu)
18 * @date 2021
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #include "WidgetsWithToolbar.h"
24 
25 #include <QAction>
26 #include <QHBoxLayout>
27 #include <QPushButton>
28 #include <QToolBar>
29 #include <QVBoxLayout>
30 
32 
33 #include "InstanceView.h"
34 
35 
37 {
38 
39  WidgetsWithToolbar::WidgetsWithToolbar(QWidget* parent) : QWidget(parent)
40  {
41  const int margin = 0;
42  this->setContentsMargins(margin, margin, margin, margin);
43 
44  _layout = new QHBoxLayout();
45  this->setLayout(_layout);
46  _layout->setContentsMargins(margin, margin, margin, margin);
47  _layout->setSpacing(0);
48 
49 
50  toolbar = new QToolBar();
51  toolbar->setOrientation(Qt::Orientation::Vertical);
52  toolbar->setContentsMargins(margin, margin, margin, margin);
53 
54  QAction* action = toolbar->addAction(QIcon(":/icons/dialog-close.ico"), "Close", [this]()
55  {
56  this->close();
57  });
58  action->setToolTip("Remove this instance view");
59 
60  _layout->addWidget(toolbar);
61  }
62 
63 
64  void WidgetsWithToolbar::addWidget(QWidget* widget)
65  {
66  ARMARX_CHECK_GREATER_EQUAL(_layout->count(), 1);
67  _layout->insertWidget(_layout->count() - 1, widget);
68  }
69 
71  {
72  // ARMARX_IMPORTANT << "Closing instance view ...";
73  emit closing();
74 
75  this->hide();
76  this->deleteLater();
77  }
78 
79 }
80 
WidgetsWithToolbar.h
armarx::armem::gui::instance::WidgetsWithToolbar::addWidget
void addWidget(QWidget *widget)
Definition: WidgetsWithToolbar.cpp:64
armarx::armem::gui::instance::WidgetsWithToolbar::close
void close()
Definition: WidgetsWithToolbar.cpp:70
armarx::armem::gui::instance
Definition: AronDataView.cpp:2
armarx::armem::gui::instance::WidgetsWithToolbar::closing
void closing()
InstanceView.h
ARMARX_CHECK_GREATER_EQUAL
#define ARMARX_CHECK_GREATER_EQUAL(lhs, rhs)
This macro evaluates whether lhs is greater or equal (>=) rhs and if it turns out to be false it will...
Definition: ExpressionException.h:123
ExpressionException.h
armarx::armem::gui::instance::WidgetsWithToolbar::toolbar
QToolBar * toolbar
Definition: WidgetsWithToolbar.h:66
armarx::armem::gui::instance::WidgetsWithToolbar::WidgetsWithToolbar
WidgetsWithToolbar(QWidget *parent=nullptr)
Definition: WidgetsWithToolbar.cpp:39