Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TalkingUIEntry.h « mumble « src - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b1bedb8f3ad92163ef5d6ea69ff14abc748deced (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Copyright 2020-2021 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#ifndef MUMBLE_MUMBLE_TALKINGUIENTRY_H_
#define MUMBLE_MUMBLE_TALKINGUIENTRY_H_

#include "Settings.h"
#include "TalkingUIComponent.h"
#include "widgets/MultiStyleWidgetWrapper.h"

#include <QIcon>
#include <QLatin1String>
#include <QString>
#include <QTimer>

#include <vector>

class QWidget;
class QLabel;
class TalkingUIContainer;
class ClientUser;
class Channel;

enum class EntryType { USER, LISTENER };

enum class EntryPriority { LOWEST, LOW, DEFAULT, HIGH };


class TalkingUIEntry : public TalkingUIComponent {
	// Needed in order for the container class to be able to modify m_container
	friend class TalkingUIContainer;

protected:
	unsigned int m_associatedUserSession;

	TalkingUIContainer *m_container = nullptr;

	EntryPriority m_priority = EntryPriority::DEFAULT;

public:
	TalkingUIEntry(unsigned int associatedUserSession);
	virtual ~TalkingUIEntry() = default;

	virtual EntryType getType() const = 0;

	virtual unsigned int getAssociatedUserSession() const;

	virtual TalkingUIContainer *getContainer();
	virtual const TalkingUIContainer *getContainer() const;

	virtual void setPriority(EntryPriority priority);
	virtual EntryPriority getPriority() const;

	virtual void setIconSize(int size) = 0;

	virtual void setDisplayString(const QString &displayString) = 0;

	virtual int compare(const TalkingUIEntry &other) const;

	bool operator==(const TalkingUIEntry &other) const;
	bool operator!=(const TalkingUIEntry &other) const;
	bool operator<(const TalkingUIEntry &other) const;
	bool operator<=(const TalkingUIEntry &other) const;
	bool operator>(const TalkingUIEntry &other) const;
	bool operator>=(const TalkingUIEntry &other) const;
};


class TalkingUIUser : public TalkingUIEntry {
protected:
	QWidget *m_backgroundWidget = nullptr;
	MultiStyleWidgetWrapper m_backgroundWidgetStyleWrapper;

	QLabel *m_talkingIcon = nullptr;
	QLabel *m_nameLabel   = nullptr;
	QLabel *m_statusIcons = nullptr;

	QString m_name;

	int m_iconSize                     = 5;
	Settings::TalkState m_talkingState = Settings::Passive;

	QTimer m_timer;
	bool m_restrictLifetime = false;

	const QIcon &getTalkingIcon(Settings::TalkState talkState) const;

	virtual void updateTalkingIcon();

public:
	struct UserStatus {
		bool muted, selfMuted, localMuted, deafened, selfDeafened;
	};

	TalkingUIUser(const ClientUser &user);
	virtual ~TalkingUIUser() override;

	virtual QWidget *getWidget() override;
	virtual const QWidget *getWidget() const override;
	virtual MultiStyleWidgetWrapper &getStylableWidget() override;

	virtual EntryType getType() const override;

	virtual QString getName() const;

	virtual int compare(const TalkingUIEntry &other) const override;

	virtual void setTalkingState(Settings::TalkState talkState);

	virtual void setIconSize(int size) override;

	virtual void setDisplayString(const QString &displayString) override;

	virtual void setLifeTime(unsigned int time);
	virtual void restrictLifetime(bool restrict);

	virtual void setStatus(UserStatus status);
};


class TalkingUIChannelListener : public TalkingUIEntry {
protected:
	QWidget *m_backgroundWidget = nullptr;
	MultiStyleWidgetWrapper m_backgroundWidgetStyleWrapper;

	QLabel *m_icon      = nullptr;
	QLabel *m_nameLabel = nullptr;

	int m_channelID;
	QString m_name;

public:
	TalkingUIChannelListener(const ClientUser &user, const Channel &channel);
	virtual ~TalkingUIChannelListener() override;

	virtual EntryType getType() const override;

	virtual QWidget *getWidget() override;
	virtual const QWidget *getWidget() const override;
	MultiStyleWidgetWrapper &getStylableWidget() override;

	virtual void setIconSize(int size) override;

	virtual void setDisplayString(const QString &displayString) override;

	virtual int getAssociatedChannelID() const;
};

#endif // MUMBLE_MUMBLE_TALKINGUIENTRY_H_