diff --git a/Release/x64/qtTsOverlay_x64.dll b/Release/x64/qtTsOverlay_x64.dll index a701d3eb1145026a1fb54bbb4581a67fa7cefa37..10d400e49d8931c50e93e2f30b76951d6ed01784 100644 Binary files a/Release/x64/qtTsOverlay_x64.dll and b/Release/x64/qtTsOverlay_x64.dll differ diff --git a/Release/x64/qtTsOverlay_x64.exp b/Release/x64/qtTsOverlay_x64.exp index b435beeb694b42ad322b2809432edd00ceacaf1e..7c6450ca56f5d8c1b316e6d0f2ca94278f042233 100644 Binary files a/Release/x64/qtTsOverlay_x64.exp and b/Release/x64/qtTsOverlay_x64.exp differ diff --git a/Release/x64/qtTsOverlay_x64.lib b/Release/x64/qtTsOverlay_x64.lib index 56d4adc9336cf69fb9a9f44d66d65c1319c2e061..40b79b25add33cf36311ba9007ba8d45bbefda31 100644 Binary files a/Release/x64/qtTsOverlay_x64.lib and b/Release/x64/qtTsOverlay_x64.lib differ diff --git a/overlaycontroller.cpp b/overlaycontroller.cpp index 522c9e070da553e35e7da62c21d40732b202ddc2..55650bc6d96021c0ebaeddd34b600e6d71df941e 100644 --- a/overlaycontroller.cpp +++ b/overlaycontroller.cpp @@ -1,5 +1,6 @@ #include "overlaycontroller.h" #include +#include //#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) diff --git a/overlaycontroller.h b/overlaycontroller.h index ddf63ea3cc07ba2bd85bdd1bb37757eb8e185afb..cbae10b605b4b58c72f39f277a3153063d4c76b3 100644 --- a/overlaycontroller.h +++ b/overlaycontroller.h @@ -5,13 +5,13 @@ #include #include #include -#include #include #define MAXLINES 5 #define BORDEROFFSET 5 #define SPACING 10 +#define TIMEOUT 5000 class QTTSOVERLAY_EXPORT OverlayController : QObject @@ -31,14 +31,8 @@ private: QVector m_speakers; QVector m_msgLines; - QTimer* m_timer; - private: void deleteChatLine(QWidget* line); - void showChat(); - -private slots: - void hideChat(); public: void addChatLine(QString message);