Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

Commit dc873479 authored by Carsten Fuhrmann's avatar Carsten Fuhrmann

new chat remove rule:

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