Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qtTsOverlay
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
C-Fu
qtTsOverlay
Commits
0a8deb16
Commit
0a8deb16
authored
Feb 24, 2017
by
Carsten Fuhrmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
72692a53
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
190 additions
and
159 deletions
+190
-159
Release/x64/qtTsOverlay_x64.dll
Release/x64/qtTsOverlay_x64.dll
+0
-0
Release/x64/qtTsOverlay_x64.exp
Release/x64/qtTsOverlay_x64.exp
+0
-0
Release/x64/qtTsOverlay_x64.lib
Release/x64/qtTsOverlay_x64.lib
+0
-0
overlaycontroller.cpp
overlaycontroller.cpp
+144
-1
overlaycontroller.h
overlaycontroller.h
+36
-1
plugin.cpp
plugin.cpp
+10
-151
plugin.h
plugin.h
+0
-6
No files found.
Release/x64/qtTsOverlay_x64.dll
View file @
0a8deb16
No preview for this file type
Release/x64/qtTsOverlay_x64.exp
View file @
0a8deb16
No preview for this file type
Release/x64/qtTsOverlay_x64.lib
View file @
0a8deb16
No preview for this file type
overlaycontroller.cpp
View file @
0a8deb16
#include "overlaycontroller.h"
#include <QDesktopWidget>
OverlayController
::
OverlayController
()
//#ifndef _DEBUG
//#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
//#endif
OverlayController
::
OverlayController
()
:
QObject
()
{
QDesktopWidget
desktop
;
m_screenHeight
=
desktop
.
screenGeometry
().
height
();
m_screenWidth
=
desktop
.
screenGeometry
().
width
();
m_speakerOffset
=
0
;
m_debugWindow
=
new
QLabel
;
m_debugWindow
->
setGeometry
(
320
,
200
,
750
,
360
);
m_debugWindow
->
setAlignment
(
Qt
::
AlignTop
|
Qt
::
AlignLeft
);
m_debugWindow
->
show
();
m_timer
=
new
QTimer
;
m_timer
->
setInterval
(
100
);
m_timer
->
setSingleShot
(
true
);
connect
(
m_timer
,
SIGNAL
(
timeout
()),
SLOT
(
debugPrint
(
"HUHU"
)));
addChatLine
(
"Test12"
);
}
OverlayController
::~
OverlayController
()
{
for
(
auto
&
it
:
m_speakers
)
delete
it
;
m_speakers
.
clear
();
for
(
auto
&
it
:
m_msgLines
)
delete
it
;
m_msgLines
.
clear
();
delete
m_debugWindow
;
delete
m_timer
;
}
void
OverlayController
::
deleteChatLine
(
QLabel
*
line
)
{
//TODO: delete the given line instead of the last
delete
m_msgLines
.
last
();
m_msgLines
.
pop_back
();
}
void
OverlayController
::
addChatLine
(
QString
message
)
{
// generate new chatline
QLabel
*
newChatLine
=
new
QLabel
;
newChatLine
->
setText
(
message
);
newChatLine
->
adjustSize
();
newChatLine
->
setWindowFlags
(
Qt
::
WindowStaysOnTopHint
|
Qt
::
SplashScreen
);
newChatLine
->
setAttribute
(
Qt
::
WA_TranslucentBackground
);
newChatLine
->
setAttribute
(
Qt
::
WA_ShowWithoutActivating
);
newChatLine
->
setGeometry
(
BOARDEROFFSET
,
BOARDEROFFSET
,
newChatLine
->
geometry
().
width
(),
LINEHEIGHT
);
newChatLine
->
setAlignment
(
Qt
::
AlignTop
|
Qt
::
AlignLeft
);
newChatLine
->
show
();
// move old messages down
for
(
auto
&
it
:
m_msgLines
)
it
->
setGeometry
(
it
->
geometry
().
x
(),
it
->
geometry
().
y
()
+
LINEHEIGHT
,
it
->
geometry
().
width
(),
it
->
geometry
().
height
());
// inseart new chat line
m_msgLines
.
push_front
(
newChatLine
);
// limit the number of lines
if
(
m_msgLines
.
size
()
>
MAXLINES
)
deleteChatLine
(
m_msgLines
.
last
());
//TODO: delete after time
//m_timer->start();
}
void
OverlayController
::
addSpeaker
(
QString
name
)
{
int
labelWidth
=
0
;
QLabel
*
newSpeaker
=
new
QLabel
;
newSpeaker
->
setText
(
name
);
newSpeaker
->
adjustSize
();
newSpeaker
->
resize
(
newSpeaker
->
size
().
width
()
+
SPACING
,
LINEHEIGHT
);
labelWidth
=
newSpeaker
->
geometry
().
width
();
newSpeaker
->
setWindowFlags
(
Qt
::
WindowStaysOnTopHint
|
Qt
::
SplashScreen
);
newSpeaker
->
setAttribute
(
Qt
::
WA_TranslucentBackground
);
newSpeaker
->
setAttribute
(
Qt
::
WA_ShowWithoutActivating
);
newSpeaker
->
setGeometry
(
BOARDEROFFSET
+
m_speakerOffset
,
m_screenHeight
-
BOARDEROFFSET
-
LINEHEIGHT
,
labelWidth
,
LINEHEIGHT
);
newSpeaker
->
setAlignment
(
Qt
::
AlignTop
|
Qt
::
AlignCenter
);
//newSpeaker->setStyleSheet("border-style: none; padding: 2px; background-color: rgba(255, 255, 255, 10);");
newSpeaker
->
show
();
m_speakerOffset
+=
labelWidth
;
m_speakers
.
push_back
(
newSpeaker
);
}
void
OverlayController
::
removeSpeaker
(
QString
name
)
{
int
index
=
-
1
;
int
labelWidth
=
0
;
// move all speaker to the left side and find the one to delete
for
(
int
i
=
0
;
i
<
m_speakers
.
size
();
i
++
)
{
QLabel
*
it
=
m_speakers
.
at
(
i
);
it
->
setGeometry
(
it
->
geometry
().
x
()
-
labelWidth
,
it
->
geometry
().
y
(),
it
->
geometry
().
width
(),
it
->
geometry
().
height
());
if
(
it
->
text
()
==
name
)
{
labelWidth
=
it
->
geometry
().
width
();
m_speakerOffset
-=
labelWidth
;
index
=
i
;
delete
it
;
}
}
// remove the deleted label from the list
if
(
index
!=
-
1
)
m_speakers
.
remove
(
index
);
}
void
OverlayController
::
debugPrint
(
QString
text
)
{
m_debugWindow
->
setText
(
text
+
"
\n
"
+
m_debugWindow
->
text
());
m_debugWindow
->
setText
(
QString
(
"HUHU"
)
+
"
\n
"
+
m_debugWindow
->
text
());
}
void
OverlayController
::
reset
()
{
for
(
auto
&
it
:
m_speakers
)
delete
it
;
m_speakers
.
clear
();
for
(
auto
&
it
:
m_msgLines
)
delete
it
;
m_msgLines
.
clear
();
m_speakerOffset
=
0
;
}
overlaycontroller.h
View file @
0a8deb16
#pragma once
#include "qttsoverlay_global.h"
#include <QObject>
#include <QString>
#include <QLabel>
#include <QVector>
#include <QTimer>
class
QTTSOVERLAY_EXPORT
OverlayController
#define MAXLINES 5
#define BOARDEROFFSET 5
#define LINEHEIGHT 15
#define SPACING 10
class
QTTSOVERLAY_EXPORT
OverlayController
:
QObject
{
Q_OBJECT
public:
OverlayController
();
~
OverlayController
();
private:
int
m_screenWidth
;
int
m_screenHeight
;
int
m_speakerOffset
;
QLabel
*
m_debugWindow
;
QVector
<
QLabel
*>
m_speakers
;
QVector
<
QLabel
*>
m_msgLines
;
QTimer
*
m_timer
;
private
slots
:
void
deleteChatLine
(
QLabel
*
line
);
public:
void
addChatLine
(
QString
message
);
void
addSpeaker
(
QString
name
);
void
removeSpeaker
(
QString
name
);
void
debugPrint
(
QString
text
);
void
reset
();
};
plugin.cpp
View file @
0a8deb16
...
...
@@ -13,11 +13,6 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <qlabel.h>
#include <qstring.h>
#include <qdesktopwidget.h>
#include <qvector.h>
#include <qtimer.h>
#include "teamspeak/public_errors.h"
#include "teamspeak/public_errors_rare.h"
#include "teamspeak/public_definitions.h"
...
...
@@ -25,6 +20,7 @@
#include "teamspeak/clientlib_publicdefinitions.h"
#include "ts3_functions.h"
#include "plugin.h"
#include "overlaycontroller.h"
#pragma region defines, global variables
...
...
@@ -48,20 +44,7 @@ static struct TS3Functions ts3Functions;
static
char
*
pluginID
=
NULL
;
QLabel
*
debugWindow
;
QVector
<
QLabel
*>
currentSpeakers
;
QVector
<
QLabel
*>
currentChatLines
;
struct
{
int
screenWidth
;
int
screenHeight
;
int
speakerOffset
;
}
info
;
#define BOARDEROFFSET 5
#define LINEHEIGHT 15
#define SPACING 10
OverlayController
*
controller
;
#ifdef _WIN32
/* Helper function to convert wchar_T to Utf-8 encoded strings on Windows */
...
...
@@ -136,16 +119,7 @@ void ts3plugin_setFunctionPointers(const struct TS3Functions funcs) {
*/
int
ts3plugin_init
()
{
QDesktopWidget
desktop
;
info
.
screenWidth
=
desktop
.
screenGeometry
().
width
();
info
.
screenHeight
=
desktop
.
screenGeometry
().
height
();
info
.
speakerOffset
=
0
;
debugWindow
=
new
QLabel
;
debugWindow
->
setGeometry
(
320
,
200
,
750
,
360
);
debugWindow
->
setAlignment
(
Qt
::
AlignTop
|
Qt
::
AlignLeft
);
debugWindow
->
show
();
controller
=
new
OverlayController
;
return
0
;
/* 0 = success, 1 = failure, -2 = failure but client will not show a "failed to load" warning */
/* -2 is a very special case and should only be used if a plugin displays a dialog (e.g. overlay) asking the user to disable
...
...
@@ -156,15 +130,7 @@ int ts3plugin_init() {
/* Custom code called right before the plugin is unloaded */
void
ts3plugin_shutdown
()
{
for
(
auto
&
it
:
currentSpeakers
)
delete
it
;
currentSpeakers
.
clear
();
for
(
auto
&
it
:
currentChatLines
)
delete
it
;
currentChatLines
.
clear
();
delete
debugWindow
;
delete
controller
;
/*
* Note:
...
...
@@ -256,104 +222,6 @@ int ts3plugin_requestAutoload() {
#pragma endregion
/****************************** helper functions ********************************/
/*
* Following functions are custom helper for the callbacks.
*/
#pragma region helperfunctions
void
generateChatLine
(
QString
message
)
{
// generate new chatline
QLabel
*
newChatLine
=
new
QLabel
;
newChatLine
->
setText
(
message
);
newChatLine
->
adjustSize
();
newChatLine
->
setWindowFlags
(
Qt
::
WindowStaysOnTopHint
|
Qt
::
SplashScreen
);
newChatLine
->
setAttribute
(
Qt
::
WA_TranslucentBackground
);
newChatLine
->
setGeometry
(
BOARDEROFFSET
,
BOARDEROFFSET
,
newChatLine
->
geometry
().
width
(),
LINEHEIGHT
);
newChatLine
->
setAlignment
(
Qt
::
AlignTop
|
Qt
::
AlignLeft
);
newChatLine
->
show
();
// move old messages down
for
(
auto
&
it
:
currentChatLines
)
it
->
setGeometry
(
it
->
geometry
().
x
(),
it
->
geometry
().
y
()
+
LINEHEIGHT
,
it
->
geometry
().
width
(),
it
->
geometry
().
height
());
// inseart new chat line
currentChatLines
.
push_front
(
newChatLine
);
if
(
currentChatLines
.
size
()
>
5
)
deleteChatLine
(
currentChatLines
.
last
());
//TODO: delete after time
//QTimer::singleShot(50, [&] { deleteChatLine(newChatLine); });
}
void
deleteChatLine
(
QLabel
*
message
)
{
delete
currentChatLines
.
last
();
currentChatLines
.
pop_back
();
}
void
generateSpeaker
(
QString
name
)
{
int
labelWidth
=
0
;
QLabel
*
newSpeaker
=
new
QLabel
;
newSpeaker
->
setText
(
name
);
newSpeaker
->
adjustSize
();
newSpeaker
->
resize
(
newSpeaker
->
size
().
width
()
+
SPACING
,
LINEHEIGHT
);
labelWidth
=
newSpeaker
->
geometry
().
width
();
newSpeaker
->
setWindowFlags
(
Qt
::
WindowStaysOnTopHint
|
Qt
::
SplashScreen
);
newSpeaker
->
setAttribute
(
Qt
::
WA_TranslucentBackground
);
newSpeaker
->
setGeometry
(
BOARDEROFFSET
+
info
.
speakerOffset
,
info
.
screenHeight
-
BOARDEROFFSET
-
LINEHEIGHT
,
labelWidth
,
LINEHEIGHT
);
newSpeaker
->
setAlignment
(
Qt
::
AlignTop
|
Qt
::
AlignCenter
);
//newSpeaker->setStyleSheet("border-style: none; padding: 2px; background-color: rgba(255, 255, 255, 10);");
newSpeaker
->
show
();
info
.
speakerOffset
+=
labelWidth
;
currentSpeakers
.
push_back
(
newSpeaker
);
}
void
deleteSpeaker
(
QString
name
)
{
int
index
=
-
1
;
int
labelWidth
=
0
;
// move all speaker to the left side and find the one to delete
for
(
int
i
=
0
;
i
<
currentSpeakers
.
size
();
i
++
)
{
QLabel
*
it
=
currentSpeakers
.
at
(
i
);
it
->
setGeometry
(
it
->
geometry
().
x
()
-
labelWidth
,
it
->
geometry
().
y
(),
it
->
geometry
().
width
(),
it
->
geometry
().
height
());
if
(
it
->
text
()
==
name
)
{
labelWidth
=
it
->
geometry
().
width
();
info
.
speakerOffset
-=
labelWidth
;
index
=
i
;
delete
it
;
}
}
// remove the deleted label from the list
if
(
index
!=
-
1
)
currentSpeakers
.
remove
(
index
);
}
void
debugPrint
(
QString
text
)
{
debugWindow
->
setText
(
text
+
"
\n
"
+
debugWindow
->
text
());
}
#pragma endregion
/************************** TeamSpeak callbacks ***************************/
/*
* Following functions are optional, feel free to remove unused callbacks.
...
...
@@ -368,23 +236,14 @@ void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int
if
(
newStatus
==
STATUS_DISCONNECTED
)
{
for
(
auto
&
it
:
currentSpeakers
)
delete
it
;
currentSpeakers
.
clear
();
for
(
auto
&
it
:
currentChatLines
)
delete
it
;
currentChatLines
.
clear
();
info
.
speakerOffset
=
0
;
controller
->
reset
();
}
else
if
(
newStatus
==
STATUS_CONNECTION_ESTABLISHED
)
{
char
*
name
;
ts3Functions
.
getServerVariableAsString
(
serverConnectionHandlerID
,
VIRTUALSERVER_NAME
,
&
name
);
debugPrint
(
QString
(
"Welcome at: %1"
).
arg
(
name
));
controller
->
debugPrint
(
QString
(
"Welcome at: %1"
).
arg
(
name
));
ts3Functions
.
freeMemory
(
name
);
}
}
...
...
@@ -449,7 +308,7 @@ void ts3plugin_onServerStopEvent(uint64 serverConnectionHandlerID, const char* s
int
ts3plugin_onTextMessageEvent
(
uint64
serverConnectionHandlerID
,
anyID
targetMode
,
anyID
toID
,
anyID
fromID
,
const
char
*
fromName
,
const
char
*
fromUniqueIdentifier
,
const
char
*
message
,
int
ffIgnored
)
{
generate
ChatLine
(
QString
(
"<%1> %2"
).
arg
(
fromName
).
arg
(
message
));
controller
->
add
ChatLine
(
QString
(
"<%1> %2"
).
arg
(
fromName
).
arg
(
message
));
return
0
;
/* 0 = handle normally, 1 = client will ignore the text message */
}
...
...
@@ -460,9 +319,9 @@ void ts3plugin_onTalkStatusChangeEvent(uint64 serverConnectionHandlerID, int sta
if
(
ts3Functions
.
getClientDisplayName
(
serverConnectionHandlerID
,
clientID
,
name
,
512
)
==
ERROR_ok
)
{
if
(
status
==
STATUS_TALKING
)
generate
Speaker
(
name
);
controller
->
add
Speaker
(
name
);
else
delet
eSpeaker
(
name
);
controller
->
remov
eSpeaker
(
name
);
}
}
...
...
@@ -529,7 +388,7 @@ void ts3plugin_onClientBanFromServerEvent(uint64 serverConnectionHandlerID, anyI
int
ts3plugin_onClientPokeEvent
(
uint64
serverConnectionHandlerID
,
anyID
fromClientID
,
const
char
*
pokerName
,
const
char
*
pokerUniqueIdentity
,
const
char
*
message
,
int
ffIgnored
)
{
generate
ChatLine
(
QString
(
"<%1> 'Wake up!' %2"
).
arg
(
pokerName
).
arg
(
message
));
controller
->
add
ChatLine
(
QString
(
"<%1> 'Wake up!' %2"
).
arg
(
pokerName
).
arg
(
message
));
return
0
;
/* 0 = handle normally, 1 = client will ignore the poke */
}
...
...
plugin.h
View file @
0a8deb16
...
...
@@ -13,12 +13,6 @@
#define PLUGINS_EXPORTDLL __attribute__ ((visibility("default")))
#endif
void
generateChatLine
(
QString
message
);
void
deleteChatLine
(
QLabel
*
message
);
void
generateSpeaker
(
QString
name
);
void
deleteSpeaker
(
QString
name
);
void
debugPrint
(
QString
text
);
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment