Commit dc873479 authored by Carsten Fuhrmann's avatar Carsten Fuhrmann
Browse files

new chat remove rule:

- delete every line after 5 sec
- but limit to max 5 lines
parent 28be81ec
#include "overlaycontroller.h"
#include <QDesktopWidget>
#include <QTimer>
//#ifndef _DEBUG
//#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
......@@ -19,12 +20,6 @@ OverlayController::OverlayController() : QObject()
m_debugWindow->setAlignment(Qt::AlignTop | Qt::AlignLeft);
m_debugWindow->show();
m_timer = new QTimer;
m_timer->setInterval(5000);
m_timer->setSingleShot(true);
connect(m_timer, SIGNAL(timeout()), this, SLOT(hideChat()));
}
OverlayController::~OverlayController()
......@@ -38,33 +33,21 @@ OverlayController::~OverlayController()
m_msgLines.clear();
delete m_debugWindow;
m_timer->stop();
delete m_timer;
}
void OverlayController::deleteChatLine(QWidget * line)
{
//TODO: delete the given line instead of the last
delete m_msgLines.last();
m_msgLines.pop_back();
}
void OverlayController::showChat()
{
for (auto &it : m_msgLines)
it->show();
}
void OverlayController::hideChat()
{
for (auto &it : m_msgLines)
it->hide();
int index = m_msgLines.indexOf(line);
if (index != -1)
{
delete m_msgLines.at(index);
m_msgLines.remove(index);
}
}
void OverlayController::addChatLine(QString message)
{
showChat();
// generate new chatline
QWidget* w = new QWidget;
QLabel* newChatLine = new QLabel(w);
......@@ -99,7 +82,7 @@ void OverlayController::addChatLine(QString message)
deleteChatLine(m_msgLines.last());
// hide after time
m_timer->start();
QTimer::singleShot(TIMEOUT, [=] {deleteChatLine(w);});
}
void OverlayController::addSpeaker(QString name)
......
......@@ -5,13 +5,13 @@
#include <QString>
#include <QWidget>
#include <QVector>
#include <QTimer>
#include <QLabel>
#define MAXLINES 5
#define BORDEROFFSET 5
#define SPACING 10
#define TIMEOUT 5000
class QTTSOVERLAY_EXPORT OverlayController : QObject
......@@ -31,14 +31,8 @@ private:
QVector<QWidget*> m_speakers;
QVector<QWidget*> m_msgLines;
QTimer* m_timer;
private:
void deleteChatLine(QWidget* line);
void showChat();
private slots:
void hideChat();
public:
void addChatLine(QString message);
......
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