forked from martijnkoopman/Qt-Ribbon-Widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathribbonbuttongroup.cpp
60 lines (50 loc) · 1.32 KB
/
ribbonbuttongroup.cpp
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
59
60
/*
* Copyright (C) Martijn Koopman
* All Rights Reserved
*
* This software is distributed WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
*
*/
#include "ribbonbuttongroup.h"
#include "ui_ribbonbuttongroup.h"
#include <QToolButton>
RibbonButtonGroup::RibbonButtonGroup(QWidget *parent)
: QWidget(parent)
, ui(new Ui::RibbonButtonGroup)
, m_title("")
{
ui->setupUi(this);
}
RibbonButtonGroup::~RibbonButtonGroup()
{
delete ui;
}
void RibbonButtonGroup::setTitle(const QString &title)
{
m_title = title;
ui->label->setText(m_title);
}
QString RibbonButtonGroup::title() const
{
return m_title;
}
int RibbonButtonGroup::buttonCount() const
{
return ui->horizontalLayout->count();
}
void RibbonButtonGroup::addButton(QToolButton *button)
{
button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
button->setMinimumSize(48, 48);
button->setAutoRaise(true);
button->setIconSize(QSize(32,32));
button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui->horizontalLayout->addWidget(button);
}
void RibbonButtonGroup::removeButton(QToolButton *button)
{
/// \todo What happens if button is not part of the layout?
ui->horizontalLayout->removeWidget(button);
}