File: InfoPanelToolBar.cpp

package info (click to toggle)
bornagain 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 91,912 kB
  • sloc: cpp: 518,586; python: 42,512; xml: 805; awk: 630; sh: 470; ansic: 37; makefile: 25
file content (58 lines) | stat: -rw-r--r-- 1,941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp
//! @brief     Declares class InfoPanelToolBar
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#include "GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h"
#include <QAction>
#include <QHBoxLayout>
#include <QToolButton>

namespace {
const int minimum_size = 25;
const QString icon_up = ":/images/dark-angle-up.svg";
const QString icon_down = ":/images/dark-angle-down.svg";
const QString expand_text = "Collapse/expand view";
} // namespace

InfoPanelToolBar::InfoPanelToolBar(QWidget* parent)
    : QToolBar(parent), m_expandAction(new QAction(expand_text, this)), m_expanded(false)
{
    setMinimumSize(minimum_size, minimum_size);
    setProperty("_q_custom_style_disabled", QVariant(true));

    m_expandAction->setIcon(QIcon(icon_up));
    m_expandAction->setToolTip(expand_text);
    connect(m_expandAction, &QAction::triggered, this, &InfoPanelToolBar::onExpandButtonClicked);

    auto empty = new QWidget();
    empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    addWidget(empty);

    addAction(m_expandAction);
}

void InfoPanelToolBar::setExpandStatus(bool status)
{
    m_expanded = status;
    if (m_expanded)
        m_expandAction->setIcon(QIcon(icon_down));
    else
        m_expandAction->setIcon(QIcon(icon_up));
}

void InfoPanelToolBar::onExpandButtonClicked()
{
    m_expanded = !m_expanded;
    setExpandStatus(m_expanded);
    emit expandButtonClicked();
}