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 
36 {
37 
38  WidgetsWithToolbar::WidgetsWithToolbar(QWidget* parent) : QWidget(parent)
39  {
40  const int margin = 0;
41  this->setContentsMargins(margin, margin, margin, margin);
42 
43  _layout = new QHBoxLayout();
44  this->setLayout(_layout);
45  _layout->setContentsMargins(margin, margin, margin, margin);
46  _layout->setSpacing(0);
47 
48 
49  toolbar = new QToolBar();
50  toolbar->setOrientation(Qt::Orientation::Vertical);
51  toolbar->setContentsMargins(margin, margin, margin, margin);
52 
53  QAction* action = toolbar->addAction(
54  QIcon(":/icons/dialog-close.ico"), "Close", [this]() { this->close(); });
55  action->setToolTip("Remove this instance view");
56 
57  _layout->addWidget(toolbar);
58  }
59 
60  void
62  {
63  ARMARX_CHECK_GREATER_EQUAL(_layout->count(), 1);
64  _layout->insertWidget(_layout->count() - 1, widget);
65  }
66 
67  void
69  {
70  // ARMARX_IMPORTANT << "Closing instance view ...";
71  emit closing();
72 
73  this->hide();
74  this->deleteLater();
75  }
76 
77 } // namespace armarx::armem::gui::instance
WidgetsWithToolbar.h
armarx::armem::gui::instance::WidgetsWithToolbar::addWidget
void addWidget(QWidget *widget)
Definition: WidgetsWithToolbar.cpp:61
armarx::armem::gui::instance::WidgetsWithToolbar::close
void close()
Definition: WidgetsWithToolbar.cpp:68
armarx::armem::gui::instance
Definition: AronDataView.cpp:3
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:61
armarx::armem::gui::instance::WidgetsWithToolbar::WidgetsWithToolbar
WidgetsWithToolbar(QWidget *parent=nullptr)
Definition: WidgetsWithToolbar.cpp:38