Commit a9a173e3 authored by Carsten Fuhrmann's avatar Carsten Fuhrmann

ChannelListWidget can be resized now

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