ChannelListWidget.cpp 1.57 KB
Newer Older
1 2 3
#include "ChannelListWidget.h"
#include <QMouseEvent>

Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
4 5
ChannelTree::ChannelTree(QWidget *parent)
	: QTreeWidget(parent)
6
{
Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
7
	m_parent = parent;
8 9 10 11

	setHeaderHidden(true);
	setExpandsOnDoubleClick(false);
	setStyleSheet("padding:2px;border-radius:5px;border-style:solid;border-width:1px;border-color:rgb(100,100,100); background-color:rgba(50,50,50,150); color:rgb(255,255,255);");
Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
12

13 14 15 16 17 18

	resize(200, 400);
	m_parent->adjustSize();

}

Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
19
ChannelTree::~ChannelTree()
20
{
Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
21

22 23
}

Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
24
void ChannelTree::mousePressEvent(QMouseEvent * event)
25 26 27
{
	if (event->button() == Qt::LeftButton)
		isMouseDown = true;
28 29
	else if (event->button() == Qt::RightButton)
		m_parent->hide();
30 31 32 33

	QTreeWidget::mousePressEvent(event);
}

Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
34
void ChannelTree::mouseReleaseEvent(QMouseEvent * event)
35 36 37 38 39 40
{
	isMouseDown = false;

	QTreeWidget::mouseReleaseEvent(event);
}

Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
41
void ChannelTree::mouseMoveEvent(QMouseEvent * event)
42 43 44 45 46 47 48
{
	if (isMouseDown)
		m_parent->move(event->globalPos());

	QTreeWidget::mouseMoveEvent(event);
}

Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
49
void ChannelTree::resizeEvent(QResizeEvent * event)
50
{
Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
51
	m_parent->resize(this->size());
52 53

	QTreeWidget::resizeEvent(event);
Carsten Fuhrmann's avatar
Carsten Fuhrmann committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
}

///////////////////////////////////////////////////////////////////////////////////////

ChannelListWidget::ChannelListWidget(QWidget *parent)
	: QWidget(parent)
{
	setAttribute(Qt::WA_TranslucentBackground);
	setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
	setGeometry(320, 200, 1, 1);

	m_child = new ChannelTree(this);
	m_child->show();
	show();
}

ChannelListWidget::~ChannelListWidget()
{
	m_child->deleteLater();
}

QTreeWidget * ChannelListWidget::getTree()
{
	return (QTreeWidget*)m_child;
}