Commit a9a173e3 authored by Carsten Fuhrmann's avatar Carsten Fuhrmann

ChannelListWidget can be resized now

parent c117f586
#include "ChannelListWidget.h"
#include <QMouseEvent>
#include <Windows.h>
#include <QSizeGrip>
#include <qboxlayout.h>
ChannelTree::ChannelTree(QWidget *parent)
ChannelTree::ChannelTree(ChannelListWidget * widget, QWidget *parent)
: QTreeWidget(parent)
{
m_parent = parent;
m_parent = widget;
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);");
setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
}
ChannelTree::~ChannelTree()
......@@ -51,18 +53,35 @@ ChannelListWidget::ChannelListWidget(QWidget *parent)
{
setAttribute(Qt::WA_TranslucentBackground);
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::SplashScreen);
move(320, 200);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
m_child = new ChannelTree(this);
layout->addWidget(m_child);
m_grip = new QSizeGrip(this);
layout->addWidget(m_grip, 0, Qt::AlignBottom | Qt::AlignRight);
show();
}
ChannelListWidget::~ChannelListWidget()
{
m_child->deleteLater();
delete m_child;
delete m_grip;
}
QTreeWidget * ChannelListWidget::getTree()
{
return (QTreeWidget*)m_child;
}
void ChannelListWidget::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
m_child->resize(size());
}
......@@ -2,13 +2,16 @@
#include <QWidget>
#include <QPoint>
#include <QTreeWidget>
#include <QSizeGrip>
class ChannelListWidget;
class ChannelTree : public QTreeWidget
{
Q_OBJECT
public:
explicit ChannelTree(QWidget *parent);
explicit ChannelTree(ChannelListWidget * widget, QWidget *parent = NULL);
~ChannelTree();
protected:
......@@ -35,6 +38,10 @@ public:
private:
ChannelTree *m_child;
QSizeGrip *m_grip;
protected:
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
public:
......
......@@ -126,7 +126,7 @@ void OverlayController::addChatLine(QString message)
deleteChatLine(m_msgLines.last());
// hide after time
QTimer::singleShot(TIMEOUT, [=] {deleteChatLine(w);});
QTimer::singleShot(TIMEOUT, [=]() {deleteChatLine(w);});
}
void OverlayController::addSpeaker(QString name)
......
......@@ -36,10 +36,8 @@ private:
QVector<QWidget*> m_msgLines;
ChannelListWidget* m_tree;
private:
void deleteChatLine(QWidget* line);
private slots:
void deleteChatLine(QWidget* line);
void treeItemClicked(QTreeWidgetItem * item, int column);
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment