-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcuteexpander.cpp
53 lines (47 loc) · 1.3 KB
/
cuteexpander.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
#include "cuteexpander.h"
#include "ui_cuteexpander.h"
CuteExpander::CuteExpander(QWidget *parent) :
QWidget(parent),
ui(new Ui::CuteExpander)
{
ui->setupUi(this);
/*QObjectList figli = this->children();
int lastY = 26;
foreach(QObject *figlio, figli)
{
QWidget *wdgFiglio = (QWidget*) figlio;
wdgFiglio->setParent(this);
wdgFiglio->setGeometry(1,lastY,width(),height());
lastY += wdgFiglio->height()+2;
}*/
ui->btnToggle->setIcon(QIcon(":/icons/icons/up_arrow_dark.png"));
ui->btnToggle->setIconSize(QSize(16,16));
ui->btnToggle->setStyleSheet("border: none; text-align: left;");
}
void CuteExpander::on_btnToggle_clicked()
{
if(this->height() == ui->btnToggle->height()+1)
{
expand();
}
else
{
unexpand();
}
}
void CuteExpander::setText(QString text)
{
ui->btnToggle->setText(text);
}
void CuteExpander::expand()
{
this->setGeometry(this->x(),this->y(),this->width(),this->maximumHeight());
ui->btnToggle->setIcon(QIcon(":/icons/icons/up_arrow_dark.png"));
emit expanded();
}
void CuteExpander::unexpand()
{
this->setGeometry(this->x(),this->y(),this->width(),ui->btnToggle->height()+1);
ui->btnToggle->setIcon(QIcon(":/icons/icons/down_arrow_dark.png"));
emit unexpanded();
}